/* Wahdan Hub — honed stone surface, obsidian bar carrying the gold mark, gold for the one action that matters. */
:root {
  --obsidian: #121316;
  --obsidian-2: #1d1f24;
  --slab: #edefec;
  --card: #ffffff;
  --ink: #17181c;
  --mute: #5b6270;
  --faint: #8a909a;
  --line: #dadddb;
  --line-2: #e8eae7;
  --gold: #c2923a;
  --gold-ink: #85600f;
  --gold-soft: #f5ecd8;
  --good: #1e7a52;
  --good-soft: #e1f1e8;
  --late: #b3261e;
  --late-soft: #f9e3e0;
  --warn: #9a5800;
  --warn-soft: #fcecd4;
  --info: #2f5e8c;
  --info-soft: #e3ecf6;
  --teal: #0f6e70;
  --teal-soft: #dff0ef;
  --radius: 10px;
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --display: "El Messiri", "Readex Pro", serif;
  /* Plex Mono has no Arabic, so Arabic words inside numbers (ج.م، ألف) fall through to Readex Pro, not a system monospace. */
  --mono: "IBM Plex Mono", "Readex Pro", ui-monospace, Consolas, monospace;
  --bar-h: 58px;
  --tab-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--slab); color: var(--ink); font: 15px/1.55 var(--font); min-height: 100dvh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
bdi.mono { unicode-bidi: isolate; direction: ltr; }
.mute { color: var(--mute); }
.faint { color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--gold); color: var(--ink); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { top: 8px; }

/* ---------------------------------------------------------------- top bar */
.bar { position: sticky; top: 0; z-index: 30; height: var(--bar-h); background: var(--obsidian); color: #e9e6df;
  display: flex; align-items: center; gap: 18px; padding-inline: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 30px; height: auto; display: block; }
.brand b { font-family: var(--display); font-weight: 600; font-size: 19px; color: #f2e7cf; letter-spacing: .01em; }
.nav { display: flex; gap: 2px; height: 100%; flex: 1; min-width: 0; }
.nav a { position: relative; display: flex; align-items: center; gap: 7px; padding-inline: 12px; text-decoration: none; color: #b9b6ae; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; }
.nav a[aria-current="page"]::after { content: ""; position: absolute; inset-inline: 10px; bottom: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, #f2d486 55%, var(--gold) 85%, transparent); }
.nav .badge { background: var(--late); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center; padding-inline: 5px; font-family: var(--mono); }
.bar-end { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.bar .ghost { background: transparent; border: 1px solid #3a3d44; color: #d9d5cc; border-radius: 8px; height: 36px; padding-inline: 10px; font-size: 13px; }
.bar .ghost:hover { border-color: #5a5e66; color: #fff; }
.bar .me { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2a2c32; color: #f2e7cf; display: grid; place-items: center; font-size: 13px; font-weight: 600; border: 1px solid #3a3d44; }
.bar-title { display: none; font-family: var(--display); font-size: 18px; color: #f2e7cf; }

/* bottom tabs (phones) */
.tabs { display: none; }

/* ---------------------------------------------------------------- page */
main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1.2; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--mute); }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.section-title { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin: 0 0 10px; }
.section-title h2 .count { font-family: var(--mono); color: var(--mute); font-weight: 400; margin-inline-start: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding-inline: 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: #b9bdb9; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: #b58630; border-color: #b58630; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--late); border-color: #e7b9b4; }
.btn.danger.solid { background: var(--late); color: #fff; border-color: var(--late); }
.btn.sm { height: 32px; padding-inline: 10px; font-size: 13px; border-radius: 7px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.wa { color: #116b3c; border-color: #bfe0cc; }
.btn.wa:hover { background: #effaf3; }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; padding: 0; color: var(--gold-ink); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.sm svg.i { width: 16px; height: 16px; }

label.f { display: block; }
label.f > span, .f-label { display: block; font-size: 13px; color: var(--mute); margin-bottom: 5px; font-weight: 500; }
label.f > span em, .f-label em { color: var(--late); font-style: normal; }
.in, select.in, textarea.in { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.in { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.in:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(194, 146, 58, .18); }
.in.mono { font-family: var(--mono); direction: ltr; text-align: start; }
[dir="rtl"] .in.mono { text-align: right; }
.in.big { height: 52px; font-size: 20px; }
.hint { font-size: 12px; color: var(--mute); margin-top: 4px; }
.err { color: var(--late); font-size: 13px; margin-top: 6px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* chips: single / multi choice */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 36px; padding-inline: 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: #b9bdb9; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.lost[aria-pressed="true"] { background: var(--late); border-color: var(--late); }
.chip.won[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
.chip .n { font-family: var(--mono); font-size: 12px; opacity: .7; }

/* stage pill */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding-inline: 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--line-2); color: var(--mute); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-NEW { background: var(--gold-soft); color: var(--gold-ink); }
.pill.s-CONTACTED { background: #eceeed; color: #4a505a; }
.pill.s-INTERESTED { background: var(--info-soft); color: var(--info); }
.pill.s-VISIT { background: var(--teal-soft); color: var(--teal); }
.pill.s-QUOTED { background: var(--warn-soft); color: var(--warn); }
.pill.s-WON { background: var(--good-soft); color: var(--good); }
.pill.s-LOST { background: var(--late-soft); color: var(--late); }
.tag { display: inline-flex; align-items: center; height: 22px; padding-inline: 7px; border-radius: 5px; background: var(--line-2); color: var(--mute); font-size: 12px; white-space: nowrap; }
.tag.code { font-family: var(--mono); direction: ltr; }

/* ---------------------------------------------------------------- lead cards (Today / phone lists) */
.lc { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lc + .lc { margin-top: 8px; }
.lc .who { min-width: 0; text-decoration: none; }
.lc .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc .who .mono { color: var(--mute); font-size: 13px; }
.lc .what { grid-column: 1 / -1; font-size: 13.5px; color: var(--mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lc .meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--mute); }
.lc .acts { display: flex; gap: 6px; align-items: flex-start; }
.lc.overdue { border-color: #ecc3be; }
.lc.overdue .when { color: var(--late); font-weight: 600; }

/* Signature: the response clock — a gold vein that runs out and turns red when first contact is late. */
.clock { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 12.5px; color: var(--gold-ink); }
.clock.late { color: var(--late); font-weight: 600; }
.vein { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--line-2); }
.vein::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, #f2d486, var(--gold)); transition: width .6s ease-out; }
[dir="rtl"] .vein::after { background: linear-gradient(270deg, #f2d486, var(--gold)); }
.vein.late::after { width: 100%; background: var(--late); }
@media (prefers-reduced-motion: no-preference) { .vein.late::after { animation: pulse 1.6s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; font-weight: 500; color: var(--mute); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfa; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #fafaf7; }
.tbl td.n, .tbl th.n { text-align: end; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .name b { display: block; font-weight: 600; }
.tbl .name .mono { font-size: 12.5px; color: var(--mute); }
.tbl .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute); }
.tbl td.bad { color: var(--late); font-weight: 600; }

/* ---------------------------------------------------------------- toolbar / filters */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .in { padding-inline-start: 36px; }
.stage-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px; }
.stage-tabs::-webkit-scrollbar { display: none; }
.stage-tabs button { flex: none; height: 36px; padding-inline: 12px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--mute); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.stage-tabs button:hover { background: #e3e6e2; }
.stage-tabs button[aria-pressed="true"] { background: var(--card); border-color: var(--line); color: var(--ink); font-weight: 600; }
.stage-tabs .n { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.filters { padding: 14px; margin-bottom: 12px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.active-filters button { height: 28px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; padding-inline: 10px; display: inline-flex; align-items: center; gap: 6px; }
.bulk { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 10px; align-items: center; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; margin-top: 12px; flex-wrap: wrap; }
.bulk select { height: 34px; border-radius: 7px; border: 0; padding-inline: 8px; color: var(--ink); }

/* ---------------------------------------------------------------- empty + notices */
.empty { padding: 28px 16px; text-align: center; color: var(--mute); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.notice { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 9px; background: var(--gold-soft); color: #5b430e; font-size: 14px; flex-wrap: wrap; }
.notice.bad { background: var(--late-soft); color: #7d1b15; }
.notice.ok { background: var(--good-soft); color: #154f36; }
.notice.info { background: var(--info-soft); color: #23466a; }
.skeleton { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, #e6e8e5 0%, #f1f2f0 50%, #e6e8e5 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton + .skeleton { margin-top: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- Today */
.today { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.today > * { min-width: 0; }
.scope { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.scope button { height: 36px; padding-inline: 14px; border: 0; background: transparent; font-size: 13.5px; color: var(--mute); }
.scope button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.visit-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; }
.visit-row + .visit-row { border-top: 1px solid var(--line-2); }
.visit-row .t { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.visit-row.done { opacity: .6; }
.day-head { font-size: 13px; color: var(--mute); font-weight: 600; margin: 18px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.day-head.is-today { color: var(--gold-ink); }

/* ---------------------------------------------------------------- lead page */
.lead-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 18px; }
.lead-top h1 { font-family: var(--display); font-size: 28px; font-weight: 600; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.lead-top .phone { font-family: var(--mono); font-size: 16px; color: var(--mute); }
.lead-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 18px; padding: 0 18px 18px; }
.fact span { display: block; font-size: 12px; color: var(--mute); }
.fact b { font-weight: 500; overflow-wrap: anywhere; }
.enquiry { margin: 0 18px 18px; padding: 12px 14px; background: #f7f7f4; border-inline-start: 3px solid var(--gold); border-radius: 6px; white-space: pre-line; }
.next-box { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.next-box.overdue { background: var(--late-soft); }
.next-box .when { font-weight: 600; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; margin-top: 16px; }
.lead-grid > * { min-width: 0; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line-2); }
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { position: relative; padding: 10px 16px 10px 16px; padding-inline-start: 38px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 18px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 14px; top: 15px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--faint); }
.timeline li.k-contact::after { border-color: var(--info); }
.timeline li.k-stage::after { border-color: var(--gold); background: var(--gold); }
.timeline li.k-payment::after { border-color: var(--good); background: var(--good); }
.timeline li.k-visit::after, .timeline li.k-visit_done::after { border-color: var(--teal); }
.timeline .head { font-size: 13px; color: var(--mute); display: flex; gap: 6px; flex-wrap: wrap; }
.timeline .head b { color: var(--ink); font-weight: 600; }
.timeline .body { white-space: pre-line; font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.side-block { padding: 14px 16px; }
.side-block + .side-block { border-top: 1px solid var(--line-2); }
.mini-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.mini-row + .mini-row { border-top: 1px dashed var(--line-2); }
.money { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-big { font-family: var(--mono); font-size: 22px; font-weight: 600; }

/* ---------------------------------------------------------------- sheets (dialogs) */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(12, 13, 15, .52); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .18s; }
.scrim.open { opacity: 1; }
.sheet { width: min(560px, 100%); max-height: calc(100dvh - 40px); background: var(--card); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(10px) scale(.99); transition: transform .2s ease-out; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.sheet.wide { width: min(860px, 100%); }
.scrim.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 14px 18px; border-bottom: 1px solid var(--line-2); flex: none; }
.sheet-head h2 { font-family: var(--display); font-size: 20px; font-weight: 600; flex: 1; min-width: 0; }
.sheet-head .sub { font-size: 13px; color: var(--mute); }
.sheet-body { padding: 16px 18px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-2); flex: none; background: #fbfbfa; flex-wrap: wrap; }
.sheet-foot .left { margin-inline-end: auto; }
.sheet .block + .block { margin-top: 16px; }
.dup { margin-top: 8px; }
.menu { position: fixed; z-index: 70; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, .16); padding: 6px; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; height: 40px; border: 0; background: none; padding-inline: 10px; border-radius: 7px; text-align: start; text-decoration: none; font-size: 14px; }
.menu button:hover, .menu a:hover { background: var(--slab); }
.menu .danger { color: var(--late); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }

/* toast */
.toasts { position: fixed; z-index: 90; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); pointer-events: auto; display: flex; gap: 10px; align-items: center; animation: up .2s ease-out; }
.toast.bad { background: var(--late); }
.toast a, .toast button { color: #f2d486; background: none; border: 0; text-decoration: underline; padding: 0; margin-inline-start: auto; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- quote builder */
.q-lines { display: grid; gap: 8px; }
.q-line { display: grid; grid-template-columns: minmax(0, 1fr) 84px 92px 104px 96px 34px; gap: 8px; align-items: center; }
.q-line .in { height: 38px; }
.q-line .tot { font-family: var(--mono); text-align: end; font-size: 14px; }
.q-head { font-size: 12px; color: var(--mute); }
.q-sum { display: grid; gap: 6px; margin-top: 14px; margin-inline-start: auto; width: min(320px, 100%); }
.q-sum div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.q-sum .grand { border-top: 2px solid var(--ink); padding-top: 8px; font-size: 19px; font-weight: 600; }

/* ---------------------------------------------------------------- overview */
.now-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.now-tile { display: block; text-decoration: none; padding: 12px 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.now-tile:hover { border-color: #b9bdb9; }
.now-tile span { display: block; font-size: 12.5px; color: var(--mute); }
.now-tile b { font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1.3; }
.now-tile small { display: block; font-size: 12px; color: var(--mute); }
.now-tile.alarm { border-color: #ecc3be; background: #fff8f7; }
.now-tile.alarm b { color: var(--late); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.kpi { padding: 16px; min-width: 0; }
.kpi + .kpi { border-inline-start: 1px solid var(--line-2); }
.kpi span { display: block; font-size: 13px; color: var(--mute); }
.kpi b { display: block; font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { font-size: 12.5px; color: var(--mute); display: block; }
.delta { font-family: var(--mono); font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--late); }
.funnel { padding: 18px; }
.f-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 120px; gap: 12px; align-items: center; }
.f-row + .f-row { margin-top: 8px; }
.f-row .lbl { font-size: 14px; }
.f-bar { height: 30px; background: var(--line-2); border-radius: 6px; overflow: hidden; position: relative; }
.f-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 6px;
  background: linear-gradient(90deg, #2b2d33, #17181c); }
[dir="rtl"] .f-bar i { background: linear-gradient(270deg, #2b2d33, #17181c); }
.f-bar i::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(118deg, transparent 0 22px, rgba(242, 212, 134, .22) 22px 23px, transparent 23px 47px); }
.f-row.won .f-bar i { background: var(--gold); }
.f-row.won .f-bar i::after { background: repeating-linear-gradient(118deg, transparent 0 22px, rgba(255, 255, 255, .35) 22px 23px, transparent 23px 47px); }
.f-row .v { font-family: var(--mono); font-size: 14px; text-align: end; }
.f-row .v small { color: var(--mute); }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 140px) minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 10px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--ink); border-radius: 5px; }
.bar-row.lost .track i { background: var(--late); }
.bar-row .n { font-family: var(--mono); text-align: end; }
.strip svg { width: 100%; height: 90px; display: block; }
.period { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- settings */
.set-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.set-nav { display: grid; gap: 2px; position: sticky; top: calc(var(--bar-h) + 16px); }
.set-nav a { padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--mute); font-size: 14px; }
.set-nav a:hover { background: #e3e6e2; }
.set-nav a[aria-current="page"] { background: var(--card); color: var(--ink); font-weight: 600; border: 1px solid var(--line); }
.list-edit { display: grid; gap: 8px; }
.list-edit .li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; gap: 8px; }
.list-edit .li.x4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px 110px 34px; }
.tpl { padding: 14px; }
.tpl + .tpl { border-top: 1px solid var(--line-2); }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; background: #fbfbfa; }
.drop.over { border-color: var(--gold); background: var(--gold-soft); }

/* ---------------------------------------------------------------- sign in */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { background: var(--obsidian); color: #e9e6df; display: flex; flex-direction: column; justify-content: space-between; padding: 40px; position: relative; overflow: hidden; }
.auth-art::before { content: ""; position: absolute; inset: -20%; background:
  radial-gradient(60% 40% at 70% 30%, rgba(194, 146, 58, .16), transparent 70%),
  repeating-linear-gradient(121deg, transparent 0 60px, rgba(242, 212, 134, .07) 60px 61px, transparent 61px 140px),
  repeating-linear-gradient(33deg, transparent 0 90px, rgba(255, 255, 255, .03) 90px 91px, transparent 91px 200px); }
.auth-art > * { position: relative; }
.auth-art img { width: 120px; }
.auth-art h2 { font-family: var(--display); font-size: 34px; font-weight: 600; color: #f2e7cf; line-height: 1.25; margin: 0; max-width: 14ch; }
.auth-art p { color: #a9a59c; max-width: 40ch; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.auth-form form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth-form h1 { font-family: var(--display); font-size: 28px; font-weight: 600; margin: 0 0 4px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .now-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(4) { border-inline-start: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--line-2); }
  .lead-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .bar { gap: 10px; padding-inline: 12px; height: 54px; --bar-h: 54px; }
  .brand b, .nav, .bar .ghost.hide-sm, .bar .me .who { display: none; }
  .bar-title { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 14px 14px calc(var(--tab-h) + 30px + env(safe-area-inset-bottom)); }
  .tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 30; inset-inline: 0; bottom: 0;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
  .tabs a, .tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--mute); font-size: 11.5px; border: 0; background: none; position: relative; }
  .tabs svg.i { width: 22px; height: 22px; }
  .tabs [aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabs [aria-current="page"]::before { content: ""; position: absolute; top: 0; inset-inline: 28%; height: 2px; background: var(--gold); border-radius: 2px; }
  .tabs .badge { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); background: var(--late); color: #fff; font-size: 10.5px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding-inline: 4px; font-family: var(--mono); }
  .page-head h1 { font-size: 24px; }
  .today, .cols-2, .cols-3, .set-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: static; display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .set-nav a { flex: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .in, select.in, textarea.in { font-size: 16px; height: 46px; }
  textarea.in { height: auto; }
  .chip { height: 40px; }
  .btn { height: 44px; }
  .btn.sm { height: 36px; }
  .btn.sm.icon { width: 36px; }
  .scrim { align-items: flex-end; padding: 0; }
  .sheet, .sheet.wide { width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; transform: translateY(30px); }
  .sheet-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; }
  .sheet-foot .left { flex: 0 0 auto; }
  .now-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-inline-start: 0; }
  .kpi:nth-child(4) { border-inline-start: 1px solid var(--line-2); }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line-2); }
  .kpi b { font-size: 22px; }
  .f-row { grid-template-columns: 86px minmax(0, 1fr) 84px; gap: 8px; }
  .lead-top h1 { font-size: 24px; }
  .action-bar { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); background: #fff; z-index: 4; border-radius: 0 0 var(--radius) var(--radius); }
  .action-bar .btn { flex: 1; }
  .q-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .q-line .lbl { grid-column: 1 / -1; }
  .q-line .unit { grid-column: auto; }
  .q-head { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 26px 20px; min-height: 200px; }
  .auth-art h2 { font-size: 24px; }
  .auth-art p { display: none; }
  .auth-art img { width: 64px; }
  .list-edit .li.x4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .list-edit .li.x4 > :nth-child(3), .list-edit .li.x4 > :nth-child(4) { grid-column: span 1; }
  .bulk { bottom: calc(var(--tab-h) + 10px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
