/* Pocket Ledger by OPTINEX. Forest #073F38, teal #087F75, gold #D49B32. */
:root {
  --forest: #073F38; --teal: #087F75; --gold: #D49B32; --mint: #DDF5EF;
  --bg: #F3F8F6; --surface: #FFFFFF; --surface2: #EAF3F0; --line: #D3E2DD;
  --text: #0D1F1C; --muted: #4B605B;
  --in: #06705F; --in-bg: #E0F3EE; --out: #A8321F; --out-bg: #FBEAE5;
  --btn-out: #D49B32; --btn-out-text: #1E1400;
  --focus: #D49B32;
  --radius: 14px; --shadow: 0 1px 2px rgba(7, 63, 56, .06), 0 4px 16px rgba(7, 63, 56, .07);
  --tabs-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #061714; --surface: #0C2622; --surface2: #11312C; --line: #1F433D;
    --text: #E6F2EF; --muted: #A2BAB5;
    --in: #5ED6C2; --in-bg: #0F3A33; --out: #FF9C8A; --out-bg: #3A1D18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #061714; --surface: #0C2622; --surface2: #11312C; --line: #1F433D;
  --text: #E6F2EF; --muted: #A2BAB5;
  --in: #5ED6C2; --in-bg: #0F3A33; --out: #FF9C8A; --out-bg: #3A1D18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 var(--font); color: var(--text); background: var(--bg);
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; }
small { font-size: .875rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.grow { flex: 1; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--gold); color: #1E1400; padding: 10px 14px; border-radius: 8px; z-index: 100; font-weight: 600; }
.skip:focus { top: 8px; }
kbd { font: 600 .8rem var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: var(--forest); color: #fff; min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand img { border-radius: 8px; }
.brand div { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 1.05rem; white-space: nowrap; }
.brand span { font-size: .72rem; color: #F0CF8E; letter-spacing: .06em; text-transform: uppercase; }
.book-pick { margin-left: auto; min-width: 0; }
.book-pick select {
  max-width: 42vw; min-height: 44px; font: 600 16px var(--font); color: #fff; background: rgba(255, 255, 255, .1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center / 18px;
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 10px; padding: 0 32px 0 12px; appearance: none; -webkit-appearance: none; text-overflow: ellipsis;
}
.book-pick select option { color: #0D1F1C; background: #fff; }
.btn-install {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 10px;
  background: var(--gold); color: #1E1400; font: 700 16px var(--font); cursor: pointer;
}
@media (max-width: 400px) { .btn-install span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .btn-install { padding: 0 10px; } .brand span { display: none; } }
@media (max-width: 340px) { .brand strong { font-size: .95rem; } .book-pick select { max-width: 34vw; } }

/* Tabs: bottom bar on phones, side rail on computers */
.tabs {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 54px; max-width: 120px;
  border: 0; background: none; color: var(--muted); font: 600 .8rem var(--font); border-radius: 12px; cursor: pointer; padding: 6px 2px;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--teal); background: var(--surface2); }
:root[data-theme="dark"] .tabs button[aria-current="page"] { color: var(--in); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs button[aria-current="page"] { color: var(--in); } }

main { display: block; max-width: 860px; margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-left)) 24px; outline: none; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 104px; }
  .top { margin-left: -104px; padding-left: 20px; }
  .tabs { top: 60px; bottom: 0; right: auto; width: 104px; flex-direction: column; justify-content: flex-start; gap: 6px; border-top: 0; border-right: 1px solid var(--line); padding: 14px 10px; }
  .tabs button { flex: none; max-width: none; min-height: 68px; }
  main { padding: 24px 28px 40px; }
}

/* Day navigation */
.daynav { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; }
.date-pick { position: relative; flex: 1; min-width: 0; text-align: center; border-radius: 12px; padding: 4px 26px; }
.date-pick h1 { display: flex; flex-direction: column; }
.d-main { font-size: clamp(1.25rem, 6.4vw, 1.5rem); font-variant-numeric: tabular-nums; white-space: nowrap; }
.d-sub { font-size: .95rem; font-weight: 500; color: var(--muted); }
.d-cal { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); }
#day-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; font-size: 16px; }
.date-pick:focus-within { outline: 3px solid var(--focus); }
.date-pick:hover { background: var(--surface2); }
.m-title { flex: 1; text-align: center; font-size: 1.4rem; }
.v-title { font-size: 1.4rem; margin: 4px 0 14px; }
.v-title small { font-size: .9rem; font-weight: 500; }

.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; }
.icon-btn.lg { width: 48px; height: 48px; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: var(--surface2); }

/* Summary cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.cards.one { grid-template-columns: 1fr; }
@media (min-width: 620px) { .cards:not(.two):not(.one) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.card span { display: block; font-size: .9rem; color: var(--muted); font-weight: 600; }
.card strong { display: block; font-size: clamp(1.1rem, 4.6vw, 1.45rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card.in strong { color: var(--in); }
.card.out strong { color: var(--out); }
.card.close { background: var(--forest); border-color: var(--forest); }
.card.close span { color: #CFE7E1; }
.card.close strong { color: #fff; }

/* Big add buttons */
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.btn-big {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 60px; border: 0; border-radius: var(--radius);
  font: 700 1.1rem var(--font); cursor: pointer; box-shadow: var(--shadow); padding: 0 10px;
}
.btn-big span { font-size: 1.5rem; line-height: 1; }
.btn-big.in { background: var(--teal); color: #fff; }
.btn-big.out { background: var(--btn-out); color: var(--btn-out-text); }
.btn-big:active { transform: translateY(1px); }

/* Entry list */
.list-h { font-size: 1rem; margin: 0 0 8px; }
@media (max-width: 520px) { .hide-sm { display: none; } }
.entries, .parties, .daylist, .catbars, .setlist { list-style: none; margin: 0; padding: 0; }
.entries { display: grid; gap: 8px; }
.entry { position: relative; border-radius: var(--radius); overflow: hidden; }
.e-del { visibility: hidden; }
.entry.open .e-del, .entry.dragging .e-del { visibility: visible; }
.e-main {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer;
  transition: transform .18s ease; touch-action: pan-y;
}
.entry.dragging .e-main { transition: none; }
.entry.open .e-main { transform: translateX(-96px); }
.e-main:hover { background: var(--surface2); }
.e-del { position: absolute; right: 0; top: 0; bottom: 0; width: 96px; border: 0; background: var(--out); color: #fff; font: 700 1rem var(--font); cursor: pointer; }
:root[data-theme="dark"] .e-del { background: #B63A27; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .e-del { background: #B63A27; } }
.e-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; }
.e-ic.in { background: var(--in-bg); color: var(--in); }
.e-ic.out { background: var(--out-bg); color: var(--out); }
.e-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.e-cat { font-weight: 650; }
.e-meta { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-amt { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.e-amt.in, .in { color: var(--in); }
.e-amt.out, .out { color: var(--out); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface2); color: var(--muted); vertical-align: 2px; text-transform: uppercase; letter-spacing: .03em; }
.empty { text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 4px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; font: 650 16px var(--font); cursor: pointer; text-decoration: none; color: var(--text); background: var(--surface2);
}
.btn.small { min-height: 44px; padding: 0 12px; font-size: .95rem; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: #066B62; }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface2); }
.btn.danger { background: #A8321F; color: #fff; }
.btn.danger-text { color: var(--out); }
.btn.link { background: none; border: 0; color: var(--teal); padding: 0 6px; text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="dark"] .btn.link { color: var(--in); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.link { color: var(--in); } }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.grid-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 10px; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel > h2 { margin-bottom: 10px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-h .btn-row { margin: 0; }
.daychart { width: 100%; height: 120px; display: block; }
.daychart line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.daychart rect { stroke: none; }
.daychart .hit { fill: transparent; cursor: pointer; }
.daychart g:hover .hit { fill: var(--surface2); }
.daychart .b-in { fill: var(--teal); stroke: none; }
.daychart .b-out { fill: var(--gold); stroke: none; }
.chart-legend { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; }
.lg-in { background: var(--teal); } .lg-out { background: var(--gold); }
.catbars { display: grid; gap: 4px; }
.cb { display: block; width: 100%; border: 0; background: none; color: var(--text); font: inherit; text-align: left; padding: 8px 6px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.cb:hover { background: var(--surface2); }
.cb-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.cb-top small { color: var(--muted); font-weight: 500; }
.cb-bar { display: block; height: 10px; background: var(--surface2); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.cb-bar i { display: block; height: 100%; border-radius: 99px; background: var(--gold); }
.cb.in .cb-bar i { background: var(--teal); }
.daylist li + li { border-top: 1px solid var(--line); }
.daylist button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 8px 6px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.daylist button:hover { background: var(--surface2); }
.daylist small { display: block; color: var(--muted); }
.dl-amts { display: flex; flex-direction: column; align-items: flex-end; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 0 0 14px; border: 0; background: var(--surface2); border-radius: 12px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span, .seg button { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; font-weight: 650; color: var(--muted); border: 0; background: none; font-size: 16px; font-family: var(--font); cursor: pointer; width: 100%; }
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); }
.seg-in input:checked + span { background: var(--teal); color: #fff; }
.seg-out input:checked + span { background: var(--btn-out); color: var(--btn-out-text); }
.seg.mini { margin: 0; min-width: 150px; }

/* Forms */
.field { display: block; border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 650; font-size: .95rem; margin-bottom: 5px; padding: 0; }
.field small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: 16px var(--font); color: var(--text); }
.field input:not([type=radio]):not([type=checkbox]), .field select {
  width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); appearance: none; -webkit-appearance: none;
}
.field select { background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23889' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center / 18px; padding-right: 34px; }
.field input[type=date] { display: block; line-height: 46px; }
.field input:focus, .field select:focus { border-color: var(--teal); outline: 3px solid color-mix(in srgb, var(--teal) 35%, transparent); outline-offset: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 360px) { .row2 { grid-template-columns: 1fr; } }
.amt-wrap { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); padding: 0 12px; }
.amt-wrap:focus-within { border-color: var(--teal); }
.amt-wrap .cur { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.amt-field .amt-wrap input { border: 0 !important; outline: none !important; font-size: 2rem !important; font-weight: 750; min-height: 64px !important; padding: 0 8px !important; font-variant-numeric: tabular-nums; background: transparent !important; }
.hint { display: block; color: var(--muted); margin-top: 4px; min-height: 1.3em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span, button.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text); font: 600 15px var(--font); cursor: pointer; }
button.chip small { color: var(--muted); font-weight: 500; }
.chip input:checked + span { background: var(--forest); border-color: var(--forest); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
button.chip.add { border-style: dashed; color: var(--teal); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: -4px 0 10px; font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); }
.form-err { color: var(--out); font-weight: 600; min-height: 1.2em; margin: 0 0 6px; }

/* Filters */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.filters .full { grid-column: 1 / -1; }
@media (min-width: 700px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.res-sum { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Parties */
.parties { display: grid; gap: 8px; }
.parties button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.parties button:hover { background: var(--surface2); }
.p-av { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--forest); color: #F0CF8E; font-weight: 750; flex: none; }
.p-name { flex: 1; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.p-bal { display: flex; flex-direction: column; align-items: flex-end; font-weight: 750; font-variant-numeric: tabular-nums; }
.p-bal small { font-weight: 500; color: var(--muted); font-size: .8rem; }

/* Settings */
.setlist li, .setlist-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setlist li:last-child { border-bottom: 0; margin-bottom: 8px; }
.setlist small, .setlist-row small { display: block; color: var(--muted); }
.setlist .btn-row { margin: 0; }
.chips.static { margin-bottom: 12px; }

/* Banner, toast */
.banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 12px; margin-bottom: 12px; border-radius: 12px; background: #FBF1DC; color: #3A2A06; border: 1px solid #EBCF92; }
.banner p { margin: 0; }
.banner div { display: flex; gap: 8px; }
.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(560px, calc(100vw - 24px)); padding: 8px 8px 8px 16px;
  background: #0B2B27; color: #fff; border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); font-weight: 550;
}
.toast .btn { background: var(--gold); color: #1E1400; }
.toast-x { width: 44px; height: 44px; border: 0; background: none; color: #fff; font-size: 1.4rem; cursor: pointer; border-radius: 10px; flex: none; }
@media (min-width: 900px) { .toast { bottom: 24px; margin-left: 52px; } }

/* Dialogs: bottom sheet on phones, centred card on computers */
dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--text); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); overflow: auto; overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(3, 20, 18, .55); }
dialog.sheet form { padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
dialog.sheet.small { max-width: 460px; }
dialog.sheet h2 { font-size: 1.25rem; margin-bottom: 12px; }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 20px; } dialog.sheet form { padding: 22px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.sheet-head + * { margin-top: 12px; }
dialog[data-type="in"] #entry-title { color: var(--in); }
dialog[data-type="out"] #entry-title { color: var(--out); }
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px -4px 0; padding: 10px 4px 2px; position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--surface); }
@media (min-width: 640px) { .sheet-actions { bottom: -22px; } }
#ask-actions { flex-direction: row-reverse; justify-content: flex-start; }
#ask-body p { margin: 0 0 12px; }
.steps { padding-left: 22px; margin: 0 0 14px; }
.steps li { margin-bottom: 10px; }
.steps .ii { width: 1.3em; height: 1.3em; vertical-align: -4px; color: var(--teal); fill: none; }
.steps svg circle { fill: currentColor; stroke: none; }

/* PIN lock */
.lock { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: var(--forest); }
.lock-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 20px; padding: 26px 22px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.lock-card h1 { font-size: 1.25rem; margin: 10px 0 16px; }
.lock-card .field { text-align: left; }
#lock-pin { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; }

.noscript { padding: 20px; text-align: center; }
#print-area { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Print: only the statement */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #000; padding: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .st { font: 11pt/1.35 var(--font); color: #000; }
  .st-head { display: flex; justify-content: space-between; border-bottom: 2px solid #073F38; padding-bottom: 6px; color: #073F38; }
  .st-head span { color: #8a6418; font-size: 9pt; text-transform: uppercase; letter-spacing: .06em; }
  .st h1 { font-size: 16pt; margin: 12px 0 2px; }
  .st-sub { margin: 0 0 10px; color: #444; }
  .st table { width: 100%; border-collapse: collapse; }
  .st th, .st td { padding: 5px 6px; border-bottom: 1px solid #ccd; text-align: left; vertical-align: top; }
  .st th { background: #EAF3F0; font-size: 9.5pt; }
  .st .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .st-sum { margin-bottom: 14px; }
  .st-sum td { font-weight: 700; font-size: 12pt; }
  .st tr { break-inside: avoid; }
  .st small { color: #555; }
  .st-foot { margin-top: 10px; color: #555; font-size: 9pt; }
}

/* very small phones (320px) */
@media (max-width: 360px) {
  .date-pick { padding: 4px 22px 4px 2px; }
  .daynav { gap: 4px; }
  .icon-btn.lg { width: 44px; height: 44px; }
  .card { padding: 10px; }
}

/* Expected payments (not counted until marked paid) */
.status-seg { margin-top: -4px; }
.status-seg input:checked + span { background: var(--surface); color: var(--text); }
.is-expected .status-seg label:last-child input:checked + span { background: #FBF1DC; color: #5A3E05; box-shadow: inset 0 0 0 2px var(--gold); }
.exp-hint { margin: -8px 0 12px; }
.xp-sum {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 60px; margin: 0 0 16px; padding: 10px 14px;
  border: 1px dashed var(--gold); border-radius: var(--radius); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.xp-sum small { display: block; color: var(--muted); }
.xp-amts { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.xp-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.xp-item { display: flex; align-items: stretch; gap: 6px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); padding: 4px; }
.xp-item .e-main { border: 0; min-height: 56px; padding: 6px 10px; flex: 1; min-width: 0; }
.xp-item .e-amt { display: flex; flex-direction: column; align-items: flex-end; }
.xp-item .e-amt small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.mark-paid { align-self: center; flex: none; margin-right: 4px; }
@media (max-width: 420px) { .xp-item { flex-wrap: wrap; } .mark-paid { width: 100%; margin: 0 4px 4px; } }
.due { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--surface2); color: var(--muted); vertical-align: 1px; }
.due.today { background: #FBF1DC; color: #5A3E05; }
.due.over { background: var(--out-bg); color: var(--out); }
.xp-sum .due { padding: 0 6px; }
.add-xp { margin: 0 0 16px; }
.xp-h { margin-top: 18px; }

/* Expected in / out cards (top row) */
@media (min-width: 620px) { .cards:not(.two):not(.one) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.xp-card { font: inherit; text-align: left; color: var(--text); cursor: pointer; border-style: dashed; border-color: var(--gold); background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.xp-card:hover { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); }
.xp-card small { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.xp-card.in strong { color: var(--in); }
.xp-card.out strong { color: var(--out); }
.over-txt { color: var(--out); }

/* Account + sync status (dot on the More tab) */
.tabs button[data-view="more"] { position: relative; }
.tabs button[data-sync]:not([data-sync="off"])::after { content: ""; position: absolute; top: 8px; right: calc(50% - 18px); width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); background: #2BB673; }
.tabs button[data-sync="syncing"]::after { background: var(--gold); }
.tabs button[data-sync="offline"]::after { background: #8A9A96; }
.tabs button[data-sync="error"]::after { background: var(--out); }
.banner.acct { background: color-mix(in srgb, var(--teal) 10%, var(--surface)); color: var(--text); border-color: color-mix(in srgb, var(--teal) 40%, transparent); }
.banner.acct div { flex-wrap: nowrap; }
.banner.acct { margin: -4px 0 16px; }
.banner.acct p { flex: 1 1 220px; font-size: .95rem; }
.acct-panel { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); }
.acct-panel p { margin: 0 0 10px; }

/* Lists never grow wider than the screen (long notes are cut with "…") */
.entries, .xp-list, .parties { grid-template-columns: minmax(0, 1fr); }
.xp-item > * { min-width: 0; }
@media (max-width: 640px) {
  .xp-item { flex-wrap: wrap; }
  .xp-item .e-main { flex: 1 1 100%; }
  .mark-paid { width: 100%; margin: 0 4px 4px; }
}

/* Sign-in gate and activation screen */
.gate { overflow-y: auto; }
.gate-card { max-width: 400px; }
.gate-card > p { margin: 0 0 12px; }
.gate-card .btn.block { margin-bottom: 10px; }
.gate-price { font-size: 1.1rem; }
.gate-price b { font-size: 2.2rem; color: var(--teal); display: block; line-height: 1.1; }
:root[data-theme="dark"] .gate-price b { color: var(--in); }
.gate-list { text-align: left; margin: 0 0 16px; padding-left: 22px; }
.gate-list li { margin-bottom: 4px; }
.small-note { font-size: .9rem; }
.center-row { justify-content: center; margin-top: 4px; }
.tag.ok { background: var(--in-bg); color: var(--in); }
.banner.demo { border-style: dashed; }
.acct-panel p, .gate-card p { overflow-wrap: anywhere; }
