/* Keel — Monval Capital
   Private-bank reporting: quiet surfaces, hairline structure, tabular figures.
   Colour is reserved for data: blue for money in, red for money out and negatives. */

:root {
  --bg: #F4F5F3;
  --panel: #FFFFFF;
  --panel-2: #F7F8F6;
  --line: #E4E7E3;
  --line-2: #D3D8D4;
  --ink: #101C26;
  --ink-2: #4B5862;
  --ink-3: #78848B;
  --neg: #A3271C;
  --in: #1C63A0;
  --out: #A93226;
  --track: #EEF0ED;
  --focus: #2F6F8C;

  /* aliases used by the editor */
  --paper: var(--bg); --paper-2: var(--panel-2); --surface: var(--panel); --rule: var(--line-2);

  --sans: "Geist", "SF Pro Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
  --gap: 16px;
  --pad: 24px;
  --max: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D151C; --panel: #131D26; --panel-2: #172330;
    --line: #22303B; --line-2: #2E3E4A;
    --ink: #E6EBEE; --ink-2: #A5B1B8; --ink-3: #75838B;
    --neg: #E07062; --in: #5598CF; --out: #D35A4B; --track: #1C2934; --focus: #7DB9D3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D151C; --panel: #131D26; --panel-2: #172330;
  --line: #22303B; --line-2: #2E3E4A;
  --ink: #E6EBEE; --ink-2: #A5B1B8; --ink-3: #75838B;
  --neg: #E07062; --in: #5598CF; --out: #D35A4B; --track: #1C2934; --focus: #7DB9D3;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; outline: none; }
main:focus, main:focus-visible { outline: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.neg { color: var(--neg); }
.stale { color: var(--neg); }

.page { max-width: calc(var(--max) + 2 * var(--gutter)); width: 100%; margin: 0 auto; padding: 0 var(--gutter); display: grid; gap: var(--gap); }

/* ---------- App shell: fixed sidebar + content ---------- */
:root { --side: 248px; --accent: var(--in); --accent-tint: color-mix(in srgb, var(--in) 9%, var(--panel)); }
.app { min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30;
  display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto;
}
.side > .mark { margin: 22px 20px 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.mark svg { width: 26px; height: 26px; flex: none; }
.mark rect { fill: var(--ink); }
.mark path { fill: var(--panel); }
.mark .sail-dim { opacity: .55; }
.mark span { font-weight: 600; font-size: 17px; letter-spacing: -0.015em; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-head { margin: 18px 20px 6px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 20px; text-decoration: none;
  font-size: 14px; font-weight: 500; color: var(--ink-2); border-right: 3px solid transparent;
}
.side-nav a:hover { color: var(--ink); background: var(--panel-2); }
.side-nav .is-active a { color: var(--accent); background: var(--accent-tint); border-right-color: var(--accent); font-weight: 600; }
.side-nav .sub a { padding: 6px 20px 6px 51px; font-size: 13px; font-weight: 400; }
.side-nav .sub.is-active a { font-weight: 500; }
.nav-icon { width: 20px; height: 20px; flex: none; stroke: currentColor; stroke-width: 1.4; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.side-foot { margin-top: auto; padding: 14px 12px 18px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.side-btn { display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; text-align: left; }
.side-btn:hover { background: var(--panel-2); color: var(--ink); }
.side-btn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.theme .i-sun { display: none; }
:root[data-theme="dark"] .theme .i-sun { display: block; }
:root[data-theme="dark"] .theme .i-moon { display: none; }

.app-main { padding-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 18px var(--gutter) 0; max-width: calc(var(--max) + 2 * var(--gutter)); width: 100%; margin: 0 auto; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.menu-btn, .mark-sm { display: none; }
.menu-btn { border: 1px solid var(--line-2); background: var(--panel); width: 36px; height: 36px; border-radius: 8px; place-items: center; cursor: pointer; }
.menu-btn svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 1.6; fill: none; stroke-linecap: round; }
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 26, .32); z-index: 25; }
.scrim[hidden] { display: none; }

.mode { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.mode button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.mode button[aria-checked="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }

.btn { border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn-ink { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn-ink:hover { opacity: .88; }
.link { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); font-size: inherit; }
.link:hover { text-decoration-color: var(--ink-3); }
.danger { color: var(--neg); }
.icon { border: 1px solid var(--line-2); background: var(--panel); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon:hover { border-color: var(--ink-3); }
.icon svg { width: 16px; height: 16px; stroke: var(--ink); stroke-width: 1.6; fill: none; }
.theme .i-sun { display: none; }
:root[data-theme="dark"] .theme .i-sun { display: block; }
:root[data-theme="dark"] .theme .i-moon { display: none; }

/* ---------- Page head ---------- */
.page-head { padding: 4px 0 4px; }
.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--line-2); }
.page-title h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.page-title p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.page-title { display: flex; flex-direction: column; align-items: flex-start; }
[data-edit-field] { border-radius: 6px; margin-left: -6px; padding: 0 6px; cursor: text; outline: none; transition: background-color .12s, box-shadow .12s; }
[data-edit-field]:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
[data-edit-field]:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
[data-edit-field].is-editing { background: var(--panel); box-shadow: 0 0 0 1px var(--line-2), 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); cursor: text; }
[data-edit-field]:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.page-title h1[data-edit-field], .page-title p[data-edit-field] { margin-left: -6px; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px var(--pad) var(--pad); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-meta { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.panel.flush { padding: 18px 0 6px; }
.panel.flush .panel-head { padding: 0 var(--pad); margin-bottom: 8px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.cols.single { grid-template-columns: minmax(0, 1fr); }
.empty-note { margin: 4px 0 0; color: var(--ink-3); }
.more { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.kpi { padding: 20px var(--pad) 22px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi-val { font-size: 30px; line-height: 1.1; font-weight: 500; letter-spacing: -0.025em; }
.kpi-sub { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.meter { width: 56px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; flex: none; }
.meter span { display: block; height: 100%; background: var(--in); border-radius: 2px; }
.notice { margin: -4px 0 0; font-size: 13px; color: var(--ink-2); padding: 10px 14px 10px 38px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; position: relative; }
.notice::before { content: ""; position: absolute; left: 14px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; border: 1.4px solid var(--ink-3); background: linear-gradient(var(--ink-3), var(--ink-3)) 50% 3px / 1.4px 2px no-repeat, linear-gradient(var(--ink-3), var(--ink-3)) 50% 6.5px / 1.4px 4.5px no-repeat; box-sizing: border-box; }
.notice b { font-weight: 600; color: var(--ink); white-space: nowrap; }
.notice .link { margin-left: 6px; }

/* ---------- Cash flow bars ---------- */
.flows { list-style: none; margin: 0; padding: 0; }
.flows li { display: grid; grid-template-columns: 150px minmax(0, 1fr) 96px; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.flows li:first-child { padding-top: 4px; }
.flow-name { font-weight: 500; text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.flow-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.flow-bars { display: grid; gap: 4px; }
.track { display: flex; height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.fbar { height: 100%; display: block; min-width: 2px; }
.fbar.in { background: var(--in); }
.fbar.out { background: var(--out); }
.track > .fbar:last-child, .track > .fbar:nth-last-child(1) { border-radius: 0 3px 3px 0; }
.fbar.planned { background: repeating-linear-gradient(135deg, currentColor 0 2px, transparent 2px 5px); margin-left: 2px; }
.fbar.in.planned { color: var(--in); }
.fbar.out.planned { color: var(--out); }
.flow-net { text-align: right; font-weight: 500; white-space: nowrap; }
.chart-foot { display: flex; align-items: center; gap: 16px; margin-top: 14px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.key .k-in { background: var(--in); }
.key .k-out { background: var(--out); }
.key .k-plan { background: repeating-linear-gradient(135deg, var(--ink-3) 0 2px, transparent 2px 4px); }
.chart-note { margin-left: auto; }

/* ---------- Costs by category ---------- */
.cats { width: 100%; border-collapse: collapse; }
.cats th, .cats td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cats tr:first-child th, .cats tr:first-child td { padding-top: 4px; }
.cats th { text-align: left; font-weight: 500; width: 104px; padding-right: 12px; }
.cat-bar-cell { padding-right: 16px !important; }
.cat-bar { display: block; height: 6px; background: var(--out); border-radius: 3px; min-width: 2px; }
.cats .num { text-align: right; white-space: nowrap; width: 72px; }
.cats .num.muted { width: 44px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { font-size: 12.5px; font-weight: 500; color: var(--ink-3); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid th:first-child, .grid td:first-child { padding-left: var(--pad); }
.grid th:last-child, .grid td:last-child { padding-right: var(--pad); }
.panel:not(.flush) .grid th:first-child, .panel:not(.flush) .grid td:first-child { padding-left: 0; }
.panel:not(.flush) .grid th:last-child, .panel:not(.flush) .grid td:last-child { padding-right: 0; }
.grid .num { text-align: right; white-space: nowrap; }
.grid .strong { font-weight: 500; }
.grid td a { font-weight: 500; text-decoration: none; }
.grid td a:hover { text-decoration: underline; text-underline-offset: 3px; }
.grid .sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.grid .sub.note { color: var(--ink-2); }
.grid tbody tr[data-href], .grid tbody tr[data-line] { cursor: pointer; }
.grid tbody tr[data-href]:hover td, .grid tbody tr[data-line]:hover td { background: var(--panel-2); }
.grid .group th, .grid .group td { background: var(--panel-2); color: var(--ink-2); font-size: 12.5px; font-weight: 600; padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.grid.compact td { padding-top: 10px; padding-bottom: 10px; vertical-align: middle; }
.grid .date { width: 56px; }
.date-chip { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 10.5px; color: var(--ink-3); line-height: 1.1; }
.date-chip b { font-size: 15px; font-weight: 600; color: var(--ink); }
.date-chip.is-today { border-color: var(--ink); }
.tag { font-size: 11.5px; font-weight: 500; border-radius: 4px; padding: 1px 6px; margin-left: 8px; vertical-align: 1px; white-space: nowrap; border: 1px solid var(--line-2); color: var(--ink-2); }
.tag.planned { border-style: dashed; }
tr.is-paused .amt { text-decoration: line-through; color: var(--ink-3); }
tr.is-planned .amt { color: var(--ink-3); }

.empty { border: 1px dashed var(--line-2); border-radius: 8px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.empty p { margin: 0; color: var(--ink-2); }

.foot { max-width: calc(var(--max) + 2 * var(--gutter)); width: 100%; margin: auto auto 0; padding-top: 40px !important; padding: 20px var(--gutter) 32px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.foot p { margin: 0; }
.foot-actions { display: flex; gap: 16px; }
.foot .link { font-weight: 400; color: var(--ink-2); }

/* ---------- Tooltip ---------- */
.tip { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; background: var(--ink); color: var(--panel); font-size: 12.5px; line-height: 1.35; padding: 6px 9px; border-radius: 6px; max-width: 280px; opacity: 0; transition: opacity .12s; }
.tip.show { opacity: 1; }

/* ---------- Editor ---------- */
dialog { border: 0; border-left: 1px solid var(--line); padding: 0; background: var(--panel); color: var(--ink); width: min(520px, 100vw); max-height: 100dvh; margin: 0 0 0 auto; height: 100dvh; }
dialog::backdrop { background: rgba(10, 18, 26, .32); }
@media (prefers-reduced-motion: no-preference) { dialog[open] { animation: slide .24s cubic-bezier(.2,.8,.2,1); } }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 24px 0; min-height: 100%; align-content: start; }
.editor-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.editor-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.editor-head .icon { border: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-wide { grid-column: 1 / -1; }
.field label, .field legend { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); min-height: 40px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.money { position: relative; }
.money span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.money input { padding-left: 26px; }
.per-month { margin: -6px 0 0; font-size: 13px; color: var(--ink-2); min-height: 1.5em; }
.per-month b { color: var(--ink); font-weight: 600; }
.toggle-set { flex-direction: row; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.toggle-set legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.toggle-set label { flex: 1; position: relative; }
.toggle-set input { position: absolute; opacity: 0; inset: 0; }
.toggle-set span { display: block; text-align: center; padding: 7px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); border-radius: 6px; }
.toggle-set input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.toggle-set input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.checked-row { display: flex; align-items: center; gap: 12px; }
.checked-row input { flex: 1; }
.editor-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; position: sticky; bottom: 0; background: var(--panel); padding: 16px 0 20px; margin-top: 8px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--panel); padding: 9px 14px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Narrow: sidebar becomes a drawer ---------- */
@media (max-width: 1080px) {
  .app-main { padding-left: 0; }
  .side { transform: translateX(-100%); box-shadow: none; }
  body.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(10, 18, 26, .18); }
  @media (prefers-reduced-motion: no-preference) { .side { transition: transform .22s cubic-bezier(.2,.8,.2,1); } }
  .topbar { justify-content: flex-start; padding-top: 14px; }
  .menu-btn { display: grid; }
  .mark-sm { display: inline-flex; }
  .mark-sm svg { width: 24px; height: 24px; }
  .topbar-tools { margin-left: auto; }
}

/* ---------- Tablet ---------- */
@media (max-width: 960px) {
  .cols, .cols.wide-left { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  :root { --pad: 16px; }
  .topbar { flex-wrap: wrap; row-gap: 12px; }
  .topbar-tools { width: 100%; justify-content: space-between; margin-left: 0; }
  .page-head { padding-top: 20px; }
  .page-title h1 { font-size: 22px; }
  .kpi { padding: 16px; }
  .kpi-val { font-size: 24px; }
  .kpi-sub { flex-wrap: wrap; row-gap: 6px; }
  .flows li { grid-template-columns: 112px minmax(0, 1fr) 72px; gap: 10px; }
  .hide-sm { display: none; }
  .chart-note { margin-left: 0; width: 100%; }
  .editor { grid-template-columns: 1fr; padding: 16px 16px 0; }
}


/* ---------- Sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login[hidden], .app[hidden] { display: none; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px 28px 28px; }
.login-mark { width: 40px; height: 40px; display: block; margin-bottom: 20px; }
.login-mark rect { fill: var(--ink); }
.login-mark path { fill: var(--panel); }
.login-mark .sail-dim { opacity: .55; }
.login h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login-lede { margin: 0 0 20px; color: var(--ink-2); }
.login label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); min-height: 42px; margin-bottom: 14px; }
.login input:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.btn-block { width: 100%; padding: 10px 14px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: default; }
.login-msg { margin: 12px 0 0; color: var(--neg); font-size: 13px; min-height: 1px; }
.login-msg:empty { display: none; }
.loading { color: var(--ink-3); padding: 40px 0; }

/* ---------- Polish pass ---------- */
/* Sidebar: net per item, collapsible property lists, account */
.side-nav a { position: relative; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-net { font-size: 12px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-net.neg { color: var(--neg); }
.side-nav .is-active .nav-net { color: inherit; opacity: .8; }
.side-nav .sub .nav-net { font-size: 11.5px; }
.has-kids > a::after { content: ""; width: 6px; height: 6px; border-right: 1.4px solid var(--ink-3); border-bottom: 1.4px solid var(--ink-3); transform: rotate(-45deg); margin-left: 2px; flex: none; transition: transform .15s; }
.has-kids.is-open > a::after { transform: rotate(45deg); }
.acct { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; margin-top: 6px; border-top: 1px solid var(--line); }
.acct-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); flex: none; }
.acct-email { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-out { border: 0; background: none; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; color: var(--ink-3); flex: none; }
.acct-out:hover { background: var(--panel-2); color: var(--ink); }
.acct-out svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Save status */
.sync { margin: 0 auto 0 0; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #3E8E5E; }
.sync[data-state="saving"] .sync-dot { background: var(--ink-3); animation: pulse 1s ease-in-out infinite; }
.sync[data-state="error"] { color: var(--neg); }
.sync[data-state="error"] .sync-dot { background: var(--neg); }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sync[data-state="saving"] .sync-dot { animation: none; } }
.btn kbd { font: 500 11px var(--sans); margin-left: 6px; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--panel) 18%, transparent); color: inherit; opacity: .8; }

/* Needs review: mark checked */
.check-cell { width: 1%; }
.mini { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 6px; padding: 4px 9px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.mini:hover { border-color: var(--ink-3); color: var(--ink); }
.mini svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Empty property */
.starter { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 28px var(--pad) 26px; }
.starter h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.starter p { margin: 0 0 18px; color: var(--ink-2); max-width: 56ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip:hover { border-color: var(--ink-3); }
.chip-dot { width: 8px; height: 8px; border-radius: 2px; }
.chip-dot.in { background: var(--in); }
.chip-dot.out { background: var(--out); }
.chip-ink { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* Toast with action */
.toast { display: flex; align-items: center; gap: 14px; pointer-events: none; }
.toast.show { pointer-events: auto; }
.toast-btn { border: 0; background: none; color: inherit; font: 600 13px var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }

/* Loading skeleton */
.sk { border-radius: 6px; background: var(--track); }
.sk-title { width: 180px; height: 26px; margin-bottom: 10px; }
.sk-line { width: 120px; height: 12px; margin: 4px 0; }
.sk-line.short { width: 80px; }
.sk-big { width: 140px; height: 28px; margin: 6px 0; }
.sk-block { height: 180px; }
@media (prefers-reduced-motion: no-preference) { .sk { animation: shimmer 1.4s ease-in-out infinite; } }
@keyframes shimmer { 50% { opacity: .55; } }

@media (max-width: 640px) {
  .sync { order: 3; width: 100%; margin: 0; }
  .btn kbd { display: none; }
  .mini span { display: none; }
  .mini { padding: 5px 7px; }
}
@media (hover: none) { .btn kbd { display: none; } }

/* ---------- Hero figure ---------- */
:root { --good: #2F7D4F; --good-tint: color-mix(in srgb, #2F7D4F 11%, var(--panel)); --bad-tint: color-mix(in srgb, var(--neg) 10%, var(--panel)); }
:root[data-theme="dark"] { --good: #63B98A; }
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.hero-main { padding: 26px var(--pad) 24px; min-width: 0; }
.hero-side { padding: 26px var(--pad) 22px; border-left: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.hero-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hero-num { margin: 10px 0 14px; font-size: clamp(44px, 6.4vw, 84px); line-height: .95; font-weight: 500; letter-spacing: -0.045em; color: var(--ink); white-space: nowrap; }
.hero-sign { font-weight: 400; margin-right: .02em; }
.hero-num.neg .hero-sign { color: var(--neg); }
.hero-num.pos .hero-sign { color: var(--good); }
.hero-cents { color: var(--ink-3); font-weight: 400; opacity: .75; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 13px; color: var(--ink-2); }
.hero-annual { font-variant-numeric: tabular-nums; }
.hero-note b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.hero-note .link { margin-left: 4px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.pill i { font-style: normal; font-weight: 600; }
.pill.good { background: var(--good-tint); border-color: transparent; color: var(--good); }
.pill.bad { background: var(--bad-tint); border-color: transparent; color: var(--neg); }
.cov-head { display: flex; justify-content: space-between; align-items: baseline; }
.cov-val { font-size: 28px; font-weight: 500; letter-spacing: -0.03em; }
.cov-sub { margin: 0; font-size: 13px; color: var(--ink-2); }
.segmeter { position: relative; }
.segs { position: relative; display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; height: 30px; }
.segs i { display: block; border-radius: 2px; background: var(--track); }
.segs i.on { background: var(--in); }
.segs i.on.over { background: var(--good); }
.segs .be { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.seg-scale { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; color: var(--ink-3); }
.be-label { color: var(--ink-2); font-weight: 500; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.three .kpi:nth-child(3) { border-left: 1px solid var(--line); border-top: 0; }
@media (prefers-reduced-motion: no-preference) {
  .segs i.on { animation: segin .5s cubic-bezier(.2,.8,.2,1) both; }
  .segs i.on:nth-child(n) { animation-delay: calc(var(--d, 0) * 1ms); }
}
@keyframes segin { from { transform: scaleY(.3); opacity: 0; } }
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .hero-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .hero-main, .hero-side { padding: 20px 16px; }
  .hero-num { font-size: 46px; }
  .kpis.three { grid-template-columns: 1fr 1fr; }
  .kpis.three .kpi:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}

/* Breathing room at the end of every page (the old footer used to provide it) */
main > .page { padding-bottom: 64px; }
@media (max-width: 640px) { main > .page { padding-bottom: calc(40px + env(safe-area-inset-bottom)); } }

/* ---------- Vacancies ---------- */
:root { --warn: #9A5B00; --warn-tint: color-mix(in srgb, #E19A1F 12%, var(--panel)); --warn-line: color-mix(in srgb, #E19A1F 38%, var(--panel)); }
:root[data-theme="dark"] { --warn: #E8B45A; --warn-tint: color-mix(in srgb, #E19A1F 12%, var(--panel)); --warn-line: color-mix(in srgb, #E19A1F 32%, var(--panel)); }
.vacancy { background: var(--warn-tint); border: 1px solid var(--warn-line); border-radius: var(--r); overflow: hidden; }
.vac-head { display: flex; gap: 14px; align-items: flex-start; padding: 18px var(--pad) 14px; }
.vac-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--panel); border: 1px solid var(--warn-line); display: grid; place-items: center; flex: none; }
.vac-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--warn); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.vac-title h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.vac-title p { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-2); }
.vac-title b { color: var(--ink); font-weight: 600; }
.vac-list { list-style: none; margin: 0; padding: 0 0 6px; }
.vac-list a { display: grid; grid-template-columns: minmax(0, 1.6fr) auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 10px var(--pad); text-decoration: none; border-top: 1px solid var(--warn-line); }
.vac-list a:hover { background: color-mix(in srgb, var(--panel) 55%, transparent); }
.vac-where { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.vac-where b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vac-where span { color: var(--ink-2); white-space: nowrap; }
.vac-days { color: var(--ink-2); font-size: 13px; }
.vac-rent { font-weight: 500; text-align: right; white-space: nowrap; }
.vac-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.vac-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.vac-state.vacant { color: var(--warn); background: var(--panel); border: 1px solid var(--warn-line); }
.vac-state.turnover { color: var(--neg); background: var(--panel); border: 1px solid color-mix(in srgb, var(--neg) 30%, var(--panel)); }
.vac-state.occupied { color: var(--good); background: var(--good-tint); }
.nav-vac { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn-tint); border: 1px solid var(--warn-line); color: var(--warn); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; margin-right: 2px; }
.toggle-set.three span { font-size: 12.5px; padding: 7px 4px; }
.grid.units td { vertical-align: middle; }
@media (max-width: 640px) {
  .vac-list a { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .vac-days { grid-column: 1; font-size: 12.5px; }
  .vac-rent { grid-row: 1; grid-column: 2; }
  .vac-state { grid-column: 2; grid-row: 2; justify-self: end; }
  .vac-where { flex-direction: column; gap: 0; }
}
.field[hidden] { display: none; }
