/* ============================================================================
   Arc design system. One file: tokens, layout, components, states.
   Purpose: make responsibility and review legible. Calm neutrals, one accent,
   status colours that mean the same thing everywhere, generous tap targets,
   nothing decorative that does not carry information.
   ========================================================================= */

:root {
  color-scheme: light;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #17202b;
  --text-2: #4a5565;
  --text-3: #6b7685;          /* 4.6:1 on white: the lightest text allowed */
  --accent: #3d4fd6;
  --accent-strong: #2f3fb8;
  --accent-soft: #eceffd;
  --on-accent: #ffffff;
  --focus: #3d4fd6;

  --ok: #157a46;        --ok-soft: #e6f4ec;
  --warn: #9a5b00;      --warn-soft: #fdf2df;
  --bad: #b42318;       --bad-soft: #fdecea;
  --info: #1f5fbf;      --info-soft: #e7effb;
  --wait: #6b3fb5;      --wait-soft: #f1ebfb;
  --muted: #5b6573;     --muted-soft: #eef0f3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 6px 24px rgba(16, 24, 40, .12);
  --sidebar: 236px;
  --tap: 40px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1318; --surface: #161b22; --surface-2: #1c222b; --border: #2a313b; --border-strong: #3a4350;
    --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8e99a8;
    --accent: #8b9bff; --accent-strong: #a3b0ff; --accent-soft: #232a4d; --on-accent: #0f1318; --focus: #a3b0ff;
    --ok: #5fd197; --ok-soft: #12301f; --warn: #f2b65c; --warn-soft: #33260f; --bad: #ff8a80; --bad-soft: #3a1714;
    --info: #7fb2ff; --info-soft: #14253d; --wait: #c5a6ff; --wait-soft: #2a1e40; --muted: #a0aab7; --muted-soft: #222831;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1318; --surface: #161b22; --surface-2: #1c222b; --border: #2a313b; --border-strong: #3a4350;
  --text: #e8ecf1; --text-2: #b4bdc9; --text-3: #8e99a8;
  --accent: #8b9bff; --accent-strong: #a3b0ff; --accent-soft: #232a4d; --on-accent: #0f1318; --focus: #a3b0ff;
  --ok: #5fd197; --ok-soft: #12301f; --warn: #f2b65c; --warn-soft: #33260f; --bad: #ff8a80; --bad-soft: #3a1714;
  --info: #7fb2ff; --info-soft: #14253d; --wait: #c5a6ff; --wait-soft: #2a1e40; --muted: #a0aab7; --muted-soft: #222831;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
small, .small { font-size: 13px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
/* hidden always hides, whatever display a class sets. */
[hidden] { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ------------------------------------------------------------------ layout */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 750; font-size: 15px; flex: none;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-org { font-size: 12px; color: var(--text-3); line-height: 1.2; }
.org-switch { margin: 0 4px 10px; }
.nav-group { margin: 10px 0 2px; padding: 0 10px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 7px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--text-2); font-weight: 520; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 620; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.btn.install { width: 100%; margin-bottom: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.me .who { min-width: 0; }
.me .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; padding: 22px 28px 64px; max-width: 1240px; width: 100%; }
/* The view takes focus on each navigation so screen readers announce it; it is
   a landmark, not a control, so it shows no ring. */
.main:focus, .main:focus-visible { outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; }
.page-head .sub { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); }

.topbar { display: none; }
.tabbar { display: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ cards */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15px; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.stat { padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 13px; color: var(--text-2); }

/* ------------------------------------------------------------------ lists */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); min-height: 56px; }
.list > li:last-child { border-bottom: 0; }
.list-empty { margin: 0; padding: 14px 16px; }
.list > li.clickable { cursor: pointer; }
.list > li.clickable:hover { background: var(--surface-2); }
.list .main-col { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list .meta { font-size: 13px; color: var(--text-2); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.list .side { display: flex; align-items: center; gap: 8px; flex: none; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ badges */

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 620; white-space: nowrap; background: var(--muted-soft); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.wait { background: var(--wait-soft); color: var(--wait); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text-2); }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.person .name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.progress.thin { height: 5px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--tap); padding: 0 15px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.btn.ok:hover { background: var(--ok-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; }
.btn.icon { width: var(--tap); padding: 0; }
.btn svg { width: 17px; height: 17px; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ forms */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 620; color: var(--text); }
.field .req { color: var(--bad); margin-left: 2px; }
.field .help { font-size: 12.5px; color: var(--text-3); }
.field .error { font-size: 12.5px; color: var(--bad); font-weight: 560; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14.5px;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); border-color: var(--focus); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: var(--tap); padding: 6px 0; cursor: pointer; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.segmented button { min-height: 36px; padding: 0 13px; border: 0; background: var(--surface); color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }

/* ------------------------------------------------------------------ tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { min-height: 42px; padding: 0 14px; border: 0; background: none; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs [aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; padding: 0 6px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); line-height: 18px; }

/* ------------------------------------------------------------------ states */

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty .icon svg { width: 22px; height: 22px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 12px; font-size: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; font-size: 14px; border: 1px solid; margin-bottom: 14px; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--text); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--text); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--text); }
.notice .grow { flex: 1; min-width: 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; margin: 10px 0; }
.sk-block { height: 64px; margin: 10px 0; }

/* ------------------------------------------------------------------ dialog */

dialog.modal { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.modal.wide { width: min(820px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 14, 20, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-2); display: flex; gap: 10px; align-items: flex-start; animation: rise .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.menu { position: relative; display: inline-block; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; z-index: 50; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; border-radius: 7px; cursor: pointer; text-align: left; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }

/* ------------------------------------------------------------------ kanban */

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow-1); }
.tile:hover { border-color: var(--border-strong); }
.tile .t { font-weight: 600; font-size: 14px; }
.tile .m { font-size: 12.5px; color: var(--text-2); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ timeline */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12.5px; color: var(--text-3); }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--text-3); font-weight: 560; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.prose { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.prose p { margin: 0 0 10px; }
.letter { background: #fff; color: #17202b; border: 1px solid var(--border); border-radius: 8px; padding: 28px 32px; font-size: 15px; line-height: 1.65; }

/* ------------------------------------------------------------------ portal (public pages) */

.public { max-width: 720px; margin: 0 auto; padding: 28px 18px 60px; }
.public .brand { padding: 0 0 18px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-2); background: var(--surface); cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; height: 54px; padding: 0 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .grow { flex: 1; min-width: 0; }
  .main { padding: 16px 16px 92px; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; color: var(--text-3); font-size: 11px; font-weight: 600; border: 0; background: none; font-family: inherit; cursor: pointer; position: relative; }
  .tabbar a[aria-current="page"] { color: var(--accent-strong); }
  .tabbar svg { width: 21px; height: 21px; }
  .tabbar .dot { position: absolute; top: 9px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
  .list > li { padding: 12px 14px; align-items: flex-start; }
  .list .side { flex-direction: column; align-items: flex-end; }
  .table.stack-mobile thead { display: none; }
  .table.stack-mobile tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.stack-mobile td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 12px; }
  .table.stack-mobile td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 600; }
  .table.stack-mobile td.num { text-align: right; }
  /* A stacked row's first cell is its title: no label, full width. */
  .table.stack-mobile td:first-child:not(.num) { justify-content: flex-start; font-weight: 600; padding-block: 6px; }
  .table.stack-mobile td:first-child:not(.num)::before { display: none; }
  .board { display: flex; }
  .board > .column { flex: 0 0 84%; }
  .board > .column.empty { flex-basis: 136px; }
  dialog.modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .letter { padding: 18px; }
  .toasts { left: 16px; right: 16px; bottom: 76px; max-width: none; }
  .hide-mobile { display: none !important; }
  /* Small controls stay compact on a desk, but a finger needs the full tap target. */
  .btn.sm, .segmented button { min-height: var(--tap); }
  .segmented { max-width: 100%; overflow-x: auto; }
}
@media (pointer: coarse) { .btn.sm, .segmented button { min-height: var(--tap); } }
@media (min-width: 761px) { .show-mobile { display: none !important; } }

.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; background: rgba(10, 14, 20, .45); }
.sheet-panel { width: 100%; max-height: 80vh; overflow-y: auto; background: var(--surface); border-radius: 16px 16px 0 0; padding: 10px 10px calc(16px + env(safe-area-inset-bottom)); }
.sheet-panel .nav a { min-height: 46px; font-size: 15px; }

@media print {
  .sidebar, .topbar, .tabbar, .page-head .actions, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .letter { border: 0; padding: 0; }
}
