/* ------------------------------------------------------------------ */
/* Tokens                                                             */
/* ------------------------------------------------------------------ */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2024;
  --ink-soft: #5b6472;
  --ink-faint: #949cab;
  --line: #dfe3e9;
  --line-strong: #b9c0cb;
  --accent: #2f6feb;
  --accent-soft: #eaf1fe;
  --neg: #c62828;      /* money out / over budget */
  --pos: #1b7f4b;      /* money in / under budget */
  --paid: #4a9d5f;     /* recorded */
  --missed: #c0392b;   /* overdue */
  --ended: #7ba3d0;    /* no more charges expected */
  --row-hi: #fffbe6;
  --sticky-shadow: 6px 0 6px -4px rgba(0, 0, 0, .12);

  /* Frozen column widths — the sticky offsets below are derived from these,
     so change them here and update the offsets together. */
  --w-act: 68px;   /* Add + cancel on the entry row, with headroom */
  --w-date: 62px;
  --w-cat: 100px;
  --w-svc: 100px;
  --w-desc: 148px;
  --w-net: 78px;

  /* Header row heights. The sticky `top` of each header row is the sum of the
     ones above it, so these three values and those offsets must agree. */
  --h-group: 19px;
  --h-name: 50px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

code {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eceff3;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ------------------------------------------------------------------ */
/* Chrome                                                             */
/* ------------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  height: 44px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand {
  font-weight: 650;
  letter-spacing: -.2px;
  font-size: 14px;
}

.tabs { display: flex; gap: 2px; }

.tab {
  border: 0;
  background: none;
  padding: 6px 11px;
  border-radius: 6px;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}
.tab:hover { background: #f0f2f5; color: var(--ink); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.saveflag { font-size: 11px; color: var(--ink-faint); min-width: 58px; text-align: right; }
.saveflag.is-busy { color: var(--accent); }
.saveflag.is-error { color: var(--neg); font-weight: 600; }

.btn {
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: #f4f6f9; }
.btn:active { background: #e9edf3; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2560d4; }
.btn-ghost { border-color: transparent; background: #f0f2f5; }
.btn-ghost:hover { background: #e6e9ee; }
.btn-danger { color: var(--neg); border-color: #eccdcd; background: #fdf5f5; }
.btn-danger:hover { background: #fbeaea; }
.btn-icon { padding: 3px 8px; line-height: 1; font-size: 15px; }
.btn-month { min-width: 118px; font-weight: 600; }

/* Views ------------------------------------------------------------- */
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.is-active { display: flex; }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 9px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
  flex-wrap: wrap;
}

.monthnav { display: flex; align-items: center; gap: 4px; }

.fld { display: flex; flex-direction: column; gap: 3px; }
.fld > span { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-faint); }
.fld > input {
  font: inherit;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  width: 132px;
}
.fld > input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.fld-grow { flex: 1; min-width: 180px; }
.fld-grow > input { width: 100%; }

.chk { display: flex; align-items: center; gap: 5px; color: var(--ink-soft); padding-bottom: 5px; cursor: pointer; }
.chk input { margin: 0; }

.hint { font-size: 11px; color: var(--ink-faint); padding-bottom: 5px; }
.hint b { color: var(--ink-soft); }

.legend { display: flex; gap: 6px; margin-left: auto; padding-bottom: 4px; }
.lg { font-size: 10px; padding: 2px 7px; border-radius: 4px; color: #fff; }
.lg-paid { background: var(--paid); }
.lg-missed { background: var(--missed); }
.lg-ended { background: var(--ended); }
.lg-future { background: var(--panel); color: var(--ink-soft); border: 1px solid var(--line-strong); }

.statusbar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 5px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 11px;
  color: var(--ink-soft);
  flex: none;
}
.statusbar .hint { padding: 0; }

/* Legend swatch for the flagged-row shading. */
.flagkey { display: flex; align-items: center; gap: 5px; color: var(--ink-soft); }
.flagkey::before {
  content: '';
  width: 20px;
  height: 11px;
  border: 1px solid #e9b9bd;
  background: #fdeced;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ */
/* Grid shell                                                         */
/* ------------------------------------------------------------------ */
/* Every view's table sits flush in the same scroll container, so they all line
   up under the toolbar rather than one of them floating inside padding. */
.gridwrap { flex: 1; min-height: 0; overflow: auto; background: var(--panel); }

table.grid,
table.pivot {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

table.grid th, table.grid td,
table.pivot th, table.pivot td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
  height: 25px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--panel);
}

table.grid thead th, table.pivot thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #eef1f5;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: left;
  font-size: 11px;
}
table.grid thead tr.hdr-group th {
  top: 0;
  height: var(--h-group);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
table.grid thead tr.hdr-name th {
  top: var(--h-group);
  height: var(--h-name);
  vertical-align: bottom;
  padding-bottom: 3px;
}
table.grid thead tr.hdr-total th {
  top: calc(var(--h-group) + var(--h-name));
  z-index: 4;
  background: #e3e8ef;
  color: var(--ink);
}

/* Account headers stack over up to three short lines so the column can be
   narrow: name, then account number, then the day it is due. */
table.grid thead tr.hdr-name th.c-amt,
table.grid thead tr.hdr-name th.c-loan {
  text-align: right;
  white-space: normal;
  overflow: visible;
}
th .a-name, th .a-num, th .a-due { display: block; line-height: 1.15; }
th .a-name { font-weight: 600; color: var(--ink); }
th .a-num { font-weight: 400; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
th .a-due { font-weight: 400; color: var(--ink-faint); font-size: 10px; }

.num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.zero { color: #c7ccd4; }

/* Frozen left block. Offsets are the running sum of the widths above. */
.stick { position: sticky; z-index: 2; }
thead .stick { z-index: 5; }
/* max-width as well as width: the table lays out automatically, so without an
   upper bound a long description widens the column instead of ellipsing. */
.c-act  { left: 0;                                                                         width: var(--w-act);  min-width: var(--w-act);  max-width: var(--w-act); }
.c-date { left: var(--w-act);                                                               width: var(--w-date); min-width: var(--w-date); max-width: var(--w-date); }
.c-cat  { left: calc(var(--w-act) + var(--w-date));                                         width: var(--w-cat);  min-width: var(--w-cat);  max-width: var(--w-cat); }
.c-svc  { left: calc(var(--w-act) + var(--w-date) + var(--w-cat));                          width: var(--w-svc);  min-width: var(--w-svc);  max-width: var(--w-svc); }
.c-desc { left: calc(var(--w-act) + var(--w-date) + var(--w-cat) + var(--w-svc));            width: var(--w-desc); min-width: var(--w-desc); max-width: var(--w-desc); }
.c-net  { left: calc(var(--w-act) + var(--w-date) + var(--w-cat) + var(--w-svc) + var(--w-desc));
          width: var(--w-net); min-width: var(--w-net); border-right: 2px solid var(--line-strong); box-shadow: var(--sticky-shadow); }

.c-amt  { width: 68px; min-width: 68px; }
.c-loan { width: 92px; min-width: 92px; border-left: 2px solid var(--line-strong); }

/* Account group tint so the debit / credit blocks stay distinguishable. */
th.grp-bank, td.grp-bank { background: #fcfdff; }
th.grp-credit, td.grp-credit { background: #fffdfa; }
th.grp-investment, td.grp-investment { background: #fbfdfb; }
thead tr.hdr-group th.grp-bank { background: #e7eef7; }
thead tr.hdr-group th.grp-credit { background: #f7eee4; }
thead tr.hdr-group th.grp-investment { background: #e7f2ea; }
thead tr.hdr-group th.grp-loan { background: #ede8f7; }


/* ------------------------------------------------------------------ */
/* Grid rows                                                          */
/* ------------------------------------------------------------------ */
tbody tr:hover > td { background: var(--row-hi); }
tbody tr:hover > td.grp-bank,
tbody tr:hover > td.grp-credit,
tbody tr:hover > td.grp-investment { background: var(--row-hi); }
tbody tr.is-dirty > td { background: #f2f8ff; }

/* Money moved but no category, so it never reaches Tracking. Listed after the
   account-group tints and repeated per group so it wins on specificity. */
tbody tr.row-flag > td,
tbody tr.row-flag > td.grp-bank,
tbody tr.row-flag > td.grp-credit,
tbody tr.row-flag > td.grp-investment { background: #fdeced; }
tbody tr.row-flag:hover > td,
tbody tr.row-flag:hover > td.grp-bank,
tbody tr.row-flag:hover > td.grp-credit,
tbody tr.row-flag:hover > td.grp-investment { background: #fbe0e2; }
/* Mark the cell that is actually at fault. */
tbody tr.row-flag-category > td.c-cat,
tbody tr.row-flag-date > td.c-date { box-shadow: inset 2px 0 0 var(--neg); }

/* The entry row, held apart from the ledger below it. */
tbody tr.row-draft > td {
  background: #f4faf5;
  border-bottom: 2px solid var(--line-strong);
}
tbody tr.row-draft:hover > td { background: #eef7f0; }
tbody tr.row-draft > td.c-act { background: #e8f4ea; }

td.cell { cursor: cell; }
td.cell.is-editing { padding: 0; box-shadow: inset 0 0 0 2px var(--accent); }
td.cell.is-editing input {
  width: 100%;
  height: 23px;
  border: 0;
  outline: 0;
  background: var(--panel);
  font: inherit;
  padding: 0 5px;
  color: var(--ink);
}
td.cell.is-editing input.num { text-align: right; font-variant-numeric: tabular-nums; }

td.c-net { font-weight: 600; }
td.c-loan { cursor: pointer; }
td.c-loan:hover { box-shadow: inset 0 0 0 1px var(--accent); }
td.c-loan .loaners { color: var(--ink-faint); font-size: 10px; }

.rowbtn {
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}
.rowbtn:hover { color: var(--neg); }

/* The entry row's commit button is labelled, since a bare tick was read as a
   status icon rather than an action. */
.rowbtn-add {
  color: #fff;
  background: var(--pos);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  letter-spacing: .3px;
}
.rowbtn-add:hover { color: #fff; background: #15653b; }

/* Delete stays out of sight until you are actually on the row. */
.rowbtn-del { opacity: 0; font-size: 15px; transition: opacity .1s; }
tbody tr:hover .rowbtn-del,
.rowbtn-del:focus { opacity: 1; }

/* Faint prompts in the empty cells of the entry row. */
.ghost { color: #b9c0cb; font-style: italic; }

.pill {
  display: inline-block;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  background: #eceff3;
  color: var(--ink-soft);
}
.pill-warn { background: #fdf0e6; color: #a5541b; }

.empty { padding: 34px 14px; color: var(--ink-faint); text-align: center; }

/* ------------------------------------------------------------------ */
/* Records grids (passwords, banking)                                 */
/* ------------------------------------------------------------------ */
table.records thead th {
  top: 0;
  height: 26px;
  vertical-align: middle;
}
table.records .r-act {
  left: 0;
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  white-space: nowrap;
  border-right: 2px solid var(--line-strong);
  box-shadow: var(--sticky-shadow);
}
table.records td.r-col { position: relative; }
table.records th.is-sorted { color: var(--accent); }
.sortarrow { margin-left: 3px; font-size: 9px; }

/* Hidden values. The dots are deliberately a fixed-ish run so the real length
   is not leaked by the width of the mask. */
.masked { color: var(--ink-faint); letter-spacing: 1px; user-select: none; }
.mono { font: 11.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.rowbtn-eye { font-size: 10px; opacity: .5; }
.rowbtn-eye:hover, .rowbtn-eye.is-on { opacity: 1; color: var(--accent); }

/* Copy sits at the right edge of a secret cell, on hover only. */
.rowbtn-copy {
  position: absolute;
  right: 1px;
  top: 3px;
  opacity: 0;
  font-size: 12px;
  background: var(--panel);
  padding: 0 3px;
}
td.is-secret:hover .rowbtn-copy { opacity: 1; }
.rowbtn-copy:hover { color: var(--accent); }

/* Multi-value cells: one chip per name. */
.chip {
  display: inline-block;
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 6px;
  margin-right: 3px;
  border-radius: 8px;
  background: #e7eef9;
  color: #2b4f80;
  vertical-align: middle;
}
tr.row-draft .chip { background: #e2efe4; color: #2c5e39; }

td.boolcell { text-align: center; }
td.boolcell input { margin: 0; cursor: pointer; }

/* A closed account: still there, visibly retired. */
tbody tr.row-off > td { background: #fafbfc; color: var(--ink-faint); }
tbody tr.row-off:hover > td { background: #f3f5f8; }
tbody tr.row-off .chip { background: #eceff3; color: var(--ink-faint); }
tbody tr.row-off td.r-col:not(.boolcell) { text-decoration: line-through; text-decoration-color: #cfd5de; }

/* Tick-box popover for picking several names. */
.mp-menu {
  position: fixed;
  z-index: 95;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 8px 22px rgba(16, 22, 30, .16);
  min-width: 176px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}
.mp-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-faint);
  padding: 3px 7px 5px;
}
.mp-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.mp-item:hover { background: var(--accent-soft); }
.mp-item input { margin: 0; }
.mp-foot {
  display: flex;
  gap: 5px;
  padding: 5px 4px 2px;
  margin-top: 3px;
  border-top: 1px solid var(--line);
}
.mp-foot input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}
.mp-foot input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.warnkey {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #a5541b;
  background: #fdf0e6;
  border: 1px solid #f0d5bd;
  padding: 1px 7px;
  border-radius: 9px;
}

/* ------------------------------------------------------------------ */
/* Pivots                                                             */
/* ------------------------------------------------------------------ */
table.pivot td.rowhdr, table.pivot th.rowhdr {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f4f6f9;
  font-weight: 600;
  width: 168px;
  min-width: 168px;
  box-shadow: var(--sticky-shadow);
}
table.pivot thead th.rowhdr { z-index: 5; }
table.pivot td.meta, table.pivot th.meta {
  position: sticky;
  left: 168px;
  z-index: 2;
  width: 46px;
  min-width: 46px;
  background: #f4f6f9;
  color: var(--ink-faint);
  font-size: 10px;
  text-align: center;
  box-shadow: var(--sticky-shadow);
}
table.pivot thead th.meta { z-index: 5; }

/* A narrow column that scrolls with the body rather than sticking. */
table.pivot td.col-plain, table.pivot th.col-plain {
  width: 60px;
  min-width: 60px;
  text-align: right;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
table.pivot td.col-wide, table.pivot th.col-wide { width: 140px; min-width: 140px; }

/* Scoped to tbody so these win over `tr.subtle td`, which would otherwise
   grey the text down into the coloured background. */
table.pivot tbody td.st-paid   { background: var(--paid) !important; color: #fff; }
table.pivot tbody td.st-missed { background: var(--missed) !important; color: #fff; }
table.pivot tbody td.st-ended  { background: var(--ended) !important; color: #f2f7fd; }
/* Not due yet: left plain, so the eye goes to the months that mean something. */
table.pivot tbody td.st-future { background: var(--panel) !important; color: #c7ccd4; }
tbody tr:hover > td.st-paid   { background: #439055 !important; }
tbody tr:hover > td.st-missed { background: #ae3427 !important; }
tbody tr:hover > td.st-ended  { background: #6f97c4 !important; }
tbody tr:hover > td.st-future { background: var(--row-hi) !important; }
td.st-blank  { background: #f8f9fb !important; }

tr.grouprow td {
  background: #eceff3;
  font-weight: 650;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-soft);
}
tr.totalrow td, tr.totalrow th {
  background: #e3e8ef;
  font-weight: 700;
  border-top: 2px solid var(--line-strong);
}
/* Dim only the row's own labels, never the data cells — greying a cell that
   sits on a coloured background just makes it unreadable. */
tr.subtle td.rowhdr { color: var(--ink-soft); font-weight: 500; }
tr.subtle td.meta { color: var(--ink-faint); }

.mcol-actual { width: 84px; min-width: 84px; }
.mcol-budget { width: 74px; min-width: 74px; color: var(--ink-soft); }
/* The month a budget period starts. Marks where a figure changed, so a jump in
   the variance has a visible cause. */
.mcol-budget.budget-start {
  font-weight: 650;
  color: var(--ink);
  box-shadow: inset 0 2px 0 var(--accent);
}
.mcol-var    { width: 84px; min-width: 84px; font-weight: 600; background: #f4f5f7; }
.mcol-cum    { width: 96px; min-width: 96px; background: #f2f4fb; }

/* Each month is a block of four columns, so the seam between months needs to
   read harder than the rules inside a block. */
table.pivot td.mcol-cum,
table.pivot th.mcol-cum,
table.pivot th.monthgroup { border-right: 2px solid var(--ink); }
table.pivot td.rowhdr,
table.pivot th.rowhdr { border-right: 2px solid var(--ink); }
th.monthgroup { text-align: center; background: #dfe5ee !important; }

.clickable { cursor: pointer; }
.clickable:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ */
/* Typeahead                                                          */
/* ------------------------------------------------------------------ */
.ta-menu {
  position: fixed;
  z-index: 90;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 8px 22px rgba(16, 22, 30, .16);
  max-height: 236px;
  overflow-y: auto;
  min-width: 168px;
  padding: 3px;
}
.ta-item {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.ta-item.is-on { background: var(--accent-soft); color: var(--accent); }
.ta-item .ta-side { color: var(--ink-faint); font-size: 10px; }
.ta-item.ta-new { color: var(--pos); }
.ta-empty { padding: 6px 8px; color: var(--ink-faint); font-size: 11px; }
.ta-item b { background: #fff3ba; border-radius: 2px; }

/* ------------------------------------------------------------------ */
/* Modals                                                            */
/* ------------------------------------------------------------------ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 34, .38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  z-index: 80;
  overflow-y: auto;
}
.modal {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(12, 18, 26, .28);
  width: 620px;
  max-width: 100%;
}
.modal-lg { width: 900px; }
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.modal-head .sub { color: var(--ink-faint); font-size: 11px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 14px 16px; }
.modal-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  border-radius: 0 0 10px 10px;
}
.modal-foot .spacer { flex: 1; }

table.edit { width: 100%; border-collapse: collapse; font-size: 12px; }
table.edit th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-faint);
  padding: 0 6px 5px;
  font-weight: 600;
}
table.edit td { padding: 2px 3px; }
table.edit input, table.edit select {
  font: inherit;
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
}
table.edit input:focus, table.edit select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
table.edit input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.edit input[type=checkbox] { width: auto; }

.summary {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.summary div { font-size: 11px; color: var(--ink-faint); }
.summary div b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

.tabstrip { display: flex; gap: 3px; padding: 10px 16px 0; }
.tabstrip button {
  border: 1px solid transparent;
  background: none;
  font: inherit;
  padding: 5px 11px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  color: var(--ink-soft);
}
.tabstrip button.is-active {
  background: var(--panel);
  border-color: var(--line);
  border-bottom-color: var(--panel);
  color: var(--ink);
  font-weight: 600;
  margin-bottom: -1px;
}

/* ------------------------------------------------------------------ */
/* Lock screen                                                       */
/* ------------------------------------------------------------------ */
.btn-lock { font-variant-emoji: text; }
.btn-lock:disabled { opacity: .45; cursor: not-allowed; }

/* Covers everything, including the header, so nothing is readable or
   clickable behind it while the file is encrypted. */
.lockscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #1b2027;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lockbox {
  width: 340px;
  max-width: 100%;
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  text-align: center;
}
.lockbox .lockicon { font-size: 30px; line-height: 1; margin-bottom: 10px; }
.lockbox h1 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.lockbox .locksub { margin: 0 0 18px; font-size: 12px; color: var(--ink-faint); line-height: 1.45; }
.lockbox input[type=password] {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: 2px;
}
.lockbox input[type=password]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.lockbox button { width: 100%; padding: 8px; font-size: 13px; }
.lockbox .lockfoot { margin: 16px 0 0; font-size: 10.5px; color: var(--ink-faint); }
.lockbox .lockfoot code { font-size: 10px; }

.lockerr {
  display: none;
  margin-top: 12px;
  padding: 7px 10px;
  border-radius: 6px;
  background: #fdeced;
  border: 1px solid #eccdcd;
  color: var(--neg);
  font-size: 11.5px;
  text-align: left;
  line-height: 1.4;
}

.lockwarn {
  margin-top: 14px;
  padding: 9px 11px;
  border-radius: 6px;
  background: #fdf4e8;
  border: 1px solid #f0dcbd;
  color: #7a4a12;
  font-size: 11.5px;
  line-height: 1.5;
}
.lockwarn-soft { background: #f4f6f9; border-color: var(--line); color: var(--ink-soft); }
.lockwarn code { font-size: 10.5px; }

/* ------------------------------------------------------------------ */
/* Toasts                                                            */
/* ------------------------------------------------------------------ */
#toast-root {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
}
.toast {
  background: #22282f;
  color: #fff;
  padding: 8px 13px;
  border-radius: 7px;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .24);
  max-width: 380px;
}
.toast.is-error { background: #a02020; }
.toast.is-ok { background: #1c6b40; }

/* The gate screen's shell command, for the no-session case. */
.lockcmd {
  margin: 0 0 4px;
  padding: 9px 11px;
  border-radius: 6px;
  background: #22282f;
  color: #e6edf3;
  font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
  user-select: all;
}
/* Two password fields stack, so trim the gap between them. */
.lockbox input[type=password] + input[type=password] { margin-top: -2px; }

/* Clear the entry row. Sits beside Add, quieter than it. */
.rowbtn-cancel {
  font-size: 14px;
  line-height: 1;
  padding: 0 3px;
  margin-left: 2px;
  color: var(--ink-faint);
}
.rowbtn-cancel:hover { color: var(--neg); }
td.c-act, td.r-act {
  white-space: nowrap;
  overflow: visible;   /* never clip the row's own controls */
  padding: 0 4px;
}

/* A row that has just been saved. Saving is otherwise silent — the write lands
   in milliseconds and nothing moves — so this is the only confirmation that an
   edit actually took. */
@keyframes rowsaved {
  0%   { background: #c7e9d2; }
  65%  { background: #e2f5e8; }
  100% { background: transparent; }
}
@keyframes savedtick {
  0%   { opacity: 0; transform: scale(.6); }
  15%  { opacity: 1; transform: scale(1.1); }
  30%  { opacity: 1; transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
tbody tr.row-saved > td { animation: rowsaved 1.4s ease-out; }
/* Beat the account-group tints and the hover rule, which are equally specific. */
tbody tr.row-saved > td.grp-bank,
tbody tr.row-saved > td.grp-credit,
tbody tr.row-saved > td.grp-investment,
tbody tr.row-saved:hover > td { animation: rowsaved 1.4s ease-out; }

/* The tick sits in the gutter, over whatever else is in that cell. */
.savedtick {
  position: absolute;
  right: 2px;
  top: 50%;
  margin-top: -8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--pos);
  pointer-events: none;
  animation: savedtick 1.4s ease-out forwards;
}
/* The tick needs a positioned ancestor, but these two cells are already sticky
   and `position: relative` here would win on specificity and unfreeze them —
   the action column would then scroll away while every other frozen column
   stayed put. Sticky is a containing block for absolute children anyway, so
   only the cells that are not sticky need the hint. */
td.c-act:not(.stick), td.r-act:not(.stick) { position: relative; }

@media (prefers-reduced-motion: reduce) {
  tbody tr.row-saved > td { animation: none; background: #d8f0de; }
  .savedtick { animation: none; opacity: 1; }
}

/* Apply, for range changes. Quiet until a date is edited, then it asks to be
   pressed — the view is showing one range while the fields say another. */
.btn-apply { border-color: transparent; background: #f0f2f5; }
.btn-apply:hover { background: #e6e9ee; }
.btn-apply.is-pending {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-apply.is-pending:hover { background: #2560d4; }
