:root {
  --paper: #f3efe6;
  --paper-deep: #e9e2d5;
  --ink: #202622;
  --muted: #71756e;
  --line: #d8d0c2;
  --white: #fbfaf6;
  --rust: #c95d43;
  --rust-soft: #f1d8cf;
  --olive: #75806c;
  --olive-soft: #dfe3d8;
  --ochre: #c89a42;
  --danger: #a33d33;
  --radius: 10px;
  --shadow: 0 18px 50px rgba(42, 39, 32, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 28px 22px 22px;
  display: flex; flex-direction: column; color: #f5f0e7; background: #202622;
  border-right: 1px solid #303a34;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand b { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.brand small { display: block; margin-top: 3px; color: #aeb6af; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { width: 34px; height: 34px; position: relative; flex: 0 0 34px; }
.brand-mark span { position: absolute; display: block; border-radius: 50%; }
.brand-mark span:nth-child(1) { width: 17px; height: 17px; left: 0; top: 1px; background: var(--rust); }
.brand-mark span:nth-child(2) { width: 13px; height: 13px; right: 0; top: 3px; background: #eee6d7; }
.brand-mark span:nth-child(3) { width: 19px; height: 19px; right: 2px; bottom: 0; background: var(--ochre); }
.nav { margin-top: 58px; display: grid; gap: 4px; }
.nav-item { width: 100%; padding: 12px 9px; display: flex; gap: 14px; align-items: center; border: 0; border-left: 2px solid transparent; color: #aeb6af; background: transparent; text-align: left; transition: .16s ease; }
.nav-item span { width: 21px; font: 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: #68716b; }
.nav-item:hover { color: #fff; background: #262e29; }
.nav-item.is-active { color: #fff; border-left-color: var(--rust); background: #29312c; }
.sync-card { margin-top: auto; padding: 14px 4px; display: grid; grid-template-columns: 9px 1fr; gap: 10px; align-items: start; border-top: 1px solid #3a433d; }
.sync-card b, .sync-card small { display: block; }
.sync-card b { font-size: 12px; font-weight: 600; }
.sync-card small { margin-top: 4px; color: #8e9890; font-size: 11px; line-height: 1.4; }
.status-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: #90a785; box-shadow: 0 0 0 4px rgba(144,167,133,.12); }
.status-dot.is-error { background: var(--rust); }
.logout { width: 100%; padding: 9px 4px; border: 0; color: #7f8982; background: transparent; font-size: 11px; text-align: left; }
.logout:hover { color: #fff; }

.workspace { min-width: 0; padding: 34px clamp(24px, 4vw, 64px) 64px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 32px; }
.topbar h1 { margin: 5px 0 0; font: 500 clamp(29px, 3.4vw, 46px)/1.06 Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--rust); font: 700 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .14em; text-transform: uppercase; }
.topbar-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; }
.period-select, .crm-toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.custom-period { display: flex; gap: 8px; align-items: flex-end; padding-left: 10px; border-left: 1px solid var(--line); }
.custom-period[hidden] { display: none; }
.custom-period label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.custom-period input { height: 39px; padding: 0 9px; }
select, input, textarea { border: 1px solid var(--line); border-radius: 5px; background: var(--white); outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(117,128,108,.12); }
.period-select select { min-width: 118px; height: 39px; padding: 0 12px; }
.button { min-height: 39px; padding: 0 16px; border: 1px solid transparent; border-radius: 5px; font-weight: 650; font-size: 12px; }
.button-quiet { border-color: var(--line); background: transparent; }
.button-quiet:hover { background: var(--white); }
.button-primary { color: #fff; background: var(--rust); }
.button-primary:hover { background: #b84d36; }
.text-button { padding: 4px 0; border: 0; color: var(--rust); background: none; font-size: 12px; font-weight: 650; }

.view { display: none; }
.view.is-active { display: block; animation: view-in .22s ease both; }
@keyframes view-in { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.loading { min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.loading[hidden] { display: none; }
.loading span { width: 30px; height: 30px; border: 2px solid var(--line); border-top-color: var(--rust); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-banner { margin-bottom: 22px; padding: 14px; border-left: 3px solid var(--danger); background: #f3ddd8; color: #792b25; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); background: rgba(251,250,246,.45); }
.metric { min-height: 144px; padding: 22px 22px 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.metric-value { margin: 19px 0 9px; font: 500 31px/1 Georgia, "Times New Roman", serif; font-variant-numeric: tabular-nums; }
.metric-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.delta { padding: 3px 6px; border-radius: 3px; font-weight: 700; font-size: 10px; }
.delta.up { color: #496047; background: var(--olive-soft); }
.delta.down { color: #8a3b2f; background: var(--rust-soft); }
.delta.flat { color: var(--muted); background: var(--paper-deep); }

.editorial-grid { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .8fr); gap: 22px; }
.editorial-grid-low { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(251,250,246,.76); box-shadow: 0 1px 0 rgba(255,255,255,.7) inset; }
.panel-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.panel-heading h2 { margin: 6px 0 0; font: 500 22px/1.15 Georgia, "Times New Roman", serif; }
.panel-note { max-width: 350px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: right; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 10px; }
.chart-legend span::before { content: ""; display: inline-block; width: 13px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--olive); }
.chart-legend .legend-leads::before { background: var(--rust); }
.timeline-chart { height: 260px; overflow: hidden; }
.timeline-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-line-views { fill: none; stroke: var(--olive); stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.chart-line-leads { fill: none; stroke: var(--rust); stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.chart-area { fill: rgba(117,128,108,.08); }
.chart-label { fill: var(--muted); font: 9px ui-monospace, monospace; }
.empty-state { height: 100%; display: grid; place-content: center; color: var(--muted); font-size: 12px; }

.comparison-list { display: grid; }
.comparison-row { padding: 14px 0; display: grid; grid-template-columns: 1fr auto; gap: 12px; border-top: 1px solid var(--line); }
.comparison-row:first-child { border-top-color: var(--ink); }
.comparison-row b { font-size: 12px; }
.comparison-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.comparison-value { text-align: right; font: 500 17px/1.1 Georgia, serif; }

.funnel-compact { display: grid; gap: 10px; }
.funnel-step { display: grid; grid-template-columns: 104px 1fr 42px; gap: 12px; align-items: center; }
.funnel-step label { color: var(--muted); font-size: 11px; }
.funnel-track { height: 9px; background: var(--paper-deep); }
.funnel-fill { height: 100%; min-width: 2px; background: var(--olive); }
.funnel-step:nth-child(4) .funnel-fill, .funnel-step:nth-child(5) .funnel-fill { background: var(--rust); }
.funnel-step b { text-align: right; font-variant-numeric: tabular-nums; }
.insights { display: grid; gap: 0; }
.insight { padding: 13px 0 13px 17px; border-top: 1px solid var(--line); position: relative; }
.insight:first-child { border-top-color: var(--ink); }
.insight::before { content: ""; position: absolute; left: 0; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--olive); }
.insight.warning::before { background: var(--rust); }
.insight.positive::before { background: var(--ochre); }
.insight b { font-size: 12px; }
.insight p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.ai-trigger { min-height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid #303a34; border-radius: 999px; color: #f5f0e7; background: #202622; font-size: 11px; font-weight: 700; white-space: nowrap; transition: .18s ease; }
.ai-trigger span { color: #e3b45d; font-size: 14px; }
.ai-trigger:hover { background: #303a34; transform: translateY(-1px); }
.ai-trigger:disabled { cursor: wait; opacity: .7; transform: none; }
.ai-recommendations[hidden] { display: none; }
.ai-recommendations { margin: -4px -5px 20px; padding: 18px; border: 1px solid #303a34; border-radius: 8px; color: #eef0eb; background: #202622; box-shadow: 0 18px 42px rgba(32,38,34,.14); }
.ai-report-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.ai-report-head h3 { margin: 7px 0 0; max-width: 560px; font: 500 20px/1.2 Georgia, serif; }
.ai-report-head small { color: #87928a; font-size: 9px; white-space: nowrap; }
.ai-kicker { color: #e3b45d; font: 700 9px ui-monospace, monospace; letter-spacing: .14em; text-transform: uppercase; }
.ai-summary { margin: 14px 0 0; color: #b9c0ba; font-size: 11px; line-height: 1.6; }
.ai-report-section { margin-top: 19px; padding-top: 16px; border-top: 1px solid #3a433d; }
.ai-report-section h4 { margin: 0 0 10px; color: #8d9890; font-size: 9px; letter-spacing: .13em; text-transform: uppercase; }
.ai-change-grid { display: grid; gap: 8px; }
.ai-change { padding-left: 12px; border-left: 2px solid #7d8a78; }
.ai-change.warning { border-left-color: var(--rust); }
.ai-change.positive { border-left-color: #d6a754; }
.ai-change b, .ai-action b { display: block; font-size: 11px; }
.ai-change p { margin: 3px 0 0; color: #aeb7b0; font-size: 10px; line-height: 1.5; }
.ai-action-list { display: grid; gap: 8px; }
.ai-action { padding: 12px; border-radius: 5px; background: #29312c; }
.ai-action > div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; align-items: baseline; }
.ai-action > div > span { color: #d9a657; font: 700 8px ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.ai-action.priority-medium > div > span { color: #a7b49f; }
.ai-action.priority-low > div > span { color: #7f8a83; }
.ai-action p { margin: 8px 0 0; color: #e0e4df; font-size: 10px; line-height: 1.55; }
.ai-action small { display: block; margin-top: 5px; color: #94a097; font-size: 9px; line-height: 1.45; }
.ai-action footer { margin-top: 10px; padding-top: 8px; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid #3c463f; color: #8f9a92; font-size: 8px; text-transform: uppercase; letter-spacing: .04em; }
.ai-caveats { margin: 14px 0 0; color: #7f8b83; font-size: 8px; line-height: 1.45; }
.recent-panel { margin-top: 22px; }
.compact-leads { display: grid; }
.compact-lead { width: 100%; padding: 13px 3px; display: grid; grid-template-columns: 1.1fr .8fr .7fr 1.6fr auto; gap: 14px; align-items: center; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; }
.compact-lead:hover { background: rgba(255,255,255,.55); }
.compact-lead b, .compact-lead span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-lead span { color: var(--muted); font-size: 11px; }
.stage-pill { display: inline-flex; width: fit-content; padding: 4px 7px; border-radius: 3px; color: #465047 !important; background: var(--olive-soft); font-size: 9px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stage-pill.stage-paid, .stage-pill.stage-in_work, .stage-pill.stage-delivered { color: #fff !important; background: var(--olive); }
.stage-pill.stage-lost { color: #7f352c !important; background: var(--rust-soft); }
.stage-pill.stage-payment_claimed { color: #6b4a12 !important; background: #efe0b9; }

.crm-toolbar { margin-bottom: 18px; display: grid; grid-template-columns: minmax(240px, 1fr) 190px 190px auto; gap: 12px; align-items: end; }
.crm-toolbar input, .crm-toolbar select { height: 43px; padding: 0 12px; }
.stage-settings-toggle { height: 43px; }
.stage-settings[hidden] { display: none; }
.stage-settings { margin-bottom: 18px; padding: 22px; border: 1px solid var(--line); border-top: 3px solid var(--ink); border-radius: 7px; background: rgba(251,250,246,.8); }
.stage-settings-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.stage-settings-head h2 { margin: 6px 0 0; font: 500 22px Georgia, serif; }
.stage-settings-head > p { max-width: 420px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; text-align: right; }
.add-stage-form { margin-top: 18px; padding: 14px; display: grid; grid-template-columns: minmax(220px,1fr) 100px auto; gap: 10px; align-items: end; background: var(--paper-deep); }
.add-stage-form label, .stage-setting-row label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.add-stage-form input:not([type="color"]) { width: 100%; height: 39px; padding: 0 10px; }
.add-stage-form input[type="color"], .stage-setting-row input[type="color"] { width: 100%; height: 39px; padding: 3px; cursor: pointer; }
.stage-settings-list { margin-top: 12px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 22px; }
.stage-setting-row { min-height: 58px; display: grid; grid-template-columns: 12px 1fr 74px; gap: 11px; align-items: center; border-top: 1px solid var(--line); }
.stage-swatch { width: 10px; height: 34px; border-radius: 3px; }
.stage-setting-row b { display: block; font-size: 11px; }
.stage-setting-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.funnel-scroll-control { min-height: 42px; margin-bottom: 10px; padding: 8px 10px; display: grid; grid-template-columns: auto 34px minmax(160px, 1fr) 34px; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: rgba(251,250,246,.82); }
.funnel-scroll-label { color: var(--muted); font: 700 9px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
.funnel-scroll-button { width: 34px; height: 26px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--ink); font-size: 15px; cursor: pointer; }
.funnel-scroll-button:hover:not(:disabled) { border-color: var(--olive); color: var(--rust); }
.funnel-scroll-button:disabled { opacity: .35; cursor: default; }
#funnel-scroll-slider { width: 100%; height: 4px; border: 0; border-radius: 999px; background: var(--paper-deep); box-shadow: none; accent-color: var(--rust); cursor: ew-resize; }
#funnel-scroll-slider:disabled { opacity: .35; cursor: default; }
.funnel-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 260px); grid-template-rows: 1fr; gap: 12px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; padding-bottom: 14px; align-items: start; scrollbar-color: var(--olive) var(--paper-deep); }
.funnel-column { min-width: 220px; min-height: 170px; padding: 14px; border: 1px solid transparent; border-top: 3px solid var(--stage-color, var(--olive)); background: rgba(251,250,246,.58); transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.funnel-column { scroll-snap-align: start; }
.funnel-column.is-drag-over { border-color: var(--rust); border-top-color: var(--rust); background: #f4e4dc; transform: translateY(-2px); }
.column-heading { margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; }
.column-heading b { font: 500 15px/1.2 Georgia, serif; }
.column-heading span { color: var(--muted); font: 11px ui-monospace, monospace; }
.lead-card { position: relative; width: 100%; margin-top: 8px; padding: 13px 32px 13px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); text-align: left; box-shadow: 0 7px 20px rgba(49,45,38,.04); cursor: pointer; }
.drag-handle { position: absolute; top: 8px; right: 8px; width: 20px; height: 24px; display: grid; place-items: center; border-radius: 3px; color: #a4a79f; font-size: 17px; line-height: 1; cursor: grab; user-select: none; }
.drag-handle:hover { color: var(--ink); background: var(--paper-deep); }
.drag-handle:active { cursor: grabbing; }
.lead-card.is-dragging { opacity: .35; transform: rotate(-1deg); }
.lead-card:hover { border-color: #a9aa9d; transform: translateY(-1px); }
.lead-card b { display: block; font-size: 12px; }
.lead-card .lead-meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.lead-card p { margin: 10px 0 0; color: #5e625d; font-size: 11px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.payment-mark { color: #52614e !important; font-weight: 700; }

.chat-compose { position: sticky; bottom: -46px; margin: 18px -46px -46px; padding: 14px 46px 18px; display: grid; grid-template-columns: 1fr auto; gap: 9px; border-top: 1px solid var(--line); background: rgba(243,239,230,.96); backdrop-filter: blur(10px); }
.chat-compose textarea { min-height: 70px; padding: 10px; resize: vertical; }
.chat-compose .button { align-self: end; }
.message { position: relative; }
.message-delete { position: absolute; top: 6px; right: 7px; width: 22px; height: 22px; border: 0; border-radius: 50%; color: #89908a; background: transparent; opacity: 0; }
.message:hover .message-delete { opacity: 1; }
.message-delete:hover { color: #fff; background: var(--danger); }
.message.pending { opacity: .72; }

.management-metrics { margin-bottom: 22px; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.management-metric { min-height: 116px; padding: 18px; display: grid; align-content: center; border-right: 1px solid var(--line); background: rgba(251,250,246,.45); }
.management-metric:last-child { border-right: 0; }
.management-metric small { color: var(--muted); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.management-metric b { margin: 12px 0 7px; font: 500 25px Georgia,serif; }
.management-metric span { color: var(--muted); font-size: 9px; }
.management-grid { display: grid; grid-template-columns: minmax(260px,.72fr) minmax(0,1.8fr); gap: 22px; }
.management-grid + .management-grid { margin-top: 22px; }
.management-grid-wide { grid-template-columns: repeat(2,minmax(0,1fr)); }
.capability-list { display: grid; }
.capability-row { min-height: 50px; display: grid; grid-template-columns: 8px 1fr; gap: 10px; align-items: center; border-top: 1px solid var(--line); }
.capability-row:first-child { border-top-color: var(--ink); }
.capability-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rust); }
.capability-dot.available { background: var(--olive); }
.capability-row b { display: block; font-size: 11px; }
.capability-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.item-control-form { display: grid; grid-template-columns: minmax(220px,1fr) 140px auto auto; gap: 9px; align-items: end; }
.item-control-form label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.item-control-form select, .item-control-form input { width: 100%; height: 39px; padding: 0 10px; }
.item-services { margin-top: 18px; }
.service-grid { padding-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; border-top: 1px solid var(--ink); }
.service-grid h3 { margin: 0 0 9px; font: 500 15px Georgia,serif; }
.service-option { min-height: 47px; padding: 8px 0; display: grid; grid-template-columns: 17px 1fr; gap: 9px; align-items: start; border-top: 1px solid var(--line); cursor: pointer; }
.service-option input { margin-top: 3px; }
.service-option b { display: block; font-size: 10px; }
.service-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.service-footer { margin-top: 12px; padding-top: 12px; display: flex; justify-content: space-between; gap: 18px; align-items: center; border-top: 1px solid var(--line); }
.service-footer p { max-width: 560px; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.review-card { padding: 15px 0; border-top: 1px solid var(--line); }
.review-card:first-child { border-top-color: var(--ink); }
.review-card header { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; }
.review-card header b { font-size: 11px; }
.review-card header span { color: var(--ochre); letter-spacing: 1px; }
.review-card time { color: var(--muted); font-size: 9px; }
.review-card > p, .review-answer p { margin: 8px 0 0; color: #5e625d; font-size: 10px; line-height: 1.55; }
.review-answer { margin-top: 10px; padding: 10px; border-left: 2px solid var(--olive); background: var(--paper-deep); }
.review-answer small { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.text-button.danger { color: var(--danger); font-size: 9px; }
.review-form { margin-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.review-form textarea { min-height: 64px; padding: 9px; resize: vertical; }
.review-form .button { align-self: end; }
.management-list-row { min-height: 55px; padding: 9px 0; display: flex; justify-content: space-between; gap: 14px; align-items: center; border-top: 1px solid var(--line); }
.management-list-row:first-child { border-top-color: var(--ink); }
.management-list-row b { display: block; font-size: 10px; }
.management-list-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.management-list-row strong { font: 500 15px Georgia,serif; }
.management-list-row > span { color: var(--muted); font-size: 9px; }
.api-status { padding: 4px 7px; border-radius: 3px; background: var(--paper-deep); text-transform: uppercase; }
.api-status.finished, .api-status.success { color: #496047; background: var(--olive-soft); }
.empty-state.compact { min-height: 84px; }

.confirm-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(22,27,24,.52); backdrop-filter: blur(3px); }
.confirm-backdrop[hidden], .confirm-dialog[hidden] { display: none; }
.confirm-dialog { position: fixed; z-index: 61; left: 50%; top: 50%; width: min(470px,calc(100vw - 32px)); padding: 26px; border: 1px solid #303a34; border-radius: 9px; color: var(--ink); background: var(--white); box-shadow: 0 30px 90px rgba(20,25,22,.3); transform: translate(-50%,-50%); }
.confirm-dialog h2 { margin: 9px 0 0; font: 500 25px Georgia,serif; }
.confirm-dialog > p:not(.eyebrow) { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.confirm-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; z-index: 40; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; border-left: 3px solid var(--olive); border-radius: 4px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(8px); transition: .2s ease; }
.toast.error { border-left-color: var(--rust); }
.toast.is-visible { opacity: 1; transform: none; }

.table-panel { padding: 28px; }
.changes-panel { margin-bottom: 22px; }
.change-form { margin: -4px 0 24px; padding: 18px; display: grid; grid-template-columns: minmax(260px, 1.5fr) 180px 150px minmax(240px, 1fr) auto; gap: 10px; align-items: end; border: 1px solid var(--line); background: var(--paper); }
.change-form[hidden] { display: none; }
.change-form label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.change-form input, .change-form select { width: 100%; height: 40px; padding: 0 10px; }
.change-list { display: grid; }
.change-row { padding: 15px 2px; display: grid; grid-template-columns: minmax(190px, 1.3fr) 130px 100px 1fr 1fr; gap: 16px; align-items: center; border-top: 1px solid var(--line); }
.change-row:first-child { border-top-color: var(--ink); }
.change-main b, .change-main small { display: block; }
.change-main b { font-size: 12px; }
.change-main small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.change-kind { font-size: 11px; font-weight: 650; }
.measurement-badge { width: fit-content; padding: 4px 6px; border-radius: 3px; background: var(--paper-deep); color: var(--muted); font-size: 9px; text-transform: uppercase; }
.measurement-badge.measured { color: #42523f; background: var(--olive-soft); }
.measurement-badge.preliminary { color: #6a511c; background: #efe0b9; }
.change-metric { font-size: 10px; color: var(--muted); }
.change-metric b { display: block; margin-top: 4px; color: var(--ink); font: 500 17px Georgia, serif; }
.change-metric .positive { color: #4e684c; }
.change-metric .negative { color: #9a4135; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 11px 10px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: .08em; text-align: right; text-transform: uppercase; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td { padding: 15px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: rgba(255,255,255,.42); }
.table-name { font-weight: 650; }
.table-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 400; }
.score { display: inline-block; min-width: 34px; padding: 4px 6px; border-radius: 3px; background: var(--paper-deep); text-align: center; }
.score.high { color: #8c352b; background: var(--rust-soft); }
.score.low { color: #41523f; background: var(--olive-soft); }

.cost-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; }
.cost-hero { grid-row: span 2; min-height: 480px; padding: 34px; background: #202622; color: #f5f0e7; }
.cost-hero .eyebrow { color: #dc866f; }
.cost-total { margin-top: 28px; font: 500 clamp(46px, 6vw, 74px)/1 Georgia, serif; }
.cost-hero > p:not(.eyebrow) { color: #9ba49d; }
.cost-bars { margin-top: 70px; display: grid; gap: 20px; }
.cost-bar-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; font-size: 11px; }
.cost-bar-row .bar { height: 8px; background: #353f38; }
.cost-bar-row .bar i { display: block; height: 100%; background: var(--rust); }
.cost-bar-row:nth-child(2) .bar i { background: var(--ochre); }
.cost-bar-row:nth-child(3) .bar i { background: var(--olive); }
.unit-metrics { display: grid; grid-template-columns: repeat(2, 1fr); }
.unit-metric { padding: 18px 10px; border-top: 1px solid var(--line); }
.unit-metric:nth-child(odd) { border-right: 1px solid var(--line); }
.unit-metric small { display: block; color: var(--muted); font-size: 10px; }
.unit-metric b { display: block; margin-top: 9px; font: 500 23px Georgia, serif; }
.rule-panel { background: #e2e4da; }
.rule-panel h2 { margin: 9px 0 12px; font: 500 23px/1.15 Georgia, serif; }
.rule-panel > p:last-child { color: #5f675b; font-size: 12px; line-height: 1.65; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(32,38,34,.4); }
.lead-drawer { position: fixed; z-index: 21; top: 0; right: 0; width: min(620px, 100%); height: 100vh; padding: 38px; overflow-y: auto; background: var(--white); border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(24,29,25,.18); transform: translateX(102%); transition: transform .25s ease; }
.lead-drawer.is-open { transform: none; }
.drawer-close { position: absolute; top: 18px; right: 20px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 24px; line-height: 1; }
.drawer-title { padding-right: 40px; }
.drawer-title h2 { margin: 7px 0 4px; font: 500 30px/1.1 Georgia, serif; }
.drawer-title p { color: var(--muted); font-size: 11px; }
.ai-review { margin-top: 20px; padding: 15px 16px; border-left: 3px solid var(--ochre); background: #f0e8d5; }
.ai-review-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.ai-review-head b { font: 500 15px Georgia, serif; }
.ai-review-head span { color: #6d6046; font: 9px ui-monospace, monospace; text-transform: uppercase; }
.ai-review p { margin: 8px 0 0; color: #5f5849; font-size: 11px; line-height: 1.55; }
.evidence-line { margin-top: 9px; padding-top: 9px; border-top: 1px solid #d8c9a6; color: #655b46; font-size: 10px; }
.lead-form { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.lead-form label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.lead-form label.full { grid-column: 1 / -1; }
.lead-form select, .lead-form input { height: 40px; padding: 0 10px; }
.lead-form textarea { min-height: 88px; padding: 10px; resize: vertical; }
.lead-form .button { grid-column: 1 / -1; }
.message-list { margin-top: 28px; display: grid; gap: 8px; }
.message-list h3 { font: 500 19px Georgia, serif; }
.message { max-width: 83%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px 9px 9px 9px; background: var(--paper); }
.message.out { margin-left: auto; border-radius: 9px 4px 9px 9px; background: #e4e8df; }
.message p { margin: 0; white-space: pre-wrap; font-size: 11px; line-height: 1.55; }
.message time { display: block; margin-top: 6px; color: var(--muted); font-size: 8px; }

.login-body { min-height: 100vh; background: #202622; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.login-intro { padding: clamp(42px, 8vw, 110px); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; color: #f5f0e7; background: #202622; }
.login-intro .brand-mark { width: 52px; height: 52px; margin-bottom: 60px; }
.login-intro .brand-mark span:nth-child(1) { width: 26px; height: 26px; }
.login-intro .brand-mark span:nth-child(2) { width: 20px; height: 20px; }
.login-intro .brand-mark span:nth-child(3) { width: 29px; height: 29px; }
.login-intro h1 { max-width: 660px; margin: 13px 0 22px; font: 500 clamp(48px, 6vw, 82px)/.96 Georgia, serif; letter-spacing: -.04em; }
.login-intro > p:not(.eyebrow) { max-width: 570px; color: #aeb6af; font-size: 15px; line-height: 1.7; }
.login-note { margin-top: 62px; padding-left: 18px; border-left: 2px solid var(--rust); }
.login-note b, .login-note span { display: block; }
.login-note b { font-size: 12px; }
.login-note span { margin-top: 6px; color: #8f9991; font-size: 11px; }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--paper); }
.login-form { width: min(390px, 100%); display: grid; gap: 20px; }
.login-form h2 { margin: 8px 0 10px; font: 500 32px Georgia, serif; }
.login-form label { display: grid; gap: 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.login-form input { height: 48px; padding: 0 13px; }
.login-form .button { height: 48px; }
.form-caption { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }
.form-error { margin: 0; padding: 10px 12px; border-left: 3px solid var(--danger); background: var(--rust-soft); color: #81382f; font-size: 11px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding: 24px 14px; align-items: center; }
  .brand > div:last-child, .nav-item:not(.is-active) { font-size: 0; }
  .brand { justify-content: center; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 14px 4px; font-size: 0; }
  .nav-item span { width: auto; font-size: 10px; }
  .nav-item.is-active::after { content: "•"; font-size: 15px; }
  .sync-card { grid-template-columns: 1fr; justify-items: center; }
  .sync-card div, .logout { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .editorial-grid, .editorial-grid-low, .cost-layout { grid-template-columns: 1fr; }
  .cost-hero { grid-row: auto; min-height: 360px; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; top: auto; bottom: 0; width: 100%; height: 66px; padding: 0 8px; display: block; border: 0; border-top: 1px solid #3c453f; }
  .sidebar .brand, .sidebar .sync-card, .sidebar form { display: none; }
  .nav { height: 100%; margin: 0; grid-template-columns: repeat(5, 1fr); align-items: stretch; }
  .nav-item, .nav-item.is-active { height: 100%; display: grid; place-content: center; border: 0; border-top: 2px solid transparent; }
  .nav-item.is-active { border-top-color: var(--rust); }
  .nav-item.is-active::after { display: none; }
  .workspace { padding: 24px 16px 92px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar h1 { font-size: 34px; }
  .topbar-actions { width: 100%; }
  .period-select { flex: 1; }
  .period-select select { width: 100%; }
  .custom-period { width: 100%; padding: 10px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .custom-period label { flex: 1; }
  .custom-period input { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 124px; padding: 17px 14px; }
  .metric-value { font-size: 26px; }
  .panel { padding: 18px; }
  .compact-lead { grid-template-columns: 1fr auto; }
  .compact-lead > span:nth-child(2), .compact-lead > span:nth-child(3), .compact-lead > span:nth-child(4) { display: none; }
  .crm-toolbar { grid-template-columns: 1fr; }
  .stage-settings-head { flex-direction: column; }
  .stage-settings-head > p { text-align: left; }
  .add-stage-form, .stage-settings-list { grid-template-columns: 1fr; }
  .funnel-scroll-control { grid-template-columns: 34px minmax(120px, 1fr) 34px; }
  .funnel-scroll-label { display: none; }
  .table-panel { padding: 14px; overflow-x: auto; }
  .change-form { grid-template-columns: 1fr; }
  .change-row { grid-template-columns: 1fr 1fr; }
  .change-main { grid-column: 1 / -1; }
  .data-table { min-width: 760px; }
  .panel-heading { flex-direction: column; }
  .ai-trigger { width: 100%; justify-content: center; }
  .ai-report-head { flex-direction: column; }
  .ai-action > div { grid-template-columns: 1fr; }
  .panel-note { text-align: left; }
  .lead-drawer { padding: 28px 18px 90px; }
  .lead-form { grid-template-columns: 1fr; }
  .lead-form label.full, .lead-form .button { grid-column: auto; }
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: 44vh; padding: 42px 28px; }
  .login-intro .brand-mark { margin-bottom: 30px; }
  .login-intro h1 { font-size: 48px; }
  .login-note { margin-top: 24px; }
  .login-panel { padding: 44px 24px; }
  .nav { grid-template-columns: repeat(6, 1fr); }
  .management-metrics { grid-template-columns: 1fr 1fr; }
  .management-metric:nth-child(2) { border-right: 0; }
  .management-metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .management-grid, .management-grid-wide, .item-control-form, .service-grid { grid-template-columns: 1fr; }
  .service-footer, .stage-settings-head { align-items: stretch; flex-direction: column; }
  .chat-compose { margin: 18px -18px -90px; padding: 12px 18px 82px; grid-template-columns: 1fr; }
}
