/* Finira console. Tokens first; every colour comes from a token so dark mode is one block. */
:root {
  --bg: #f5f5f2; --surface: #ffffff; --surface-2: #efefeb; --fg: #1a1c19; --muted: #62645c;
  --line: #e0e0d9; --line-strong: #c9c9c0;
  --accent: #1f55d1; --accent-hover: #1a46ad; --accent-fg: #ffffff; --accent-soft: #e6edfc;
  --ok: #176b3a; --ok-soft: #e0f3e7; --warn: #8a4b0a; --warn-soft: #fcefd6;
  --bad: #b3261e; --bad-soft: #fbe5e3; --info: #1f55d1; --info-soft: #e6edfc;
  --mute-soft: #ebebe6; --violet: #5b3fb0; --violet-soft: #ece7fa;
  --shadow: 0 1px 2px rgba(20, 22, 18, .06), 0 4px 16px rgba(20, 22, 18, .06);
  --radius: 10px; --side: 232px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131412; --surface: #1c1d1a; --surface-2: #252622; --fg: #ecece7; --muted: #a2a49a;
    --line: #2e302b; --line-strong: #43463f;
    --accent: #7c9cff; --accent-hover: #9ab2ff; --accent-fg: #0d1430; --accent-soft: #1f2a4d;
    --ok: #6fd596; --ok-soft: #173424; --warn: #f0b660; --warn-soft: #3a2a10;
    --bad: #ff8a80; --bad-soft: #3d1b18; --info: #7c9cff; --info-soft: #1f2a4d;
    --mute-soft: #2a2b27; --violet: #b9a5ff; --violet-soft: #2a2347;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); } .small-text { font-size: 13px; }
.nowrap { white-space: nowrap; } .right { text-align: right; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
        padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--fg); font-weight: 650; font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo { display: block; width: 30px; height: 30px; flex: none; border-radius: 8px; }      /* logo.svg: blue square, white F */
.brand-name { letter-spacing: -.01em; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
nav svg { width: 18px; height: 18px; flex: none; }
.nav-label { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: flex; gap: 10px; align-items: baseline; }
.checks .tick { width: 18px; flex: none; text-align: center; color: var(--muted); }
.checks li.done { color: var(--muted); } .checks li.done .tick { color: var(--ok); font-weight: 700; }
.count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--warn); color: var(--bg); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.bridge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: none; }
.bridge.ok { color: var(--ok); } .bridge.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.bridge.off { color: var(--warn); } .bridge.off .dot { background: var(--warn); }
.content { min-width: 0; }
.lbanner { margin: 20px 32px 0; max-width: 1116px; }
main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 4px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 8px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 14px;
       border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
       font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--muted); }
input[type=text], input[type=password], input[type=search], input[type=email], input.ctl, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 400; }
input::placeholder { color: var(--muted); opacity: .8; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 200px; }
.stack { display: grid; gap: 14px; }

/* ---------- cards, tiles, chips ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-align: left;
        font: inherit; color: var(--fg); cursor: pointer; }
.tile:hover { border-color: var(--line-strong); }
.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .n { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .l { font-size: 13px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 550; white-space: nowrap;
        background: var(--mute-soft); color: var(--muted); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.drafted { background: var(--info-soft); color: var(--info); }
.chip.flagged, .chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.posted { background: var(--ok-soft); color: var(--ok); }
.chip.error { background: var(--bad-soft); color: var(--bad); }
.chip.rule_matched { background: var(--violet-soft); color: var(--violet); }
.chip.rejected, .chip.dismissed { background: var(--mute-soft); color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px;
          background: var(--info-soft); color: var(--info); font-weight: 500; }
.banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
/* rules suggested from past postings */
.c-pick { width: 40px; } .c-pick input { width: 18px; height: 18px; }
.learn-skipped summary { cursor: pointer; font-weight: 550; padding: 8px 0; }
.learn-skipped > * + * { margin-top: 8px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; padding: 10px 14px; font-size: 12.5px; font-weight: 600;
     color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt-in { color: var(--ok); font-weight: 600; } .amt-out { font-weight: 600; }
.cp { font-weight: 550; } .bin { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.purpose { max-width: 340px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { text-align: center; padding: 48px 20px; display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--muted); }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- upload ---------- */
.drop { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 40px 20px; border: 2px dashed var(--line-strong);
        border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 36px; height: 36px; color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop .file { font-weight: 600; word-break: break-all; }

/* ---------- reports ---------- */
textarea { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font: inherit; resize: vertical; min-height: 76px; }
tfoot td { font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) 1fr minmax(90px, auto); gap: 10px; align-items: center; font-size: 13.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
input[type=date] { width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font: inherit; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(440px, 100%); }
.login .brand { padding: 0; margin-bottom: 20px; gap: 12px; font-size: 20px; font-weight: 700; }
.login .brand .logo { width: 38px; height: 38px; border-radius: 10px; }

/* ---------- dialog, toasts ---------- */
.dialog { border: 0; padding: 0; background: transparent; color: var(--fg); max-width: 100vw; max-height: 100vh; }
.dialog::backdrop { background: rgba(10, 12, 9, .5); }
.sheet { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--surface);
         border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.sheet-head { padding: 18px 20px 4px; } .sheet-body { padding: 12px 20px 8px; display: grid; gap: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; word-break: break-word; }
.picks { display: grid; gap: 6px; max-height: 190px; overflow: auto; }
.pick { text-align: left; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit; cursor: pointer; }
.pick:hover { border-color: var(--line-strong); }
.pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; width: min(360px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; animation: pop .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .shell { display: block; padding-bottom: 68px; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; padding: 0; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; flex-direction: row; justify-content: space-around; gap: 0;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; }
  .nav-label { display: none; }
  .count { position: absolute; margin: -4px 0 0 18px; min-width: 16px; line-height: 16px; font-size: 11px; }
  nav a { position: relative; flex-direction: column; gap: 2px; padding: 6px 14px; font-size: 12px; flex: 1 0 auto; align-items: center; }   /* more pages than fit: the bar scrolls sideways */
  main { padding: 18px 16px 32px; }
  .lbanner { margin: 12px 16px 0; }
  h1 { font-size: 21px; }
  .bridge #bridge-text { display: none; }
  .tiles { display: flex; overflow-x: auto; gap: 8px; margin-inline: -16px; padding: 2px 16px 6px; scroll-snap-type: x proximity; }
  .tile { flex: 0 0 auto; min-width: 104px; padding: 8px 12px; scroll-snap-align: start; }
  .tile .n { font-size: 20px; }
  .purpose { max-width: none; }
  .actions { justify-content: flex-start; }
}
/* Tables turn into cards when the content column gets narrower than about 800px */
@media (max-width: 1100px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  table.cards td { padding: 0; border: 0; }
  table.cards td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 12px; }
  table.cards td.span2 { grid-column: 1 / -1; }
  table.cards td.c-cp { order: 1; } table.cards td.c-amt { order: 2; } table.cards td.c-date { order: 3; }
  table.cards td.c-purpose { order: 4; grid-column: 1 / -1; } table.cards td.c-status { order: 5; }
  table.cards td.c-act { order: 6; grid-column: 1 / -1; margin-top: 6px; }
  table.cards td.c-pick { order: 0; grid-column: 1 / -1; }
  table.cards td.num { text-align: right; }
  .purpose { max-width: none; }
  .actions { justify-content: flex-start; }
}
/* Wide screens: Edit and Reject are icon-only to keep the row on one line */
@media (min-width: 1101px) { .actions { flex-wrap: nowrap; } .actions .lbl { display: none; } .actions .btn.secondary, .actions .btn.danger { padding: 4px 8px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* a payment the AI could not settle: its candidates, then the buttons. They may wrap and the names may be long */
.actions.many { flex-wrap: wrap; justify-content: flex-end; max-width: 330px; margin-left: auto; }
@media (min-width: 1101px) { .actions.many { flex-wrap: wrap; } .actions.many .btn { white-space: normal; text-align: left; } }
@media (max-width: 1100px) { .actions.many { justify-content: flex-start; max-width: none; margin-left: 0; } }

/* ---------- company switcher ---------- */
.company { justify-content: space-between; width: 100%; text-align: left; overflow: hidden; }
.company span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* language switch: always visible, out of the way */
.lang { position: fixed; top: 10px; right: 12px; z-index: 50; min-width: 40px; }

/* storage meter on the Backups page */
.meter { height: 8px; margin-top: 6px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 320px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.warn > span { background: var(--warn); }
