:root {
  --font: 'Onest', 'Segoe UI', system-ui, sans-serif;
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.79rem + 0.15vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.92rem + 0.1vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;

  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--text-base); color-scheme: dark; line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.xs { font-size: var(--text-xs); }
.min0 { min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── кнопки й поля ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: var(--text-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, filter .15s;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.tiny { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); font-weight: 500; }
.btn.block { width: 100%; height: 44px; }
.btn:focus-visible, .fchip:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.link { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.icon-btn { border: 0; background: none; color: var(--faint); cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; }
.icon-btn:hover { color: var(--text); }

.field { display: block; margin-bottom: var(--space-4); }
.field > span:first-child { display: block; font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--space-1); font-weight: 500; }
.field input, .field select, .month select, .field-inline select {
  width: 100%; height: 44px; padding: 0 var(--space-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
}
.month select, .field-inline select { height: 40px; width: auto; min-width: 150px; font-size: var(--text-sm); font-weight: 500; }
.field input:focus, .field select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.pass { position: relative; display: block; }
.pass input { padding-right: 44px; }
.pass .icon-btn { position: absolute; right: 4px; top: 4px; }

/* ── бренд ── */
.brand { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); white-space: nowrap; }
.brand b { font-weight: 700; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); position: relative; flex: none; }
.mark::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 9px; border-radius: 2px; background: var(--primary); }
.mark::before { content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border-radius: 1px; background: var(--hl); }

/* ── вхід ── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-6); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: var(--space-8) var(--space-6) var(--space-6); box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: var(--space-8); }
.login-card h1 { margin-bottom: var(--space-1); }
.login-card > p.muted { font-size: var(--text-sm); margin-bottom: var(--space-6); }
.demo-note { margin-top: var(--space-4); font-size: var(--text-xs); color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }

/* ── каркас: бічна панель ── */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-5) var(--space-3); background: var(--side-bg); color: var(--side-text); border-right: 1px solid var(--side-line); }
.side-brand { padding: 0 var(--space-3); color: var(--text); }
.side .mark { background: var(--surface-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-i { display: flex; align-items: center; gap: var(--space-3); height: 42px; padding: 0 var(--space-3); border: 0; border-radius: 9px; background: none; color: var(--side-muted); font-size: var(--text-sm); font-weight: 500; cursor: pointer; text-align: left; transition: background-color .15s, color .15s; }
.nav-i:hover { background: var(--side-hover); color: var(--text); }
.nav-i[aria-current="page"] { background: var(--side-active); color: var(--text); box-shadow: inset 3px 0 0 var(--primary); }
.nav-i[aria-current="page"] svg { color: var(--primary-ink); }
.nav-i svg { flex: none; }
.nav-l { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); font-size: 0.6875rem; font-weight: 700; display: inline-grid; place-items: center; }
.nav-b.warn { background: var(--hl); color: #111; border-color: var(--hl); }
.nav-i:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--side-line); min-width: 0; }
.side-foot .who-t { display: flex; flex-direction: column; line-height: 1.25; font-size: var(--text-sm); font-weight: 500; min-width: 0; flex: 1; color: var(--text); }
.side-foot .who-t > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .icon-btn { color: var(--faint); }
.side-foot .icon-btn:hover { color: var(--text); background: var(--side-hover); }
.main { min-width: 0; }

.top { position: sticky; top: 0; z-index: 20; background: var(--top-bg); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1240px; margin: 0 auto; padding: var(--space-3) var(--space-6); display: flex; align-items: center; gap: var(--space-4); min-height: 64px; }
.top-brand, .top-logout { display: none; }
.top-title { font-weight: 600; font-size: var(--text-sm); color: var(--muted); }
.top-r { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-size: var(--text-xs); font-weight: 700; flex: none; }

.avatar.lg { width: 48px; height: 48px; font-size: var(--text-sm); }
.avatar.sm { width: 26px; height: 26px; font-size: 0.6875rem; }

/* ── сторінка ── */
.wrap { max-width: 1240px; margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-12); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page-head p { font-size: var(--text-sm); margin-top: 2px; }
.me-title { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.me-tools { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); margin-bottom: var(--space-4); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.ok { background: var(--pos-soft); color: var(--pos); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.info { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.page-head .status { margin-bottom: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }

/* підсумок */
.summary { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--space-4); box-shadow: var(--shadow); }
.sum-cell { background: var(--surface); padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.label { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.big { font-size: var(--text-xl); font-weight: 700; line-height: 1.1; }
.big small { font-size: var(--text-sm); font-weight: 500; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
.chip { font-size: var(--text-xs); font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.accent { background: var(--hl-soft); border-color: var(--hl-line); color: var(--hl-ink); }

.delta { font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--faint); }

/* картки метрик */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.metric header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.metric h2 { font-size: var(--text-sm); font-weight: 600; color: var(--muted); text-transform: none; }
.fact-line { display: flex; align-items: baseline; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-3); }
.fact { font-size: var(--text-xl); font-weight: 700; line-height: 1.1; }
.fact.empty { font-size: var(--text-lg); font-weight: 600; color: var(--faint); }
.unit { color: var(--muted); font-weight: 500; font-size: var(--text-sm); }
.of { margin-left: auto; font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.bar { height: 8px; border-radius: 99px; background: var(--grid); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s cubic-bezier(.2, .8, .2, 1); }
.bar.over > span { background: var(--pos); }
.bar.thin { height: 4px; margin-top: 4px; }
.pct-line { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); margin: var(--space-2) 0 var(--space-3); font-size: var(--text-xs); flex-wrap: wrap; }
.pct { font-size: var(--text-base); font-weight: 700; }
.kv { margin: 0; border-top: 1px solid var(--border); padding-top: var(--space-2); }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: 5px 0; font-size: var(--text-xs); }
.kv dt { color: var(--muted); min-width: 0; }
.kv dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }
.ok-text { color: var(--pos); }
.flag { font-size: 0.6875rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.conv p { margin-top: var(--space-1); margin-bottom: var(--space-3); line-height: 1.5; }

/* графік */
#me-chart-box { margin-bottom: var(--space-4); }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.chart-head h2 { font-size: var(--text-base); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; height: 30px; padding: 0 var(--space-3); border-radius: 6px; font-size: var(--text-xs); font-weight: 500; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.chart-wrap { position: relative; height: 260px; }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: center; font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-3); }
.legend span { display: inline-block; vertical-align: middle; margin-right: 4px; }
.lg-bar { width: 10px; height: 10px; border-radius: 2px; background: var(--c-bar); }
.lg-bar.alt { background: var(--c-bar-2); }
.lg-line { width: 16px; height: 2.5px; background: var(--c-line); }
.lg-dash { width: 16px; border-top: 2px dashed var(--c-pace); }
.empty-state p { margin-top: var(--space-2); font-size: var(--text-sm); }

/* таблиці */
.table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th { text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--muted); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.journal td { padding: var(--space-2) var(--space-3); }
.edited { color: var(--warn); font-weight: 600; }

.board thead { position: sticky; top: 0; z-index: 1; }
.board tr.grp th { border-bottom: 0; padding-bottom: 0; text-align: center; color: var(--text); font-size: var(--text-xs); }
.board tbody tr { cursor: pointer; transition: background-color .12s; }
.board tbody tr:hover { background: var(--surface-2); }
.board tr.mine { background: var(--primary-soft); }
.board tr.mine:hover { background: var(--primary-soft-2); }
.place-col { width: 44px; }
.delta-col { width: 56px; }
.name-col { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.place { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 700; font-size: var(--text-sm); background: var(--surface-2); border: 1px solid var(--border); }
.place.p1 { background: var(--hl); color: #111; border-color: var(--hl); }
.place.p2, .place.p3 { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-ink); }
.pctb { display: inline-block; min-width: 44px; text-align: right; font-weight: 600; }
.pctb.hit { color: var(--pos); }
.pts { font-weight: 700; font-size: var(--text-base); }
.badge { margin-left: 6px; font-size: 0.6875rem; font-weight: 700; color: var(--pos); background: var(--pos-soft); border-radius: 4px; padding: 1px 5px; vertical-align: 1px; }
.you { font-size: 0.6875rem; font-weight: 700; color: var(--on-primary); background: var(--primary); border-radius: 4px; padding: 1px 6px; }
.miss { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); font-size: 0.6875rem; font-weight: 700; }

.board-cards { display: none; list-style: none; margin: 0; padding: 0; }
.rules { margin-top: var(--space-4); }
.rules summary { cursor: pointer; font-weight: 600; font-size: var(--text-sm); }
.rules ul { margin: var(--space-3) 0 0; padding-left: var(--space-5); font-size: var(--text-sm); color: var(--muted); line-height: 1.6; }

.foot { margin-top: var(--space-8); text-align: center; }

/* діалог */
.dialog { border: 0; border-radius: 16px; padding: var(--space-6); width: min(520px, calc(100vw - 2 * var(--space-4))); box-shadow: 0 24px 64px rgba(0, 0, 0, .5); background: var(--dialog-bg); color: var(--text); border: 1px solid var(--border-strong); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(var(--backdrop-blur, 0px)); }
.dialog h2 { margin-bottom: var(--space-4); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); }
.dlg-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }

.toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); background: var(--sel-bg); color: var(--sel-text); font-size: var(--text-sm); padding: var(--space-3) var(--space-4); border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 2 * var(--space-4)); }
.fab { display: none; }

/* ── статуси ── */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pending { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border-strong); }
.st-sent { background: var(--primary-soft); color: var(--primary-ink); }
.st-attention { background: var(--hl-soft); color: var(--hl-ink); }
.st-fuelled { background: var(--pos-soft); color: var(--pos); }
.st-regular { background: var(--primary); color: var(--on-primary); }
.st-recontact { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.st-recontact::before { background: var(--hl); }
.st-taken { background: transparent; color: var(--primary-ink); box-shadow: inset 0 0 0 1px var(--primary-line); }
.warn-text { color: var(--warn); font-weight: 600; }

.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.fchip { display: inline-flex; align-items: center; gap: var(--space-2); height: 34px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); font-size: var(--text-xs); font-weight: 500; cursor: pointer; white-space: nowrap; }
.fchip .n { font-weight: 700; color: var(--muted); }
.fchip[aria-selected="true"] { background: var(--sel-bg); color: var(--sel-text); border-color: var(--sel-bg); }
.fchip[aria-selected="true"] .n { color: var(--sel-text); opacity: .7; }
.search { margin-bottom: var(--space-4); }
.search input { width: 100%; max-width: 420px; height: 40px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.clients tbody tr { cursor: pointer; transition: background-color .12s; }
.clients tbody tr:hover { background: var(--surface-2); }
.clients td { vertical-align: top; }
.cl-name { font-weight: 600; overflow-wrap: anywhere; }
.clients .cl-name { white-space: normal; max-width: 280px; }
.hint { margin-top: 4px; white-space: normal; max-width: 220px; }
.ttn { font-variant-numeric: tabular-nums; color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.ttn:hover { text-decoration-color: var(--primary); }
.cl-cards { display: none; list-style: none; margin: 0; padding: 0; }

/* повторний контакт */
.rc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.rc { display: flex; flex-direction: column; gap: var(--space-3); }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.rc-head h2 { font-size: var(--text-base); }
.rc-kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-sm); }
.rc-kv dt { font-size: 0.6875rem; color: var(--muted); }
.rc-kv dd { margin: 2px 0 0; font-weight: 600; font-size: var(--text-sm); overflow-wrap: anywhere; }
.rc-why { font-size: var(--text-sm); line-height: 1.5; }
.rc-taken { font-size: var(--text-sm); line-height: 1.5; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 6px 6px 0; }
.rc-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: auto; }

/* відправка */
.ship-stats { display: flex; gap: var(--space-2); }
.ship-stats > div { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-4); min-width: 120px; }
.ship-stats b { font-size: var(--text-lg); }
.ship td { vertical-align: top; }
.ship .cl-name { white-space: normal; max-width: 260px; }
.ttn-form { display: flex; gap: var(--space-2); }
.ttn-form input { width: 150px; height: 30px; padding: 0 var(--space-2); border: 1px solid var(--border-strong); border-radius: 6px; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.ttn-form input:focus { outline: none; border-color: var(--primary); }

/* віджет клієнтів у профілі */
.cw { margin-bottom: var(--space-4); }
.cw-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); }
.cw-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; text-align: left; min-width: 0; }
.cw-cell:disabled { cursor: default; }
.cw-cell b { font-size: var(--text-lg); }
.cw-cell span { color: var(--muted); }
.cw-cell.f-attention b { color: var(--hl-ink); }
.cw-cell.f-fuelled b { color: var(--pos); }
.cw-cell:not(:disabled):hover { border-color: var(--border-strong); background: var(--surface); }
.cw-att { list-style: none; margin: var(--space-3) 0 0; padding: 0; border-top: 1px solid var(--border); }
.cw-att li { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); cursor: pointer; flex-wrap: wrap; }
.cw-att li:last-child { border-bottom: 0; }
.cw-att li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--hl); align-self: center; }
.cw-att .cl-name { flex: 1; min-width: 0; font-size: var(--text-sm); }

/* картка клієнта */
.wide-dlg { width: min(620px, calc(100vw - 2 * var(--space-4))); max-height: calc(100dvh - 2 * var(--space-6)); }
.cd h2 { margin-bottom: var(--space-1); }
.cd > p.muted { margin-bottom: var(--space-4); }
.cd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.cd-head .icon-btn { margin: -6px -6px 0 0; }
.cd-status { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-3) 0 var(--space-4); }
.cd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); padding: var(--space-4); background: var(--surface-2); border-radius: var(--radius-sm); }
.cd-grid .wide { grid-column: 1 / -1; }
.cd-grid dt { font-size: var(--text-xs); color: var(--muted); }
.cd-grid dd { margin: 2px 0 0; font-weight: 600; font-size: var(--text-sm); overflow-wrap: anywhere; }
.cd-grid a { color: inherit; }
.cd-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.note-form { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.note-form input { flex: 1; min-width: 0; height: 40px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.cd-h3 { font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--space-2); }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 48px 1fr; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); line-height: 1.45; }
.tl li:last-child { border-bottom: 0; }
.tl li.note .tl-t { color: var(--text); }
.tl li.note .tl-t { font-style: normal; }
.tl li.note { background: var(--surface-2); margin: 0 calc(-1 * var(--space-2)); padding-left: var(--space-2); padding-right: var(--space-2); border-radius: 6px; }
.tl-d { color: var(--muted); font-size: var(--text-xs); padding-top: 2px; }
.field textarea { width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; font-size: var(--text-sm); resize: vertical; }
.field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

/* вибір клієнтів у введенні даних */
.hint-c { margin: -8px 0 var(--space-3); }
.fuel-pick b { color: var(--text); font-size: var(--text-sm); margin-left: 4px; }
.picked { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.picked:empty { display: none; }
.pick { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 99px; background: var(--pos-soft); color: var(--pos); font-size: var(--text-xs); font-weight: 600; max-width: 100%; }
.pick button { border: 0; background: none; color: inherit; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1; }
.pick button:hover { background: var(--pos-soft); filter: brightness(1.3); }
.fuel-pick select { width: 100%; height: 44px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.fuel-pick p { margin-top: var(--space-1); }

/* ── адаптив ── */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: var(--space-5) var(--space-2); align-items: center; }
  .side-brand .brand-t, .nav-l, .side-foot .who-t { display: none; }
  .side-brand { padding: 0; }
  .nav-i { width: 52px; justify-content: center; padding: 0; position: relative; }
  .nav-b { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 0.625rem; }
  .side-foot { flex-direction: column; padding: var(--space-3) 0 0; }
  .cw-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40; flex-direction: row; padding: 4px var(--space-1) calc(4px + env(safe-area-inset-bottom)); gap: 0; }
  .side-brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; }
  .nav-i { flex: 1; width: auto; height: 54px; flex-direction: column; gap: 2px; font-size: 0.625rem; }
  .nav-i[hidden] { display: none; }
  .nav-l { display: block; font-size: 0.625rem; max-width: 100%; }
  .nav-i[data-short] .nav-l { font-size: 0; }
  .nav-i[data-short] .nav-l::after { content: attr(data-s); font-size: 0.625rem; }
  .nav-i[aria-current="page"] { box-shadow: inset 0 2px 0 var(--primary); }
  .nav-b { top: 4px; right: calc(50% - 22px); }
  .top-in { padding: var(--space-2) var(--space-4); min-height: 56px; gap: var(--space-3); }
  .top-brand, .top-logout { display: flex; }
  .top-title { color: var(--text); font-size: var(--text-base); }
  #btn-entry { display: none; }
  .wrap { padding: var(--space-4) var(--space-4) calc(var(--space-12) + 120px); }
  .summary { grid-template-columns: 1fr 1fr; }
  .sum-cell.wide { grid-column: 1 / -1; }
  .fab { display: inline-flex; position: fixed; left: var(--space-4); right: var(--space-4); bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 30; height: 48px; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: var(--text-base); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); cursor: pointer; }
  .fab[hidden] { display: none !important; }
  .toast { bottom: calc(136px + env(safe-area-inset-bottom)); }
  #board-table > .card.flush { display: none; }
  .board-cards { display: flex; flex-direction: column; gap: var(--space-2); }
  .bc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow); cursor: pointer; }
  .bc.mine { background: var(--primary-soft); border-color: var(--primary-line); }
  .bc-top { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
  .bc-top .nm { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
  .bc-pts { white-space: nowrap; text-align: right; }
  .bc-pts b { font-size: var(--text-lg); }
  .bc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
  .mini { display: flex; flex-direction: column; font-size: var(--text-sm); min-width: 0; }
  .month select { min-width: 0; }
  .cl-table { display: none; }
  .cl-cards { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
  .clc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
  .clc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--space-4)) var(--space-3); padding: 0 var(--space-4) 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .search input { max-width: none; }
  .ship-stats { width: 100%; }
  .ship-stats > div { flex: 1; min-width: 0; }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .chart-wrap { height: 220px; }
  .me-tools, .me-tools select, .me-tools .btn { width: 100%; }
  .cw-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rc-grid { grid-template-columns: 1fr; }
  .rc-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cd-grid { grid-template-columns: 1fr 1fr; }
  .clc-top { flex-direction: column; }
}

/* ── нові блоки: огляд, менеджери, перемикач дизайну ── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); box-shadow: var(--shadow); min-width: 0; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); margin-bottom: var(--space-4); }
.funnel { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.fn-row { display: grid; grid-template-columns: 150px 1fr 80px; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.fn-bar { height: 10px; background: var(--grid); border-radius: 99px; overflow: hidden; }
.fn-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.fn-bar > span.hl { background: var(--hl); }
.fn-n { text-align: right; font-weight: 700; }
.ov-kv { margin-top: var(--space-2); }
.st-list { display: flex; flex-direction: column; }
.st-row { display: flex; justify-content: space-between; align-items: center; padding: var(--space-2) 0; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; text-align: left; }
.st-row:last-child { border-bottom: 0; }
.st-row b { font-size: var(--text-base); }
.st-row:hover b { color: var(--primary-ink); }
.chart-wrap.tall { height: 340px; }
.mgr td { white-space: nowrap; }
.theme-sel select { height: 40px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); font-weight: 500; }
.login-theme { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.reassign { display: inline-flex; align-items: center; gap: var(--space-2); }
.reassign select { height: 40px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); }
.card, .summary, .bc, .clc { box-shadow: var(--shadow); }
.flag { color: var(--hl-ink); background: var(--hl-soft); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ov-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .theme-sel select { height: 36px; padding: 0 var(--space-2); font-size: var(--text-xs); } .top-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } .fn-row { grid-template-columns: 110px 1fr 64px; } .top-in .month select { max-width: 150px; padding-right: 28px; } }

/* ══════════ ТЕМИ ══════════
   Основа — чорний, менше синього, ще менше жовтого. */

/* 1. Мінімалізм: плоско, чисто, тонкі лінії, без тіней */
/* 2. Скло: глибокий чорний з синім світінням, напівпрозорі панелі з розмиттям */
[data-theme="glass"] {
  --font: 'Onest', 'Segoe UI', system-ui, sans-serif;
  --bg: #04050a; --surface: rgba(255, 255, 255, .045); --surface-2: rgba(255, 255, 255, .06); --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .16);
  --text: #f4f6fb; --muted: #a3a9ba; --faint: #6c7286;
  --primary: #4b7bff; --primary-hover: #6a92ff; --on-primary: #ffffff; --primary-soft: rgba(75, 123, 255, .16); --primary-soft-2: rgba(75, 123, 255, .24); --primary-ink: #a6c0ff; --primary-line: rgba(75, 123, 255, .45);
  --hl: #ffcc1a; --hl-soft: rgba(255, 204, 26, .12); --hl-ink: #ffd54a; --hl-line: rgba(255, 204, 26, .35);
  --pos: #4fd08b; --pos-soft: rgba(79, 208, 139, .14); --neg: #ff7a6b; --neg-soft: rgba(255, 122, 107, .14); --warn: #ffcc1a; --warn-soft: rgba(255, 204, 26, .12);
  --side-bg: rgba(255, 255, 255, .03); --side-text: #f4f6fb; --side-muted: #959cb0; --side-hover: rgba(255, 255, 255, .06); --side-active: rgba(75, 123, 255, .16); --side-line: rgba(255, 255, 255, .08);
  --sel-bg: #f4f6fb; --sel-text: #070910; --top-bg: rgba(6, 8, 16, .45); --dialog-bg: rgba(16, 19, 30, .82); --ring: rgba(75, 123, 255, .4); --backdrop-blur: 6px;
  --c-bar: rgba(75, 123, 255, .6); --c-bar-2: rgba(244, 246, 251, .3); --c-line: #f4f6fb; --c-pace: #6c7286; --grid: rgba(255, 255, 255, .07);
  --shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 12px 40px rgba(0, 0, 0, .35); --radius: 18px; --radius-sm: 10px;
}
[data-theme="glass"] body {
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(46, 92, 255, .32), transparent 60%),
    radial-gradient(700px 520px at 95% 30%, rgba(36, 70, 200, .18), transparent 65%),
    radial-gradient(520px 380px at 70% 105%, rgba(255, 204, 26, .06), transparent 70%),
    #04050a;
  background-attachment: fixed;
}
[data-theme="glass"] .card, [data-theme="glass"] .kpi, [data-theme="glass"] .summary, [data-theme="glass"] .bc, [data-theme="glass"] .clc,
[data-theme="glass"] .login-card, [data-theme="glass"] .side, [data-theme="glass"] .dialog, [data-theme="glass"] .ship-stats > div {
  -webkit-backdrop-filter: blur(22px) saturate(150%); backdrop-filter: blur(22px) saturate(150%);
}
[data-theme="glass"] .login-card { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .12); }
[data-theme="glass"] .summary { background: var(--border); }
[data-theme="glass"] .sum-cell { background: rgba(10, 12, 20, .55); }
[data-theme="glass"] .tbl th { background: rgba(255, 255, 255, .03); }
[data-theme="glass"] .btn.primary { background: linear-gradient(180deg, #5a87ff, #3b68f0); box-shadow: 0 6px 20px rgba(59, 104, 240, .35), inset 0 1px 0 rgba(255, 255, 255, .25); }
[data-theme="glass"] .field input, [data-theme="glass"] .field select, [data-theme="glass"] select, [data-theme="glass"] input, [data-theme="glass"] textarea { background-color: rgba(255, 255, 255, .05); }
[data-theme="glass"] select option { background: #10131e; }
[data-theme="glass"] .nav-i { border-radius: 12px; }
[data-theme="glass"] .nav-i[aria-current="page"] { box-shadow: inset 0 0 0 1px var(--primary-line); }
@media (max-width: 860px) { [data-theme="glass"] .side { background: rgba(8, 10, 18, .72); } }

.note-form input, .ttn-form input { background: var(--surface); color: var(--text); }
[data-theme="glass"] .note-form input, [data-theme="glass"] .ttn-form input { background: rgba(255, 255, 255, .05); }

/* робоча версія */
.login-err { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--danger, #ff6b6b); }
.login-err:empty { display: none; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.set-acts { display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.btn.sm { padding: 4px 10px; font-size: var(--text-xs); min-height: 0; }
.row-hidden td { opacity: .55; }
.set-add { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; margin: var(--space-4) 0 var(--space-2); }
.set-add .field { flex: 1 1 200px; margin: 0; }
.plan-in { width: 110px; text-align: right; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 6px 8px; font: inherit; }
.plan-in:focus { border-color: var(--primary); outline: none; }
.pw-box { font: 600 1.25rem/1.4 ui-monospace, monospace; letter-spacing: .04em; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin: var(--space-4) 0; user-select: all; }
.audit { list-style: none; margin: 0; padding: 0; max-height: 480px; overflow: auto; }
.audit li { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
#view-settings .card { margin-bottom: var(--space-5); }
.audit-q { height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); min-width: 220px; }
.plan-why { white-space: normal; max-width: 340px; margin-top: 2px; line-height: 1.35; }
td.num .plan-why { margin-left: auto; text-align: right; }
.plan-next { min-width: 230px; }
