/* Bank Sync — light theme. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --primary: #2f54eb;
  --primary-hover: #1d3fd1;
  --primary-soft: #eef2ff;
  --ok: #15803d;      --ok-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --err: #b91c1c;     --err-soft: #fee2e2;
  --credit: #15803d;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --sidebar: 240px;
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.break { word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--err); }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 700; font-size: 15px; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2f54eb, #6a8bff); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.nav-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.me-text { min-width: 0; }
.me-email { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; color: var(--text); }
.me-links { display: flex; gap: 10px; font-size: 12.5px; }
.me-links button.link { font-size: 12.5px; }

.content { flex: 1; min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 36px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; margin-bottom: 8px; display: inline-block; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .brand { justify-content: center; padding-bottom: 22px; font-size: 18px; }
.auth-box .card { padding: 28px; }
.auth-box h1 { font-size: 20px; margin-bottom: 6px; }
.auth-box .lead { color: var(--muted); margin-bottom: 20px; }
.auth-box .btn-block { width: 100%; justify-content: center; margin-top: 4px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ---------- Cards, tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 20px 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 18px; align-items: start; }
.cols > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.tile-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile-value { font-size: 26px; font-weight: 650; margin-top: 2px; letter-spacing: -.01em; }
.tile-value.small-val { font-size: 16px; margin-top: 8px; font-weight: 600; }
.tile.ok .tile-value { color: var(--ok); }
.tile.warn .tile-value { color: var(--warn); }
.tile.err .tile-value { color: var(--err); }

/* ---------- Alerts ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); color: #14532d; border: 1px solid #bbf7d0; margin: 0 0 18px; }
.flash.error { background: var(--err-soft); color: #7f1d1d; border-color: #fecaca; }
.flash.warn { background: var(--warn-soft); color: #78350f; border-color: #fde68a; }
.flash.info { background: var(--primary-soft); color: #1e3a8a; border-color: #c7d2fe; }
.flash p { margin: 0 0 8px; }
.flash p:last-child { margin: 0; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin: 0 0 14px; }
label > input, label > select, label > textarea { margin-top: 6px; }
.help { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 8px 11px; width: 100%; min-height: 38px; transition: border-color .15s, box-shadow .15s;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--primary); margin: 0; }
input[type=file] { padding: 6px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 84, 235, .15); }
input::placeholder, textarea::placeholder { color: #94a3b8; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); margin: 0; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; align-items: end; }
.form-grid.tight { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row label { margin: 0; flex: 1; min-width: 160px; }
.row .grow { flex: 2; min-width: 260px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 16px; align-items: center; }
.checks-title { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
details.advanced { border: 1px dashed var(--line-2); border-radius: var(--radius-sm); padding: 10px 14px; margin: 4px 0 16px; background: var(--surface-2); }
details.advanced summary { cursor: pointer; font-weight: 500; color: var(--text-2); font-size: 13px; }
details.advanced[open] summary { margin-bottom: 12px; }
details summary { cursor: pointer; }
input.tiny { width: 90px; }

/* ---------- Buttons ---------- */
button, .button {
  font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
button:hover, .button:hover { background: var(--surface-2); border-color: #94a3b8; text-decoration: none; color: var(--text); }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
button.danger { color: var(--err); border-color: #fecaca; }
button.danger:hover { background: var(--err-soft); }
button.small, .button.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
button.link { border: 0; background: none; color: var(--primary); padding: 0; min-height: 0; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
form.inline { display: inline; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tbody tr:hover td { background: #fafbff; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid.compact td { padding: 8px 14px; font-size: 13px; }
.card > table.grid, .card > .table-wrap { margin: 0 -22px -20px; width: calc(100% + 44px); }
.card > table.grid th:first-child, .card > .table-wrap th:first-child, .card > table.grid td:first-child, .card > .table-wrap td:first-child { padding-left: 22px; }
.card.flush > table.grid, .card.flush > .table-wrap { margin: 0; width: 100%; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.credit .amount, .amount.credit { color: var(--credit); }
tr.pendingrow td { background: #fffdf5; }
tr.warnrow td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.revoked td { opacity: .55; }
td .sub, .sub-line { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px !important; }
.empty .button { margin-top: 10px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f1f5f9; color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain::before { display: none; }
.badge.active, .badge.booked, .badge.filed, .badge.credit, .badge.ok, .badge.matched { background: var(--ok-soft); color: var(--ok); }
.badge.pending, .badge.unmatched, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.error, .badge.expired, .badge.debit { background: var(--err-soft); color: var(--err); }
.badge.disabled, .badge.ignored, .badge.duplicate { background: #f1f5f9; color: var(--muted); }

/* ---------- Connection cards (dashboard) ---------- */
.company-block { margin-bottom: 26px; }
.company-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.company-title h2 { margin: 0; }
.conn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.conn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.conn.attention { border-color: #fcd34d; box-shadow: 0 0 0 3px #fef3c7; }
.conn-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.conn-name { font-weight: 600; font-size: 15px; color: var(--text); }
.conn-bank { color: var(--muted); font-size: 12.5px; }
.conn-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.conn-facts dt { color: var(--muted); }
.conn-facts dd { margin: 0; }
.conn-error { background: var(--err-soft); color: #7f1d1d; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px; }

/* ---------- Steps (connection setup) ---------- */
.steps { counter-reset: step; }
.step { position: relative; padding: 0 0 22px 44px; }
.step:last-child { padding-bottom: 0; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--muted); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.step::after { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1px; background: var(--line); }
.step:last-child::after { display: none; }
.step.done::before { content: "✓"; background: var(--ok-soft); border-color: #86efac; color: var(--ok); }
.step.current::before { background: var(--primary); border-color: var(--primary); color: #fff; }
.step h3 { margin: 3px 0 6px; font-size: 14.5px; }
.step p { color: var(--text-2); }

/* ---------- Search / filters ---------- */
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.searchbar input { padding-left: 42px; min-height: 46px; font-size: 15px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.filters label { margin: 0; }
.resultbar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; color: var(--muted); }
.resultbar strong { color: var(--text); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 18px 0 4px; color: var(--muted); }

/* ---------- Misc ---------- */
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 9px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
pre.raw { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: var(--radius-sm); overflow: auto; max-height: 440px; font-size: 12px; margin: 12px 0 0; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; list-style: none; padding: 0; margin: 16px 0 20px; }
.codes li code { display: block; text-align: center; font-size: 15px; padding: 8px; background: var(--surface-2); }
.qr { display: block; margin: 8px auto 16px; background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
input.copy, textarea.copy { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--surface); }
textarea.copy { width: 100%; resize: none; line-height: 1.45; margin: 4px 0 10px; white-space: pre-wrap; word-break: break-all; }
.acct-row { display: grid; grid-template-columns: minmax(200px, 1.3fr) repeat(4, minmax(120px, 1fr)) auto auto; gap: 12px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); }
.acct-row:last-child { border-bottom: 0; }
.acct-row label { margin: 0; }
.acct-id strong { display: block; }
.kvp { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); padding: 0 6px; border-radius: 5px; margin: 1px 2px 1px 0; font-size: 12px; }
.actions-col form { margin: 0 0 6px; }
.htmx-request #results { opacity: .55; transition: opacity .15s; }
.dot { color: var(--line-2); margin: 0 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on, .tabs a:hover { color: var(--text); border-bottom-color: var(--primary); text-decoration: none; }

@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 10px; }
  .nav-section { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .me-email { display: none; }
  .page { padding: 20px 16px 48px; }
  .acct-row { grid-template-columns: 1fr 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
}
.center-gap { text-align: center; margin-top: 14px; }
.card.narrow { max-width: 560px; }
.center-gap-left { margin-top: 12px; }
input.tiny-month { width: 170px; }
label.check.remember { margin: 2px 0 14px; color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Cards ---------- */
/* A small card-shaped mark with the last four digits: solid for physical
   cards, dashed outline for virtual ones. */
.cardglyph { flex: none; display: inline-flex; align-items: flex-end; justify-content: flex-end; width: 46px; height: 30px; padding: 3px 5px; border-radius: 5px; background: linear-gradient(135deg, #1e293b, #334155); color: #e2e8f0; font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .04em; position: relative; }
.cardglyph::before { content: ""; position: absolute; left: 6px; top: 7px; width: 9px; height: 7px; border-radius: 2px; background: #cbd5e1; opacity: .85; }
.cardglyph.virtual { background: var(--primary-soft); color: var(--primary); border: 1.5px dashed #a5b4fc; }
.cardglyph.virtual::before { display: none; }
.cardglyph.large { width: 64px; height: 42px; font-size: 13px; padding: 4px 7px; border-radius: 7px; }
.cardglyph.large::before { left: 8px; top: 10px; width: 12px; height: 9px; }
.cardcell { display: flex; gap: 12px; align-items: center; color: inherit; }
.cardcell:hover { color: inherit; text-decoration: none; }
.cardcell:hover .cardname { color: var(--primary); text-decoration: underline; }
.cardname { font-weight: 600; color: var(--text); }
.cardhead { display: flex; gap: 14px; align-items: center; }
.cardref { white-space: nowrap; }
tr.deletedrow td { background: var(--surface-2); }
tr.deletedrow .cardglyph { opacity: .45; }
tr.deletedrow .cardname { color: var(--muted); }
.badge.frozen, .badge.locked { background: var(--warn-soft); color: var(--warn); }
.badge.inactive, .badge.terminated, .badge.deleted { background: #f1f5f9; color: var(--muted); }
.table-foot { margin: 10px 0 0; }
.cards-table .cardcell { min-width: 230px; }
@media (max-width: 720px) {
  .cards-table .col-accts { display: none; }
}
.contents { display: contents; }
