:root {
  --bg: #f6f2e9;
  --surface: #fffdf8;
  --ink: #241e16;
  --muted: #6e6455;
  --line: #e5dac6;
  --gold: #8a6410;
  --gold-soft: #f2e5c2;
  --gold-strong: #7a5a12;
  --in: #1b7546;
  --in-soft: #e0f1e6;
  --in-strong: #1b7546;
  --out: #b0342a;
  --out-soft: #f7e2de;
  --out-strong: #b0342a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 14px rgba(60, 40, 10, .05);
  --tabbar-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120e;
    --surface: #201c16;
    --ink: #f1ebdf;
    --muted: #a99e8b;
    --line: #393227;
    --gold: #e2b955;
    --gold-soft: #3a2f17;
    --in: #62c993;
    --in-soft: #183223;
    --out: #ff8b7f;
    --out-soft: #3c1e1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Nirmala UI", "Noto Sans Devanagari", "Mangal", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(var(--tabbar-h) + 80px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }
.in { color: var(--in); }
.out { color: var(--out); }
.loading, .empty { color: var(--muted); text-align: center; padding: 16px 0; margin: 0; }
.hint, .note { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.note { margin: 12px 0 0; padding: 10px 12px; background: var(--gold-soft); border-radius: 10px; color: var(--ink); }
.print-only { display: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700; font-size: 1.1rem; color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.month-switch { display: flex; align-items: center; flex-shrink: 0; }
.month-switch button {
  border: 0; background: transparent; color: var(--ink); font: inherit;
  height: 40px; min-width: 40px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
}
.month-switch button:hover { background: var(--gold-soft); }
.month-switch .month-label { font-weight: 650; font-size: .95rem; padding: 0 6px; }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 16px; display: grid; gap: 14px; }
#banner { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.banner {
  margin-top: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; font-size: .88rem;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { margin: 0 0 12px; font-size: .95rem; font-weight: 650; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.head-actions { display: flex; gap: 6px; }
.welcome ol { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 12px; }
@media (min-width: 520px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- home ---------- */
.hero { border-radius: var(--radius); padding: 18px 20px; color: #fff; background: linear-gradient(135deg, #17603a, #23844f); }
.hero.is-loss { background: linear-gradient(135deg, #872a21, #b2433a); }
.hero-label { font-size: .9rem; opacity: .9; }
.hero-amount { font-size: 2.3rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; margin: 2px 0 6px; overflow-wrap: anywhere; }
.hero-sub { font-size: .82rem; opacity: .9; }
.hero-sub a { color: inherit; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles .tile:last-child { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, 1fr); } .tiles .tile:last-child { grid-column: auto; display: block; } }
.tile, .balances > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.balances { display: grid; gap: 8px; }
.balances > div { background: var(--bg); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.balances .k { font-size: .9rem; }
.k { font-size: .76rem; color: var(--muted); }
.v { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.tile .v { font-size: clamp(.9rem, 4.2vw, 1.05rem); }
.balance-total { text-align: right; margin-top: 10px; color: var(--muted); }
.balance-total b { color: var(--ink); font-size: 1.05rem; }

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--gold-soft) 35%, transparent); }
.row-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.row-icon.in { background: var(--in-soft); color: var(--in); }
.row-icon.out { background: var(--out-soft); color: var(--out); }
.row-icon.move { background: var(--gold-soft); color: var(--gold); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 700; white-space: nowrap; }
.day-head { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); padding: 16px 2px 4px; font-weight: 650; border-bottom: 1px solid var(--line); }
#search { margin-bottom: 10px; }
.filter-seg { margin-bottom: 4px; display: flex; overflow-x: auto; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: .92rem;
  border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--gold); }
.btn.small { padding: 6px 10px; font-size: .82rem; }
.btn.primary { background: var(--gold-strong); color: #fff; border-color: transparent; }
.btn.danger { color: var(--out); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.icon-btn { border: 0; background: var(--bg); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; flex-shrink: 0; }

input, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.f { display: grid; gap: 6px; font-size: .84rem; color: var(--muted); font-weight: 600; min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font: inherit; font-size: .88rem; cursor: pointer;
}
.chip:hover { border-color: var(--gold); }
.chip.on { background: var(--out-strong); border-color: var(--out-strong); color: #fff; }
.sheet[data-dir="in"] .chip.on { background: var(--in-strong); border-color: var(--in-strong); }
.chip.add { border-style: dashed; color: var(--muted); margin-top: 6px; }
.chip.quick.in { border-left: 4px solid var(--in); }
.chip.quick.out { border-left: 4px solid var(--out); }
.chip-group + .chip-group { margin-top: 10px; }
.chip-label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; font-weight: 650; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; max-width: 100%; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: .88rem; padding: 8px 12px;
  border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; white-space: nowrap; flex: 1;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dir-seg button.on[data-dir="in"] { background: var(--in-strong); color: #fff; }
.dir-seg button.on[data-dir="out"] { background: var(--out-strong); color: #fff; }

/* ---------- floating buttons & tab bar ---------- */
.fab-row {
  position: fixed; left: 0; right: 0; z-index: 6;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; gap: 10px; justify-content: center; padding: 10px 16px; pointer-events: none;
}
.fab {
  pointer-events: auto; flex: 1; max-width: 230px; border: 0; border-radius: 999px;
  padding: 14px 16px; font: inherit; font-weight: 700; color: #fff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.fab-in { background: var(--in-strong); }
.fab-out { background: var(--out-strong); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .72rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.tabbar button.active { color: var(--gold); }

/* ---------- dialogs ---------- */
.sheet, .confirm { border: 0; padding: 0; background: var(--surface); color: var(--ink); }
.sheet {
  width: 100%; max-width: 560px; max-height: 94vh; margin: auto auto 0;
  border-radius: 18px 18px 0 0; overflow: auto;
}
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 18px; } }
.sheet::backdrop, .confirm::backdrop { background: rgba(20, 14, 5, .5); }
.sheet-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h3 { margin: 0; }
.amount-field { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--out); padding: 2px; }
.sheet[data-dir="in"] .amount-field { border-color: var(--in); }
.sheet[data-dir="move"] .amount-field { border-color: var(--gold); }
.amount-field .cur { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.amount-field input { border: 0; background: transparent; font-size: 2.2rem; font-weight: 750; padding: 4px 0; outline: none; }
.flabel { font-size: .84rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.newcat { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 10px; }
.newcat select { width: auto; }
.mode-seg { display: flex; }
.msg { font-size: .88rem; min-height: 1.2em; }
.msg.err { color: var(--out); }
.msg.ok { color: var(--in); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; max-width: 220px; padding: 12px 14px; }
.sheet-actions .danger { margin-right: auto; flex: 0 0 auto; }

.confirm { width: calc(100% - 32px); max-width: 420px; border-radius: 16px; }
.confirm-body { padding: 20px; }
.confirm-body h3 { margin: 0 0 8px; }
.confirm-body p { margin: 0 0 18px; color: var(--muted); }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 12px;
  display: flex; gap: 14px; align-items: center; width: max-content; max-width: calc(100% - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-size: .9rem;
}
.toast button { background: transparent; border: 0; color: var(--gold-soft); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
@media (prefers-color-scheme: dark) { .toast button { color: var(--gold-strong); } }

/* ---------- report ---------- */
.pl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pl td { padding: 7px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.pl td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.pl .sec td { text-align: left !important; padding-top: 18px; font-weight: 700; color: var(--gold); border-bottom: 1px solid var(--line); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.pl .sub td:first-child { padding-left: 12px; }
.pl .total td { font-weight: 700; border-bottom: 1px solid var(--ink); }
.pl .total.strong td { font-size: 1.05rem; }
.pl .grand td { font-size: 1.2rem; font-weight: 800; border-bottom: 3px double currentColor; padding-top: 14px; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 12px; font-size: .9rem; }
.bar { grid-column: 1 / -1; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--out); }
.bar > span.purchase { background: var(--gold); }

.mini { width: 100%; border-collapse: collapse; font-size: .92rem; }
.mini th { text-align: right; font-size: .76rem; color: var(--muted); font-weight: 650; padding: 4px 0 6px 10px; border-bottom: 1px solid var(--line); }
.mini th:first-child { text-align: left; padding-left: 0; }
.mini td { padding: 7px 0 7px 10px; text-align: right; border-bottom: 1px dashed var(--line); white-space: nowrap; }
.mini td:first-child { text-align: left; padding-left: 0; }
.mini .total td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--ink); }
.table-scroll { overflow-x: auto; }
.year { font-size: .88rem; }
.year tr[data-month] { cursor: pointer; }
.year tr.current td { background: var(--gold-soft); }
.year tr.dim td { color: var(--muted); }

/* ---------- settings ---------- */
.cat-group { margin-bottom: 16px; }
.cat-group-head { font-size: .88rem; margin-bottom: 6px; }
.cat-line { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cat-line input { padding: 8px 10px; }
.cat-line.archived input { opacity: .5; text-decoration: line-through; }
.tag { font-size: .7rem; background: var(--gold-soft); color: var(--gold); padding: 2px 8px; border-radius: 99px; font-weight: 700; text-transform: uppercase; }
.add-cat { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.add-cat .grid3 { margin-bottom: 0; }
.add-cat .btn { justify-self: start; }

/* ---------- print (report only) ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; --gold: #000; --gold-soft: #eee; --in: #000; --out: #000; }
  body { padding: 0; font-size: 12pt; }
  .topbar, .tabbar, .fab-row, #banner, .toast, .no-print { display: none !important; }
  .print-only { display: block; }
  .print-head h1 { margin: 0; font-size: 18pt; }
  .print-head p { margin: 2px 0 12px; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0 0 12px; break-inside: avoid; }
}

/* ---------- books, items, lend & borrow ---------- */
:root { --home: #2c5f8f; --home-soft: #e1ebf5; }
@media (prefers-color-scheme: dark) { :root { --home: #8fbbe6; --home-soft: #1c2b3a; } }

.tag.home { background: var(--home-soft); color: var(--home); margin-right: 6px; vertical-align: 1px; }
.home-tile { cursor: pointer; }
.home-tile .tag { margin-right: 2px; }

.book-seg button.on[data-book="shop"] { background: var(--gold-strong); color: #fff; }
.book-seg button.on[data-book="home"] { background: #2c5f8f; color: #fff; }
.sheet[data-book="home"] { box-shadow: inset 0 4px 0 #2c5f8f; }
.sheet[data-book="shop"] { box-shadow: inset 0 4px 0 var(--gold-strong); }
.dir-seg { display: flex; }

.item-search { margin-bottom: 10px; }
.chip.add.strong { border-style: solid; border-color: var(--gold); color: var(--gold); font-weight: 650; margin: 0 0 10px; }
.newcat { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 12px; padding: 12px; border: 1px solid var(--gold); border-radius: 12px; background: var(--gold-soft); }
.newcat-title { font-weight: 700; font-size: .85rem; }
.newcat select { width: 100%; }
.newcat-actions { display: flex; gap: 8px; justify-content: flex-end; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.filters .seg { overflow-x: auto; }
.report-seg { display: flex; width: 100%; }

.link-card { cursor: pointer; }
.owe-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.owe-row > div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.loan-buttons { margin: 12px 0 8px; }

.people { list-style: none; margin: 0; padding: 0; }
.person { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 2px; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person-main { min-width: 0; cursor: pointer; flex: 1; }
.person-owe { font-weight: 650; font-size: .92rem; margin: 2px 0; }
.person-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
details summary { cursor: pointer; font-weight: 650; color: var(--muted); }

.items-title { font-size: 1rem; margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.cat-line select { width: 96px; flex-shrink: 0; padding: 8px 6px; font-size: .8rem; color: var(--muted); }
.cat-line input { flex: 1; }
.add-cat { border-top: 0; padding-top: 0; margin-bottom: 4px; }

/* ---------- compact item picker ---------- */
.picked {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--out); background: var(--out-soft);
}
.sheet[data-dir="in"] .picked { border-color: var(--in); background: var(--in-soft); }
.picked-main { min-width: 0; }
.picked-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked-group { font-size: .78rem; color: var(--muted); }
.all-items {
  max-height: min(38vh, 300px); overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.chip.more { color: var(--gold); border-color: var(--gold); font-weight: 650; }
.picker-foot { margin-top: 8px; }
.picker-foot .chip.add { margin-top: 0; }

/* ---------- credit & own types ---------- */
.credit-field { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.pay-seg { display: flex; }
.pay-seg button.on[data-pay="credit"] { background: var(--gold-strong); color: #fff; }
.due-hint { font-size: .9rem; color: var(--muted); }
.due-hint:empty { display: none; }
.credit-tag { color: var(--gold); font-weight: 650; }
.owe-row.single { grid-template-columns: 1fr; }
.balances.owed .k { font-size: .82rem; }
.newtype { display: grid; gap: 8px; }
.type-hint { margin: 0; font-size: .78rem; }
.pl .type-row td { font-weight: 650; }
.pl .subsub td { font-size: .85rem; color: var(--muted); border-bottom-style: dotted; }
.pl .subsub td:first-child { padding-left: 28px; }
.type-block { margin: 8px 0 10px 10px; padding-left: 10px; border-left: 3px solid var(--gold-soft); }
.type-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.type-head input { font-weight: 700; padding: 8px 10px; flex: 1; }
.add-cat + .add-cat { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.person .row-sub { white-space: normal; }

/* ---------- how to use ---------- */
.how-to { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 8px; }
.welcome .card-head { margin-bottom: 10px; }
.welcome .hint { margin: 4px 0 0; }
.how-to-box summary { cursor: pointer; list-style-position: inside; }
.how-to-box[open] summary { margin-bottom: 12px; }

/* ---------- settings menu & pages ---------- */
.card.menu { padding: 4px 0; }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: 0; border-top: 1px solid var(--line); color: var(--ink);
  font: inherit; padding: 14px 16px; cursor: pointer;
}
.menu-row:first-child { border-top: 0; }
.menu-row:hover { background: color-mix(in srgb, var(--gold-soft) 35%, transparent); }
.menu-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.menu-title { font-weight: 650; }
.menu-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-sub.warn { color: var(--out); font-weight: 600; }
.menu-arrow { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.subpage-head { display: flex; align-items: center; gap: 12px; }
.subpage-head h2 { margin: 0; font-size: 1.05rem; }

#itemsFilter { margin-bottom: 10px; }
.items-seg { display: flex; margin-bottom: 12px; }
.add-row { display: grid; gap: 8px; margin-bottom: 10px; }
.add-box { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.add-box > summary { cursor: pointer; font-weight: 650; color: var(--gold); padding: 10px 0; list-style: none; }
.add-box > summary::-webkit-details-marker { display: none; }
.add-box[open] { padding-bottom: 12px; background: var(--gold-soft); border-color: var(--gold); }
.add-box .grid2, .add-box .grid3 { margin-bottom: 10px; }

.item-group { border-top: 1px solid var(--line); }
.item-group > summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 2px; cursor: pointer; list-style: none;
}
.item-group > summary::-webkit-details-marker { display: none; }
.item-group > summary::before { content: '›'; color: var(--muted); font-size: 1.2rem; width: 12px; transition: transform .15s; }
.item-group[open] > summary::before { transform: rotate(90deg); }
.ig-title { font-weight: 650; flex: 1; }
.ig-dir { font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }
.ig-dir.in { background: var(--in-soft); color: var(--in); }
.ig-dir.out { background: var(--out-soft); color: var(--out); }
.ig-count { min-width: 28px; text-align: center; font-size: .8rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; }
.ig-body { padding: 0 0 12px 20px; }
.hidden-items { margin-top: 8px; }
.hidden-items > summary { cursor: pointer; color: var(--muted); font-size: .85rem; padding: 6px 0; }
.ig-body { max-height: min(60vh, 520px); overflow-y: auto; padding-right: 4px; }

/* ---------- language & BS date ---------- */
.bs-date { display: grid; grid-template-columns: 1.1fr 1.4fr 0.9fr; gap: 6px; }
.bs-date select { padding: 10px 8px; }
.seg.wide { display: flex; width: 100%; }
.lang-page .f { margin-bottom: 14px; }
.lang-quick { width: 100%; margin-bottom: 12px; border-color: var(--gold); color: var(--gold); }
:lang(ne) .hero-amount, :lang(ne) .v { letter-spacing: 0; }
