:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --ink: #16362f;
  --muted: #6c7e79;
  --line: #dce8e3;
  --primary: #1d6758;
  --primary-dark: #124e43;
  --accent: #e3f2eb;
  --accent-strong: #c9e7db;
  --warning: #e9b44f;
  --danger: #bd4f47;
  --info: #417c9e;
  --shadow: 0 12px 38px rgba(25, 70, 60, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; max-width: 1680px; margin: 0 auto; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; min-height: 100vh; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; background: #fbfdfc; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; color: #fff; background: var(--primary); font-size: 13px; font-weight: 850; box-shadow: 0 8px 24px rgba(20, 80, 68, .2); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
nav { display: grid; gap: 5px; margin-top: 34px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; border-radius: 12px; padding: 11px 14px; text-align: left; background: transparent; color: #657873; font-size: 14px; font-weight: 680; cursor: pointer; transition: .18s ease; }
.nav-item span { color: inherit; font-size: 10px; font-variant-numeric: tabular-nums; opacity: .58; }
.nav-item:hover { background: var(--accent); color: var(--ink); }
.nav-item.active { color: #fff; background: var(--primary); box-shadow: 0 4px 14px rgba(29, 103, 88, .16); }
.goal-card { margin-top: auto; padding: 17px; border-radius: 17px; background: var(--accent); }
.goal-card > div:first-child, .goal-line { display: flex; justify-content: space-between; gap: 12px; }
.goal-card span, .goal-card strong { font-size: 13px; }
.goal-card small { color: var(--muted); font-size: 12px; }
.progress { height: 8px; margin: 13px 0 10px; overflow: hidden; border-radius: 99px; background: #fff; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s ease; }

main { min-width: 0; padding: 0 38px 52px; }
.topbar { position: sticky; top: 0; z-index: 9; min-height: 78px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-bottom: 1px solid var(--line); background: rgba(243, 247, 245, .91); backdrop-filter: blur(14px); }
.search { width: min(430px, 50%); margin-right: auto; position: relative; }
.search span { position: absolute; left: 14px; top: 8px; color: var(--muted); font-size: 21px; }
.search input { width: 100%; height: 42px; padding: 0 14px 0 40px; border: 0; border-radius: 13px; outline: none; background: #eaf1ee; color: var(--ink); }
.search input:focus { box-shadow: 0 0 0 3px rgba(29, 103, 88, .14); }
.save-state { color: var(--muted); font-size: 12px; }
.workspace { padding-top: 29px; }
.loading-state { min-height: 50vh; display: grid; place-items: center; align-content: center; gap: 13px; color: var(--muted); }
.loading-state i { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 15px; border: 0; border-radius: 11px; font-size: 14px; font-weight: 760; text-decoration: none; cursor: pointer; transition: .18s ease; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.secondary { color: var(--ink); border: 1px solid var(--line); background: #fff; }
.button.secondary:hover:not(:disabled) { background: var(--surface-soft); }
.button.light { color: #fff; border: 1px solid rgba(255,255,255,.24); background: rgba(255,255,255,.08); }
.button.light:hover { background: rgba(255,255,255,.16); }
.button.white { color: var(--primary); background: #fff; }
.button.danger { color: var(--danger); background: #fbecea; }
.button.compact { min-height: 32px; padding: 0 10px; font-size: 12px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 23px; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: var(--surface-soft); }
.text-button { border: 0; background: transparent; color: var(--primary); font-size: 13px; font-weight: 730; cursor: pointer; }
.text-button:hover { text-decoration: underline; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-heading-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--primary); font-size: 14px; font-weight: 760; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 42px); line-height: 1; letter-spacing: -.045em; }
.page-heading p { margin-bottom: 0; color: var(--muted); font-size: 16px; }
.context-badge { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: rgba(255,255,255,.6); font-size: 12px; font-weight: 680; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-top: 28px; }
.metric { min-height: 132px; padding: 18px; border: 1px solid rgba(208, 225, 219, .78); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.metric > span, .metric > small { display: block; color: var(--muted); }
.metric > span { font-size: 14px; font-weight: 660; }
.metric > strong { display: block; margin: 12px 0 3px; font-size: 32px; letter-spacing: -.04em; }
.metric > small { font-size: 12px; }
.metric.warning strong, .overdue-text { color: var(--danger); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 23px; margin-top: 24px; }
.main-column, .side-column, .stack { display: grid; align-content: start; gap: 23px; }
.focus-card { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 25px; border-radius: 18px; color: #fff; background: linear-gradient(135deg, var(--primary), #174f49); box-shadow: 0 18px 48px rgba(14, 68, 58, .2); }
.focus-card h2 { margin: 15px 0 7px; font-size: 24px; letter-spacing: -.025em; }
.focus-card p, .focus-card small { color: rgba(255,255,255,.72); }
.focus-card p { margin: 0; font-size: 14px; }
.pill { display: inline-flex; margin-right: 9px; padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.14); font-size: 12px; font-weight: 720; }
.focus-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.focus-empty { color: var(--ink); background: linear-gradient(135deg, #edf7f2, #dcefe6); box-shadow: none; }
.focus-empty p, .focus-empty small { color: var(--muted); }

.panel { overflow: hidden; border: 1px solid rgba(208, 225, 219, .8); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.panel.flat { box-shadow: none; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .activity-card h2 { margin-bottom: 4px; font-size: 16px; letter-spacing: -.015em; }
.panel-heading p, .activity-card p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.panel-content { padding: 20px; }
.panel-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.panel-toolbar .field-inline { min-width: 150px; }
.panel-toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { height: 42px; padding: 0 10px; color: var(--muted); text-align: left; font-size: 12px; font-weight: 720; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td { height: 66px; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); }
.company-cell { min-width: 210px; }
.phone-cell { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; color: var(--primary); background: var(--accent); font-size: 11px; font-weight: 760; white-space: nowrap; }
.status.interest { color: #286a3b; background: #e4f4e5; }
.status.appointment { color: #2b6385; background: #e5f1f7; }
.status.closed { color: #776e65; background: #efedeb; }
.status.warning { color: #8e5b05; background: #fff0cc; }
.status.danger { color: var(--danger); background: #fbe9e7; }
.priority { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--line); }
.priority.high { background: var(--danger); }
.priority.low { background: #7ca6b7; }

.timeline { margin: 0; padding: 9px 15px 13px; list-style: none; }
.timeline li { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 12px; align-items: start; padding: 13px 5px; border-radius: 10px; }
.timeline li:hover { background: var(--surface-soft); }
.timeline i { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--line); }
.timeline li.overdue i { background: var(--danger); }
.timeline li.today i { background: var(--warning); }
.timeline strong, .timeline small { display: block; }
.timeline strong { font-size: 13px; }
.timeline small, .timeline time { margin-top: 5px; color: var(--muted); font-size: 12px; }
.activity-card { padding: 20px; border-radius: 17px; background: var(--accent); }
.goal-line { margin-top: 22px; font-size: 13px; }
.mini-stats { display: grid; grid-template-columns: repeat(3,1fr); margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(25,66,57,.1); text-align: center; }
.mini-stats strong, .mini-stats small { display: block; }
.mini-stats strong { font-size: 18px; }
.mini-stats small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.empty-state { min-height: 230px; display: grid; place-items: center; align-content: center; padding: 32px 20px; text-align: center; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 15px; color: var(--primary); background: var(--accent); font-weight: 800; }
.empty-state h3 { margin-bottom: 7px; font-size: 17px; }
.empty-state p { max-width: 430px; margin-bottom: 17px; color: var(--muted); font-size: 14px; line-height: 1.55; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .55fr); gap: 23px; margin-top: 24px; }
.followup-list { display: grid; gap: 9px; }
.followup-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 13px; align-items: center; padding: 14px 15px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.followup-card.is-overdue { border-color: #efc8c4; background: #fffafa; }
.followup-card .check { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.followup-card .check:hover { color: #fff; border-color: var(--primary); background: var(--primary); }
.followup-card h3 { margin: 0 0 5px; font-size: 14px; }
.followup-card p { margin: 0; color: var(--muted); font-size: 12px; }
.followup-card time { color: var(--muted); font-size: 12px; font-weight: 700; text-align: right; white-space: nowrap; }
.section-label { margin: 25px 0 10px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.section-label:first-child { margin-top: 0; }

.calendar-shell { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 23px; margin-top: 24px; }
.calendar-panel { padding: 20px; }
.calendar-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.calendar-header h2 { margin: 0; font-size: 19px; text-transform: capitalize; }
.calendar-controls { display: flex; gap: 7px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.weekday { min-height: 34px; display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.day-cell { min-height: 112px; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.day-cell.outside { background: #f8faf9; color: #a7b3af; }
.day-cell.today { box-shadow: inset 0 0 0 2px var(--primary); }
.day-number { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-size: 12px; font-weight: 750; }
.day-cell.today .day-number { color: #fff; background: var(--primary); }
.calendar-event { display: block; width: 100%; margin-top: 5px; overflow: hidden; padding: 5px 6px; border: 0; border-radius: 7px; color: var(--primary-dark); background: var(--accent); font-size: 10px; font-weight: 700; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.calendar-event.overdue { color: var(--danger); background: #fbe9e7; }
.agenda-list { display: grid; gap: 9px; }
.agenda-item { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.agenda-item time { display: block; margin-bottom: 5px; color: var(--primary); font-size: 12px; font-weight: 800; }
.agenda-item strong { display: block; font-size: 13px; }
.agenda-item small { display: block; margin-top: 4px; color: var(--muted); }

.source-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 23px; margin-top: 24px; }
.source-hero { padding: 24px; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #1d6758, #285d7a); box-shadow: 0 18px 48px rgba(23, 75, 69, .16); }
.source-hero .source-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.source-hero h2 { margin: 20px 0 7px; font-size: 24px; }
.source-hero p { max-width: 650px; color: rgba(255,255,255,.73); line-height: 1.58; }
.source-status { padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.14); font-size: 12px; font-weight: 750; }
.source-status.ready { color: #173e35; background: #c9f1dc; }
.source-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.settings-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: var(--shadow); }
.settings-card h2 { margin-bottom: 4px; font-size: 16px; }
.settings-card > p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch-row span { font-size: 13px; line-height: 1.45; }
.switch-row small { display: block; margin-top: 4px; color: var(--muted); }
.source-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 23px; }
.source-stats div { padding: 15px; border-radius: 13px; background: rgba(255,255,255,.1); }
.source-stats strong, .source-stats small { display: block; }
.source-stats strong { font-size: 22px; }
.source-stats small { margin-top: 4px; color: rgba(255,255,255,.66); font-size: 11px; }
.info-box { padding: 15px; border: 1px solid #cfe2ea; border-radius: 13px; color: #28566f; background: #eef7fb; font-size: 13px; line-height: 1.55; }
.warning-box { padding: 15px; border: 1px solid #edd9aa; border-radius: 13px; color: #74520c; background: #fff8e8; font-size: 13px; line-height: 1.55; }
.research-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.research-card { display: grid; align-content: start; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.research-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 700; }
.research-card h3 { margin: 0; font-size: 17px; }
.research-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.research-card .research-meta { color: var(--ink); font-weight: 650; }
.research-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.research-actions a { padding: 0; text-align: left; }

.field { display: grid; gap: 7px; }
.field > span { color: #536862; font-size: 12px; font-weight: 720; }
.field input, .field select, .field textarea, .field-inline select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: #fff; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .field-inline select:focus { border-color: #77a89d; box-shadow: 0 0 0 3px rgba(29,103,88,.11); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; padding: 20px 22px; }
.span-2 { grid-column: span 2; }

.dialog { width: min(640px, calc(100% - 28px)); max-height: min(860px, calc(100vh - 28px)); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: #fff; box-shadow: 0 28px 90px rgba(17,53,45,.28); }
.dialog::backdrop { background: rgba(18, 46, 40, .42); backdrop-filter: blur(3px); }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 21px 22px 15px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.dialog-heading .eyebrow { margin-bottom: 5px; font-size: 12px; }
.dialog-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(420px, calc(100% - 48px)); transform: translateY(18px); padding: 11px 14px; border-radius: 11px; color: #fff; background: #183e36; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1120px) {
  .dashboard-grid, .split-layout, .calendar-shell, .source-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2,1fr); }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .calendar-shell > aside, .source-grid > aside { order: -1; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; min-height: auto; height: auto; padding: 13px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  nav { display: flex; gap: 4px; margin-top: 13px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; padding: 8px 11px; }
  .nav-item span { display: none; }
  .goal-card { display: none; }
  main { padding: 0 15px 36px; }
  .topbar { min-height: 68px; }
  .search { width: 100%; }
  .save-state { display: none; }
  .topbar .button { min-width: 42px; padding: 0 12px; font-size: 0; }
  .topbar .button::after { content: '+'; font-size: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .focus-card { align-items: flex-start; flex-direction: column; }
  .focus-actions { justify-content: flex-start; }
  .side-column { grid-template-columns: 1fr; }
  .source-stats { grid-template-columns: 1fr; }
  .research-grid { grid-template-columns: 1fr; }
  .calendar-panel { padding: 10px; }
  .day-cell { min-height: 78px; padding: 5px; }
  .calendar-event { padding: 4px; font-size: 0; }
  .calendar-event::before { content: '•'; font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 112px; padding: 15px; }
  .metric > strong { font-size: 26px; }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4) { display: none; }
  .followup-card { grid-template-columns: auto minmax(0,1fr); }
  .followup-card time { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
