@font-face { font-family: 'Familjen Grotesk'; font-weight: 500 700; font-display: swap; src: url('fonts/familjen-grotesk-latin.woff2') format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-weight: 400 600; font-display: swap; src: url('fonts/hanken-grotesk-latin.woff2') format('woff2'); }

/* Brand tokens: swap these (and BRAND in app.js) when the name and look are decided. */
:root {
  --bg: #f5f6f1; --bg2: #ebede6; --card: #fff; --ink: #1d2024; --ink2: #3d4046; --stone: #6f726b; --line: #d6d8d0; --line2: #ebede6;
  --orange: #e5641c; --orange-deep: #c4520f; --orange-soft: #fbe9de; --sea: #3a5f6f; --sea-soft: #dfe8ea; --ok: #2f7d4f; --ok-soft: #e1efe6;
  --nav: #1d2024; --nav2: #2a2e33; --nav-ink: #f5f6f1; --nav-dim: #c9ccc4; --nav-off: #8a8d85; --nav-line: #3d4046;
  --display: 'Familjen Grotesk', "Helvetica Neue", Arial, sans-serif; --body: 'Hanken Grotesk', "Segoe UI", Helvetica, Arial, sans-serif;
  --focus: #e5641c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #16181b; --bg2: #1f2226; --card: #23262b; --ink: #f0f1ec; --ink2: #c9ccc4; --stone: #9a9d94; --line: #34383e; --line2: #2c3035;
    --orange: #f2793a; --orange-deep: #f2793a; --orange-soft: #3a261b; --sea: #8fb3c2; --sea-soft: #1f2e34; --ok: #6cc08f; --ok-soft: #1b2e23;
    --nav: #101214; --nav2: #23262b; --focus: #f2793a; }
}
:root[data-theme="dark"] { --bg: #16181b; --bg2: #1f2226; --card: #23262b; --ink: #f0f1ec; --ink2: #c9ccc4; --stone: #9a9d94; --line: #34383e; --line2: #2c3035;
  --orange: #f2793a; --orange-deep: #f2793a; --orange-soft: #3a261b; --sea: #8fb3c2; --sea-soft: #1f2e34; --ok: #6cc08f; --ok-soft: #1b2e23;
  --nav: #101214; --nav2: #23262b; --focus: #f2793a; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--card); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
svg { flex: none; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.topbar { display: none; }
.nav { flex: 0 0 264px; width: 264px; background: var(--nav); color: var(--nav-ink); padding: 24px 18px; display: flex; flex-direction: column; gap: 22px; position: relative; }
.nav-head { display: flex; align-items: center; gap: 12px; padding-right: 34px; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: var(--nav-ink); color: var(--nav); display: flex; align-items: center; justify-content: center; font: 700 17px var(--display); flex: none; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.agency { display: flex; flex-direction: column; min-width: 0; }
.agency b { font: 700 18px/1.2 var(--display); }
.agency small { font-size: 12px; color: var(--nav-dim); }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--nav-line); background: transparent; color: var(--nav-ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--nav2); }
.nav-toggle { position: absolute; top: 14px; right: 14px; }
.links { display: flex; flex-direction: column; gap: 2px; }
.link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--nav-dim); text-decoration: none; position: relative; min-height: 42px; }
.link:hover { background: var(--nav2); color: var(--nav-ink); }
.link[aria-current="page"] { background: var(--nav2); color: var(--nav-ink); font-weight: 600; }
.link.off { color: var(--nav-off); cursor: default; }
.link.off:hover { background: transparent; color: var(--nav-off); }
.link .soon { margin-left: auto; font-size: 11px; }
.badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.inbox-box { margin-top: auto; background: var(--nav2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.inbox-box small { font-size: 12px; color: var(--nav-dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.inbox-box b { font-size: 13px; word-break: break-all; }
.powered { font-size: 12px; color: var(--nav-off); }
.me { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 4px; }
.inbox-box ~ .me { margin-top: 4px; }
.me small { font-size: 12px; color: var(--nav-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--nav-ink); font-size: 13px; text-decoration: underline; cursor: pointer; }

/* sign-in, no access and agency choice: no menu, one card in the middle */
.shell.gated .nav, .shell.gated .topbar { display: none; }
.shell.gated .main { justify-content: center; align-items: center; }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: min(440px, 100%); display: flex; flex-direction: column; gap: 14px; }
.gate-card h1 { font: 700 26px/1.2 var(--display); margin: 0; }
.gate-card p { margin: 0; color: var(--ink2); }
.gate-brand { font: 700 15px var(--display); color: var(--orange-deep); }
.choose { display: flex; flex-direction: column; gap: 10px; }
.choose .btn { justify-content: flex-start; }

/* folded menu (desktop) */
.shell.folded .nav { flex-basis: 76px; width: 76px; padding: 18px 0; align-items: center; gap: 16px; }
.shell.folded .nav-head { padding: 0; flex-direction: column; }
.shell.folded .agency, .shell.folded .link .label, .shell.folded .link .soon, .shell.folded .inbox-box, .shell.folded .powered, .shell.folded .me { display: none; }
.shell.folded .nav-toggle { position: static; order: -1; }
.shell.folded .links { align-items: center; gap: 4px; }
.shell.folded .link { width: 44px; height: 44px; min-height: 0; padding: 0; justify-content: center; }
.shell.folded .badge { position: absolute; top: 1px; right: -2px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; font-size: 11px; text-align: center; }

.main { flex: 1 1 auto; min-width: 0; padding: 32px clamp(16px, 3vw, 44px) 56px; display: flex; flex-direction: column; gap: 22px; }
.main:focus { outline: none; }
.loading, .empty { color: var(--stone); }
.empty { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; text-align: center; }

/* phone: menu becomes a drawer */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--nav); color: var(--nav-ink); padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .topbar-name { font: 700 17px var(--display); }
  .nav, .shell.folded .nav { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); flex-basis: auto; padding: 24px 18px; align-items: stretch; z-index: 40; transform: translateX(-102%); transition: transform .2s ease; overflow-y: auto; }
  .shell.drawer .nav { transform: none; }
  .shell.folded .agency, .shell.folded .link .label, .shell.folded .link .soon, .shell.folded .inbox-box, .shell.folded .powered, .shell.folded .me { display: revert; }
  .shell.folded .nav-head { flex-direction: row; }
  .shell.folded .links { align-items: stretch; }
  .shell.folded .link { width: auto; height: auto; min-height: 42px; padding: 9px 12px; justify-content: flex-start; }
  .shell.folded .badge { position: static; }
  .nav-toggle { display: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .main { padding: 20px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none !important; } }

/* ---------- page parts ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; }
h1 { margin: 0; font: 700 34px/1.1 var(--display); letter-spacing: -.02em; }
.lede { margin: 4px 0 0; font-size: 14px; color: var(--stone); }
h2 { margin: 0; font: 700 19px/1.25 var(--display); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.card.flush { padding: 0; overflow: hidden; gap: 0; }
.card.flush > h2, .card-head { padding: 18px 22px; border-bottom: 1px solid var(--line2); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .k { font-size: 13px; color: var(--stone); font-weight: 600; }
.stat .v { font: 700 28px var(--display); }
.stat .s { font-size: 13px; color: var(--ink2); }
.stat.warn { background: var(--orange-soft); border-color: var(--orange-soft); }
.stat.warn .k { color: var(--orange-deep); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.muted { color: var(--stone); }
.small { font-size: 13px; }
.note { font-size: 12px; color: var(--stone); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink2); }
.btn.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.go { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg2); color: var(--ink2); white-space: nowrap; }
.pill.warn { background: var(--orange-soft); color: var(--orange-deep); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.sea { background: var(--sea-soft); color: var(--sea); }
.who-ai { background: var(--sea-soft); color: var(--sea); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--stone); font-size: 13px; font-weight: 600; padding: 11px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 18px; border-bottom: 1px solid var(--line2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
td b { font-weight: 600; }

/* needs-you list */
.todo { display: flex; flex-direction: column; gap: 10px; }
.todo a { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; background: var(--bg); border-radius: 12px; text-decoration: none; }
.todo a:hover { background: var(--bg2); }
.todo .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--orange-soft); color: var(--orange-deep); display: flex; align-items: center; justify-content: center; font: 700 16px var(--display); }
.todo .t { font-weight: 600; }
.todo .d { font-size: 14px; color: var(--ink2); }
.todo .amt { font: 700 17px var(--display); white-space: nowrap; }

/* bills */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.split { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.bill-list { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bill-item { text-align: left; width: 100%; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.bill-item[aria-current="true"] { border: 2px solid var(--ink); padding: 11px 13px; }
.bill-item .top { display: flex; justify-content: space-between; gap: 10px; }
.bill-item .sup { font: 700 15px var(--display); }
.bill-item .sub { font-size: 13px; color: var(--stone); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bill-detail { flex: 2 1 480px; min-width: 0; }
.holds { background: var(--orange-soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.holds p { margin: 0; }
.holds .h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--orange-deep); }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; font-size: 14px; background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.facts dt { color: var(--stone); }
.facts dd { margin: 0; font-weight: 600; word-break: break-word; }
.why { font-size: 13px; color: var(--stone); font-weight: 400; }
.fix { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line2); padding-top: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink2); }
.field select, .field input { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--card); font-size: 15px; font-weight: 400; color: var(--ink); }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 16px; text-align: center; color: var(--stone); font-size: 14px; background: var(--card); }
.drop.over { border-color: var(--orange); color: var(--ink); background: var(--orange-soft); }
.drop label { text-decoration: underline; cursor: pointer; color: var(--ink); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* connections */
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-mark { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font: 700 15px var(--display); flex: none; }
.conn-mark.qb { background: #2ca01c; } .conn-mark.bank { background: #3a5f6f; } .conn-mark.alto { background: #5a2d82; } .conn-mark.mail { background: #e5641c; }
.conn-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.conn-name b { font: 700 18px var(--display); }
.conn-name span { font-size: 13px; color: var(--stone); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 60; }
.error { background: var(--orange-soft); color: var(--orange-deep); border-radius: 12px; padding: 14px 16px; font-weight: 600; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.done { background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.done b { font-weight: 700; }
.done a { color: inherit; font-weight: 600; }
