:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --panel-2: #f0f2ef;
  --text: #1d2420;
  --muted: #66706a;
  --line: #dfe3de;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --good: #23784f;
  --bad: #b23b31;
  --warn: #9a6a00;
  --bad-soft: #f8e5e2;
  --warn-soft: #f8efd8;
  --good-soft: #e1f1e7;
  --bar: #2f6f5e;
  --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 10px rgba(20, 30, 25, .04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --panel: #1c211e;
    --panel-2: #232925;
    --text: #e6ebe7;
    --muted: #97a29b;
    --line: #2f3632;
    --accent: #5fb398;
    --accent-ink: #0d1411;
    --accent-soft: #1f3530;
    --good: #5cc58f;
    --bad: #f0857a;
    --warn: #e2b54f;
    --bad-soft: #3a2220;
    --warn-soft: #3a3020;
    --good-soft: #1d3428;
    --bar: #5fb398;
    --bar-2: #e2b54f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 0.875rem/1.45 var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1 { font-size: 1.375rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 0.9375rem; margin: 0 0 10px; }
h3 { font-size: 0.8125rem; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.75rem; }
.num { text-align: right; white-space: nowrap; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

/* Layout */
.shell { display: grid; grid-template-columns: minmax(220px, 14rem) minmax(0, 1fr); min-height: 100vh; }
.shell > * { min-width: 0; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 650; padding: 0 8px 18px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 7px; }
#nav a:hover { background: var(--panel-2); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 0 8px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  #nav a { white-space: nowrap; padding: 6px 10px; }
  main { padding: 18px 16px 60px; }
}

/* Panels & grids */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.panel + .panel { margin-top: 16px; }
.grid > .panel + .panel, .stack > .panel + .panel { margin-top: 0; }
.stack > .panel + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
@media (max-width: 1100px) { .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid.k3 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .grid.k4 { grid-template-columns: 1fr; } }

.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 0.75rem; }
.kpi .value { font-size: 1.5rem; font-weight: 650; margin-top: 2px; letter-spacing: -.01em; }
.kpi .sub { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 0.75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:not(.group) td:first-child { min-width: 160px; }
tr.dim td { opacity: .55; }
tr.group td { background: var(--panel-2); font-weight: 600; }
tfoot td { font-weight: 650; border-bottom: 0; border-top: 2px solid var(--line); }
td.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.clickable { cursor: pointer; }

/* Buttons & forms */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 7px 12px; border-radius: 7px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--panel-2); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); background: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; padding: 4px 8px; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--panel-2); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%;
}
input[type=checkbox] { width: auto; accent-color: var(--accent); transform: scale(1.15); }
input[type=color] { padding: 2px; height: 36px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--muted); }
label.field > span { font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.875rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h3.form-sec { margin: 8px 0 -4px; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.form-grid h3.form-sec:first-child { margin-top: 0; }
.contact-info { display: flex; flex-direction: column; gap: 3px; font-size: 0.8125rem; min-width: 0; }
.contact-info a { overflow-wrap: anywhere; }
.contact-info .muted { font-size: 0.75rem; }
.contact-search { width: 100%; max-width: 360px; margin: 0 0 14px; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.inline input, .inline select { width: auto; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 15, 12, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 1rem; }
.dlg-body { padding: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--panel); }

/* Bits */
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.75rem; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.person-card { display: flex; flex-direction: column; gap: 12px; }
.person-card .top { display: flex; gap: 12px; align-items: center; }
.person-card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.person-card dt { color: var(--muted); }
.person-card dd { margin: 0; text-align: right; font-weight: 600; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 170px) 1fr auto; gap: 10px; align-items: center; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 99px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: var(--bar); }
.progress.over > i { background: var(--bad); }

.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks .ico { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.checks .ok .ico { background: var(--good-soft); color: var(--good); }
.checks .no .ico { background: var(--bad-soft); color: var(--bad); }
.checks .hm .ico { background: var(--warn-soft); color: var(--warn); }

.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 0.6875rem; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty button { margin-top: 10px; }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.month-nav { display: inline-flex; align-items: center; gap: 6px; }
.month-nav strong { min-width: 130px; text-align: center; }
.amount-input { width: 110px; text-align: right; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--bad); color: #fff; }

/* Stage 1: accounts & register */
[hidden] { display: none !important; }
.split-lines td { padding: 4px 6px; }
.split-lines select, .split-lines input { width: 100%; }
.toolbar > select { width: auto; max-width: 100%; }

/* Contact groups */
fieldset.group-checks { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.group-checks legend { padding: 0; margin-bottom: 6px; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
fieldset.group-checks .check-row { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chips button { border-radius: 99px; padding: 4px 12px; font-size: 0.8125rem; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chips button .n { opacity: .75; margin-left: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.pill.g-household { background: var(--good-soft); color: var(--good); }
.pill.g-lender { background: var(--warn-soft); color: var(--warn); }
.pill.g-borrower { background: var(--bad-soft); color: var(--bad); }

/* Contact search box (combobox) */
.combo-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--muted); }
.combo-field > span { font-weight: 600; }
.combo { position: relative; }
.combo > input[role=combobox] { width: 100%; }
.combo-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px); max-height: 260px; overflow: auto; margin: 0; padding: 4px 0; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 0.875rem; color: var(--text); }
.combo-list li { padding: 6px 10px; cursor: pointer; }
.combo-list li.combo-head { cursor: default; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 8px; }
.combo-list li[role=option]:hover, .combo-list li.active { background: var(--accent-soft); }
.combo-list li[data-new] { color: var(--accent); font-weight: 600; }
.actual-grid td, .actual-grid th { white-space: nowrap; }
.actual-grid td:first-child, .actual-grid th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.actual-grid tr.group td:first-child { background: var(--panel-2); }
/* Stage 5: receipts */
.rcpt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rcpt-card { display: flex; gap: 12px; padding: 12px; margin: 0; }
.rcpt-thumb { flex: 0 0 88px; }
.rcpt-img { width: 88px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.rcpt-doc { width: 88px; height: 110px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.rcpt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rcpt-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rcpt-fields input { width: 100%; min-width: 0; }
.rcpt-body .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.rcpt-drop.drag { outline: 2px dashed var(--accent); outline-offset: -6px; }
.rcpt-mini { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.rcpt-mini-item { position: relative; }
.rcpt-mini-item .rcpt-img, .rcpt-mini-item .rcpt-doc { width: 64px; height: 80px; }
.rcpt-mini-item button { position: absolute; top: -6px; right: -6px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; }
.rcpt-match-top { display: flex; gap: 12px; align-items: center; }
.rcpt-match-top .rcpt-img, .rcpt-match-top .rcpt-doc { width: 56px; height: 70px; }
.rcpt-text summary { cursor: pointer; color: var(--muted); }
.rcpt-text pre { white-space: pre-wrap; font-size: 0.6875rem; max-height: 180px; overflow: auto; background: var(--panel-2); padding: 6px; border-radius: 6px; margin: 4px 0 0; }

/* ---- Stage 7: Reports ---- */
.rep-grid tr.rep-total td { font-weight: 600; border-top: 2px solid var(--line); }
.rep-grid tfoot tr.rep-total td { border-top: 3px double var(--line); }
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --panel: #fff; --panel-2: #f0f0f0; --text: #000; --muted: #444; --line: #bbb; }
  body { background: #fff; }
  .sidebar, .no-print, .page-head .actions, #toast, dialog { display: none !important; }
  .shell { display: block; }
  main { padding: 0 !important; max-width: none !important; }
  .print-only { display: block; }
  .panel { box-shadow: none; border: 1px solid #ccc; break-inside: avoid-page; }
  .table-wrap { overflow: visible !important; }
  .actual-grid td:first-child, .actual-grid th:first-child { position: static; }
  table { font-size: 0.625rem; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Sidebar groups & icons ---- */
#nav { gap: 0; }
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
.nav-head { all: unset; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 0.6875rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 4px; border-radius: 6px; }
.nav-head:hover { color: var(--text); }
.nav-head:focus-visible { outline: 2px solid var(--accent); }
.nav-caret { transition: transform .15s; font-size: 0.625rem; }
.nav-group.closed .nav-caret { transform: rotate(-90deg); }
.nav-group.closed a:not(.active) { display: none; }
#nav a { display: flex; align-items: center; gap: 10px; }
.nav-ico { width: 18px; height: 18px; flex: none; opacity: .85; }
#nav a.active .nav-ico { opacity: 1; }
.nav-custom { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--muted); font-size: 0.8125rem; padding: 8px 10px; border-radius: 7px; margin-top: 4px; }
.nav-custom:hover { background: var(--panel-2); color: var(--text); }
.navc-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.navc-item { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-top: 1px solid var(--line); }
.navc-item:first-of-type { border-top: 0; }
.navc-item select { max-width: 150px; }
.navc-item.dim { opacity: .5; }
@media (max-width: 860px) {
  .nav-group { display: contents; }
  .nav-head, .nav-custom span { display: none; }
  .nav-group.closed a:not(.active) { display: flex; }
}

/* ---- Calendar ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-head { font-size: 0.75rem; font-weight: 600; color: var(--muted); padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.cal-day { min-height: 104px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-day.out { background: var(--panel-2); opacity: .55; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.hol .cal-num span:first-child { color: var(--bad); }
.cal-num { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 600; padding: 0 2px; }
.cal-chip { all: unset; box-sizing: border-box; display: flex; justify-content: space-between; gap: 4px; font-size: 0.6875rem; line-height: 1.3; padding: 2px 5px; border-radius: 4px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 3px solid; background: var(--panel-2); }
.cal-chip:hover { filter: brightness(.95); }
.cal-chip .cal-amt { color: var(--muted); flex: none; }
.cal-chip.done { opacity: .6; text-decoration: line-through; }
.k-expense { border-color: var(--bar); } .k-card { border-color: var(--bar-2); } .k-loan { border-color: var(--bad); }
.k-payday { border-color: var(--good); background: var(--good-soft); } .k-holiday { border-color: var(--muted); font-style: italic; } .k-custom { border-color: #5b7fd6; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: currentColor; border: 0; }
.cal-dot.k-expense { color: var(--bar); } .cal-dot.k-card { color: var(--bar-2); } .cal-dot.k-loan { color: var(--bad); } .cal-dot.k-payday { color: var(--good); } .cal-dot.k-holiday { color: var(--muted); } .cal-dot.k-custom { color: #5b7fd6; }
@media (max-width: 700px) {
  .cal-day { min-height: 64px; }
  .cal-chip { font-size: 0; padding: 0; height: 6px; border-left-width: 0; border-radius: 3px; background: currentColor; }
  .cal-chip.k-expense { color: var(--bar); } .cal-chip.k-card { color: var(--bar-2); } .cal-chip.k-loan { color: var(--bad); } .cal-chip.k-payday { color: var(--good); } .cal-chip.k-holiday { color: var(--muted); } .cal-chip.k-custom { color: #5b7fd6; }
  .cal-num .small { display: none; }
}

/* ---- Accounts & text size ---- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.login-card .field input { width: 100%; }
.login-size { display: flex; align-items: center; justify-content: center; gap: 2px; margin-top: 8px; }
.login-size button { padding: 2px 6px; line-height: 1; }
.nav-user { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 0 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.nav-user .nav-me { flex: 1; min-width: 0; }
.nav-user .nav-me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-budget { display: flex; flex-direction: column; gap: 2px; padding: 0 0 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.nav-budget select { width: 100%; font-weight: 600; }
.nav-size { display: flex; flex: none; }
.nav-size button { padding: 4px 6px; font-size: 0.8125rem; }
.size-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.size-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; padding: 8px 10px; }
.size-pick.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 860px) {
  .nav-user { border: 0; margin: 0; padding: 0; }
  .nav-user .nav-me span { display: none; }
}

/* ---- Appearance: modes (Auto / Light / Bright white / Dark) and background pictures ---- */
:root { --hol: #b8362b; --hol-soft: #fbe7e4; }
@media (prefers-color-scheme: dark) { :root { --hol: #f0857a; --hol-soft: #3a2321; } }
html[data-mode="light"], html[data-mode="white"] {
  --bg: #f5f6f4; --panel: #ffffff; --panel-2: #f0f2ef; --text: #1d2420; --muted: #66706a; --line: #dfe3de;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e2efe9; --good: #23784f; --bad: #b23b31; --warn: #9a6a00;
  --bad-soft: #f8e5e2; --warn-soft: #f8efd8; --good-soft: #e1f1e7; --bar: #2f6f5e; --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 10px rgba(20, 30, 25, .04); --hol: #b8362b; --hol-soft: #fbe7e4; color-scheme: light;
}
html[data-mode="white"] { --bg: #ffffff; --panel: #ffffff; --panel-2: #f5f7f9; --line: #e4e7eb; --shadow: 0 1px 3px rgba(0, 0, 0, .06); }
html[data-mode="dark"] {
  --bg: #141816; --panel: #1c211e; --panel-2: #232925; --text: #e6ebe7; --muted: #97a29b; --line: #2f3632;
  --accent: #5fb398; --accent-ink: #0d1411; --accent-soft: #1f3530; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #5fb398; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="sepia"] {
  --bg: #f4ecdc; --panel: #fbf6ec; --panel-2: #f1e7d4; --text: #3a2f22; --muted: #7a6a55; --line: #e2d5bd;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e6eadb; --good: #3f7a3a; --bad: #a8402f; --warn: #94650a;
  --bad-soft: #f4e0d6; --warn-soft: #f3e6c8; --good-soft: #e3ebd5; --bar: #2f6f5e; --bar-2: #b9852f;
  --shadow: 0 1px 2px rgba(70, 50, 20, .08), 0 2px 10px rgba(70, 50, 20, .05); --hol: #a8402f; --hol-soft: #f4e0d6; color-scheme: light;
}
html[data-mode="contrast"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #eeeeee; --text: #000000; --muted: #2b2b2b; --line: #000000;
  --accent: #0b4f3e; --accent-ink: #ffffff; --accent-soft: #d6ece4; --good: #0a5c2f; --bad: #9e1b12; --warn: #6b4a00;
  --bad-soft: #fbdcd8; --warn-soft: #fbedc8; --good-soft: #d4efdd; --bar: #0b4f3e; --bar-2: #8a5a00;
  --shadow: none; --hol: #9e1b12; --hol-soft: #fbdcd8; color-scheme: light;
}
html[data-mode="contrast"] .panel, html[data-mode="contrast"] .kpi { border-width: 2px; }
html[data-mode="contrast"] a { text-decoration: underline; }
html[data-mode="contrast"] :focus-visible { outline: 3px solid #000; outline-offset: 2px; }
html[data-mode="dim"] {
  --bg: #23272e; --panel: #2c313a; --panel-2: #343a44; --text: #dfe3ea; --muted: #a1a9b6; --line: #3e4551;
  --accent: #6fbfa5; --accent-ink: #11161a; --accent-soft: #2a3d3a; --good: #6ccb98; --bad: #f08f84; --warn: #e5bc63;
  --bad-soft: #43302f; --warn-soft: #433a2a; --good-soft: #283d33; --bar: #6fbfa5; --bar-2: #e5bc63; --shadow: none;
  --hol: #f08f84; --hol-soft: #43302f; color-scheme: dark;
}
html[data-mode="midnight"] {
  --bg: #000000; --panel: #0d0f0e; --panel-2: #161917; --text: #eef2ef; --muted: #9aa39d; --line: #262b28;
  --accent: #5fb398; --accent-ink: #000000; --accent-soft: #15261f; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #2b1715; --warn-soft: #2b2415; --good-soft: #13261c; --bar: #5fb398; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #2b1715; color-scheme: dark;
}
/* More modes */
html[data-mode="mist"] {
  --bg: #eef2f6; --panel: #ffffff; --panel-2: #e8edf3; --text: #1c2430; --muted: #5f6b7a; --line: #d8dfe8;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e2efe9; --good: #23784f; --bad: #b23b31; --warn: #9a6a00;
  --bad-soft: #f8e5e2; --warn-soft: #f8efd8; --good-soft: #e1f1e7; --bar: #2f6f5e; --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 10px rgba(20, 30, 40, .04); --hol: #b8362b; --hol-soft: #fbe7e4; color-scheme: light;
}
html[data-mode="sage"] {
  --bg: #eef3ec; --panel: #fbfdf9; --panel-2: #e5ede1; --text: #1e2a1f; --muted: #5f6e60; --line: #d5e0d1;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #dfece2; --good: #23784f; --bad: #b23b31; --warn: #9a6a00;
  --bad-soft: #f8e5e2; --warn-soft: #f8efd8; --good-soft: #e1f1e7; --bar: #2f6f5e; --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 10px rgba(20, 30, 40, .04); --hol: #b8362b; --hol-soft: #fbe7e4; color-scheme: light;
}
html[data-mode="blush"] {
  --bg: #f9eff0; --panel: #fffafa; --panel-2: #f4e4e6; --text: #33212a; --muted: #7a6168; --line: #ecd8dc;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e2efe9; --good: #23784f; --bad: #b23b31; --warn: #9a6a00;
  --bad-soft: #f8e5e2; --warn-soft: #f8efd8; --good-soft: #e1f1e7; --bar: #2f6f5e; --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 10px rgba(20, 30, 40, .04); --hol: #b8362b; --hol-soft: #fbe3e1; color-scheme: light;
}
html[data-mode="sand"] {
  --bg: #f2ead9; --panel: #fbf7ef; --panel-2: #ece2cd; --text: #2f281d; --muted: #756a57; --line: #e0d4bb;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e4eada; --good: #23784f; --bad: #b23b31; --warn: #9a6a00;
  --bad-soft: #f8e5e2; --warn-soft: #f8efd8; --good-soft: #e1f1e7; --bar: #2f6f5e; --bar-2: #c58b2d;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 10px rgba(20, 30, 40, .04); --hol: #a8402f; --hol-soft: #f4e0d6; color-scheme: light;
}
html[data-mode="ocean"] {
  --bg: #0f1a2a; --panel: #152338; --panel-2: #1c2d45; --text: #e3ebf5; --muted: #93a4bb; --line: #26384f;
  --accent: #5fb398; --accent-ink: #0f1a2a; --accent-soft: #1b3a3a; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #5fb398; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="forestnight"] {
  --bg: #111a14; --panel: #17231b; --panel-2: #1e2c22; --text: #e3ede5; --muted: #93a698; --line: #2a3a2e;
  --accent: #6cc39f; --accent-ink: #111a14; --accent-soft: #1c3a2c; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #6cc39f; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="mocha"] {
  --bg: #1e1814; --panel: #28201b; --panel-2: #312821; --text: #efe6dd; --muted: #a89888; --line: #3d322a;
  --accent: #6fbfa5; --accent-ink: #1e1814; --accent-soft: #2a332c; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #6fbfa5; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="plum"] {
  --bg: #1b1422; --panel: #241b2d; --panel-2: #2d2338; --text: #ece4f3; --muted: #a597b5; --line: #3a2e47;
  --accent: #6fbfa5; --accent-ink: #1b1422; --accent-soft: #24333a; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #6fbfa5; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="contrastdark"] {
  --bg: #000000; --panel: #000000; --panel-2: #1a1a1a; --text: #ffffff; --muted: #e0e0e0; --line: #ffffff;
  --accent: #7ee0bd; --accent-ink: #000000; --accent-soft: #0f3a2c; --good: #5cc58f; --bad: #f0857a; --warn: #e2b54f;
  --bad-soft: #3a2220; --warn-soft: #3a3020; --good-soft: #1d3428; --bar: #7ee0bd; --bar-2: #e2b54f; --shadow: none;
  --hol: #f0857a; --hol-soft: #3a2321; color-scheme: dark;
}
html[data-mode="contrastdark"] .panel, html[data-mode="contrastdark"] .kpi { border-width: 2px; }
html[data-mode="contrastdark"] a { text-decoration: underline; }
html[data-mode="contrastdark"] :focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* Spacing */
html[data-density="compact"] .panel { padding: 10px; }
html[data-density="compact"] .panel + .panel { margin-top: 10px; }
html[data-density="compact"] .grid { gap: 10px; }
html[data-density="compact"] td, html[data-density="compact"] th { padding-top: 3px; padding-bottom: 3px; }
html[data-density="compact"] button, html[data-density="compact"] .btn { padding: 4px 9px; }
html[data-density="comfy"] .panel { padding: 22px; }
html[data-density="comfy"] .panel + .panel { margin-top: 22px; }
html[data-density="comfy"] .grid { gap: 22px; }
html[data-density="comfy"] td, html[data-density="comfy"] th { padding-top: 9px; padding-bottom: 9px; }
html[data-font="mono"] body { font-size: 0.8125rem; }
.own-color { cursor: pointer; }
.own-color input[type="color"] { width: 30px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
body { background-color: var(--bg); background-image: var(--bg-image, none); background-size: var(--bg-size, auto); background-attachment: fixed; background-position: center bottom; }
html[data-bg]:not([data-bg="none"]) .panel, html[data-bg]:not([data-bg="none"]) .kpi { box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 18px rgba(0, 0, 0, .05); }

/* Holidays: a day off is tinted and labelled */
.cal-day.hol { background: var(--hol-soft); }
.cal-day.hol .cal-num span:first-child { color: var(--hol); }
.cal-day.bank { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--panel-2) 8px 10px); }
.cal-off { font-style: normal; font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--hol); margin-left: 4px; }
.cal-off.bank { color: var(--muted); }
.cal-chip.k-holiday { border-color: var(--hol); color: var(--hol); background: transparent; font-weight: 600; font-style: normal; }
.cal-dot.k-holiday { color: var(--hol); }
.pill.hol { background: var(--hol-soft); color: var(--hol); }
@media (max-width: 700px) { .cal-chip.k-holiday { color: var(--hol); } .cal-off { display: none; } }

/* Appearance picker */
.theme-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.swatch i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.swatch.on, .mode-pick.on, .bg-pick.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bg-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.bg-pick { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; text-align: left; }
.bg-pick .bg-thumb { display: block; width: 100%; height: 70px; border-radius: 6px; border: 1px solid var(--line); background-color: var(--bg); background-size: auto; background-position: center bottom; }
.bg-pick .bg-thumb.scene { background-size: cover; }

.warn-row td { background: var(--warn-soft); }
.radio-opt { display: flex; align-items: flex-start; gap: 10px; text-align: left; cursor: pointer; padding: 4px 0; }
.radio-opt input { margin-top: 3px; flex: none; }
.radio-opt > span { flex: 1; }
.radio-opt input[type=radio] { width: auto; min-width: 0; }
.nav-credit { font-size: 0.6875rem; color: var(--muted); margin: 14px 10px 4px; }
.nav-credit a { color: var(--muted); font-weight: 600; }
.nav-credit a:hover { color: var(--accent); }
@media (max-width: 860px) { #nav .nav-credit { display: none; } }
@media print { .nav-credit { display: none; } }

.date-warn { border-color: var(--warn); background: var(--warn-soft); margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
button.pill.warn { cursor: pointer; border: 0; font: inherit; font-size: 0.75rem; }

.payoff-deadlines { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.k-promo { border-color: #d9480f; background: #fff1e6; color: #a33a0c; font-weight: 600; }
.cal-dot.k-promo { color: #d9480f; background: currentColor; }
@media (prefers-color-scheme: dark) { html[data-mode="auto"] .cal-chip.k-promo, html:not([data-mode]) .cal-chip.k-promo { background: #3a2316; color: #ffb38a; } }
html[data-mode="dark"] .cal-chip.k-promo, html[data-mode="dim"] .cal-chip.k-promo, html[data-mode="midnight"] .cal-chip.k-promo, html[data-mode="ocean"] .cal-chip.k-promo, html[data-mode="forestnight"] .cal-chip.k-promo, html[data-mode="mocha"] .cal-chip.k-promo, html[data-mode="plum"] .cal-chip.k-promo, html[data-mode="contrastdark"] .cal-chip.k-promo { background: #3a2316; color: #ffb38a; }
@media (max-width: 700px) { .cal-chip.k-promo { color: #d9480f; } }
.brand-sub { display: block; font-size: 0.6875rem; font-weight: 500; color: var(--muted); }
#brand-name { line-height: 1.2; }
.rcpt-tax summary { cursor: pointer; }
.rcpt-tax label { display: flex; flex-direction: column; gap: 2px; }
.login-box { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; }
.login-box dl { margin: 6px 0 0; grid-template-columns: max-content minmax(0, 1fr); }
.login-box dd { text-align: left; overflow-wrap: anywhere; }

/* Contact photos */
.dot-photo { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; margin-right: 6px; vertical-align: -4px; }
.avatar { position: relative; cursor: pointer; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-cam { position: absolute; right: 0; bottom: 0; font-size: 0.75rem; background: var(--panel); border-radius: 50%; padding: 1px 2px; opacity: 0; transition: opacity .15s; }
.avatar:hover .avatar-cam, .avatar:focus-within .avatar-cam { opacity: 1; }
.avatar:not(.has-photo) .avatar-cam { opacity: .8; }
.dlg-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 10px; }

.btn.disabled { opacity: .5; pointer-events: none; }

/* Big contact photos */
.photo-view { max-width: 100%; max-height: 70vh; border-radius: 10px; box-shadow: var(--shadow); }
.contact-hero { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; margin: 0 0 12px; }
.contact-hero img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; display: block; }
.person-card .top.photo-banner { position: relative; margin: -16px -16px 0; padding: 16px; min-height: 120px; align-items: flex-end;
  background: linear-gradient(to right, var(--panel) 30%, color-mix(in srgb, var(--panel) 55%, transparent) 65%, transparent), var(--banner) center / cover no-repeat;
  border-radius: var(--radius) var(--radius) 0 0; }
.person-card .top.photo-banner .avatar { width: 56px; height: 56px; box-shadow: 0 0 0 3px var(--panel); }
button.avatar { cursor: zoom-in; }

/* Orders */
.k-order { border-color: #7a5cc7; } .cal-dot.k-order { color: #7a5cc7; background: currentColor; }
@media (max-width: 700px) { .cal-chip.k-order { color: #7a5cc7; } }

/* Version & releases */
.release { border-left: 3px solid var(--line, #ccc); padding: 2px 0 2px 14px; margin: 14px 0; }
.release.latest { border-left-color: var(--accent, #2e8b57); }
.release h3 { margin: 0 0 6px; }
.release ul { margin: 0; padding-left: 18px; }
.release li { margin: 3px 0; }

/* Calendar: share & export */
.share-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.code-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 0.75rem; line-height: 1.45; white-space: pre; }
@media print {
  .cal-grid { grid-template-columns: repeat(7, 1fr) !important; font-size: 0.6rem; }
  .cal-day { min-height: 80px; break-inside: avoid; }
  .month-nav button { display: none; }
}
.cal-share, .cal-share details, .share-row { min-width: 0; max-width: 100%; }
.cal-share .code-box { max-width: 100%; }

/* Company logos */
.bank-logo { width: 20px; height: 20px; border-radius: 5px; object-fit: contain; background: #fff; vertical-align: -5px; margin-right: 6px; box-shadow: 0 0 0 1px var(--line); }
.small .bank-logo { width: 16px; height: 16px; vertical-align: -3px; border-radius: 4px; }
.logo-strip { margin: 0 0 12px; }
.logo-strip > div { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.logo-pick { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.logo-pick > button:first-child { padding: 4px; border-radius: 10px; background: #fff; border: 2px solid var(--line); line-height: 0; }
.logo-pick.on > button:first-child { border-color: var(--accent, #2e8b57); box-shadow: 0 0 0 2px var(--accent, #2e8b57); }
.logo-pick img { width: 48px; height: 48px; object-fit: contain; }
.contact-hero.logo { background: #fff; display: flex; justify-content: center; padding: 12px; }
.contact-hero.logo img { width: auto !important; height: auto !important; max-width: 128px; max-height: 128px; object-fit: contain; }

/* Fill in from the web: review */
.lookup-table td { vertical-align: top; }
.lookup-table select { width: 100%; min-width: 180px; }

/* Sortable tables: click a heading */
th[data-sortable] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sortable]:hover { color: var(--text); text-decoration: underline dotted; text-underline-offset: 3px; }
th[data-sortable]::after { content: ' ↕'; opacity: 0.25; font-size: 0.8em; }
th[data-sorted="asc"]::after { content: ' ▲'; opacity: 0.8; }
th[data-sorted="desc"]::after { content: ' ▼'; opacity: 0.8; }
@media print { th[data-sortable]::after { content: none; } }

/* Words explained: dotted underline + pop-up meaning */
.term { border-bottom: 1px dotted currentColor; cursor: help; }
.term:focus { outline: 2px solid var(--accent, #2e8b57); outline-offset: 1px; border-radius: 2px; }
.tip-pop { position: fixed; z-index: 1000; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 10px 12px; font-size: 0.875rem; line-height: 1.45; font-weight: 400; text-transform: none; letter-spacing: normal; }
.tip-pop strong { display: block; margin-bottom: 2px; }
.tip-pop a { display: inline-block; margin-top: 6px; }
@media print { .term { border-bottom: none; } .tip-pop { display: none; } }

/* My account: me card + menu photo */
.me-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.me-photo { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; padding: 0; border: 3px solid var(--panel-2); background: var(--panel-2); }
.me-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.me-initials { display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--muted); }
.nav-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }

/* Words explained: pictures */
.gpic { width: 100%; height: auto; display: block; }
.tip-pic { background: var(--panel-2); border-radius: 8px; padding: 6px; margin-bottom: 8px; }
.gloss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.gloss-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--panel); }
.gloss-card h3 { margin: 6px 0 4px; }
.gloss-card p { margin: 0; }
.gloss-pic { background: var(--panel-2); border-radius: 10px; padding: 8px; }
.gloss-eg { margin-top: 6px !important; color: var(--muted); }
.gloss-hit { outline: 3px solid var(--accent, #2e8b57); }

/* Linked contacts */
[data-linked] { position: relative; }
[data-linked]::after { content: '🔗'; position: absolute; top: 8px; right: 10px; font-size: 0.95rem; }

/* Company directory */
.dir-row { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; flex-wrap: wrap; }
.dir-noimg { font-size: 1.6rem; width: 36px; text-align: center; }
input[readonly], select:disabled { opacity: .75; cursor: not-allowed; }
.dir-row > div:nth-child(2) { flex: 1 1 180px; }
@media (max-width: 640px) { .dir-row > div:last-child { flex-basis: 100%; justify-content: flex-start !important; } }

/* Clickable totals (a contact's card) */
.kpi-btn { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); }
.kpi-btn:hover, .kpi-btn:focus-visible { border-color: var(--accent, #4a7dff); }
.kpi-more { opacity: .6; }

/* Recording an invoice: a "varies" line still to fill in */
tr.needs-fill input[name=amount] { outline: 2px solid var(--warn, #c80); outline-offset: 1px; }
tr.just-filled input[name=amount] { outline: 2px solid var(--good, #2a8); outline-offset: 1px; }

/* How to pay (contacts) */
.pm-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pm-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.pm-card.pm-default { border-color: var(--accent); }
.pm-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Files */
.file-folders { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.file-folder { display: flex; gap: 10px; align-items: center; margin: 0; padding: 10px 12px; cursor: pointer; }
.file-folder:hover { border-color: var(--accent); }
.file-folder > div:nth-child(2) { flex: 1; }
.ff-ico { font-size: 1.6rem; }

/* Calendar: price check reminders */
.cal-chip.k-review { background: color-mix(in srgb, #d08a00 18%, transparent); }

/* Care team */
.care-card { margin: 0; padding: 10px 12px; display: grid; gap: 3px; }
.pill.g-care { background: color-mix(in srgb, #d0426a 15%, transparent); }

/* Find a doctor: photos to check it's really them */
.fd-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.fd-photo { padding: 0; border: 2px solid var(--line); border-radius: 8px; width: 72px; height: 88px; overflow: hidden; background: transparent; cursor: pointer; }
.fd-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fd-photo.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Right-click menu (contextmenu.js) */
.ctx-menu { position: fixed; z-index: 1000; min-width: 220px; max-width: min(360px, calc(100vw - 8px)); max-height: calc(100vh - 8px); overflow: auto; background: var(--panel, var(--bg)); color: var(--text); border: 1px solid var(--line, #8884); border-radius: 10px; box-shadow: 0 10px 30px #0006; padding: 4px; }
.ctx-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 7px 10px; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--hover, #8882); outline: none; }
.ctx-sep { height: 1px; background: var(--line, #8884); margin: 4px 6px; }
.ctx-hint { font-size: .78em; color: var(--muted, #888); padding: 4px 10px 2px; }
.drop-here { outline: 2px dashed var(--accent, #4a9); outline-offset: -2px; background: color-mix(in srgb, var(--accent, #4a9) 10%, transparent); }
.pv-strip { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.pv-thumb { position: relative; padding: 0; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: none; cursor: pointer; }
.pv-thumb.on { border-color: var(--accent); }
.pv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-thumb span { position: absolute; right: 2px; bottom: 0; font-size: 12px; }
.chips-gap { width: 1px; align-self: stretch; background: var(--border, #444); margin: 2px 6px; }
.care-past { opacity: .8; border-style: dashed; }
.person-card.is-closed { opacity: .72; }
/* a closed business: its logo greyed with a red ring, and a 🚫 by its name */
.person-card.is-closed .avatar, .dlg-photo.is-closed { filter: grayscale(1); box-shadow: 0 0 0 3px var(--bad, #d33); }
.closed-icon { font-size: 1.05em; }

/* Unsorted files (Income page) */
.inbox-panel { margin-bottom: 12px; }
.inbox-empty { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.inbox-row { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.inbox-row.for-admin { background: var(--warn-soft); margin: 0 -14px; padding: 10px 14px; }
.inbox-thumb { flex: 0 0 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 28px; text-decoration: none; background: var(--panel); }
.inbox-thumb img { width: 100%; height: 100%; object-fit: cover; }
.inbox-main { flex: 1; min-width: 0; }
.inbox-btns { margin-top: 6px; flex-wrap: wrap; gap: 4px; }
.job-row.is-current { border-left: 3px solid var(--good, #2e9d5b); padding-left: 8px; }

/* Pay stub review and moving */
.stub-review tr.needs-who td { background: var(--warn-soft); }
tr.is-sel td { background: var(--accent-soft); }

/* Monthly paperwork: a bill or statement still to upload */
tr.pw-missing td:first-child { border-left: 3px solid var(--warn); }
.stub-drop.drag { outline: 2px dashed var(--accent, #2563eb); outline-offset: -6px; }
/* Paystubs: filed / not filed at a glance */
.stub-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.stub-stat { display: block; border: 1px solid var(--line, #8883); border-left-width: 5px; border-radius: 8px; padding: 8px 12px; color: inherit; text-decoration: none; }
.stub-stat-n { font-size: 1.35em; font-weight: 700; }
.stub-stat-l { font-weight: 600; }
.stub-stat.is-filed { border-left-color: var(--good); background: var(--good-soft); }
.stub-stat.is-waiting { border-left-color: var(--warn); background: var(--warn-soft); }
.stub-stat.is-none { border-left-color: var(--line, #8885); opacity: .75; }
.stub-review { border: 2px solid var(--warn); }
/* Unsorted files: a real preview of each file */
.inbox-thumb { flex: 0 0 120px; height: 150px; background: #fff; }
.inbox-thumb img { object-fit: cover; object-position: top; }
.inbox-read { margin: 2px 0; }
@media (max-width: 600px) { .inbox-thumb { flex-basis: 84px; height: 108px; } }
/* A form about a file (sorting an upload): the file on the left, the fields on the right */
.form-with-preview { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.form-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 6px; }
.form-preview iframe, .form-preview img { width: 100%; height: min(62vh, 640px); border: 1px solid var(--line); border-radius: 8px; background: #fff; object-fit: contain; }
.form-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form-tools button.busy { opacity: .7; }
.form-tool-msg { flex-basis: 100%; }
.just-read { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft) !important; }
@media (max-width: 760px) { .form-with-preview { grid-template-columns: 1fr; } .form-preview iframe, .form-preview img { height: 42vh; } .form-preview { position: static; } }
.stub-emp-in { width: 100%; min-width: 150px; }
.stub-emp-in.is-empty { border-color: var(--warn); }

/* Employment: a job read off pay stubs, not verified yet */
.job-check { margin-top: 6px; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 8px; background: var(--panel-2); }
.job-check a { margin-right: 8px; white-space: nowrap; }

/* Map pins */
.map-pin { padding: 1px 8px; margin-left: 6px; }
.map-pin.is-on { background: var(--accent); color: #fff; }
.map-box { margin: 4px 0 10px; border: 1px solid var(--border, #8884); border-radius: 10px; overflow: hidden; background: var(--panel, transparent); }
.map-box iframe { display: block; width: 100%; height: 240px; border: 0; }
.map-box > div { padding: 6px 10px; }
.contact-info + .map-box, .contact-info .map-box { margin-top: 6px; }

/* Tools page */
.tool-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px; margin-top: 8px; }
.tool-facts code, .tool-card h3 + .small code { word-break: break-all; font-size: 0.8em; }
.tool-log { max-height: 260px; overflow: auto; font-size: 0.75rem; white-space: pre-wrap; background: var(--bg-2, #0001); padding: 8px; border-radius: 8px; }
/* Tools: how-to guide */
.guide-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.guide-step { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.guide-n { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; }
.guide-body > strong { display: block; margin: 4px 0 2px; }
.guide-body ul { margin: 4px 0; padding-left: 18px; }
.guide-shot, .guide-draw { display: block; max-width: min(100%, 560px); height: auto; margin-top: 8px; border-radius: 10px; border: 1px solid var(--border, #8884); box-shadow: 0 2px 10px #0002; }
.guide-shot { cursor: zoom-in; }
.copy-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.copy-line code { padding: 4px 8px; border-radius: 6px; background: var(--bg-2, #0002); word-break: break-all; font-size: 0.8em; }

/* Retirement */
.ret-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 10px; }
.ret-tile { border: 1px solid var(--border, #8884); border-radius: 10px; padding: 8px 10px; }
.ret-tile.is-done { opacity: 0.6; }
.ret-count { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.ret-label { font-weight: 600; margin: 2px 0; }
.ret-big { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ret-amt { font-size: 1.8rem; font-weight: 800; }
.ret-explain ul, .ret-explain ol { padding-left: 20px; margin: 4px 0 10px; }
.ret-explain li { margin: 3px 0; }
.ret-joblist { list-style: none; padding: 0; margin: 4px 0; }
.ret-joblist li { margin: 4px 0; }
.ret-joblist label { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; cursor: pointer; }

/* A contact who has a sign-in account */
.acct-pill { background: color-mix(in srgb, var(--accent) 22%, transparent); border: 1px solid var(--accent); font-weight: 600; vertical-align: middle; font-size: 0.75rem; }
.person-card.is-account { box-shadow: inset 4px 0 0 var(--accent); }
.person-card .acct-pill { display: block; width: fit-content; max-width: 100%; white-space: normal; margin: 3px 0 1px; }

/* IOUs: screenshots / photos of each transfer */
.iou-proofs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.iou-proof { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border: 1px solid var(--line, #3334); border-radius: 6px; overflow: hidden; font-size: 22px; text-decoration: none; background: var(--panel-2, transparent); }
.iou-proof img { width: 100%; height: 100%; object-fit: cover; }
