:root {
  --ink: #17201b;
  --muted: #627066;
  --paper: #f8f5ee;
  --panel: #ffffff;
  --wash: #edf2ed;
  --line: #d8ddd7;
  --green: #234735;
  --green-2: #3f7455;
  --saffron: #b08a3c;
  --burgundy: #7a2028;
  --red: #a13f31;
  --amber: #966a17;
  --blue: #2f6284;
  --shadow: 0 8px 24px rgba(23, 32, 27, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 10px 12px calc(78px + env(safe-area-inset-bottom));
}

.splash,
.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  text-align: center;
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark {
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 245, 238, 0.95);
  backdrop-filter: blur(12px);
}

.domain {
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.role-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--wash);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.2;
}

.role-pill {
  color: var(--green);
  border: 1px solid #cbd8cf;
}

.badge.today {
  color: #fff;
  background: var(--green-2);
}

.badge.overdue {
  color: #fff;
  background: var(--red);
}

.badge.blocked {
  color: #fff;
  background: var(--amber);
}

.badge.done {
  color: #fff;
  background: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.metric {
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-value {
  font-size: 24px;
  font-weight: 830;
  line-height: 1.1;
}

.metric-label {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 48px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 780;
}

.tab.active {
  color: #fff;
  background: var(--green);
}

.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0 10px;
}

.section-title {
  font-size: 16px;
  font-weight: 820;
  line-height: 1.25;
}

.stack {
  display: grid;
  gap: 10px;
}

.lead-card,
.form-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lead-card {
  padding: 13px;
}

.lead-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.lead-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.lead-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.next-action {
  margin-top: 11px;
  padding: 10px;
  border-radius: 7px;
  color: #42351f;
  background: #f2edde;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 41px;
  padding: 9px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 780;
  line-height: 1.15;
  text-align: center;
}

.btn.primary {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.btn.ghost {
  color: var(--green);
  border-color: #cfe0d3;
  background: #edf5ee;
}

.btn.danger {
  color: #fff;
  border-color: var(--burgundy);
  background: var(--burgundy);
}

.btn[aria-disabled="true"],
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.form-panel {
  padding: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.table-panel {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f5f7f4;
  font-size: 12px;
  font-weight: 800;
}

.empty {
  padding: 28px 14px;
  border: 1px dashed #cbd4ce;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 60;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  background: var(--red);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(23, 32, 27, 0.42);
}

.modal {
  width: min(720px, 100%);
  max-height: min(88vh, 780px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.22);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-body {
  padding: 14px;
}

.close-btn {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
}

.hidden {
  display: none !important;
}

@media (min-width: 920px) {
  .shell {
    padding-bottom: 18px;
  }

  .tabs {
    position: sticky;
    top: 67px;
    bottom: auto;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 12px 0;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .tab {
    min-height: 40px;
  }
}

@media (max-width: 820px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .table-panel {
    overflow-x: auto;
  }
}

@media (max-width: 360px) {
  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid,
  .actions {
    grid-template-columns: 1fr;
  }
}
