:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --card: #111111;
  --card-hi: #161616;
  --line: #1d1d1d;
  --line-2: #272727;
  --text: #ededed;
  --text-2: #a3a3a3;
  --text-3: #6f6f6f;
  --pos: #4ade80;
  --neg: #f87171;
  --warn: #f5b045;
  --blue: #3b7ef0;
  --dennis: #3b7ef0;
  --filip: #11a89a;
  --together: #d4d4d4;
  --r: 12px;
  --r-sm: 8px;
  --gap: 16px;
  --gutter: 24px;
  --f: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
[hidden] { display: none !important; }

.wrap { max-width: 1280px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.num, td.r, .money { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn-t { color: var(--warn); }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.r { text-align: right; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 52px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.top-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.updated { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.viewer { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto; text-decoration: none; color: var(--text-2); font-weight: 500; font-size: 13px;
  padding: 10px 12px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--text); }

main { padding-top: 24px; padding-bottom: 64px; }
.loading { color: var(--text-3); padding: 80px 0; text-align: center; }

/* ---------- grid ---------- */
.stack { display: grid; gap: var(--gap); }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; }
.c5 { grid-column: span 5; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 0; min-height: 32px; }
.section-head h2 { font-size: 15px; }
.section-head .sub { color: var(--text-3); font-size: 12px; font-weight: 400; margin-left: 8px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
.card-head h3 { font-size: 13px; font-weight: 600; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 16px 0; }
.empty { color: var(--text-3); font-size: 13px; padding: 4px 0; }

/* ---------- tiles ---------- */
.tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tiles.t4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.tile .lab { color: var(--text-2); font-size: 12px; font-weight: 500; }
.tile .val { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.tile.hero { background: var(--card-hi); border-color: var(--line-2); }

/* stat strip inside a card */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; }
.stat { padding: 4px 16px 4px 0; min-width: 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--line); }
.stat .lab { color: var(--text-2); font-size: 12px; }
.stat .val { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; white-space: nowrap; }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--line-2); color: var(--text); }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--card-hi); color: var(--text);
  cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #1c1c1c; border-color: #333; }
.btn.primary { background: var(--text); color: #0a0a0a; border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); }
.btn.danger.arm { background: var(--neg); color: #0a0a0a; border-color: var(--neg); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { color: var(--text-2); font-size: 12px; font-weight: 500; }
.field > small { color: var(--text-3); font-size: 11px; }
input, select, textarea {
  width: 100%; height: 36px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); outline: none; font-size: 14px; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { border-color: #4a4a4a; }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=date] { color-scheme: dark; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.form-actions .left { margin-right: auto; }

/* ---------- tables ---------- */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--text-3); font-weight: 500; font-size: 12px; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--card-hi); }
tr.total td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
td.wrap-cell { white-space: normal; min-width: 160px; }
td.urgent { color: var(--neg); font-weight: 600; }
.card .tscroll table th:first-child, .card .tscroll table td:first-child { padding-left: 16px; }

.who { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot.dennis { background: var(--dennis); }
.dot.filip { background: var(--filip); }
.dot.together { background: var(--together); }
.badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 500; background: var(--line-2); color: var(--text-2); vertical-align: middle; }
.badge.live { color: var(--pos); background: rgba(74, 222, 128, .1); }
.badge.pend { color: var(--warn); background: rgba(245, 176, 69, .1); }

/* ---------- compare (Dennis | Filip) ---------- */
.cmp th.p, .cmp td.p { text-align: right; width: 28%; }
.cmp tr.sep td { color: var(--text-3); font-size: 12px; font-weight: 500; padding-top: 14px; }
.cmp td.lab { color: var(--text-2); }

/* ---------- flags ---------- */
.flags { display: grid; gap: 8px; }
.flag { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; }
.flag .lvl { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.flag .lvl i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.flag.bad { border-color: rgba(248, 113, 113, .35); }
.flag.bad .lvl { color: var(--neg); } .flag.bad .lvl i { background: var(--neg); }
.flag.warn { border-color: rgba(245, 176, 69, .3); }
.flag.warn .lvl { color: var(--warn); } .flag.warn .lvl i { background: var(--warn); }
.flag.info .lvl { color: var(--text-2); } .flag.info .lvl i { background: var(--text-3); }

/* ---------- lists ---------- */
.rows { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.click { cursor: pointer; }
.row.click:hover { background: var(--card-hi); }
.row .nm { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- spending ---------- */
.filters { display: grid; grid-template-columns: auto minmax(0, 1.2fr) minmax(0, 1fr) auto minmax(0, 1.4fr); gap: 8px; align-items: center; }
.sum-line { color: var(--text-2); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }
.sum-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.day-group { border-bottom: 1px solid var(--line); }
.day-group:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--card-hi); color: var(--text-2); font-size: 12px; font-weight: 600; position: sticky; top: var(--top-h, 94px); z-index: 2; border-bottom: 1px solid var(--line); }
.day-head .tot { font-variant-numeric: tabular-nums; display: flex; gap: 12px; }
.txn { display: grid; grid-template-columns: minmax(0, 1fr) auto 236px; gap: 16px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.txn:last-child { border-bottom: 0; }
.txn .nm { font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.txn .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn .meta { color: var(--text-3); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.txn .seg { justify-self: end; }
.txn.dimmed .nm, .txn.dimmed .amt { color: var(--text-3); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--f); font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .zero-l { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover, .chart .hit.on { fill: rgba(255, 255, 255, .03); }
.chart .xh { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }

.tip { position: fixed; z-index: 50; pointer-events: none; background: #1a1a1a; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; min-width: 150px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.tip .t-h { color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.tip .t-r { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.tip .t-r i { height: 2px; width: 12px; border-radius: 1px; display: block; }
.tip .t-r b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; color: var(--text); }
.tip .t-r span { color: var(--text-2); }

/* ---------- connect ---------- */
.guide { background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 12px 14px; font: 12px/1.55 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; color: var(--text-2); margin: 0; }
.note { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.status i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.status.ok { color: var(--pos); } .status.ok i { background: var(--pos); }
.status.error { color: var(--neg); } .status.error i { background: var(--neg); }
.status.pending { color: var(--warn); } .status.pending i { background: var(--warn); }
.status.other { color: var(--text-3); }
.err-line { color: var(--neg); font-size: 12px; margin-top: 2px; white-space: normal; }

/* ---------- modal, toast ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 16px; }
.modal-box { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 16px; }
.modal-body .ro { color: var(--text-3); font-size: 12px; grid-column: 1 / -1; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #0a0a0a; font-weight: 500; font-size: 13px; padding: 10px 16px; border-radius: var(--r-sm); max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.toast.bad { background: var(--neg); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login h1 { font-size: 20px; }
.login p { color: var(--text-2); margin: 0; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; }
  .c3 { grid-column: span 6; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; }
  .stat:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .wide { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --gap: 12px; }
  main { padding-top: 16px; }
  .tiles, .tiles.t4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 14px; }
  .tile .val { font-size: 21px; }
  .c3 { grid-column: span 12; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat, .stat + .stat { padding: 4px 12px 4px 0; border-left: 0; }
  .stat:nth-child(2n) { padding-left: 12px; border-left: 1px solid var(--line); }
  .stat .val { font-size: 18px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .updated { display: none; }
  .txn { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  .txn .seg { grid-column: 1 / -1; justify-self: start; }
  .flag { grid-template-columns: 1fr; gap: 4px; }
  .section-head { flex-wrap: wrap; }
  .card { padding: 14px; }
  .card.flush .card-head { padding: 14px 14px 0; }
  .card-head { flex-wrap: wrap; row-gap: 4px; }
}

.logout { color: var(--text-3); font-size: 12px; text-decoration: none; white-space: nowrap; }
.logout:hover { color: var(--text); }
.login .bad-key { color: var(--neg); font-size: 12px; margin: -4px 0 0; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); padding: 16px; }
.banner b { font-weight: 600; }
.banner p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.paid { color: var(--text-3); }
.small { font-size: 13px; font-weight: 500; }
.cell-meta { color: var(--text-3); font-size: 12px; margin-top: 2px; padding-left: 16px; }
.grid > * > .card { height: 100%; }
.urgent-t { color: var(--neg); font-weight: 600; }
.show-sm { display: none; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  td.wrap-cell { min-width: 0; }
}

/* the accounts behind one connection */
.row.conn .conn-accts { grid-column: 1 / -1; display: grid; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; }
.conn-acct { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.conn-acct:last-child { border-bottom: 0; }
.conn-acct .nm { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.conn-acct .meta { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.conn-acct .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
