:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --panel-soft: #f8faf7;
  --ink: #17201a;
  --muted: #667064;
  --line: #dfe6dc;
  --accent: #236c4a;
  --accent-strong: #174f37;
  --accent-soft: #e4f2eb;
  --warning: #a14b12;
  --warning-soft: #fff1df;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(35, 49, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #18231c;
  color: #eef6ef;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e7b657;
  color: #1c2118;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-card small,
.sidebar-card span {
  color: #c4d2c3;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  color: #dbe7dd;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  display: grid;
  gap: 8px;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  max-width: 820px;
  margin: 4px 0 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.04;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.filters,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.icon-button,
.voice-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover {
  border-color: var(--accent);
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--panel-soft);
  border-color: var(--line);
}

.full {
  width: 100%;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.kpi {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.kpi small,
.kpi span,
.field-label,
td small,
.followup-item span,
.candidate-list small,
.review-card dd,
.pipeline-row span {
  color: var(--muted);
}

.kpi strong {
  font-size: 34px;
  line-height: 1;
}

.kpi.alert {
  background: var(--warning-soft);
  border-color: #f0d0a2;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  grid-row: span 3;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header.compact {
  align-items: center;
}

.panel h2,
.review-card h3 {
  margin: 3px 0 0;
  font-size: 22px;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 108, 74, 0.14);
}

.filters {
  width: min(520px, 100%);
}

.filters input {
  flex: 1 1 230px;
}

.filters select {
  flex: 0 0 170px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  background: var(--panel-soft);
  color: #3c463f;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

.customer-cell {
  display: grid;
  gap: 4px;
}

.customer-cell strong {
  max-width: 190px;
  overflow-wrap: anywhere;
}

.money-cell {
  display: grid;
  gap: 7px;
  min-width: 130px;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.missing-phone-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
  font-weight: 850;
}

.upload-box {
  display: grid;
  gap: 7px;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  border: 1px dashed #9db4a4;
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  display: none;
}

.upload-box span {
  font-weight: 800;
}

.upload-box:focus-visible,
.upload-box.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 108, 74, 0.14);
}

.screenshot-preview {
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 750;
}

.candidate-list,
.followup-list,
.bill-list,
.pipeline-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.candidate,
.followup-item,
.bill-item,
.pipeline-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.candidate,
.followup-item,
.bill-item,
.pipeline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.candidate strong,
.followup-item strong,
.bill-item strong {
  overflow-wrap: anywhere;
}

.bill-item span,
.bill-amount span {
  display: block;
  color: var(--muted);
}

.bill-amount {
  text-align: right;
  min-width: 110px;
}

.voice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #eef5f0;
}

.voice-button {
  background: #24352a;
  color: #ffffff;
}

.review-card {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.review-card dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
}

.review-card dt {
  font-weight: 800;
}

.review-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.pipeline-row {
  align-items: stretch;
}

.pipeline-bar {
  flex: 1;
  min-width: 80px;
  border-radius: 999px;
  background: #e5ebe2;
  overflow: hidden;
}

.pipeline-bar span {
  display: block;
  height: 100%;
  min-height: 10px;
  background: var(--accent);
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: none;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(20, 32, 24, 0.24);
}

dialog::backdrop {
  background: rgba(12, 18, 14, 0.42);
}

.dialog-card {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.span-2 {
  grid-column: span 2;
}

.end {
  justify-content: flex-end;
  margin-top: 18px;
}

.hidden {
  display: none !important;
}

.crm-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.crm-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #18231c;
  color: #eef6ef;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.crm-brand > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e7b657;
  color: #17201a;
  font-weight: 900;
}

.crm-brand strong,
.crm-brand small {
  display: block;
}

.crm-brand small,
.session-card small {
  color: #c4d2c3;
}

.crm-nav {
  display: grid;
  gap: 8px;
}

.crm-nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe7dd;
  padding: 11px 12px;
  text-align: left;
  font-weight: 750;
}

.crm-nav button:hover,
.crm-nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.session-card {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
}

.session-card label {
  display: grid;
  gap: 5px;
  color: #dbe7dd;
  font-size: 13px;
  font-weight: 750;
}

.session-card select {
  background: #ffffff;
  color: var(--ink);
}

.muted-control {
  opacity: 0.82;
}

.crm-main {
  padding: 28px;
}

.crm-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.crm-topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-button input {
  display: none;
}

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

.metric-grid.compact-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.metric-card small,
.metric-card span,
.muted-text,
.task-card span,
.lead-card span,
.mobile-work-card span,
.report-row span,
.empty-state,
.line-clamp {
  color: var(--muted);
}

.metric-card strong {
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.05;
}

.dashboard-grid,
.import-grid,
.queue-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.wide-panel {
  grid-column: span 1;
}

.filter-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.lead-drop-strip {
  display: grid;
  grid-template-columns: minmax(210px, 0.35fr) minmax(280px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #b8d7c5;
  border-radius: 8px;
  background: #eff8f2;
  box-shadow: var(--shadow);
}

.lead-drop-strip h2 {
  margin: 3px 0 0;
  font-size: 21px;
}

.lead-drop-strip small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.lead-drop-strip small[data-tone="success"] {
  color: var(--accent-strong);
  font-weight: 750;
}

.lead-drop-strip small[data-tone="error"] {
  color: var(--danger);
  font-weight: 750;
}

.lead-drop-strip textarea {
  min-height: 54px;
  resize: vertical;
}

.lead-drop-dialog .candidate-list {
  margin-top: 14px;
}

.drop-upload {
  margin-bottom: 10px;
}

.filter-panel input {
  flex: 1 1 260px;
}

.filter-panel select {
  flex: 0 0 170px;
}

.lead-desk .desktop-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.desktop-table table {
  min-width: 1120px;
}

.desktop-table td strong,
.desktop-table td small {
  display: block;
}

.line-clamp {
  display: -webkit-box;
  max-width: 260px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mobile-card-list {
  display: none;
}

.task-list,
.mobile-work-list,
.pipeline-list,
.chip-list {
  display: grid;
  gap: 10px;
}

.task-card,
.lead-card,
.mobile-work-card,
.report-row,
.candidate {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.task-card,
.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-card.due {
  background: var(--warning-soft);
  border-color: #f0d0a2;
}

.missing-phone-row,
.missing-phone-card {
  background: #fff8ec;
  border-color: #efc57f;
}

.task-card p,
.lead-card p,
.mobile-work-card p {
  margin: 5px 0 0;
}

.stage-tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 850;
}

.money-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.money-strip span {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 6px 8px;
  font-weight: 750;
  color: var(--ink);
}

.last-chat {
  color: #3d4a40;
}

.mobile-work-card,
.lead-card {
  display: grid;
  gap: 10px;
}

.mobile-work-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.candidate {
  display: grid;
  grid-template-columns: auto 1fr auto;
}

.candidate input {
  width: auto;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ocr-status {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ocr-status[data-tone="success"] {
  border-color: #b8d7c5;
  background: #eff8f2;
  color: var(--accent-strong);
}

.ocr-status[data-tone="error"] {
  border-color: #f1b6ae;
  background: #fff1ef;
  color: var(--danger);
}

.inline-form {
  display: flex;
  gap: 10px;
}

.chip-list {
  grid-template-columns: repeat(auto-fit, minmax(90px, max-content));
  margin-top: 12px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 6px 10px;
  font-weight: 750;
}

.crm-dialog {
  width: min(840px, calc(100vw - 24px));
}

.timeline {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.timeline h3 {
  margin: 0 0 10px;
}

.timeline div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.review-card dl {
  display: grid;
  grid-template-columns: 130px 1fr;
}

@media (max-width: 1050px) {
  .crm-shell {
    grid-template-columns: 1fr;
  }

  .crm-sidebar {
    position: static;
    height: auto;
  }

  .crm-nav {
    grid-template-columns: repeat(8, minmax(110px, 1fr));
    overflow-x: auto;
  }

  .session-card {
    margin-top: 0;
  }

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

  .dashboard-grid,
  .import-grid,
  .queue-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .sidebar-card {
    margin-top: 0;
  }

  .content-grid,
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel.wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .crm-main,
  .crm-sidebar {
    padding: 16px;
  }

  .crm-topbar,
  .task-card,
  .report-row,
  .mobile-work-head {
    flex-direction: column;
    align-items: stretch;
  }

  .crm-topbar h1 {
    font-size: 32px;
  }

  .topbar-actions,
  .filter-panel,
  .lead-drop-strip,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .lead-drop-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .desktop-table {
    display: none;
  }

  .mobile-card-list {
    display: grid;
    gap: 10px;
  }

  .candidate {
    grid-template-columns: auto 1fr;
  }

  .candidate > span {
    grid-column: 2;
  }

  .timeline div,
  .review-card dl {
    grid-template-columns: 1fr;
  }

  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .candidate,
  .followup-item,
  .bill-item,
  .pipeline-row {
    flex-direction: column;
    align-items: stretch;
  }

  .bill-amount {
    text-align: left;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .topbar h1 {
    font-size: 34px;
  }
}
