/* Harbor design system — premium, calm, mobile-first.
   Palette checked for contrast (WCAG AA for text on its surface):
   dark  text #F6F7F3 on #101210 ≈ 17:1, muted #A6AEA5 on #242823 ≈ 6.4:1,
   light text #171A17 on #FFFFFF ≈ 17:1, muted #5C635B on #F6F7F3 ≈ 5.7:1.
   Lime #B8FF17 is a fill colour (with dark text ≈ 14:1), never body text on
   white. Type scale: 12 · 14 · 16 · 20 · 28 · 40. Spacing: 4-pt grid. */

:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef0ea;
  --ink: #171a17; /* contrast blocks */
  --on-ink: #f6f7f3;
  --text: #171a17;
  --muted: #5c635b;
  --line: rgba(23, 26, 23, 0.08);
  --accent: #b8ff17;
  --on-accent: #12160b;
  --accent-soft: rgba(184, 255, 23, 0.22);
  --danger: #d6453a;
  --danger-soft: rgba(214, 69, 58, 0.1);
  --warn: #b7791f;
  --ok: #2f8f46;
  --shadow: 0 1px 2px rgba(16, 18, 16, 0.04), 0 8px 24px rgba(16, 18, 16, 0.06);
  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 28px;
  --t-12: 12px;
  --t-14: 14px;
  --t-16: 16px;
  --t-20: 20px;
  --t-28: 28px;
  --t-40: 40px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101210;
  --surface: #242823;
  --surface-2: #1a1d19;
  --ink: #2d322c;
  --on-ink: #f6f7f3;
  --text: #f6f7f3;
  --muted: #a6aea5;
  --line: rgba(246, 247, 243, 0.08);
  --accent-soft: rgba(184, 255, 23, 0.14);
  --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, 0.14);
  --warn: #f2b84b;
  --ok: #7ad48a;
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101210;
    --surface: #242823;
    --surface-2: #1a1d19;
    --ink: #2d322c;
    --text: #f6f7f3;
    --muted: #a6aea5;
    --line: rgba(246, 247, 243, 0.08);
    --accent-soft: rgba(184, 255, 23, 0.14);
    --danger: #ff6b5e;
    --danger-soft: rgba(255, 107, 94, 0.14);
    --warn: #f2b84b;
    --ok: #7ad48a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-16) / 1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS WebView zooms into inputs smaller than 16px. */
input, select, textarea { font-size: var(--t-16); }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- layout ---------- */
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(92px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(12px + var(--safe-top)) 20px 8px; display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: var(--t-28); font-weight: 700; letter-spacing: -0.02em; margin: 0; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.topbar h1 .h1-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 400px) { .topbar { padding-left: 16px; padding-right: 16px; gap: 8px; } .topbar h1 { font-size: 24px; } .space-btn { max-width: 44vw; } }
.dev-badge { flex: none; }
.content { padding: 4px 16px 24px; }
.dev-badge { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 3px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }

/* space selector pill */
.space-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 8px 12px 8px 10px; font-size: var(--t-14); font-weight: 600; cursor: pointer; max-width: 60vw; }
.space-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--accent)); }
.space-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-list { display: grid; gap: 8px; }
.space-option { display: flex; align-items: center; gap: 12px; border: 0; background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px; text-align: left; cursor: pointer; font-size: var(--t-16); }
.space-option.on { background: var(--ink); color: var(--on-ink); }
.space-option .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.space-option .grow { flex: 1; }

/* bottom navigation */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; padding: 0 12px calc(10px + var(--safe-bottom)); pointer-events: none; }
.tabbar-inner { pointer-events: auto; display: flex; align-items: center; width: 100%; max-width: 520px; background: var(--ink); border-radius: var(--r-lg); padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.tab { flex: 1; border: 0; background: none; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; color: rgba(246, 247, 243, 0.6); cursor: pointer; border-radius: 20px; transition: color 0.2s var(--ease); }
.tab.on { color: var(--on-ink); }
.tab.on svg { color: var(--accent); }
.tab-ai { flex: none; width: 56px; height: 56px; margin: -18px 6px 0; border-radius: 50%; border: 4px solid var(--bg); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(184, 255, 23, 0.35); }

/* ---------- typography helpers ---------- */
.h2 { font-size: var(--t-20); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.eyebrow { font-size: var(--t-12); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-size: var(--t-14); }
.kpi { font-size: var(--t-40); font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--r-md); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: var(--t-16); font-weight: 650; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card.ink { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.card.ink .muted { color: rgba(246, 247, 243, 0.66); }
.card.tap { cursor: pointer; transition: transform 0.15s var(--ease); }
.card.tap:active { transform: scale(0.985); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: var(--r-md); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card .stat { background: var(--surface-2); box-shadow: none; }
.stat b { display: block; font-size: var(--t-28); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { display: block; margin-top: 4px; font-size: var(--t-12); color: var(--muted); line-height: 1.3; }
.stat.accent { background: var(--accent); color: var(--on-accent); }
.stat.accent span { color: rgba(18, 22, 11, 0.7); }

/* AI hero card */
.ai-card { background: var(--ink); color: var(--on-ink); border-radius: var(--r-lg); padding: 20px; margin-bottom: 12px; position: relative; overflow: hidden; }
.ai-card .orb { position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(184, 255, 23, 0.55), rgba(184, 255, 23, 0) 70%); pointer-events: none; }
.ai-card h2 { font-size: var(--t-20); margin: 6px 0 4px; }
.ai-card p { margin: 0 0 16px; color: rgba(246, 247, 243, 0.7); font-size: var(--t-14); max-width: 32ch; }

/* list items */
.item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.item:first-child { border-top: 0; padding-top: 4px; }
.item .time { width: 44px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--t-14); padding-top: 2px; }
.item .title { font-weight: 550; word-break: break-word; line-height: 1.35; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item .meta, .sheet .meta { font-size: var(--t-12); color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.clickable { cursor: pointer; }
.overdue { color: var(--danger); }
.prio-high { color: var(--danger); font-weight: 600; }
.check { flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent); background: none; display: grid; place-items: center; cursor: pointer; color: transparent; transition: background 0.15s var(--ease); padding: 0; }
.check:active { border-color: var(--text); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.check[aria-busy="true"] { opacity: 0.5; }
.more-btn { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.more-btn:active { background: var(--surface-2); }

/* badges */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; color: var(--text); background: color-mix(in srgb, var(--tag) 16%, transparent); font-weight: 600; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tag); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.danger { color: var(--danger); background: var(--danger-soft); }
.pill.accent { background: var(--accent); color: var(--on-accent); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s var(--ease); }

/* buttons */
.btn { border: 0; border-radius: 999px; padding: 12px 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; font-weight: 600; font-size: var(--t-16); transition: transform 0.12s var(--ease), opacity 0.2s; }
.btn:active { transform: scale(0.97); }
.btn.small { padding: 8px 14px; font-size: var(--t-14); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.card.ink .btn.secondary, .ai-card .btn.secondary { background: rgba(246, 247, 243, 0.12); color: var(--on-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: none; color: var(--text); padding-left: 8px; padding-right: 8px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.btn.dark { background: var(--ink); color: var(--on-ink); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--text); padding: 0; }
.fab { position: fixed; right: max(20px, calc(50% - 300px)); bottom: calc(100px + var(--safe-bottom)); z-index: 5; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); cursor: pointer; }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 0; width: 100%; cursor: pointer; text-align: left; color: inherit; font-weight: 600; }

/* toolbar, segmented control, chips */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; min-width: 0; }
.toolbar input { flex: 1 1 160px; }
.toolbar label { white-space: nowrap; }
.toolbar input[type="checkbox"] { flex: none; }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: 999px; cursor: pointer; font-size: var(--t-14); font-weight: 550; white-space: nowrap; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--surface-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: var(--t-14); }
.chip.on { background: var(--ink); color: var(--on-ink); }
/* Phone filter bar: search + «Фильтры (N)», active filters as removable chips. */
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.filter-bar input { flex: 1 1 auto; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; }
.filter-bar .btn { flex: none; }
.active-filters { margin-bottom: 10px; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-size: var(--t-16); }
.check-row:first-child { border-top: 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* date strip */
.days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 50px; border: 0; background: var(--surface); border-radius: var(--r-md); padding: 8px 0; cursor: pointer; text-align: center; font-size: var(--t-12); color: var(--muted); box-shadow: var(--shadow); }
.day b { display: block; font-size: var(--t-20); color: var(--text); font-variant-numeric: tabular-nums; }
.day.on { background: var(--ink); color: var(--on-ink); }
.day.on b { color: var(--accent); }
.day.has::after { content: ""; display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 3px auto 0; }

/* sheets & dialogs */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(8, 10, 8, 0.48); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s var(--ease); }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: calc(var(--tg-viewport-stable-height, 100vh) * 0.92); border-radius: var(--r-lg) var(--r-lg) 0 0; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); animation: rise 0.28s var(--ease); }
/* dvh follows the on-screen keyboard and the browser bars (vh does not on iOS). */
@supports (height: 100dvh) { .sheet { max-height: calc(var(--tg-viewport-stable-height, 100dvh) * 0.92); } }
.sheet:has(.sheet-foot) { padding-bottom: 0; overflow: hidden; }
.sheet::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; margin-top: 8px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px 6px; }
.sheet-head h2 { font-size: var(--t-20); margin: 0; font-weight: 700; }
.sheet-body { overflow-y: auto; padding: 8px 20px 24px; min-height: 0; flex: 1 1 auto; }
/* Actions of a long sheet stay on screen: the body scrolls, the footer does not. */
.sheet-foot { border-top: 1px solid var(--line); padding: 12px 20px calc(12px + var(--safe-bottom)); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--bg); }
.sheet-foot .btn { flex: 1 1 auto; }
.sheet-foot .foot-note { flex: 1 1 100%; font-size: var(--t-12); color: var(--muted); }
/* Keyboard open / very low screen: keep the buttons, drop the explanatory line. */
@media (max-height: 520px) { .sheet-foot { padding-top: 8px; padding-bottom: calc(8px + var(--safe-bottom)); } .sheet-foot .foot-note { display: none; } }
.menu-list { display: grid; gap: 4px; }
.menu-item { display: flex; align-items: center; gap: 12px; border: 0; background: var(--surface); border-radius: var(--r-sm); padding: 14px 16px; text-align: left; cursor: pointer; font-size: var(--t-16); color: var(--text); }
.menu-item.danger { color: var(--danger); }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: var(--t-14); color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; color: var(--text); font-size: var(--t-16); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--text); }
.field textarea { min-height: 84px; resize: vertical; }
/* A field never pushes the page wider than the screen: native date / month /
   file inputs have a fixed intrinsic width that otherwise stretches the
   layout (and with it the fixed tab bar) on a phone. */
.field input, .field select, .field textarea { width: 100%; min-width: 0; max-width: 100%; }
.field input[type="file"] { padding: 10px; font-size: var(--t-14); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sheet-actions .btn { flex: 1 1 auto; }
.notice { background: var(--accent-soft); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; font-size: var(--t-14); }
.notice.danger { background: var(--danger-soft); }

/* states */
.state { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 36px 0; color: var(--muted); }
.empty { text-align: center; padding: 32px 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.empty-title { font-weight: 650; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--text); animation: spin 0.8s linear infinite; display: inline-block; }
.spinner.small { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--r-md); height: 88px; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(104px + var(--safe-bottom)); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 999px; font-size: var(--t-14); max-width: 520px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); animation: rise 0.2s var(--ease); }
.toast.error { background: var(--danger); color: #fff; }
.update-bar { position: sticky; top: 0; z-index: 7; display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--surface-2); color: var(--text); padding: calc(8px + var(--safe-top)) 16px 8px; font-size: var(--t-14); }
.update-bar button { border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent, #101210); font-weight: 600; padding: 6px 14px; font-size: var(--t-14); cursor: pointer; }
.offline { position: sticky; top: 0; z-index: 7; background: var(--danger); color: #fff; padding: 8px 16px; font-size: var(--t-14); text-align: center; }

/* modules grid */
.modules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.module { background: var(--surface); border-radius: var(--r-md); padding: 16px; border: 0; text-align: left; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-height: 120px; color: var(--text); }
.module .ico { width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; }
.module b { font-size: var(--t-16); }
.module span { font-size: var(--t-12); color: var(--muted); }
table.simple { width: 100%; border-collapse: collapse; font-size: var(--t-14); }
table.simple td, table.simple th { padding: 8px 4px; border-top: 1px solid var(--line); text-align: left; }
table.simple th { color: var(--muted); font-weight: 500; font-size: var(--t-12); }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* ---------- Voice Mode ---------- */
.voice { position: fixed; inset: 0; z-index: 40; background: #0c0e0c; color: #f6f7f3; display: flex; flex-direction: column; padding: calc(12px + var(--safe-top)) 20px calc(20px + var(--safe-bottom)); animation: fade 0.25s var(--ease); }
.voice-top { display: flex; align-items: center; gap: 12px; }
.voice-top h2 { flex: 1; margin: 0; font-size: var(--t-20); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.voice .icon-btn { background: rgba(246, 247, 243, 0.1); color: #f6f7f3; }
.voice-state { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-14); color: rgba(246, 247, 243, 0.7); margin-top: 4px; }
.voice-state .led { width: 8px; height: 8px; border-radius: 50%; background: rgba(246, 247, 243, 0.4); }
.voice-state.listening .led { background: #ff5a4f; box-shadow: 0 0 0 4px rgba(255, 90, 79, 0.25); }
.voice-state.speaking .led, .voice-state.acting .led { background: #b8ff17; }
.voice-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 16px; min-height: 0; }
.voice-stage .orb-wrap { flex-shrink: 0; }
/* Only the text and cards scroll: the voice visualisation is never pushed away. */
.voice-scroll { width: 100%; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 14px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 0 1 auto; }
.voice-scroll > * { flex-shrink: 0; }
.voice.busy .voice-stage { justify-content: flex-start; padding-top: 8px; }
.voice.busy .orb-wrap { width: 120px; height: 120px; }
.voice.busy .orb-core { width: 76px; height: 76px; }
.orb-wrap, .orb-core { transition: width 0.3s var(--ease), height 0.3s var(--ease), transform 0.08s linear; }
.orb-wrap { position: relative; width: 200px; height: 200px; display: grid; place-items: center; flex: none; }
.orb-core { width: 128px; height: 128px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e6ff9a, #b8ff17 45%, #5f8a00 100%); transform: scale(var(--level, 1)); transition: transform 0.08s linear; box-shadow: 0 0 80px rgba(184, 255, 23, 0.35); }
.orb-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(184, 255, 23, 0.35); animation: pulse 2.4s var(--ease) infinite; }
.orb-ring.r2 { animation-delay: 0.8s; }
.voice.idle .orb-core, .voice.connecting .orb-core, .voice.ended .orb-core { filter: grayscale(0.7) brightness(0.6); }
.voice.idle .orb-ring, .voice.ended .orb-ring { animation: none; opacity: 0.2; }
.voice.thinking .orb-core, .voice.acting .orb-core { animation: breathe 1.4s ease-in-out infinite; }
@keyframes pulse { from { transform: scale(0.7); opacity: 0.8; } to { transform: scale(1.15); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(0.9); } }
.voice-text { width: 100%; max-width: 520px; text-align: center; min-height: 80px; }
.voice-text .you { color: rgba(246, 247, 243, 0.55); font-size: var(--t-14); margin-bottom: 10px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.voice-text .ai { font-size: var(--t-20); line-height: 1.35; font-weight: 500; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.voice.busy .voice-text { min-height: 0; }
.voice.busy .voice-text .ai { font-size: var(--t-16); -webkit-line-clamp: 3; }
.voice-more { background: none; border: 0; color: #b8ff17; font: inherit; font-size: var(--t-14); padding: 6px 0 0; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.voice-cards { width: 100%; display: grid; gap: 8px; }
.voice-card.doc { display: flex; align-items: center; gap: 12px; }
.voice-card .doc-icon { color: #b8ff17; flex-shrink: 0; }
.voice-card .doc-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.voice-open { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; background: rgba(184, 255, 23, 0.14); color: #b8ff17; border: 0; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: var(--t-14); font-weight: 600; cursor: pointer; }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.cmp-tile { background: rgba(246, 247, 243, 0.06); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.cmp-name { font-size: var(--t-12); font-weight: 700; letter-spacing: 0.06em; color: rgba(246, 247, 243, 0.6); }
.cmp-total { font-size: var(--t-20); font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cmp-total span { font-size: var(--t-14); font-weight: 500; color: rgba(246, 247, 243, 0.7); }
.cmp-tile ul { margin: 8px 0 0; padding: 0; list-style: none; font-size: var(--t-12); color: rgba(246, 247, 243, 0.75); display: grid; gap: 3px; }
.cmp-tile li { overflow-wrap: anywhere; }
.cmp:not(.open) .cmp-tile li { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.cmp-tile li::before { content: "· "; }
.cmp-tile li.only { color: #f6f7f3; }
.cmp-tile li.only::before { content: "+ "; color: #b8ff17; font-weight: 700; }
.cmp-note { font-size: var(--t-12); margin-top: 6px; }
.cmp-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: var(--t-14); color: rgba(246, 247, 243, 0.75); }
.voice-card { background: #1c201b; border-radius: var(--r-md); padding: 12px 14px; text-align: left; }
.voice-card .muted { color: rgba(246, 247, 243, 0.6); }
.voice-controls { display: flex; justify-content: center; align-items: center; gap: 16px; }
.vbtn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(246, 247, 243, 0.1); color: #f6f7f3; display: grid; place-items: center; cursor: pointer; padding: 0; }
.vbtn.big { width: 72px; height: 72px; background: #b8ff17; color: #12160b; }
.vbtn.big.off { background: rgba(246, 247, 243, 0.14); color: #f6f7f3; }
.vbtn.end { background: #ff5a4f; color: #fff; }
.vbtn:disabled { opacity: 0.4; }
.voice-input { display: flex; gap: 8px; width: 100%; max-width: 520px; margin: 0 auto 12px; }
.voice-input input { flex: 1; min-width: 0; background: #1c201b; border: 1px solid rgba(246, 247, 243, 0.12); color: #f6f7f3; border-radius: 999px; padding: 12px 16px; }
.voice-confirm { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.voice-history { position: absolute; inset: auto 0 0 0; max-height: calc(100% - 230px - var(--safe-top)); background: #151814; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 16px 20px calc(20px + var(--safe-bottom)); overflow-y: auto; z-index: 2; }
.voice-history .turn { padding: 8px 0; border-top: 1px solid rgba(246, 247, 243, 0.08); font-size: var(--t-14); }
.voice-history .turn b { color: #b8ff17; font-weight: 600; margin-right: 6px; }
.demo-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(184, 255, 23, 0.16); color: #b8ff17; }
.voice-note { font-size: var(--t-12); color: rgba(246, 247, 243, 0.5); text-align: center; margin-top: 10px; }

/* voice picker (settings and Voice Mode) */
.voice-picker { display: grid; gap: 6px; max-height: 44vh; overflow-y: auto; }
.vp-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--r-md); padding: 4px 6px 4px 4px; }
.vp-row.on { box-shadow: inset 0 0 0 2px var(--accent); }
.vp-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: inherit; text-align: left; padding: 8px; cursor: pointer; font-size: var(--t-14); }
.vp-pick b { display: block; font-weight: 600; }
.vp-mark { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 1.5px solid var(--line); }
.vp-row.on .vp-mark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.vp-note { display: block; font-size: var(--t-12); color: var(--muted); margin-top: 2px; }
.vp-error { display: block; font-size: var(--t-12); color: #e5484d; margin-top: 2px; }
.vp-play { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; }
.vp-play:disabled { opacity: 0.5; }
.voice-picker.dark .vp-row { background: #1c201b; }
.voice-picker.dark .vp-note { color: rgba(246, 247, 243, 0.55); }
.voice-picker.dark .vp-mark { border-color: rgba(246, 247, 243, 0.3); }
.voice-picker.dark .vp-play { background: #b8ff17; color: #101210; }
.spin { animation: spin 0.9s linear infinite; }

/* Google Drive (Документы) */
.drive-head .drive-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); flex: none; }
.drive-file { width: 100%; border: 0; background: none; color: inherit; font: inherit; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.drive-kind { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.drive-text { white-space: pre-wrap; word-break: break-word; font: var(--t-14) / 1.45 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border-radius: var(--r-md); padding: 12px; max-height: 50vh; overflow-y: auto; margin: 0 0 8px; }

/* OpenAI budget (Настройки) */
.budget-row { padding: 10px 0; border-top: 1px solid var(--line); }
.budget-row:first-of-type { border-top: 0; }
.budget-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 6px; }
.budget-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.budget-bar.l80 i { background: #f5a524; }
.budget-bar.l95 i, .budget-bar.lexhausted i { background: #e5484d; }
.budget-warn.l80 { color: #c27c00; font-weight: 600; }
.budget-warn.l95, .budget-warn.lexhausted { color: #e5484d; font-weight: 600; }
.voice-state { display: flex; flex-wrap: wrap; row-gap: 2px; }
.voice-clock { font-variant-numeric: tabular-nums; color: rgba(246, 247, 243, 0.85); white-space: nowrap; margin-left: auto; padding-left: 8px; }
.voice-clock.warn { color: #ffb020; font-weight: 600; }
.voice-silence { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: var(--t-14); color: rgba(246, 247, 243, 0.7); margin: 0 auto 10px; min-height: 32px; }
.voice-pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(184, 255, 23, 0.14); color: #b8ff17; border: 0; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: var(--t-14); font-weight: 600; cursor: pointer; }
.voice-pill.quiet { background: rgba(246, 247, 243, 0.08); color: rgba(246, 247, 243, 0.8); font-weight: 500; }
/* «История AI» */
.hist-overlay { position: fixed; inset: 0; z-index: 45; background: var(--bg); display: flex; flex-direction: column; overflow-y: auto; padding-top: var(--safe-top); animation: fade 0.2s var(--ease); }
.hist-overlay .content { padding-bottom: calc(24px + var(--safe-bottom)); }
.hist-search { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 999px; padding: 4px 4px 4px 14px; margin-bottom: 10px; box-shadow: var(--shadow); color: var(--muted); }
.hist-search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--text); padding: 8px 0; outline: none; }
.hist-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }
.hist-group { font-size: var(--t-12); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 14px 4px 6px; }
.hist-item { display: flex; gap: 12px; width: 100%; text-align: left; border: 0; background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); color: var(--text); font: inherit; cursor: pointer; align-items: flex-start; }
.hist-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.hist-ico.voice { background: var(--ink); color: var(--accent); }
.hist-topic { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-weight: 600; line-height: 1.35; }
.hist-item .meta { font-size: var(--t-12); color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.hist-turns { display: grid; gap: 8px; margin-bottom: 12px; }
.hist-turn { border-radius: var(--r-md); padding: 10px 12px; font-size: var(--t-14); line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.hist-turn.user { background: var(--surface-2); margin-left: 24px; }
.hist-turn.ai { background: var(--surface); border: 1px solid var(--line); margin-right: 24px; }
.hist-who { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; white-space: normal; }
.hist-partial { color: var(--warn); font-style: normal; }
.hist-block h3 { margin-bottom: 6px; }
.hist-line { display: flex; gap: 6px; align-items: flex-start; font-size: var(--t-14); padding: 3px 0; overflow-wrap: anywhere; }
.hist-line svg { flex: none; margin-top: 3px; color: var(--accent-ink, var(--muted)); }
.hist-fact-text { font-weight: 550; line-height: 1.4; margin: 8px 0; overflow-wrap: anywhere; }
.hist-fact textarea { width: 100%; box-sizing: border-box; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; padding: 8px 10px; margin: 8px 0; }
.voice-call { width: 100%; }
.voice-call-line { font-size: var(--t-14); padding: 2px 0; }

/* sign-in outside Telegram (installed app, browser) */
.signin { min-height: 100dvh; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom)); text-align: center; max-width: 420px; margin: 0 auto; }
.signin h1 { font-size: var(--t-28); margin: 4px 0 0; }
.signin p { margin: 0 0 8px; }
.signin-mark { border-radius: 16px; box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(0, 0, 0, 0.12); } /* the white Harbor tile stays visible on a light background */
.signin-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.signin-code { width: 100%; box-sizing: border-box; font: 600 clamp(15px, 5vw, 22px)/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; text-align: center; padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.signin-code:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.signin-form .btn { justify-content: center; min-height: 52px; }
.signin-error { color: var(--danger); font-size: var(--t-14); }
.install-hint { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: var(--surface-2); border-radius: var(--r-md); padding: 12px 12px 12px 14px; font-size: var(--t-14); margin-top: 12px; width: 100%; box-sizing: border-box; }
.link-code { background: var(--surface-2); border-radius: var(--r-md); padding: 12px; margin: 8px 0; }
.link-code b { display: block; font: 700 22px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; margin-top: 4px; user-select: all; }

/* team and notification settings */
.team-row { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; color: inherit; font: inherit; }
.team-row:first-child { border-top: 0; }
.perm-list { border: 0; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; }
.perm-list legend { font-size: var(--t-14); color: var(--muted); font-weight: 500; margin-bottom: 4px; padding: 0; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: var(--t-16); border-top: 1px solid var(--line); cursor: pointer; }
.check-row:first-of-type { border-top: 0; }
.check-row input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.sheet-h { font-size: var(--t-16); margin: 20px 0 6px; }

/* Touch screens: at least 40–44 px to tap (Apple HIG / WCAG 2.5.8). */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .chip, .btn.small, .seg button { min-height: 40px; }
  .tab { min-height: 44px; }
}

/* ---------- Desktop and tablet (≥768 px wide, not a phone on its side) ----------
   Only the desktop shell uses these classes; below 768 px nothing changes.
   Tablet: a narrow icon rail; desktop (≥1200): the full menu, collapsible. */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.shell.rail { grid-template-columns: 72px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; scrollbar-width: thin; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: var(--t-20); letter-spacing: -0.02em; }
.shell.rail .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-item { display: flex; align-items: center; gap: 12px; border: 0; background: none; color: var(--muted); border-radius: var(--r-sm); padding: 10px 12px; font-size: var(--t-14); font-weight: 550; cursor: pointer; text-align: left; min-height: 40px; }
.side-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item:hover { background: var(--surface); color: var(--text); }
.side-item.on { background: var(--ink); color: var(--on-ink); }
.side-item.on svg { color: var(--accent); }
.side-item.ai:not(.on) svg { color: var(--text); }
.shell.rail .side-item { justify-content: center; padding: 10px 0; }
.side-toggle { margin-top: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.dtop { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--bg); border-bottom: 1px solid var(--line); }
.dtop-title { margin: 0; font-size: var(--t-20); font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.dtop-title .h1-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dtop .space-btn { max-width: 240px; }
.dtop .icon-btn { width: 40px; height: 40px; flex: none; }
.dtop .icon-btn:hover, .dtop .icon-btn.on { background: var(--ink); color: var(--on-ink); }
.pop-wrap { position: relative; }
.pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 260px; max-width: min(420px, 90vw); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 12px 40px rgba(8, 10, 8, 0.18); padding: 6px; display: grid; gap: 4px; animation: fade 0.15s var(--ease); }
.pop .space-option { padding: 10px 12px; font-size: var(--t-14); background: none; border-radius: var(--r-sm); color: var(--text); }
.pop .space-option:hover { background: var(--surface-2); }
.pop .space-option.on { background: var(--ink); color: var(--on-ink); }
.pop-h { font-size: var(--t-12); color: var(--muted); font-weight: 600; padding: 8px 12px 2px; }
.gsearch { flex: 1 1 200px; max-width: 520px; margin-left: auto; display: flex; align-items: center; }
.gsearch input { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 9px 34px 9px 38px; font-size: var(--t-14); color: var(--text); }
.gsearch input:focus { outline: none; border-color: var(--text); }
.gsearch-ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.gsearch-clear { position: absolute; right: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; width: 24px; height: 24px; }
.gsearch-results { left: 0; right: 0; max-width: none; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dcontent { padding: 24px 28px 48px; width: 100%; max-width: 1600px; }
.dcontent.v-ai { max-width: none; padding: 16px; }
.small-text { font-size: var(--t-12); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* dashboard */
.dash { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.dash-side { display: grid; gap: 12px; align-content: start; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.dash-side .card { margin-bottom: 0; }
.widget .card-head h3 { gap: 8px; }
.widget-embed .card { box-shadow: none; padding: 0; margin: 0; background: none; }
.widget-embed .card h3 { display: none; }
.dash .stats { gap: 12px; }

/* toolbars, tables, bulk actions */
.dtoolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dtoolbar .seg { margin-bottom: 0; flex: 0 1 auto; max-width: 100%; }
.dtoolbar .toolbar { margin-bottom: 0; flex: 1 1 420px; justify-content: flex-end; align-items: center; }
.dtoolbar .toolbar input[type="search"] { max-width: 360px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-14); cursor: pointer; white-space: nowrap; }
.check-inline input { width: 18px; height: 18px; accent-color: var(--accent); }
.bulk { position: sticky; top: 69px; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--ink); color: var(--on-ink); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 12px; }
.bulk .btn.secondary { background: rgba(246, 247, 243, 0.12); color: var(--on-ink); }
.bulk .btn.ghost { color: var(--on-ink); }
.bulk .muted { color: rgba(246, 247, 243, 0.66); }
.table-card { padding: 0; overflow: hidden; }
/* position: an absolutely placed child (the .sr-only header label) stays inside the scroller instead of widening the page. */
.table-scroll { overflow-x: auto; position: relative; }
/* Task table: below 1500 px the priority moves under the title (fewer columns, no sideways scrolling at 1366). */
.prio-under { display: none; }
@media (max-width: 1499px) { .dtable .col-prio { display: none; } .prio-under { display: block; } }
.dtable { width: 100%; border-collapse: collapse; font-size: var(--t-14); }
.dtable th { text-align: left; font-weight: 600; font-size: var(--t-12); color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.dtable td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover { background: var(--surface-2); }
.dtable tr.picked { background: var(--accent-soft); }
.dtable tr.done .cell-link span { text-decoration: line-through; color: var(--muted); }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable .col-check { width: 40px; }
.dtable .col-check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.dtable .col-title { min-width: 240px; max-width: 520px; }
.dtable .col-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtable .col-actions { width: 1%; white-space: nowrap; position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 12px -10px rgba(0, 0, 0, 0.35); }
.dtable tbody tr:hover .col-actions { background: var(--surface-2); }
.dtable tr.picked .col-actions { background: var(--accent-soft); }
.warn-text { color: var(--warn, #b7791f); }
.row-toggle { width: 26px; height: 26px; margin-right: 4px; vertical-align: middle; }
.dtable .col-title .cell-link { display: inline; }
.dtable tr.row-details td { background: var(--surface-2); padding-top: 4px; }
.th-sort { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 0; }
.th-sort:hover { color: var(--text); }
.cell-link { border: 0; background: none; color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-align: left; padding: 0; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.cell-link span { overflow-wrap: anywhere; }
.cell-link:hover span { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; background: none; }
.row-actions .icon-btn:hover { background: var(--surface-2); }
.table-foot { padding: 10px 14px; border-top: 1px solid var(--line); }

/* CRM pipeline board: columns scroll inside the board, never the page */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col { background: var(--surface-2); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.board-card { border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--r-sm); padding: 10px 12px; text-align: left; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 4px; }
.board-card b { overflow-wrap: anywhere; font-weight: 600; }
.board-card .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--t-12); color: var(--muted); }

/* inbox */
.inbox-split { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 16px; align-items: start; }
.inbox-reader { position: sticky; top: 85px; max-height: calc(100vh - 100px); overflow-y: auto; }
.seg-count { margin-left: 6px; font-size: var(--t-12); color: var(--muted); font-variant-numeric: tabular-nums; }
.mail-row { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); padding: 10px 6px; cursor: pointer; border-radius: 0; }
.mail-row:first-child { border-top: 0; }
.mail-row:hover, .mail-row.on { background: var(--surface-2); }
.mail-row.unread .mail-subject, .mail-row.unread b { font-weight: 700; }
.mail-row .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: var(--t-12); color: var(--muted); }
.mail-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-subject { font-size: var(--t-14); margin-top: 2px; }
.note-bar { background: var(--accent-soft); border-radius: var(--r-sm); padding: 8px 12px; font-size: var(--t-14); margin-bottom: 10px; }
.reader-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.alert { display: flex; gap: 10px; border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; font-size: var(--t-14); }
.alert.danger { background: var(--danger-soft); color: var(--text); }
.alert.danger svg { color: var(--danger); flex: none; }
.alert ul, ul.reasons { margin: 6px 0 0; padding-left: 18px; }
ul.reasons { color: var(--muted); font-size: var(--t-14); margin-bottom: 10px; }
.thread-msg { border-top: 1px solid var(--line); padding: 10px 0; }
.thread-msg:first-of-type { border-top: 0; }
.thread-msg.current { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px; }
.thread-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-14); margin-top: 4px; }
.defanged { color: var(--danger); background: var(--danger-soft); border-radius: 4px; padding: 0 3px; overflow-wrap: anywhere; }
.attach { display: flex; align-items: center; gap: 6px; font-size: var(--t-14); padding: 4px 0; flex-wrap: wrap; }
.confirm-box { background: var(--surface); border-radius: var(--r-sm); padding: 12px; margin: 12px 0; display: grid; gap: 6px; }

/* event card */
.event-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.event-head .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--t-12); color: var(--muted); margin-top: 4px; }
.readiness { background: var(--ink); color: var(--on-ink); border-radius: var(--r-md); padding: 10px 14px; text-align: center; min-width: 110px; }
.readiness b { display: block; font-size: var(--t-28); color: var(--accent); font-variant-numeric: tabular-nums; }
.readiness span { font-size: var(--t-12); opacity: 0.75; }
.event-tabs { flex-wrap: nowrap; scroll-padding-inline: 24px; mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%); }
/* Event tabs stay on top while the card scrolls; arrows when they do not fit. */
.event-tabs-wrap { position: sticky; top: 0; z-index: 2; background: var(--bg); display: flex; align-items: center; gap: 4px; padding: 4px 0; margin-bottom: 8px; }
.event-tabs-wrap .event-tabs { flex: 1 1 auto; margin-bottom: 0; min-width: 0; }
.event-tabs-wrap .icon-btn { flex: none; }
.check.na { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.missing-item { flex-wrap: wrap; }
.missing-actions { flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; }
@media (max-width: 640px) { .missing-actions { justify-content: flex-start; width: 100%; } }
/* A missing checklist item: who, when, status, proof, next step. */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 6px 0 0; font-size: var(--t-12); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 380px) { .facts { grid-template-columns: minmax(0, 1fr); } .facts dt { margin-top: 4px; } }
.item.picked { background: var(--surface-2); border-radius: var(--r-sm); }
/* Estimate lines on a phone: one card per line (label · value), no sideways scrolling. */
@media (max-width: 640px) {
  .dtable.est thead { display: none; }
  .dtable.est, .dtable.est tbody, .dtable.est tr, .dtable.est td { display: block; width: 100%; }
  .dtable.est tr { padding: 10px 0; border-top: 1px solid var(--line); }
  .dtable.est td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .dtable.est td::before { content: attr(data-label); color: var(--muted); font-size: var(--t-12); text-align: left; }
  .dtable.est td.col-title { display: block; text-align: left; padding-bottom: 6px; }
  .dtable.est td.col-title::before { content: none; }
  .dtable.est .cell-input { max-width: 120px; }
}
/* Archive rows: on a phone the actions go under the text (the name and details keep the full width). */
.archive-item .grow { min-width: 0; }
.archive-actions { flex-wrap: nowrap; }
@media (max-width: 640px) {
  .archive-item { flex-direction: column; gap: 8px; }
  .archive-actions { flex-wrap: wrap; }
}
.reopen-row { gap: 8px; margin-top: 10px; align-items: flex-end; flex-wrap: wrap; }
.reopen-row .field { flex: 1 1 200px; margin-bottom: 0; }
.decision-legend { margin: -4px 0 8px; }
.decision-note { flex: 1 1 220px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: var(--t-14); }
.month-log { margin-top: 10px; }
.month-log > div { padding: 2px 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; }
.lead-row .grow { min-width: 0; }
.lead-message { margin-top: 6px; overflow-wrap: anywhere; }
.lead-actions { flex: none; flex-wrap: wrap; justify-content: flex-end; max-width: 46%; }
@media (max-width: 640px) { .lead-row { flex-direction: column; gap: 8px; } .lead-actions { max-width: none; justify-content: flex-start; } }
.batch { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.req { border-top: 1px solid var(--line); padding: 6px 0; }
.req summary { cursor: pointer; }
/* The batch approval sheet: what leaves, to whom, in which state. */
.send-summary { background: var(--surface); border-radius: var(--r-sm); padding: 12px; display: grid; gap: 8px; font-size: var(--t-14); }
.send-summary .kv { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.send-summary .kv span:first-child { color: var(--muted); }
.recipients { display: flex; flex-wrap: wrap; gap: 6px; }
.recipients .pill { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.confirm-box .n { font-size: var(--t-12); color: var(--muted); }
.confirm-box .kv-line { overflow-wrap: anywhere; }
.chat { display: flex; flex-direction: column; gap: 8px; height: calc(100vh - 200px); min-height: 360px; }
.chat-list { flex: 1; overflow-y: auto; background: var(--surface); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 75%; background: var(--surface-2); border-radius: 14px; padding: 8px 12px; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; background: var(--accent-soft); }
.chat-meta { font-size: var(--t-12); color: var(--muted); }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-receipt { font-size: var(--t-12); color: var(--muted); display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin-top: 2px; flex-wrap: wrap; text-align: right; }
.chat-receipt.all { color: var(--ok); }
.chat-divider { align-self: stretch; text-align: center; font-size: var(--t-12); color: var(--accent-ink, var(--text)); border-top: 1px solid var(--accent); padding-top: 4px; margin: 4px 0; font-weight: 600; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; color: var(--text); resize: none; }
.cell-input { width: 90px; text-align: right; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; color: var(--text); font-size: var(--t-14); }
.dtable.est td { vertical-align: top; }

/* calendar */
.cal-bar .row { flex-wrap: nowrap; }
.cal-title { margin-left: 8px; white-space: nowrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-wd { font-size: var(--t-12); color: var(--muted); font-weight: 600; padding: 0 8px 2px; }
.cal-day { background: var(--surface); border-radius: var(--r-sm); padding: 8px; min-height: 112px; display: flex; flex-direction: column; gap: 4px; min-width: 0; box-shadow: var(--shadow); }
.cal-grid.week .cal-day { min-height: 420px; }
.cal-day.other { opacity: 0.5; }
.cal-day.addable { cursor: copy; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: var(--t-14); font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-ev { border: 0; background: var(--surface-2); border-radius: 8px; padding: 4px 6px; display: flex; align-items: center; gap: 6px; font-size: var(--t-12); color: var(--text); cursor: pointer; text-align: left; min-width: 0; width: 100%; }
.cal-ev:hover { background: var(--accent-soft); }
.cal-ev .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dot); flex: none; }
.cal-ev.cancelled { text-decoration: line-through; opacity: 0.6; }
.cal-time { font-variant-numeric: tabular-nums; color: var(--muted); flex: none; }
.cal-busy { font-size: var(--t-12); color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, transparent 6px 12px); border-radius: 8px; padding: 4px 6px; }

/* Harbor AI: history · dialog · context */
.ai-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; height: calc(100vh - 69px - 32px); min-height: 480px; }
.ai-col { min-width: 0; min-height: 0; overflow-y: auto; }
.ai-history, .ai-context { display: none; background: var(--surface-2); border-radius: var(--r-lg); padding: 14px; }
.ai-col-h { font-size: var(--t-16); margin: 4px 4px 12px; }
.ai-dialog { display: flex; }
.voice.embedded { position: relative; inset: auto; z-index: auto; flex: 1; min-height: 0; border-radius: var(--r-lg); padding: 16px 24px 20px; animation: none; overflow: hidden; }
.voice.embedded .voice-scroll { max-width: 760px; }

@media (min-width: 768px) and (min-height: 520px) {
  /* Sheets become centred dialogs on a wide screen. */
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 640px; max-height: min(86vh, 900px); border-radius: var(--r-lg); padding-bottom: 8px; animation: fade 0.2s var(--ease); box-shadow: 0 24px 80px rgba(8, 10, 8, 0.3); }
  .sheet::before { display: none; }
  .sheet-head { padding-top: 18px; }
  .fab { right: 32px; bottom: 32px; }
}
@media (min-width: 1200px) {
  .dtoolbar .toolbar { flex-wrap: nowrap; }
  .dtoolbar .toolbar input[type="search"] { flex: 1 1 140px; min-width: 120px; }
  .ai-split { grid-template-columns: 320px minmax(0, 1fr); }
  .ai-split.no-history { grid-template-columns: minmax(0, 1fr); }
  .ai-history { display: block; }
}
@media (min-width: 1280px) {
  .dash { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: start; }
  .dash-side { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1600px) {
  .ai-split { grid-template-columns: 320px minmax(0, 1fr) 340px; }
  .ai-split.no-history { grid-template-columns: minmax(0, 1fr) 340px; }
  .ai-context { display: block; }
  .dash { grid-template-columns: minmax(0, 1fr) 440px; }
}
@media (max-width: 1199px) {
  .dtop { padding: 12px 20px; }
  .dcontent { padding: 20px 20px 40px; }
  .dtop .space-btn { max-width: 180px; }
}
