/* Travel CRM — Organic direction: sand surfaces, terracotta accent, moss / ochre / clay
   for state, Fraunces for headings, Epilogue for UI and figures, 16px+ rounding, light grain. */

:root {
  --sand: #E8DCC7;
  --oat: #D4B895;
  --surface: #EEE5D4;          /* panels: lighter sand, below the cream range */
  --surface-2: #E3D5BD;        /* hover / zebra */
  --line: #CFBD9F;
  --line-soft: #DCCDB2;
  --ink: #2E241A;
  --ink-2: #5E4E3C;
  --ink-3: #7A6852;
  --terracotta: #C66B3D;
  --terracotta-deep: #9E4E26;  /* filled buttons: white text reaches 5:1 */
  --clay: #B08B6E;
  --ochre: #C08E3A;
  --moss: #606C38;
  --sage: #8B9D83;
  --rust: #9C3D21;

  --ok-bg: #D5D9BB; --ok-ink: #44501F;
  --warn-bg: #EBD3A4; --warn-ink: #7A5514;
  --bad-bg: #E9C2AE; --bad-ink: #8A2F15;

  --r-lg: 20px; --r-md: 16px; --r-sm: 10px;
  --f-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --f-ui: 'Epilogue', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.33, .1, .25, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--sand); color: var(--ink);
  font: 14px/1.5 var(--f-ui);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
/* Grain: 2.5% feTurbulence noise over the whole page */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1, h2 { font-family: var(--f-display); font-optical-sizing: auto; letter-spacing: -.01em; }
a { color: var(--terracotta-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; vertical-align: -3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.strong { font-weight: 600; }
.ok-text { color: var(--ok-ink); font-weight: 600; }
.bad-text { color: var(--bad-ink); font-weight: 600; }
:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: calc(12px + env(safe-area-inset-top, 0)) 24px 12px;
  background: color-mix(in srgb, var(--sand) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 22px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 8px;
  background: radial-gradient(circle at 35% 35%, var(--ochre), var(--terracotta) 70%);
}
.nav { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 99px; }
.nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 99px; text-decoration: none; color: var(--ink-2); font-weight: 500;
  transition: background .3s var(--ease), color .3s var(--ease);
}
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.nav a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(46, 36, 26, .12); }
.nav-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--terracotta-deep); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.clocks { display: flex; gap: 12px; font-size: 12px; color: var(--ink-3); }
.clocks b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 500;
  transition: background .3s var(--ease), border-color .3s var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--terracotta-deep); border-color: var(--terracotta-deep); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #8A421F; }
.btn.danger { background: var(--bad-bg); border-color: #DDA88D; color: var(--bad-ink); }
.btn.ghost { background: none; border-color: transparent; }
.danger-text { color: var(--bad-ink); }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; min-height: 38px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; border-radius: 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--terracotta); box-shadow: 0 0 0 3px color-mix(in srgb, var(--terracotta) 22%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235E4E3C' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }

/* ---------- Page layout ---------- */
.view { max-width: 1560px; margin: 0 auto; padding: 22px 24px 60px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 34px; line-height: 1.1; }
.sub { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 360px; }
.search .ic { position: absolute; left: 12px; color: var(--ink-3); }
.search input { width: 100%; padding-left: 36px; border-radius: 99px; }
.filters select { border-radius: 99px; }
.check { display: inline-flex; gap: 7px; align-items: center; padding: 0 6px; color: var(--ink-2); cursor: pointer; }
.check input { min-height: 0; accent-color: var(--terracotta-deep); width: 16px; height: 16px; }
.inline-date { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; }
.inline-date input { border-radius: 99px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 99px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 9px; border-radius: 99px; cursor: pointer; color: var(--ink-3); display: inline-flex; align-items: center; }
.seg.text button { padding: 6px 13px; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(46, 36, 26, .12); }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--ink-2);
}
.pill .ic { vertical-align: 0; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.muted { background: transparent; border: 1px solid var(--line); color: var(--ink-3); }
.pill.peak { background: #D9DFD3; color: #3F5138; }
.pill.sample { background: var(--warn-bg); color: var(--warn-ink); cursor: help; }
.st-new { background: #E2D5C0; color: #5E4E3C; }
.st-contacted { background: #DCD3C0; color: #4E4A35; }
.st-quoted { background: #EBD3A4; color: #7A5514; }
.st-negotiation { background: #EBC6A8; color: #85401C; }
.st-booked { background: var(--ok-bg); color: var(--ok-ink); }
.st-travelled { background: #D2DACD; color: #3F5138; }
.st-lost { background: transparent; border: 1px solid #D6A994; color: var(--bad-ink); }

/* ---------- Pipeline board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)) minmax(160px, .6fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: color-mix(in srgb, var(--oat) 30%, var(--sand)); border-radius: var(--r-lg); padding: 10px; min-height: 240px; transition: background .3s var(--ease), box-shadow .3s var(--ease); }
.kcol > header { display: flex; align-items: baseline; gap: 8px; padding: 4px 6px 10px; }
.kcol h3 { font-size: 14px; }
.count { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.kcol-val { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kcol-body { display: flex; flex-direction: column; gap: 9px; max-height: calc(100vh - 290px); min-height: 120px; overflow-y: auto; padding: 2px; }
.kcol-empty { color: var(--ink-3); font-size: 13px; text-align: center; margin: 24px 0; }
.kcol.over, .drop-zone.over { box-shadow: inset 0 0 0 2px var(--terracotta); background: color-mix(in srgb, var(--terracotta) 12%, var(--sand)); }
.is-dragging .kcol:not(.closed), .is-dragging .drop-zone { box-shadow: inset 0 0 0 1px var(--line); }

/* Boarding-pass card: main body + perforated stub with days to departure */
.kcard {
  --notch: 7px;
  display: grid; grid-template-columns: minmax(0, 1fr) 64px; cursor: grab;
  border-radius: var(--r-md); background: transparent;
  filter: drop-shadow(0 1px 1px rgba(46, 36, 26, .14));
  transition: transform .35s var(--ease), filter .35s var(--ease);
}
.kcard:hover { transform: translateY(-2px); filter: drop-shadow(0 4px 6px rgba(46, 36, 26, .16)); }
.kcard.dragging { opacity: .45; }
.kcard-main {
  padding: 11px 12px 10px 13px; min-width: 0;
  background:
    radial-gradient(circle at 100% 0, transparent var(--notch), var(--surface) calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at 100% 100%, transparent var(--notch), var(--surface) calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
  border-radius: var(--r-md) 0 0 var(--r-md);
}
.stub {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 8px 4px; text-align: center;
  background:
    radial-gradient(circle at 0 0, transparent var(--notch), var(--oat) calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at 0 100%, transparent var(--notch), var(--oat) calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.stub::before { /* perforation */
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px;
  background: radial-gradient(circle, var(--sand) 1.2px, transparent 1.6px) 0 0 / 2px 7px repeat-y;
}
.stub b { font-size: 26px; line-height: 1; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.stub span { font-size: 11px; color: var(--ink-2); }
.stub em { font-style: normal; font-size: 11px; color: var(--ink-2); margin-top: 5px; font-weight: 600; }
.stub-empty { font-size: 11px; color: var(--ink-2); line-height: 1.2; }
.kcard.soon .stub { background:
    radial-gradient(circle at 0 0, transparent var(--notch), var(--terracotta) calc(var(--notch) + .5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at 0 100%, transparent var(--notch), var(--terracotta) calc(var(--notch) + .5px)) bottom / 100% 51% no-repeat; }
.kcard.soon .stub b, .kcard.soon .stub span, .kcard.soon .stub em { color: #fff; }
.kcard-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 20px; min-width: 0; }
.kcard-top .ref { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kcard-top .pill { flex: none; }
.ref { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stub b.today { font-size: 15px; }
.kcard h4 { font-size: 14.5px; margin: 3px 0 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-trip, .kcard-meta { margin: 0; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-meta { color: var(--ink-3); }
.kcard-foot { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: 12px; }
.kcard-foot b { font-weight: 600; white-space: nowrap; }
.kcard-foot span { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kcol.closed { display: flex; flex-direction: column; gap: 12px; background: none; padding: 0; }
.drop-zone {
  border: 1.5px dashed var(--clay); border-radius: var(--r-lg); padding: 18px 14px; min-height: 150px;
  display: flex; flex-direction: column; gap: 4px; transition: background .3s var(--ease);
}
.drop-zone h3 { font-size: 14px; }
.drop-zone b { font-size: 30px; font-weight: 700; line-height: 1.1; }
.drop-zone span { font-size: 12px; color: var(--ink-3); }
.drop-zone.lost { border-color: #C9927A; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border-radius: var(--r-md); overflow: auto; border: 1px solid var(--line-soft); }
.table-wrap.compact { border: 0; border-radius: 12px; background: transparent; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
.data th, .data td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
.data th { font-size: 11.5px; font-weight: 600; color: var(--ink-3); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.data th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.data th button:focus-visible { outline: 2px solid var(--terracotta); }
.data th[aria-sort="ascending"] button::after, .data th[aria-sort="descending"] button::after {
  content: ''; border: 4px solid transparent; border-bottom-color: currentColor; margin-top: -4px;
}
.data th[aria-sort="descending"] button::after { border-bottom-color: transparent; border-top-color: currentColor; margin-top: 4px; }
.data th[aria-sort="ascending"], .data th[aria-sort="descending"] { color: var(--ink); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data tbody tr:last-child td { border-bottom: 0; }
.data.clickable tbody tr { cursor: pointer; transition: background .2s var(--ease); }
.data.clickable tbody tr:hover, .data.clickable tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.data tfoot td { font-weight: 700; border-top: 1.5px solid var(--line); border-bottom: 0; background: var(--surface-2); }
.compact .data th { background: transparent; position: static; }
.empty-cell { text-align: center !important; color: var(--ink-3); padding: 24px !important; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.pager .muted { margin-right: auto; font-size: 13px; }
.wa { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--ink); }
.wa:hover { color: var(--terracotta-deep); text-decoration: underline; }
.group-title { font-size: 15px; margin: 22px 0 8px; }
.group-title .muted { font-weight: 500; }
.foot { color: var(--ink-3); font-size: 12px; margin: 14px 2px 0; }

.empty-state { background: var(--surface); border-radius: var(--r-lg); padding: 48px 20px; text-align: center; }
.empty-state h3 { font-family: var(--f-display); font-size: 20px; margin-bottom: 4px; }
.empty-state p { color: var(--ink-3); margin: 0; }

/* ---------- Stats & KPIs ---------- */
.stat-row, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat, .kpi { background: var(--surface); border-radius: var(--r-md); padding: 13px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat span, .kpi span { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat b, .kpi b { font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.kpi b { font-size: 25px; }
.stat em, .kpi em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.stat.alert { background: var(--bad-bg); }
.stat.alert span, .stat.alert em { color: var(--bad-ink); }

/* ---------- Rejections: outcome tiles, heat matrix ---------- */
.otiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.otile {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 1px;
  background: var(--surface); border-radius: var(--r-md); padding: 11px 14px; border: 1.5px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.otile:hover { background: var(--surface-2); }
.otile:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }
.otile-name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.otile-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--bad-ink); flex: none; }
.otile.ok .otile-name::before { background: var(--moss); }
.otile.warn .otile-name::before { background: var(--ochre); }
.otile b { font-size: 24px; font-weight: 700; line-height: 1.2; }
.otile em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.otile.on { border-color: var(--terracotta); background: color-mix(in srgb, var(--terracotta) 10%, var(--surface)); }
.matrix th { white-space: normal; vertical-align: bottom; min-width: 64px; }
.matrix td[style] { background: color-mix(in srgb, var(--terracotta) calc(var(--heat) * 45%), transparent); font-weight: 600; }
.outcome-select {
  min-height: 0; padding: 3px 26px 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  border: 1px solid transparent; background-position: right 9px center; cursor: pointer;
}
.outcome-select.ok { background-color: var(--ok-bg); color: var(--ok-ink); }
.outcome-select.warn { background-color: var(--warn-bg); color: var(--warn-ink); }
.outcome-select.bad { background-color: var(--bad-bg); color: var(--bad-ink); }
.outcome-select:hover { border-color: var(--clay); }
.outcome-select option { background: var(--surface); color: var(--ink); }
.note-cell { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }

/* ---------- Panels & charts ---------- */
.panel { background: var(--surface); border-radius: var(--r-lg); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.panel h3 { font-size: 15px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; margin-bottom: 14px; }
.wide-panel { margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.chart-body[data-pane="table"] { max-height: 320px; overflow: auto; }
.chart-empty { color: var(--ink-3); text-align: center; padding: 40px 0; font-size: 13px; }

.hbars { display: flex; flex-direction: column; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px; outline: none; }
.hbar:hover, .hbar:focus-visible { background: var(--surface-2); }
.hbar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; display: flex; align-items: center; }
.hbar-track i { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--terracotta); min-width: 0; transition: width .5s var(--ease); }
.hbar-val { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }

.cols { --h: 180px; padding-left: 40px; }
.cols-plot { position: relative; height: var(--h); border-bottom: 1px solid var(--clay); }
.grid-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-soft); }
.grid-line span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; padding: 0 2px; }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px 6px 0 0; outline: none; }
.col i { display: block; width: min(70%, 34px); background: var(--terracotta); border-radius: 4px 4px 0 0; transition: height .5s var(--ease); }
.col:hover, .col:focus-visible { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
.col:hover i, .col:focus-visible i { background: var(--terracotta-deep); }
.cols-x { display: flex; gap: 2px; padding: 6px 2px 0; }
.cols-x span { flex: 1; text-align: center; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(46, 36, 26, .32); animation: fade .3s var(--ease); }
.drawer-ov { display: flex; justify-content: flex-end; }
.drawer {
  width: min(640px, 100%); height: 100%; background: var(--sand); display: flex; flex-direction: column;
  border-radius: var(--r-lg) 0 0 var(--r-lg); box-shadow: -10px 0 30px rgba(46, 36, 26, .18);
  animation: slide .4s var(--ease);
}
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { font-size: 26px; line-height: 1.15; }
.eyebrow { margin: 0 0 2px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.head-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.drawer-actions { display: flex; gap: 6px; align-items: flex-start; }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 22px 20px; }
.drawer-body fieldset { border: 0; margin: 0; padding: 14px 0 6px; border-bottom: 1px solid var(--line-soft); }
.drawer-body fieldset:last-child { border-bottom: 0; }
legend { font-family: var(--f-display); font-weight: 600; font-size: 16px; padding: 0; margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field input, .field select { width: 100%; }
.field small { color: var(--ink-3); font-size: 11.5px; }
.field.full { grid-column: 1 / -1; }
.calc { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 8px; }
.calc > div { background: var(--surface); border-radius: 12px; padding: 8px 10px; }
.calc span { display: block; font-size: 11px; color: var(--ink-3); }
.calc b { font-size: 14px; font-variant-numeric: tabular-nums; }
.calc p { grid-column: 1 / -1; margin: 0; }
.note-add { display: flex; gap: 8px; margin-bottom: 12px; }
.note-add input { flex: 1; border-radius: 99px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 4px; }
.timeline li::before { content: ''; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--clay); border: 2px solid var(--sand); }
.timeline li.tl-stage::before { background: var(--terracotta); }
.timeline li.tl-note::before { background: var(--moss); }
.timeline p { margin: 0; font-size: 13px; }
.drawer-foot { display: flex; gap: 8px; align-items: center; padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0)); border-top: 1px solid var(--line-soft); }
.spacer { flex: 1; }

/* ---------- Modal ---------- */
.overlay:not(.drawer-ov) { display: grid; place-items: center; padding: 16px; z-index: 60; }
.dialog { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--sand); border-radius: var(--r-lg); box-shadow: 0 20px 50px rgba(46, 36, 26, .25); animation: rise .35s var(--ease); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.dialog-head h2 { font-size: 22px; }
.dialog-body { padding: 8px 20px 14px; }
.dialog-body p { margin: 0 0 8px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Sign-in, loading, notices ---------- */
.signed-out .nav, .signed-out .top-tools { display: none; }
.login { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h2 { font-size: 28px; line-height: 1.15; }
.login-card .sub { margin-top: -8px; }
.login-card .btn { justify-content: center; padding: 11px; }
.brand-mark.big { width: 40px; height: 40px; display: block; }
.login-error { margin: 0; min-height: 1.2em; color: var(--bad-ink); font-size: 13px; }
.loading { color: var(--ink-3); text-align: center; padding: 80px 0; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; margin: 12px 0 0; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.notice .btn { padding: 5px 12px; }

/* ---------- Tooltip & toast ---------- */
.tip {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; max-width: 300px;
  background: var(--ink); color: var(--sand); padding: 7px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 6px 16px rgba(46, 36, 26, .25);
}
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0)); z-index: 95;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--sand); padding: 10px 18px; border-radius: 99px; font-weight: 500;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1420px) {
  .clocks { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0)) 14px 10px; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: 7px 12px; }
  .new-label { display: none; }
  #new-lead-btn { padding: 9px 11px; }
  .top-tools { gap: 6px; }
  .pill.sample, #sync-pill { display: none; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg button { white-space: nowrap; }
  .stat-row, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat b, .kpi b { font-size: 19px; overflow-wrap: anywhere; }
  .filters select { flex: 1 1 140px; }
  .brand h1 { font-size: 19px; }
  .view { padding: 16px 14px 50px; }
  .page-head h2 { font-size: 28px; }
  .board { grid-template-columns: repeat(6, 82vw); scroll-snap-type: x mandatory; }
  .board > * { scroll-snap-align: start; }
  .kcol-body { max-height: none; }
  .drawer { border-radius: 0; }
  .calc { grid-template-columns: 1fr 1fr; }
  .settings { grid-template-columns: 1fr; }
  .search { max-width: none; }
}
@media print {
  .topbar, .filters, .head-actions, body::before { display: none; }
  body { background: #fff; }
}
