/* Recon Hub panel - one stylesheet for the panel and the shared report page. RTL, light and dark. */
@font-face { font-family: 'Vazirmatn'; src: url('vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f3f5fb; --bg2: #e9edf7; --card: #ffffff; --card2: #f8f9fd; --ink: #121829; --ink2: #364055; --muted: #6a7389;
  --line: #e2e7f1; --line2: #cfd6e6; --brand: #4f46e5; --brand2: #9333ea; --brand-soft: #eef0ff; --ring: rgba(79, 70, 229, .35);
  --deb: #c2410c; --deb-bg: #fff1e6; --cre: #0f766e; --cre-bg: #e3f6f2;
  --ok: #15803d; --ok-bg: #e7f6ec; --warn: #b45309; --warn-bg: #fff4dc; --bad: #c0262d; --bad-bg: #fde9ea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 22px rgba(16, 24, 40, .06); --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);
  --glass: rgba(255, 255, 255, .78); --r: 16px; --r-s: 11px; --side: 236px; --top: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111b; --bg2: #121827; --card: #161c2b; --card2: #1b2334; --ink: #e8ecf6; --ink2: #c3cbdc; --muted: #8e98ad;
    --line: #262f43; --line2: #33405a; --brand: #8b85ff; --brand2: #c084fc; --brand-soft: #23264a; --ring: rgba(139, 133, 255, .4);
    --deb: #fb923c; --deb-bg: #3a2414; --cre: #2dd4bf; --cre-bg: #0f2f2c;
    --ok: #4ade80; --ok-bg: #12301f; --warn: #fbbf24; --warn-bg: #352a10; --bad: #f87171; --bad-bg: #3a1a1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 26px rgba(0, 0, 0, .28); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    --glass: rgba(18, 24, 38, .78); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d111b; --bg2: #121827; --card: #161c2b; --card2: #1b2334; --ink: #e8ecf6; --ink2: #c3cbdc; --muted: #8e98ad;
  --line: #262f43; --line2: #33405a; --brand: #8b85ff; --brand2: #c084fc; --brand-soft: #23264a; --ring: rgba(139, 133, 255, .4);
  --deb: #fb923c; --deb-bg: #3a2414; --cre: #2dd4bf; --cre-bg: #0f2f2c;
  --ok: #4ade80; --ok-bg: #12301f; --warn: #fbbf24; --warn-bg: #352a10; --bad: #f87171; --bad-bg: #3a1a1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 26px rgba(0, 0, 0, .28); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --glass: rgba(18, 24, 38, .78); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.65 Vazirmatn, Tahoma, 'Segoe UI', sans-serif; font-feature-settings: 'ss01'; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 21px; margin: 0 0 4px; } h3 { font-size: 15px; margin: 0; }
.ic { flex: none; }
.muted { color: var(--muted); } .grow { flex: 1; } .num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.mono { font-family: Consolas, 'Courier New', monospace; direction: ltr; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; margin: 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; display: flex; gap: 6px; align-items: flex-start; }
.okmsg { color: var(--ok); font-weight: 600; } .bad-text { color: var(--bad); font-weight: 600; }
.offscreen { position: fixed; top: -1000px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 8px; }

/* buttons ----------------------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 15px;
  border: 1px solid var(--line2); background: var(--card); color: var(--ink); border-radius: 12px; cursor: pointer; font-weight: 600;
  transition: transform .12s, box-shadow .2s, background .2s, border-color .2s; white-space: nowrap; }
.btn:hover { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border: 0; box-shadow: 0 6px 18px var(--ring); }
.btn.primary:hover { box-shadow: 0 8px 26px var(--ring); }
.btn.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 48px; font-size: 15px; border-radius: 14px; padding: 10px 20px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 12.5px; border-radius: 9px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent;
  color: var(--ink2); cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: var(--bg2); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }

/* inputs ------------------------------------------------------------------------------------------ */
.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 12px; background: var(--card);
  transition: border-color .15s, box-shadow .15s; outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.input.big { min-height: 48px; font-size: 15.5px; }
.input.bad { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); }
.input.date { width: 128px; text-align: center; direction: ltr; }
textarea.input { resize: vertical; }
.input-wrap { position: relative; display: block; }
.input-wrap .in-input { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .ic { position: absolute; right: 12px; color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-right: 38px; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.f-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; margin: 6px 0; }
.switch input { appearance: none; width: 40px; height: 23px; border-radius: 99px; background: var(--line2); position: relative; cursor: pointer;
  transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; right: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: right .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { right: 20px; }
.range { width: 100%; accent-color: var(--brand); }
.seg { display: inline-flex; background: var(--bg2); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
.radio-list { display: grid; gap: 6px; }
.radio { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio small { margin-inline-start: auto; }
.radio input { accent-color: var(--brand); }

/* toasts and dialogs ------------------------------------------------------------------------------ */
.toasts { position: fixed; inset-inline: 0; bottom: 88px; display: grid; justify-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast { display: flex; gap: 8px; align-items: center; background: #111827; color: #fff; padding: 10px 16px; border-radius: 14px;
  box-shadow: var(--shadow-lg); animation: rise .25s ease-out; max-width: min(92vw, 520px); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .4s; }
.sheet-back { position: fixed; inset: 0; background: rgba(9, 12, 22, .45); backdrop-filter: blur(3px); display: grid; place-items: center;
  z-index: 80; padding: 16px; animation: fade .18s; }
.sheet-back.out { opacity: 0; transition: opacity .18s; }
.sheet { width: min(520px, 100%); max-height: min(88dvh, 820px, calc(var(--vvh, 100dvh) - 24px)); display: flex; flex-direction: column; background: var(--card);
  border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); }
.sheet.wide { width: min(760px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; font-size: 15.5px; }
.sheet-body { padding: 4px 18px 14px; overflow: auto; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.sheet-foot .btn.primary { order: -1; }
@media (max-width: 640px) {
  .sheet-back { place-items: end stretch; padding: 0; }
  .sheet, .sheet.wide { width: 100%; border-radius: 22px 22px 0 0; max-height: min(92dvh, calc(var(--vvh, 100dvh) - 8px)); animation: up .26s cubic-bezier(.2, .9, .3, 1); }
  .sheet-foot .btn { flex: 1; }
  .sheet-back.pin-top { place-items: start stretch; top: var(--vvt, 0px); bottom: auto; height: var(--vvh, 100dvh); }
  .sheet-back.pin-top .sheet { height: 100%; max-height: none; border-radius: 0 0 22px 22px; animation: down .24s cubic-bezier(.2, .9, .3, 1); }
}
.picker-search { position: sticky; top: -4px; z-index: 1; background: var(--card); padding: 4px 0 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes down { from { transform: translateY(-30%); opacity: .4; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* login and splash -------------------------------------------------------------------------------- */
.logo { width: var(--s, 34px); height: var(--s, 34px); border-radius: 30%; display: inline-grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #6366f1, #9333ea); box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden; }
.aurora { position: absolute; inset: -30%; background: radial-gradient(40% 35% at 30% 30%, rgba(99, 102, 241, .45), transparent 70%),
  radial-gradient(35% 30% at 75% 65%, rgba(147, 51, 234, .38), transparent 70%), radial-gradient(30% 30% at 60% 20%, rgba(14, 165, 233, .3), transparent 70%);
  filter: blur(40px); animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(4%, -3%) rotate(8deg); } }
.login-card { position: relative; width: min(420px, 100%); background: var(--glass); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 26px; padding: 28px 26px 22px; box-shadow: var(--shadow-lg); }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.login-brand b { display: block; font-size: 21px; letter-spacing: .3px; }
.login-brand small { color: var(--muted); }
.login-err { color: var(--bad); min-height: 22px; margin: 4px 0 8px; font-weight: 600; }
.login-note { display: flex; gap: 8px; color: var(--muted); font-size: 12px; margin: 16px 0 0; line-height: 1.8; }
.login-note .ic { margin-top: 3px; color: var(--ok); }
.splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 20px; }
.splash > b { font-size: 20px; }
.bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; width: 100%; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand2), var(--brand)); border-radius: 99px; transition: width .35s; }
.bar.thin { height: 5px; width: min(280px, 70vw); }
.splash .bar i { animation: none; }
.meter { width: 100% !important; }
.meter[data-s="0"] i, .meter[data-s="1"] i { background: var(--bad); } .meter[data-s="2"] i { background: var(--warn); } .meter[data-s="3"] i, .meter[data-s="4"] i { background: var(--ok); }

/* shell ------------------------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: var(--top) 1fr; grid-template-areas: "top top" "side view"; min-height: 100dvh; }
.top { grid-area: top; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.3); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; margin-inline-end: 6px; }
.fresh { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 4px 11px; font-size: 12px; color: var(--ink2); cursor: pointer; }
.save-dot { font-size: 12px; color: var(--muted); min-width: 0; }
.save-dot.saved { color: var(--ok); } .save-dot.error { color: var(--bad); font-weight: 700; } .save-dot.dirty { color: var(--warn); }
.save-dot { white-space: nowrap; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 12px; }
.user-btn:hover { background: var(--bg2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; color: #fff; flex: none;
  background: linear-gradient(135deg, #0ea5e9, #6366f1); font-size: 17px; }
.avatar.small { width: 30px; height: 30px; font-size: 13px; }
.side { grid-area: side; position: sticky; top: var(--top); height: calc(100dvh - var(--top)); padding: 14px 10px; display: flex; flex-direction: column; gap: 3px;
  border-inline-start: 1px solid var(--line); background: var(--card2); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 12px; color: var(--ink2); font-weight: 600; border: 0;
  background: transparent; cursor: pointer; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--bg2); }
.nav-item.on { background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--ok); padding: 8px 12px; }
.view { grid-area: view; padding: 18px 20px 40px; min-width: 0; }
.bottom { display: none; }
.page { display: grid; gap: 14px; max-width: 1400px; margin: 0 auto; }
.page.narrow { max-width: 720px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "view"; }
  .side { display: none; }
  .u-name { display: none; }
  .fresh span { max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .view { padding: 12px 10px 96px; }
  .bottom { display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 40; background: var(--glass); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom .nav-item { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; justify-content: center; }
  .brand b { display: none; }
  .save-dot { font-size: 0; }
  .save-dot:not(:empty)::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
}
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { display: grid; justify-items: center; gap: 6px; padding: 16px 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--card2);
  cursor: pointer; font-weight: 600; color: var(--ink2); }
.kv-list { display: grid; gap: 8px; margin: 8px 0 14px; }
.kv-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }

/* cards, chips, pills ----------------------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-title { margin-bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; background: var(--bg2); color: var(--ink2);
  font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; background: var(--bg2); font-size: 12.5px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 4px 13px; border: 1px solid var(--line2); border-radius: 99px;
  background: var(--card); cursor: pointer; font-weight: 600; color: var(--ink2); transition: all .15s; }
.chip small { color: var(--muted); font-weight: 500; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; } .chip.on small { color: rgba(255, 255, 255, .8); }
.chip.small { min-height: 30px; padding: 2px 11px; font-size: 12.5px; }
.chip.chip-asset.on { background: hsl(var(--h) 65% 46%); border-color: hsl(var(--h) 65% 46%); }
.f-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.f-field { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 600; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); }
.flag.round { border-radius: 50%; box-shadow: none; }
.chip .flag { margin-inline-end: -2px; }
.asset { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 8px; font-weight: 700; font-size: 12px; direction: ltr; white-space: nowrap;
  background: hsl(var(--h, 230) 85% 94%); color: hsl(var(--h, 230) 60% 30%); }
:root[data-theme="dark"] .asset { background: hsl(var(--h, 230) 40% 20%); color: hsl(var(--h, 230) 80% 78%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .asset { background: hsl(var(--h, 230) 40% 20%); color: hsl(var(--h, 230) 80% 78%); } }
.bal { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; white-space: nowrap; }
.bal .tag { font-size: 10.5px; padding: 0 6px; border-radius: 6px; font-weight: 800; }
.bal.deb { color: var(--deb); } .bal.deb .tag { background: var(--deb-bg); }
.bal.cre { color: var(--cre); } .bal.cre .tag { background: var(--cre-bg); }
.bal.zero { color: var(--muted); }
.bal.big { font-size: 20px; } .bal.big .tag { font-size: 12px; }

/* dashboard --------------------------------------------------------------------------------------- */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--brand-soft), var(--card) 60%); }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kpi { display: flex; gap: 12px; align-items: center; }
.kpi small { display: block; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 19px; }
.kpi .muted { font-size: 12px; }
.kpi-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.kpi.good .kpi-ic { background: var(--ok-bg); color: var(--ok); } .kpi.bad .kpi-ic { background: var(--bad-bg); color: var(--bad); }
.kpi.warn .kpi-ic { background: var(--warn-bg); color: var(--warn); } .kpi.bad b { color: var(--bad); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.qcard { color: var(--ink); display: grid; gap: 8px; transition: transform .15s, box-shadow .2s; }
.qcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.q-top { display: flex; justify-content: space-between; align-items: center; }
.q-sum { font-size: 20px; font-weight: 800; }
.q-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kind { display: inline-flex; gap: 6px; font-size: 12px; background: var(--bg2); border-radius: 8px; padding: 2px 8px; color: var(--ink2); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab { padding: 9px 16px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--ink2); font-weight: 700;
  display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.tab.on { background: var(--brand); color: #fff; border-color: var(--brand); } .tab small { opacity: .8; }

/* data grids -------------------------------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: var(--cols); font-size: 13px; overflow-x: auto; }
.g-head, .g-row { display: contents; }
.g-head span { background: var(--card2); color: var(--muted); font-weight: 700; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.g-row span { padding: 9px 10px; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.g-row:hover span { background: var(--card2); }
.g-row.warn span { background: var(--warn-bg); } .g-row.next span { background: var(--brand-soft); }
.grid .num { text-align: left; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 760px) {
  .grid { display: block; }
  .g-head { display: none; }
  .g-row { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .g-row span { border: 0; padding: 2px 0; }
  .g-row span::before { content: attr(data-l); display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
  .g-row span[data-l=""]::before { content: none; }
  .g-row span.wide { grid-column: 1 / -1; }
  .grid .num { text-align: right; }
}
.skeleton { border-radius: var(--r); background: linear-gradient(90deg, var(--card) 25%, var(--bg2) 50%, var(--card) 75%); background-size: 200% 100%;
  animation: shimmer 1.2s infinite; height: 60px; }
.skeleton.tall { height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sec-list { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; color: var(--ink2); }

/* ledger ------------------------------------------------------------------------------------------ */
.ledger { display: grid; gap: 12px; max-width: 1400px; margin: 0 auto; }
.party-card { display: grid; gap: 12px; background: linear-gradient(135deg, var(--brand-soft), var(--card) 55%); }
.pc-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.party-btn { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line2); background: var(--card); padding: 8px 12px 8px 10px;
  border-radius: 16px; cursor: pointer; flex: 1; min-width: 260px; text-align: right; transition: border-color .15s, box-shadow .15s; }
.party-btn:hover { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.pb-text { display: grid; flex: 1; min-width: 0; }
.pb-text b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-text small { color: var(--muted); }
.rot { transform: rotate(-90deg); color: var(--muted); }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pc-bals { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px dashed transparent; background: transparent; padding: 4px;
  margin: -4px; border-radius: 14px; cursor: pointer; text-align: right; color: inherit; transition: border-color .15s, background .15s; }
.pc-bals:hover { border-color: var(--line2); background: var(--glass); }
.pc-zoom { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--brand); padding: 3px 9px;
  border-radius: 99px; background: var(--brand-soft); }
.mini-bal { display: inline-flex; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px; }
.hero-empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 46px 18px; color: var(--ink2); }
.hero-empty .ic { color: var(--brand); }
.party-list { display: grid; gap: 8px; margin-top: 12px; }
.party-item { display: grid; gap: 4px; text-align: right; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  cursor: pointer; transition: border-color .12s, background .12s; }
.party-item:hover, .party-item.sel { border-color: var(--brand); background: var(--brand-soft); }
.party-item.current { box-shadow: inset 4px 0 0 var(--brand); }
.pi-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pi-meta { font-size: 12px; color: var(--muted); }
.pi-bals { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.pi-bals .mini-bal { padding: 2px 8px; }
.recon { border-color: var(--warn); background: linear-gradient(135deg, var(--warn-bg), var(--card) 70%); }
.recon-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 9px; color: var(--warn); }
.recon-top b.num { color: var(--ink); }
.recon .bar i { background: linear-gradient(90deg, #f59e0b, #16a34a); }
.recon-slot { display: none; }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: clip; }
.rows-top { position: sticky; top: var(--top); z-index: 5; background: var(--card); border-radius: var(--r) var(--r) 0 0; }
.rows-bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.rows-bar .search-wrap { min-width: 220px; }
.rows-bar .switch { margin: 0; }
.sort-btn { flex: none; }
.boundary { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 9px 12px; font-size: 12.5px; font-weight: 700;
  color: var(--warn); background: var(--warn-bg); border-bottom: 1px solid var(--line); }
.lhead, .lrow { display: grid; grid-template-columns: 92px 104px 96px 150px 160px 76px minmax(0, 1fr) 34px; align-items: center; gap: 0 10px; padding: 0 12px; }
.lhead.recon-on, .lrow.recon-on { grid-template-columns: 46px 92px 104px 96px 150px 160px 76px minmax(0, 1fr) 34px; }
.lhead { background: var(--card2); color: var(--muted); font-size: 12px; font-weight: 700; padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.lrow { border-bottom: 1px solid var(--line); min-height: 52px; padding-top: 8px; padding-bottom: 8px; transition: background .2s, opacity .2s, transform .2s; }
.lrow:hover { background: var(--card2); }
.lrow.recon-on { cursor: pointer; }
.lrow.ticked { background: var(--ok-bg); }
.lrow.ticked .c:not(.run) { opacity: .78; }
.lrow.flagged { background: var(--bad-bg); }
.lrow.flagged .tick { background: var(--bad); border-color: var(--bad); color: #fff; }
.lrow.outside { opacity: .5; }
.lrow.outside:hover { opacity: .85; }
.lrow.leaving { opacity: 0; transform: translateX(-30px); }
.lrow .c small { display: none; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.tick { width: 34px; height: 34px; border-radius: 11px; border: 2px solid var(--line2); background: var(--card); display: grid; place-items: center;
  color: transparent; cursor: pointer; transition: all .15s; }
.tick:hover { border-color: var(--ok); }
.lrow.ticked .tick { background: var(--ok); border-color: var(--ok); color: #fff; transform: scale(1.04); }
.c.date { font-variant-numeric: tabular-nums; font-weight: 600; }
.c.doc { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.type { font-size: 11.5px; font-weight: 800; padding: 1px 8px; border-radius: 7px; background: var(--bg2); color: var(--ink2); }
.type.t-TBN { background: #e0ecff; color: #1d4ed8; } .type.t-TSN { background: #f2e8ff; color: #7e22ce; } .type.t-TPQ { background: #e6f4f1; color: #0f766e; }
.type.t-Py { background: #fff1d6; color: #a16207; } .type.t-Rt { background: #ffe4e8; color: #be123c; }
:root[data-theme="dark"] .type { filter: brightness(.75) saturate(1.2); }
.no { color: var(--muted); }
.c.amt { display: grid; gap: 1px; }
.deb-amt, .cre-amt { display: flex; gap: 6px; align-items: baseline; }
.deb-amt b { color: var(--deb); } .cre-amt b { color: var(--cre); }
.deb-amt b::before { content: '+ '; opacity: .55; } .cre-amt b::before { content: '− '; opacity: .55; }
.c.rate { color: var(--muted); font-size: 12.5px; }
.c.text { display: grid; gap: 1px; min-width: 0; }
.other { font-weight: 600; color: var(--ink2); font-size: 12.5px; }
.desc { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.more-rows { width: 100%; border-radius: 0; min-height: 46px; }
@media (max-width: 760px) {
  .lhead { display: none; }
  .lrow, .lrow.recon-on { grid-template-columns: 1fr auto auto; grid-template-areas: "date doc more" "as amt amt" "run run rate" "text text text";
    gap: 4px 10px; padding: 12px; }
  .lrow.recon-on { grid-template-columns: 44px 1fr auto auto; grid-template-areas: "tick date doc more" "tick as amt amt" "tick run run rate" "tick text text text"; }
  .lrow .tick { grid-area: tick; align-self: center; width: 38px; height: 38px; }
  .c.date { grid-area: date; } .c.doc { grid-area: doc; justify-content: flex-end; } .c.as { grid-area: as; } .c.amt { grid-area: amt; justify-items: end; }
  .c.run { grid-area: run; display: flex; gap: 6px; align-items: center; } .c.rate { grid-area: rate; text-align: left; } .c.text { grid-area: text; }
  .lrow .more { grid-area: more; width: 30px; height: 30px; }
  .lrow .c small { display: inline; }
  .party-btn { min-width: 0; }
  .pc-actions { width: 100%; } .pc-actions .btn { flex: 1; } .pc-actions .btn.ghost, .pc-actions .card-btn { display: none; }
  .input.date { width: 112px; }
  .rows-bar { padding: 8px 10px; }
  .rows-bar .search-wrap { min-width: 0; flex-basis: 100%; }
  .pc-zoom { margin-inline-start: auto; }
}
.input.date.small { width: 118px; min-height: 32px; padding: 3px 8px; margin-inline-start: auto; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.stat { display: grid; justify-items: center; padding: 14px; border-radius: 16px; background: var(--bg2); }
.stat b { font-size: 26px; } .stat.good { background: var(--ok-bg); color: var(--ok); } .stat.bad { background: var(--bad-bg); color: var(--bad); }
.diff-sum { display: grid; gap: 8px; }
.diff-sum > div { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.link-ready { display: flex; align-items: center; gap: 10px; color: var(--ok); font-weight: 700; margin-bottom: 10px; }
.print-head { display: none; }

/* balance card (always light: it is what the other side sees) ------------------------------------- */
.bc-back { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); overflow: auto; background: rgba(9, 12, 22, .5);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); animation: fade .2s; }
.bc-back.out { opacity: 0; transition: opacity .2s; }
.bc-card { width: min(440px, 100%); flex: none; background: #fff; color: #121829; border-radius: 26px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35); animation: pop .26s cubic-bezier(.2, .9, .3, 1.2); }
.bc-head { position: relative; display: grid; gap: 2px; padding: 22px 22px 20px; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, #4f46e5, #9333ea); }
.bc-head::after { content: ''; position: absolute; width: 170px; height: 170px; border-radius: 50%; background: rgba(255, 255, 255, .09); left: -50px; top: -70px; }
.bc-head b { font-size: 22px; line-height: 1.45; }
.bc-head small { color: rgba(255, 255, 255, .86); font-size: 13px; }
.bc-list { padding: 4px 18px; }
.bc-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 2px; border-bottom: 1px solid #eef0f6; }
.bc-row:last-child { border-bottom: 0; }
.bc-flag { display: grid; place-items: center; min-width: 39px; }
.bc-flag .flag { box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.bc-flag .flag.round { box-shadow: none; }
.bc-noflag { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #eef0ff; color: #4f46e5; font-weight: 800; }
.bc-name { display: grid; min-width: 0; }
.bc-name b { font-size: 16px; overflow-wrap: anywhere; }
.bc-name small { color: #6a7389; direction: ltr; text-align: right; font-size: 12px; }
.bc-amt { display: grid; justify-items: end; gap: 3px; }
.bc-amt b { font-size: 20px; font-weight: 800; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bc-amt .lbl { font-size: 11.5px; font-weight: 800; padding: 1px 9px; border-radius: 7px; }
.bc-row.deb .bc-amt b, .bc-row.deb .lbl { color: #c2410c; } .bc-row.deb .lbl { background: #fff1e6; }
.bc-row.cre .bc-amt b, .bc-row.cre .lbl { color: #0f766e; } .bc-row.cre .lbl { background: #e3f6f2; }
.bc-empty { margin: 0; padding: 26px 0; text-align: center; color: #6a7389; font-weight: 700; }
.bc-foot { padding: 10px 22px 16px; color: #8a92a6; font-size: 12px; text-align: center; border-top: 1px solid #f1f2f7; }
.bc-tools { width: min(520px, 100%); display: grid; gap: 10px; justify-items: center; transition: opacity .25s, transform .25s; }
.bc-back.clean .bc-tools { opacity: 0; transform: translateY(14px); pointer-events: none; }
.bc-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bc-chips .chip { background: rgba(255, 255, 255, .9); color: #364055; border-color: transparent; }
.bc-chips .chip.on { background: #4f46e5; color: #fff; }
.bc-btns { display: flex; gap: 8px; }
.bc-hint { margin: 0; color: rgba(255, 255, 255, .85); font-size: 12px; text-align: center; }

/* shared report page ------------------------------------------------------------------------------ */
.report { max-width: 1100px; margin: 0 auto; padding: 18px 14px 60px; display: grid; gap: 14px; }
.report-head { display: grid; gap: 10px; background: linear-gradient(135deg, var(--brand-soft), var(--card) 60%); }
.rh-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.rh-title { display: flex; gap: 12px; align-items: center; }
.rh-title h1 { font-size: 21px; margin: 0; }
.rh-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.countdown { font-weight: 800; color: var(--warn); }
.note-box { background: var(--card); border: 1px dashed var(--line2); border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; }
.report .rows-top { top: 0; }
.r-bals { display: flex; flex-wrap: wrap; gap: 8px; }
.lrow.opening { background: var(--card2); }
.lrow.opening .c.doc .type { background: var(--brand-soft); color: var(--brand); }
.r-rows .lrow, .r-rows .lhead { grid-template-columns: 92px 104px 96px 150px 160px 76px minmax(0, 1fr); }
.r-rows .lrow.has-tick, .r-rows .lhead.has-tick { grid-template-columns: 34px 92px 104px 96px 150px 160px 76px minmax(0, 1fr); }
.ok-mark { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--ok); color: #fff; }
.no-mark { width: 26px; height: 26px; border-radius: 8px; border: 2px dashed var(--bad); }
.bad-mark { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bad); color: #fff; }
.r-foot { text-align: center; color: var(--muted); font-size: 12px; display: flex; gap: 6px; justify-content: center; align-items: center; }
@media (max-width: 760px) {
  .r-rows .lrow, .r-rows .lrow.has-tick { grid-template-columns: 1fr auto; grid-template-areas: "date doc" "as amt" "run rate" "text text"; }
  .r-rows .lrow.has-tick { grid-template-columns: 34px 1fr auto; grid-template-areas: "tick date doc" "tick as amt" "tick run rate" "tick text text"; }
  .r-rows .mark { grid-area: tick; }
}

/* print ------------------------------------------------------------------------------------------- */
@media print {
  :root { --bg: #fff; --card: #fff; --card2: #fff; --shadow: none; }
  body { background: #fff; font-size: 11px; }
  .top, .side, .bottom, .filters, .pc-actions, .recon, .more, .tick, .more-rows, .toasts, .party-btn .rot, .btn, .icon-btn, .rows-bar, .pc-zoom,
  .boundary { display: none !important; }
  .rows { overflow: visible; } .rows-top { position: static; }
  .shell { display: block; } .view { padding: 0; }
  .print-head { display: block; font-size: 14px; margin-bottom: 8px; }
  .card, .rows { box-shadow: none; border-color: #ccc; }
  .lrow { break-inside: avoid; min-height: 0; }
  .filters, .report-actions { display: none !important; }
}
