/* Neandertallauf Planungstool – stylesheet
   Design tokens: limestone neutrals, valley green accent (configurable via /theme.css),
   Düssel blue for information. Status is never conveyed by colour alone. */

:root {
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --bg: #eceee9;
  --surface: #ffffff;
  --surface-2: #f5f6f3;
  --ink: #1b231f;
  --ink-2: #4f5a54;
  --ink-3: #737d77;
  --line: #d3d8d1;
  --line-strong: #b8c0b8;
  --info: #25637d;
  --info-bg: #e3eef3;
  --ok: #2c7340;
  --ok-bg: #e2f0e5;
  --warn: #8a5a0c;
  --warn-bg: #f7ecd6;
  --wait: #6a4c93;
  --wait-bg: #eee8f6;
  --danger: #a82a21;
  --danger-bg: #f8e3e1;
  --muted-bg: #eceeea;
  --focus: #1b6fb0;
  --shadow: 0 1px 2px rgba(27, 35, 31, .08), 0 4px 16px rgba(27, 35, 31, .06);
  --radius-s: 4px;
  --radius-m: 8px;
  --sidebar-w: 256px;
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, "Noto Sans", sans-serif;
  --font-display: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Segoe UI", sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111613;
  --surface: #181f1b;
  --surface-2: #1e2621;
  --ink: #e2e8e3;
  --ink-2: #b1bcb5;
  --ink-3: #87938b;
  --line: #2b3530;
  --line-strong: #3b4740;
  --info: #7dbad4;
  --info-bg: #17303b;
  --ok: #7fc794;
  --ok-bg: #173022;
  --warn: #e3b35e;
  --warn-bg: #362a14;
  --wait: #b9a2de;
  --wait-bg: #2a2238;
  --danger: #f08b82;
  --danger-bg: #3a1c19;
  --muted-bg: #222a25;
  --focus: #6fb3ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #111613;
    --surface: #181f1b;
    --surface-2: #1e2621;
    --ink: #e2e8e3;
    --ink-2: #b1bcb5;
    --ink-3: #87938b;
    --line: #2b3530;
    --line-strong: #3b4740;
    --info: #7dbad4;
    --info-bg: #17303b;
    --ok: #7fc794;
    --ok-bg: #173022;
    --warn: #e3b35e;
    --warn-bg: #362a14;
    --wait: #b9a2de;
    --wait-bg: #2a2238;
    --danger: #f08b82;
    --danger-bg: #3a1c19;
    --muted-bg: #222a25;
    --focus: #6fb3ea;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  line-height: 1.45; font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:root[data-theme="dark"] a, :root[data-theme="dark"] .link { color: #8fcaa9; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] a { color: #8fcaa9; } }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: .005em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .6rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; padding: 2px 4px 12px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; color: var(--accent); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: .98rem; line-height: 1.1; }
.brand-name small { display: block; font-family: var(--font); font-weight: 400; color: var(--ink-3); font-size: .74rem; }

/* The event selector is styled as a race bib: the one bold element of the UI. */
.bib { position: relative; margin: 2px 2px 14px; }
.bib > summary {
  list-style: none; cursor: pointer; display: block; background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius-s); padding: 10px 14px 9px; position: relative;
}
.bib > summary::-webkit-details-marker { display: none; }
.bib > summary::before, .bib > summary::after {
  content: ""; position: absolute; top: 7px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 calc(100% + 0px) 0 0 transparent;
}
.bib > summary::before { left: 7px; }
.bib > summary::after { right: 7px; }
.bib-year { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: .02em; }
.bib-title { font-size: .8rem; opacity: .9; display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.bib-empty { font-family: var(--font-display); font-size: 1rem; }
.bib[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.bib-menu {
  position: absolute; z-index: 30; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line-strong);
  border-top: none; border-radius: 0 0 var(--radius-s) var(--radius-s); box-shadow: var(--shadow); max-height: 60vh; overflow-y: auto; padding: 6px 0;
}
.bib-menu h4 { margin: 8px 12px 2px; font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.bib-menu a { display: flex; justify-content: space-between; padding: 5px 12px; color: var(--ink); text-decoration: none; font-size: .9rem; }
.bib-menu a:hover, .bib-menu a[aria-current="true"] { background: var(--surface-2); }
.bib-menu details summary { padding: 5px 12px; cursor: pointer; font-size: .85rem; color: var(--ink-2); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-size: .93rem;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav a.disabled { opacity: .45; pointer-events: none; }
.nav .badge { margin-left: auto; }
.nav-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-foot { font-size: .72rem; color: var(--ink-3); padding: 8px 10px 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar form.search { flex: 1; max-width: 520px; display: flex; }
.topbar input[type="search"] { width: 100%; }
.topbar .menu-toggle { display: none; }
.page { padding: 20px 24px 48px; max-width: 1680px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: .82rem; color: var(--ink-3); margin-bottom: 4px; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb span + span::before { content: "›"; margin: 0 6px; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); padding: 6px 12px; border-radius: var(--radius-s); font: inherit; font-size: .9rem;
  cursor: pointer; text-decoration: none; line-height: 1.3; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: .82rem; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.btn.is-busy::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"],
input[type="number"], input[type="search"], input[type="url"], input[type="datetime-local"], select, textarea {
  font: inherit; font-size: .93rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-s); padding: 6px 9px; width: 100%; min-width: 0;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
select[multiple] { min-height: 110px; }
input[type="file"] { font: inherit; font-size: .9rem; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
label { font-size: .85rem; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 3px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: .8rem; color: var(--ink-3); margin-top: 3px; font-weight: 400; }
.field .error, .form-error { color: var(--danger); font-size: .82rem; margin-top: 3px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.form-error { background: var(--danger-bg); padding: 8px 10px; border-radius: var(--radius-s); margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: .92rem; }
.check input { width: auto; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; font-size: .92rem; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Panels, tiles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { flex: 1; font-size: 1rem; }
.panel-body { padding: 12px 14px; }
.panel-body.flush { padding: 0; }
.panel.note { border-left: 3px solid var(--accent); }
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; color: var(--ink); text-decoration: none; display: block; }
a.tile:hover { border-color: var(--line-strong); text-decoration: none; box-shadow: var(--shadow); }
.tile h3 { font-size: .95rem; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.tile .kv { display: flex; justify-content: space-between; font-size: .9rem; padding: 2px 0; }
.tile .kv b { font-variant-numeric: tabular-nums; }
.stat { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; }
.kpi .v { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.kpi .l { font-size: .8rem; color: var(--ink-3); }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bars .row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 8px; align-items: center; font-size: .86rem; }
meter { width: 100%; height: 10px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 600; padding: 1px 8px 1px 6px;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.neutral { background: var(--muted-bg); color: var(--ink-2); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.muted { background: transparent; color: var(--ink-3); border-color: var(--line); }
.chip.plain::before { display: none; }
.chip.ok::before { border-radius: 1px; }
.chip.danger::before { border-radius: 0; transform: rotate(45deg); }
.chip.wait::before { background: transparent; border: 2px solid currentColor; width: 5px; height: 5px; }
.tag { display: inline-block; font-size: .75rem; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink-2); margin: 1px 2px 1px 0; }
.badge { display: inline-block; min-width: 20px; text-align: center; font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--danger); color: #fff; }
.badge.soft { background: var(--muted-bg); color: var(--ink-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-weight: 600; font-size: .78rem; color: var(--ink-3); padding: 7px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap; z-index: 1;
}
table.data th a { color: inherit; }
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.title-cell { max-width: 420px; }
table.data td.title-cell a { color: var(--ink); font-weight: 600; }
table.data .clip { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.kv { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.kv th { text-align: left; font-weight: 600; color: var(--ink-3); padding: 4px 10px 4px 0; width: 38%; vertical-align: top; font-size: .84rem; }
table.kv td { padding: 4px 0; }
tr.is-done td { color: var(--ink-3); }
tr.is-overdue td.due { color: var(--danger); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 150px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; flex-wrap: wrap; }
.segmented a { padding: 5px 11px; font-size: .86rem; color: var(--ink-2); text-decoration: none; border-right: 1px solid var(--line); background: var(--surface); }
.segmented a:last-child { border-right: none; }
.segmented a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-size: .92rem; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: .76rem; color: var(--ink-3); margin-left: 3px; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 0; font-size: .88rem; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 8px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list > li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: .8rem; color: var(--ink-3); }
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.doc-card { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); align-items: flex-start; }
.doc-card .title { font-weight: 600; color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.ft { width: 30px; height: 36px; border-radius: 3px; display: grid; place-items: center; font-size: .6rem; font-weight: 800; color: #fff; flex: none; background: #6b7a72; }
.ft.pdf { background: #b3372c; } .ft.doc { background: #2b5ea8; } .ft.xls { background: #2d7a45; }
.ft.img { background: #7a5aa6; } .ft.mail { background: #25637d; } .ft.zip { background: #8a6d1f; }
.star { color: var(--warn); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li.milestone::before { background: var(--accent); transform: rotate(45deg); border-radius: 1px; }
.timeline .when { font-size: .8rem; color: var(--ink-3); }

.empty { text-align: center; padding: 26px 16px; color: var(--ink-3); }
.empty p { margin-bottom: 10px; }
.callout { padding: 10px 12px; border-radius: var(--radius-s); background: var(--info-bg); color: var(--ink); margin-bottom: 12px; font-size: .92rem; }
.callout.warn { background: var(--warn-bg); }
.callout.danger { background: var(--danger-bg); }
.prose { white-space: normal; }
.pre { white-space: pre-wrap; font-size: .88rem; }

/* ---------- Toasts & drawer ---------- */
.toasts { position: fixed; top: 12px; right: 12px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--ok); padding: 10px 12px; border-radius: var(--radius-s); box-shadow: var(--shadow); font-size: .92rem; display: flex; gap: 10px; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--info); }
.toast button { margin-left: auto; background: none; border: none; color: var(--ink-3); cursor: pointer; font-size: 1rem; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 12, .38); z-index: 60; display: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .18s ease-out; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-backdrop.open { display: block; }
.drawer-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.drawer-head h2 { flex: 1; font-size: 1.05rem; }
.drawer-body { padding: 16px; overflow-y: auto; flex: 1; }
.skeleton { height: 14px; background: var(--surface-2); border-radius: 3px; margin: 10px 0; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 26px; box-shadow: var(--shadow); }
.auth-card.wide { width: min(620px, 100%); }
.auth-card .brand { padding: 0 0 18px; }

/* ---------- Preview ---------- */
.preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-m); min-height: 480px; display: grid; place-items: center; overflow: hidden; }
.preview iframe, .preview embed { width: 100%; height: 78vh; border: 0; background: #fff; }
.preview img { max-width: 100%; max-height: 78vh; cursor: zoom-in; }
.preview img.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.preview .text { padding: 16px; width: 100%; align-self: start; white-space: pre-wrap; font-size: .9rem; }
.mail-frame { width: 100%; min-height: 360px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; }
.mail-msg { border: 1px solid var(--line); border-radius: var(--radius-m); margin-bottom: 10px; background: var(--surface); }
.mail-msg > summary { padding: 10px 14px; cursor: pointer; display: flex; gap: 12px; align-items: baseline; list-style: none; }
.mail-msg > summary::-webkit-details-marker { display: none; }
.mail-msg .body { padding: 0 14px 14px; }
.suggest { border: 1px dashed var(--line-strong); border-radius: var(--radius-s); padding: 6px 10px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; padding: 0 1px; border-radius: 2px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--line); gap: 1px; }
.cal-grid .dow { background: var(--surface-2); font-size: .78rem; font-weight: 600; padding: 4px 6px; color: var(--ink-3); }
.cal-grid .day { background: var(--surface); min-height: 96px; padding: 4px 6px; font-size: .8rem; }
.cal-grid .day.other { background: var(--surface-2); color: var(--ink-3); }
.cal-grid .day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-grid .day .n { font-weight: 700; }
.cal-grid .day a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; border: 1px solid var(--line-strong); border-bottom: none; border-radius: var(--radius-s) var(--radius-s) 0 0; padding: 3px; background: var(--surface-2); }
.editor { min-height: 260px; max-height: 60vh; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 0 0 var(--radius-s) var(--radius-s); padding: 10px 12px; background: var(--surface); line-height: 1.5; }
.editor:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.editor blockquote { border-left: 3px solid var(--line-strong); margin: 0 0 0 4px; padding-left: 10px; color: var(--ink-2); }
.suggest.check { cursor: pointer; font-weight: 400; }

.sparkline { width: 100%; height: 120px; color: var(--accent); display: block; margin-bottom: 10px; }
.callout.ok { border-color: var(--ok); background: var(--ok-bg); }

.snippet { color: var(--ink-2); margin-top: 3px; }
mark { background: var(--warn-bg); color: inherit; padding: 0 1px; border-radius: 2px; }
kbd { font: 600 0.8em/1 ui-monospace, monospace; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; background: var(--surface-2); }

.list li.unread { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.list li.unread b { font-weight: 700; }

.bars.money .row { grid-template-columns: minmax(110px, 170px) 1fr 110px; }
.bars meter { width: 100%; }

.big-secret { font-size: 1.4rem; letter-spacing: .06em; padding: 12px 16px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-s); display: inline-block; user-select: all; }

.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 5; }
.cleanup-actions { gap: 12px 24px; padding: 10px 0 4px; }
.cleanup-actions form { border-left: 3px solid var(--line); padding-left: 12px; }

/* Inline controls inside button rows keep their natural width. */
.btn-row > input[type="search"], .btn-row > input[type="text"], .btn-row > input[type="email"],
.btn-row > select, .panel-head.btn-row select { width: auto; min-width: 180px; flex: 0 1 auto; }
.btn-row > input[type="search"] { min-width: 220px; }
table.data td.title-cell { min-width: 220px; }
table.data td.clip { display: table-cell; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.timeline-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.timeline-links .tag { display: inline-flex; align-items: center; gap: 4px; }

.btn.danger-text { color: var(--danger); }
table.data td .btn-row { flex-wrap: nowrap; gap: 4px; }
table.data td .btn-row form { margin: 0; }

.doc-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.doc-card-actions a { color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .columns { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-105%); transition: transform .18s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar .menu-toggle { display: inline-flex; }
  .page { padding: 16px 14px 40px; }
  .topbar { padding: 8px 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  table.data .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .actions, .toasts { display: none !important; }
  .shell { display: block; }
}
dl.summary { display: grid; grid-template-columns: minmax(160px, max-content) 1fr; gap: 4px 16px; margin: 0; }
dl.summary dt.group { grid-column: 1 / -1; font-weight: 700; margin-top: 10px; border-bottom: 1px solid var(--line); }
dl.summary dt { color: var(--ink-2); }
dl.summary dd { margin: 0; }
.topic-mark { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  border-radius: 6px; margin-right: 6px; vertical-align: -4px; color: #fff; background: var(--ink-3); }
.topic-mark .icon { width: 13px; height: 13px; }
.topic-mark.c-green { background: #2f7d4f; } .topic-mark.c-blue { background: #2f5f9e; }
.topic-mark.c-orange { background: #c06a1b; } .topic-mark.c-red { background: #a82a21; }
.topic-mark.c-purple { background: #6c4a9e; } .topic-mark.c-teal { background: #1f7a7a; }
.topic-mark.c-grey { background: #6b716d; }
.master-info { margin-bottom: 12px; }
.quick-edit { color: var(--ink-3); text-decoration: none; font-size: .85em; padding: 0 2px; }
.quick-edit:hover { color: var(--accent); }
table.audit-diff { margin-top: 6px; font-size: .85rem; }
table.audit-diff th, table.audit-diff td { padding: 2px 8px 2px 0; vertical-align: top; }
.cal-entry { display: inline-flex; align-items: baseline; gap: 4px; }
.cal-entry.done a { text-decoration: line-through; color: var(--ink-3); }
.cal-entry.kind-payment .icon { color: #8a5a00; }
.cal-entry.kind-event .icon { color: var(--accent); }
.cal-week { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cal-week .panel.today { outline: 2px solid var(--accent); }
.panel.overdue .panel-head h2 { color: var(--danger); }
.danger-text { color: var(--danger); }
.btn-row > input.short, .panel-head.btn-row input.short { width: 150px; min-width: 120px; flex: 0 0 auto; }
