/* Money Manager: a ledger book on screen. Pale ruled paper, blue-black ink,
   red ink for money owed, ledger green for actions. Amounts lead; chrome stays quiet. */

/* The Saudi riyal sign (U+20C1) and the UAE dirham sign (U+20C3): most system fonts have no
   glyph for them yet, so these fonts supply just those two characters (unicode-range) and
   every other character keeps the system font. Sources and licences: fonts/SOURCES.md. */
/* One weight per face: Chrome matches weight before unicode-range, so faces with overlapping
   weight ranges hide each other. Text at 600 or more takes the bold riyal. size-adjust brings
   each sign to the height of the digits beside it, as SAMA's guide asks (the riyal glyph is
   0.62 em tall and the dirham 1.0 em; the digits about 0.7 em). */
@font-face { font-family: "MM Currency"; src: url("../fonts/saudi-riyal.woff2") format("woff2"); unicode-range: U+20C1; font-weight: 400; font-display: block; size-adjust: 114%; }
@font-face { font-family: "MM Currency"; src: url("../fonts/saudi-riyal-bold.woff2") format("woff2"); unicode-range: U+20C1; font-weight: 700; font-display: block; size-adjust: 114%; }
@font-face { font-family: "MM Currency"; src: url("../fonts/uae-dirham.woff2") format("woff2"); unicode-range: U+20C3; font-weight: 400; font-display: block; size-adjust: 72%; }
@font-face { font-family: "MM Currency"; src: url("../fonts/uae-dirham.woff2") format("woff2"); unicode-range: U+20C3; font-weight: 700; font-display: block; size-adjust: 72%; }
:root {
  --paper: #f2f5f1;
  --sheet: #ffffff;
  --ink: #18233a;
  --pencil: #5e6878;
  --rule: #d8e0d8;
  --rule-strong: #b9c6bb;
  --green: #17694a;
  --green-wash: #e3efe7;
  --red: #b42318;
  --red-wash: #fbeae8;
  --backdrop: rgb(24 35 58 / 0.45);
  --radius: 6px;
  --font: "MM Currency", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", "Noto Sans Arabic", "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1418;
    --sheet: #161d22;
    --ink: #e4eaef;
    --pencil: #97a2af;
    --rule: #26313a;
    --rule-strong: #3a4753;
    --green: #4cc08c;
    --green-wash: #173226;
    --red: #ff7a6e;
    --red-wash: #3a1e1c;
    --backdrop: rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- amounts: the halala digits sit apart ---------- */
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-feature-settings: "tnum"; }
.amt .cur { color: var(--pencil); margin-inline-end: 0.28em; font-weight: inherit; }
.amt .cur.is-code { font-size: 0.72em; margin-inline-end: 0.35em; letter-spacing: 0.02em; }
.amt.neg .cur { color: inherit; opacity: 0.8; }
.amt .frac { font-size: 0.78em; color: var(--pencil); }
.amt.neg, .amt.neg .frac { color: var(--red); }
.amt.neg .frac { opacity: 0.8; }

/* ---------- an older server still running ---------- */
.update-bar { margin: 0; padding: 10px 20px; background: #fff4e0; color: #7a4a00; font-size: 14px; }
@media (prefers-color-scheme: dark) { .update-bar { background: #3a2c12; color: #f5c56b; } }
body:has(.update-bar) .app { height: calc(100dvh - 42px); }

/* ---------- sync ---------- */
.sync-btn { display: inline-flex; align-items: center; gap: 6px; position: relative; color: var(--green); }
.sync-btn.is-error { color: var(--red); border-color: var(--red); }
.sync-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.sync-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 16px; }
.sync-steps.big li { line-height: 1.5; }
.sync-steps .sheet-actions { margin-top: 10px; }
.step-result, .step-result2 { margin-top: 8px; color: var(--green); font-weight: 600; }

/* ---------- frame ---------- */
.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 650; margin-inline-end: auto; min-width: 0; }
.version {
  font-size: 12px;
  font-weight: 600;
  color: var(--pencil);
  border: 1px solid var(--rule-strong);
  border-radius: 99px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.back { display: none; }

.btn {
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn .short { display: none; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1418; } }
.icon-btn { border: 0; background: transparent; font-size: 26px; line-height: 1; width: 40px; height: 40px; border-radius: var(--radius); cursor: pointer; color: var(--pencil); }
.icon-btn:hover { background: var(--green-wash); color: var(--ink); }

/* ---------- accounts ---------- */
.sidebar { overflow-y: auto; border-inline-end: 1px solid var(--rule); padding: 18px 12px 32px; }
.side-empty { color: var(--pencil); padding: 8px; }
.networth { padding: 4px 10px 14px; }
.nw-label { color: var(--pencil); font-size: 13px; }
.amt.nw { font-size: 28px; font-weight: 650; letter-spacing: -0.01em; }
.nw-others { color: var(--pencil); font-size: 13px; margin-top: 4px; }
.check { font-size: 13px; padding: 8px 10px; margin: 0 0 14px; border-radius: var(--radius); }
.check.is-on { background: var(--green-wash); color: var(--green); }
.check.is-on::before { content: "✓ "; font-weight: 700; }
.check.is-off { background: var(--red-wash); color: var(--red); }
.check.is-note { background: var(--sheet); color: var(--pencil); border: 1px solid var(--rule); }
.hint { font-size: 13px; color: var(--pencil); padding: 0 10px 12px; }
.linkish { border: 0; background: none; padding: 0; color: var(--green); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.group { margin-top: 10px; }
.group-head { margin: 0; }
.group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--pencil);
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
@media (hover: hover) { .group-toggle:hover { background: var(--sheet); color: var(--ink); } }
.chev { flex: none; width: 10px; height: 10px; display: grid; place-items: center; transition: transform 0.15s; }
.chev::before { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.group-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { flex: none; font-size: 11px; font-weight: 600; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--rule); color: var(--pencil); text-align: center; }
.group-total { margin-inline-start: auto; flex: none; font-weight: 500; }
.group-total .amt { font-size: 13px; }
.group-total .amt:not(.neg), .group-total .amt:not(.neg) .frac { color: var(--pencil); }
.group-total .mixed { font-size: 12px; font-weight: 500; }
.owed { margin: 0 0 14px; display: grid; gap: 4px; }
.owed-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); text-align: start; cursor: pointer; }
.owed-row:hover { border-color: var(--green); }
.owed-row.is-current { border-color: var(--green); background: var(--green-wash); }
.owed-text { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owed-row.is-you .amt { color: var(--red); }
.owed-setup { font-size: 12px; justify-self: start; margin: 2px 2px 0; }
.owed-list { display: grid; gap: 2px; margin: 12px 0; max-height: 50vh; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius); padding: 6px; }
.owed-list label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.owed-list label:hover { background: var(--paper); }
.owed-list input { width: 18px; height: 18px; accent-color: var(--green); }
.owed-list .tiny { display: inline; margin-inline-start: auto; }
.owed-head { font-size: 13px; font-weight: 600; color: var(--pencil); margin: 0 2px 2px; }
.owed-row.is-owe .amt { color: var(--pencil); }
.owed-row.is-owed .amt, .owed-row.is-owed .amt .frac { color: var(--green); }
.owed-all { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--green); font-weight: 600; cursor: pointer; text-align: start; }
.owed-all:hover, .owed-all.is-current { background: var(--green-wash); }
.owed-all .chev-r { margin-inline-start: auto; font-size: 18px; line-height: 1; }

/* ---------- budgets ---------- */
.search-badge.budget-badge { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2317694a' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='2' y='3' width='12' height='10' rx='2'/%3E%3Cpath d='M2 6.5h12M5 10h3'/%3E%3C/svg%3E"); }
.budget-scroll { flex: 1; overflow-y: auto; padding: 4px 24px 32px; }
.bsec { font-size: 14px; color: var(--pencil); font-weight: 600; margin: 18px 0 8px; }
.bcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.bcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); cursor: pointer; text-align: start; }
.bcard:hover { border-color: var(--green); }
.bcard-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bcard-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard-sub { font-size: 12px; color: var(--pencil); }
.bfig .amt { font-weight: 650; }
.bfig.big .amt { font-size: 30px; letter-spacing: -0.01em; }
.bfig.is-owed .amt, .bfig.is-owed .amt .frac, .bfig.is-left .amt, .bfig.is-left .amt .frac { color: var(--green); }
.bfig.is-over .amt, .bfig.is-over .amt .frac { color: var(--red); }
.bfig.is-owe .amt, .bfig.is-even .amt { color: var(--ink); }
.blist { display: grid; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--sheet); }
.brow { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.2fr) minmax(170px, auto) minmax(150px, auto); gap: 14px; align-items: center; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; cursor: pointer; text-align: start; }
.brow:last-child { border-bottom: 0; }
.brow:hover { background: var(--paper); }
.brow-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.brow-bar { height: 8px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.brow-bar span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.brow.is-over .brow-bar span { background: var(--red); }
.brow-used { font-size: 13px; color: var(--pencil); text-align: end; white-space: nowrap; }
.brow-used .of { margin: 0 2px; }
.brow-fig { text-align: end; white-space: nowrap; }
.brow-fig .word, .word-big { font-size: 13px; color: var(--pencil); margin-inline-start: 4px; }
.word-big { font-size: 15px; }
.is-budget .reg-cols, .is-budget .row { grid-template-columns: 104px minmax(0, 1fr) minmax(110px, 0.55fr) 150px 160px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-line input { width: 18px; height: 18px; accent-color: var(--green); }
.pick-filter { padding: 7px 10px !important; font-size: 14px !important; }
.pick-list { display: grid; gap: 1px; max-height: 220px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px; }
.pick-list.short { max-height: 150px; }
.pick-list label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 14px; }
.pick-list label:hover { background: var(--paper); }
.field .pick-list input, .field .check-line input { width: 16px; height: 16px; min-width: 0; padding: 0; margin: 0; accent-color: var(--green); flex: none; box-shadow: none; }
.field .pick-list label > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.pick-list { overflow-x: hidden; }
.pick-list .tiny { display: inline; margin-inline-start: auto; }
.credits { margin: 28px 10px 0; font-size: 11px; line-height: 1.4; color: var(--pencil); }
.acct-list { list-style: none; margin: 0; padding: 0; }
.acct {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-inline-start: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  text-align: start;
  cursor: pointer;
}
@media (hover: hover) { .acct:hover { background: var(--sheet); } }
.acct.is-current { background: var(--green-wash); border-inline-start-color: var(--green); }
.acct-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Arabic names keep their right-to-left reading order but line up on the left like the rest */
.acct-name, .group-name, .c-title, .c-note, .c-cat, .reg-name { text-align: left; }

/* ---------- account icons: the bank's own icon over a letter tile ---------- */
.aicon {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
  background: hsl(var(--h) 40% 90%);
  color: hsl(var(--h) 45% 28%);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.aicon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; opacity: 0; }
.aicon.has-img img { opacity: 1; }
.aicon::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(24 35 58 / 0.1); pointer-events: none; }
.aicon.lg { width: 44px; height: 44px; border-radius: 11px; font-size: 18px; }
.aicon.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.aicon.xs { width: 18px; height: 18px; border-radius: 5px; font-size: 10px; }
@media (prefers-color-scheme: dark) {
  .aicon { background: hsl(var(--h) 25% 24%); color: hsl(var(--h) 55% 82%); }
  .aicon::after { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); }
}

/* ---------- search all accounts ---------- */
.side-search { padding: 0 2px 14px; }
.side-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--sheet) no-repeat 11px 50% / 15px 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235e6878' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E");
}
.side-search input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-wash); }
.search-badge { flex: none; width: 44px; height: 44px; border-radius: 11px; background: var(--green-wash) no-repeat center / 22px 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2317694a' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E"); }
.search-total, .found { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.search-total { font-size: 18px; font-weight: 650; justify-content: flex-end; }
.dot { color: var(--pencil); }

/* ---------- register ---------- */
.main { min-width: 0; min-height: 0; display: flex; }
.loading, .welcome { margin: auto; max-width: 520px; padding: 24px; }
.welcome h2 { font-size: 24px; margin-bottom: 10px; }
.welcome p { color: var(--pencil); margin-bottom: 18px; }
.register { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--sheet); }
.reg-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 22px 24px 14px; }
.reg-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.reg-name { font-size: 22px; font-weight: 650; }
.reg-meta { color: var(--pencil); font-size: 13px; margin-top: 2px; }
.amt.reg-balance { font-size: 30px; font-weight: 650; letter-spacing: -0.01em; }
.reg-tools { display: flex; align-items: center; gap: 12px; padding: 0 24px 12px; }
.search {
  flex: 1;
  max-width: 460px;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
}
.found { color: var(--pencil); font-size: 13px; }
.reg-cols, .row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) minmax(120px, 0.7fr) 150px 150px;
  gap: 14px;
  align-items: center;
  padding: 0 24px;
}
.is-search .reg-cols, .is-search .row { grid-template-columns: 104px minmax(0, 1fr) minmax(110px, 0.55fr) minmax(110px, 0.6fr) 160px; }
.is-owed .reg-cols, .is-owed .row { grid-template-columns: 104px minmax(0, 1fr) minmax(110px, 0.55fr) 150px 160px; }
.owed-now { display: flex; flex-direction: column; align-items: flex-end; }
.owed-now > .amt { font-size: 30px; font-weight: 650; letter-spacing: -0.01em; }
.is-owed .reg-meta + .reg-meta { margin-top: 4px; }
.d-word { color: var(--pencil); font-weight: 500; font-size: 12px; margin-inline-end: 4px; }
.reg-cols { font-size: 12px; font-weight: 600; color: var(--pencil); padding-block: 6px; border-block: 1px solid var(--rule); }
.num { text-align: end; }
.reg-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.reg-rows { position: relative; }
.row {
  position: absolute;
  inset-inline: 0;
  width: 100%;
  height: 56px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: start;
  cursor: pointer;
}
@media (hover: hover) { .row:hover { background: var(--paper); } }
.row:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.row.flash { animation: flash 2.6s ease-out; }
@keyframes flash { 0%, 40% { background: var(--green-wash); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row.flash { animation: none; background: var(--green-wash); } }
.c-date { color: var(--pencil); font-size: 13px; font-variant-numeric: tabular-nums; }
.c-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.c-text { display: flex; flex-direction: column; min-width: 0; }
.c-acct { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; }
.c-acct > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }

/* month and year dividers */
.divider { position: absolute; inset-inline: 0; display: flex; align-items: flex-end; gap: 12px; padding: 0 24px 6px; border-bottom: 1px solid var(--rule-strong); }
.divider.is-month { background: var(--paper); font-size: 13px; }
.divider.is-year { background: var(--sheet); border-bottom: 2px solid var(--ink); padding-bottom: 5px; }
.divider .d-label { font-weight: 650; }
.divider.is-year .d-label { font-size: 22px; line-height: 1; letter-spacing: -0.01em; }
.divider .d-year { color: var(--pencil); font-weight: 500; }
.divider .d-count { color: var(--pencil); font-size: 12px; }
.divider .d-sums { margin-inline-start: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; font-size: 13px; }
.divider.is-year .d-sums { font-size: 14px; font-weight: 600; }
.d-in .amt, .d-in .amt .frac { color: var(--green); }
.d-in .units::before { content: "+"; }
.c-title, .c-note, .c-cat { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-title { font-weight: 550; }
.c-note { font-size: 13px; color: var(--pencil); }
.c-cat { font-size: 13px; }
.c-cat.is-none { color: var(--pencil); font-style: italic; }
.c-amt { display: flex; align-items: baseline; justify-content: flex-end; }
.c-run .amt { color: var(--pencil); }
.c-run .amt.neg { color: var(--red); }
.c-amt .st-rec { color: var(--green); font-size: 12px; margin-inline-end: 6px; }
.c-amt .st-pend { font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 99px; background: var(--red-wash); color: var(--red); margin-inline-end: 8px; }
.reg-empty { padding: 24px; color: var(--pencil); }

/* ---------- import sheet ---------- */
.sheet { position: fixed; inset: 0; background: var(--backdrop); display: grid; place-items: center; padding: 24px; z-index: 10; overflow: auto; }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: min(780px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.25);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 10px; }
.sheet-head h2 { font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 4px 22px 22px; }
.sheet-body h3 { font-size: 15px; margin: 22px 0 8px; }
.sheet-body p + p { margin-top: 10px; }
.lead { color: var(--pencil); margin-bottom: 16px; }
.drop {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 38px 20px;
  border: 2px dashed var(--rule-strong);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  text-align: center;
}
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within, .drop.is-over, .drop:hover { border-color: var(--green); background: var(--green-wash); }
.drop-main { font-weight: 650; font-size: 17px; }
.drop-sub { color: var(--pencil); font-size: 13px; }
.note { color: var(--pencil); font-size: 13px; margin-top: 12px; }
.problem { background: var(--red-wash); color: var(--red); padding: 10px 12px; border-radius: var(--radius); margin-top: 14px; }
.steps { list-style: none; padding: 4px 0 8px; margin: 0; display: grid; gap: 10px; }
.steps li { padding-inline-start: 28px; position: relative; color: var(--pencil); }
.steps li::before { position: absolute; inset-inline-start: 0; width: 20px; text-align: center; }
.steps li.is-done { color: var(--ink); }
.steps li.is-done::before { content: "✓"; color: var(--green); font-weight: 700; }
.steps li.is-now { color: var(--ink); font-weight: 600; }
.steps li.is-now::before { content: "…"; }
.verdict { font-size: 17px; font-weight: 650; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.verdict.is-on { background: var(--green-wash); color: var(--green); }
.verdict.is-on::before { content: "✓ "; }
.verdict.is-off { background: var(--red-wash); color: var(--red); }
.table-wrap { max-height: 46vh; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.check-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.check-table th, .check-table td { padding: 7px 12px; border-bottom: 1px solid var(--rule); text-align: start; font-weight: 400; }
.check-table thead th { position: sticky; top: 0; background: var(--sheet); font-size: 12px; font-weight: 600; color: var(--pencil); }
.check-table .num { text-align: end; }
.check-table tr.grp th { background: var(--paper); font-size: 12px; font-weight: 600; color: var(--pencil); padding-block: 5px; }
.check-table tbody th { font-weight: 550; }
.check-table tr.is-off { background: var(--red-wash); }
.mark { width: 32px; text-align: center; }
.ok { color: var(--green); font-weight: 700; }
.bad { color: var(--red); font-weight: 700; }
.tiny { display: block; font-size: 12px; color: var(--pencil); font-weight: 400; }
.facts { margin: 0; display: grid; gap: 6px; }
.facts div { display: grid; grid-template-columns: 210px 1fr; gap: 12px; }
.facts dt { color: var(--pencil); }
.facts dd { margin: 0; }
.later { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; }
.remainders { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.remainders li { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.r-date { color: var(--pencil); font-size: 13px; }
.r-what { display: flex; flex-direction: column; min-width: 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.sheet-actions + .tiny { margin-top: 10px; }
.warn { background: #fff4e0; color: #7a4a00; padding: 10px 12px; border-radius: var(--radius); margin-top: 14px; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2c12; color: #f5c56b; } }

/* ---------- the transaction form ---------- */
.sheet-panel.entry { width: min(580px, 100%); }
.entry-form { display: grid; gap: 14px; padding-top: 4px; }
.kinds { display: inline-flex; flex-wrap: wrap; justify-self: start; gap: 2px; margin: 0; padding: 3px; border: 1px solid var(--rule-strong); border-radius: 8px; background: var(--paper); }
.kinds legend.field-label { width: 100%; padding: 0 0 6px; }
.kinds.dir { border: 0; padding: 0; background: none; gap: 6px; }
.kinds.dir span { border: 1px solid var(--rule-strong); }
.kinds label { position: relative; }
.kinds input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.kinds span { display: block; padding: 6px 16px; border-radius: 6px; font-weight: 600; color: var(--pencil); }
.kinds input:checked + span { background: var(--green); color: #fff; }
.kinds input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
@media (prefers-color-scheme: dark) { .kinds input:checked + span { color: #0f1418; } }
.kind-fixed { font-weight: 650; color: var(--pencil); }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--pencil); }
.f-cur, .f-tocur, .f-sub { font-weight: 500; }
.copy-of { font-size: 13px; color: var(--pencil); margin-inline-start: 12px; margin-inline-end: auto; }
.sheet-head:has(.copy-of) { justify-content: flex-start; }
.site-row { display: flex; align-items: center; gap: 10px; }
.site-field.is-off { opacity: 0.55; }
.site-row input { flex: 1; }
.up-btn { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--green); }
.up-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.up-panel { display: grid; gap: 8px; padding: 10px 12px; border: 1px dashed var(--rule-strong); border-radius: var(--radius); background: var(--paper); }
.up-panel.is-over, .site-tile.is-over .aicon { outline: 2px solid var(--green); outline-offset: 2px; }
.up-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.up-line .up-url { flex: 1; min-width: 180px; padding: 7px 10px !important; font-size: 14px !important; }
.up-or { font-size: 13px; color: var(--pencil); }
.up-note { margin-inline-start: auto; }
.site-tile .aicon.sm { width: 40px; height: 40px; border-radius: 9px; }
.field input, .field select, .field textarea, .part select, .part input {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 16px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .part select:focus, .part input:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px var(--green-wash);
}
.field.has-err input, .field.has-err select, .part .bad { border-color: var(--red); }
#f-amount { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; padding-block: 6px; }
.f-err { color: var(--red); font-size: 13px; }
.f-hint { color: var(--pencil); font-size: 13px; }
.f-err:empty, .f-hint:empty { display: none; }
.f-row.two { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; }
.field .linkish { justify-self: start; font-size: 13px; margin-top: 2px; }
.parts { display: grid; gap: 8px; }
.part { display: grid; grid-template-columns: minmax(0, 1fr) 132px 36px; gap: 8px; align-items: center; }
.part input { font-variant-numeric: tabular-nums; }
.icon-btn.small { width: 36px; height: 36px; font-size: 22px; }
.split-actions { display: flex; gap: 18px; flex-wrap: wrap; }
.split-actions .linkish { font-size: 13px; }
.split-sum { font-size: 13px; color: var(--pencil); }
.split-sum.is-ok { color: var(--green); }
.split-sum.is-off { color: var(--red); }
.f-extra { font-size: 13px; color: var(--pencil); }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--red-wash); color: var(--red); }
.confirm span { flex: 1 1 220px; }
.entry-actions { margin-top: 4px; }
.btn.danger { color: var(--red); border-color: var(--red); margin-inline-start: auto; }
.btn.danger-fill { background: var(--red); border-color: var(--red); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger-fill { color: #0f1418; } }

/* ---------- a short message after saving ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
body.sheet-open .toast { opacity: 0; }

/* ---------- phones and narrow windows ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand { font-size: 16px; white-space: nowrap; gap: 7px; }
  .version { padding-inline: 6px; }
  .topbar .btn { padding-inline: 10px; }
  /* in an account's register the back button needs the room; importing stays on the accounts screen */
  .app.show-register #open-import { display: none; }
  #open-import { display: none; } /* a phone gets its ledger by Sync; the welcome screen keeps a link to import */
  .sync-btn .sync-label { display: none; }
  .sync-btn { padding-inline: 8px; }
  .topbar { gap: 6px; }
  .app.show-register .brand-name { font-size: 15px; }
  .btn .long { display: none; }
  .btn .short { display: inline; }
  .back { display: none; }
  .app.show-register .back { display: inline-block; }
  .app.show-register .sidebar { display: none; }
  .app:not(.show-register) .main { display: none; }
  .app.is-empty .main { display: flex; } /* nothing yet: the welcome screen, not an empty list */
  .app.is-empty .sidebar { display: none; }
  .sidebar { border: 0; }
  .reg-head { padding: 16px 16px 10px; align-items: flex-start; flex-direction: column; gap: 4px; }
  .reg-tools { padding: 0 16px 10px; }
  .reg-cols { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main amt" "date run";
    padding: 0 16px;
    row-gap: 0;
  }
  .row .c-main { grid-area: main; }
  .row .c-amt { grid-area: amt; }
  .row .c-date { grid-area: date; font-size: 12px; }
  .row .c-run { grid-area: run; font-size: 12px; }
  .row .c-cat, .row .c-note { display: none; }
  .budget-scroll { padding: 4px 16px 24px; }
  .budgets-page .reg-head { flex-direction: row; align-items: center; }
  .brow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name fig" "bar used"; row-gap: 6px; }
  .brow-name { grid-area: name; } .brow-fig { grid-area: fig; } .brow-bar { grid-area: bar; } .brow-used { grid-area: used; font-size: 12px; }
  .is-budget .row { grid-template-areas: "main amt" "date run"; grid-template-columns: minmax(0, 1fr) auto; }
  .is-budget .row .c-acct { display: none; }
  .bfig.big .amt { font-size: 26px; }
  .is-owed .row { grid-template-areas: "main amt" "date run"; grid-template-columns: minmax(0, 1fr) auto; }
  .is-owed .row .c-acct { display: none; }
  .owed-now { align-items: flex-start; }
  .is-search .row { grid-template-areas: "main amt" "date acct"; grid-template-columns: minmax(0, 1fr) auto; }
  .row .c-acct { grid-area: acct; justify-self: end; font-size: 12px; }
  .row .c-main .aicon.sm { width: 26px; height: 26px; }
  .divider { padding-inline: 16px; }
  .divider .d-count { display: none; }
  .search-total { justify-content: flex-start; font-size: 15px; }
  .row .c-amt .st-rec { display: none; }
  .sheet { padding: 0; }
  .sheet-panel, .sheet-panel.entry { border-radius: 0; width: 100%; height: 100vh; height: 100dvh; max-height: none; }
  .part { grid-template-columns: minmax(0, 1fr) 112px 36px; }
  .reg-head .aicon.lg { width: 36px; height: 36px; border-radius: 9px; font-size: 15px; }
  .facts div { grid-template-columns: 1fr; gap: 0; }
  .remainders li { grid-template-columns: minmax(0, 1fr) auto; }
  .remainders .r-date { grid-column: 1 / -1; }
}
.up-err { color: var(--red); font-size: 13px; margin: 0; }
.up-err:empty { display: none; }
