:root { --bg:#f4f6f9; --card:#fff; --ink:#1d2433; --muted:#6b7385; --line:#e3e7ee; --brand:#1f6feb; --ok:#1a7f37; --bad:#cf222e; }
* { box-sizing: border-box; }
body { margin:0; font:14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background:var(--bg); color:var(--ink); }
header { display:flex; align-items:center; gap:16px; flex-wrap:wrap; padding:12px 16px; background:#14213d; color:#fff; }
header h1 { margin:0; font-size:18px; }
header .mode { margin-left:auto; color:#cfe0ff; }
nav { display:flex; flex-wrap:wrap; gap:4px; padding:8px 16px; background:#fff; border-bottom:1px solid var(--line); }
nav a { padding:6px 12px; border-radius:6px; color:var(--ink); text-decoration:none; }
nav a.on, nav a:hover { background:#e8f0fe; color:var(--brand); }
main { max-width:1100px; margin:16px auto; padding:0 16px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:16px; margin-bottom:16px; }
h2 { margin:0 0 12px; font-size:17px; } h3 { margin:12px 0 8px; font-size:15px; } h3 small { color:var(--muted); font-weight:normal; }
.row { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; margin-bottom:10px; }
label { display:flex; flex-direction:column; gap:3px; font-size:12px; color:var(--muted); }
input, select, textarea { font:inherit; padding:7px 9px; border:1px solid #c9d0db; border-radius:6px; background:#fff; color:var(--ink); min-width:0; }
input:focus, select:focus { outline:2px solid #9cc0ff; border-color:var(--brand); }
button { font:inherit; padding:7px 14px; border:0; border-radius:6px; background:var(--brand); color:#fff; cursor:pointer; }
button.ghost { background:#eef1f5; color:var(--ink); }
button.link { background:none; color:var(--brand); padding:2px 4px; }
button.danger { color:var(--bad); }
.scroll { overflow-x:auto; }
table { width:100%; border-collapse:collapse; }
th, td { padding:7px 8px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
th { font-size:12px; color:var(--muted); font-weight:600; background:#fafbfc; }
td input, td select { width:100%; }
.n { text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
tfoot td, tr.total td { font-weight:600; border-top:2px solid var(--line); }
tr.grp td { font-weight:600; background:#f7f9fc; }
.muted { color:var(--muted); font-size:12px; }
.cards { display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr)); gap:12px; margin-bottom:16px; }
.stat { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:12px 14px; }
.stat b { display:block; font-size:19px; margin-top:4px; font-variant-numeric:tabular-nums; }
.two { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.diff-bad { color:var(--bad); font-weight:600; } .diff-ok { color:var(--ok); font-weight:600; }
.flash { position:fixed; right:16px; bottom:16px; padding:10px 16px; border-radius:8px; color:#fff; opacity:0; transition:opacity .2s; pointer-events:none; }
.flash.ok { background:var(--ok); opacity:1; } .flash.err { background:var(--bad); opacity:1; }
.clickable tbody tr { cursor:pointer; } .clickable tbody tr:hover, .clickable tbody tr.sel { background:#eef4ff; }
.two > * { min-width:0; }
.row > * { min-width:0; }
label > input, label > select { max-width:100%; }
.wide { flex:1; }
.nowrap { white-space:nowrap; }
a.att { display:inline-block; margin:4px 8px 0 0; font-size:12px; color:var(--brand); text-decoration:none; word-break:break-all; }
#vAtt .att-item { display:inline-flex; align-items:center; margin-right:8px; }

nav .nav-h { padding:6px 4px 6px 12px; font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); align-self:center; border-left:1px solid var(--line); }
.spread { justify-content:space-between; align-items:center; }
.spread h2 { margin:0; }
a.btn { display:inline-flex; align-items:center; padding:7px 14px; border-radius:6px; background:var(--brand); color:#fff; text-decoration:none; }
a.btn.ghost, button.ghost { background:#eef1f5; color:var(--ink); }
button.ghost.danger { color:var(--bad); }
a.link { color:var(--brand); padding:2px 4px; text-decoration:none; }
.small { font-size:12px; }
.badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:12px; font-weight:600; white-space:nowrap; }
.b-paid { background:#dafbe1; color:#116329; } .b-part { background:#fff1c2; color:#7a4d00; } .b-over { background:#ffe0e0; color:#a40e26; }
.b-unpaid { background:#eef1f5; color:#424a53; } .b-open { background:#ddf4ff; color:#0550ae; } .b-conv { background:#eef1f5; color:#6b7385; }
.stat button { margin-top:8px; width:100%; }
.doc-foot { display:grid; grid-template-columns:1fr 320px; gap:16px; margin:12px 0; align-items:start; }
.doc-foot textarea { width:100%; }
.totals td { padding:5px 8px; }
.totals tr.total td { font-size:16px; font-weight:700; border-top:2px solid var(--ink); }
table.dlines td input, table.dlines td select { min-width:60px; }
dialog { border:0; border-radius:12px; padding:16px; width:min(480px, calc(100vw - 24px)); box-shadow:0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background:rgba(0,0,0,.35); }
dialog h2 { margin-top:0; }

/* phones */
@media (max-width:700px) {
  nav .nav-h { display:none; }
  .doc-foot { grid-template-columns:1fr; }
  table.dlines thead { display:none; }
  table.dlines tbody tr { display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; padding:10px 0; border-bottom:1px solid var(--line); }
  table.dlines tbody td { border:0; padding:0; }
  table.dlines tbody td:first-child { grid-column:1 / -1; }
  table.dlines td.amt { align-self:center; font-weight:600; }
  table.dlines td.amt::before { content:'₹'; }
  body { font-size:15px; }
  header { padding:10px 12px; gap:4px 12px; }
  header h1 { font-size:17px; }
  nav { flex-wrap:nowrap; overflow-x:auto; padding:6px 12px; scrollbar-width:none; }
  nav a { white-space:nowrap; }
  main { margin:12px auto; padding:0 12px; }
  .card { padding:12px; border-radius:8px; }
  .two { grid-template-columns:1fr; gap:0; }
  /* 16px stops iOS zooming into fields; 42px is a comfortable tap target */
  input, select, textarea, button { font-size:16px; min-height:42px; }
  .row > * { flex:1 1 140px !important; }
  .row > .wide { flex-basis:100% !important; }
  .row > .badge, .row.spread > h2 { flex:0 1 auto !important; }
  th, td { padding:6px 5px; }
  .hide-sm { display:none; }
  .stmt { font-size:13px; }
  .in-out td.nowrap { white-space:normal; } /* period wraps so all four interest columns fit */
  /* ledger statement: one small card per entry (date + amount / details / balance + actions) */
  table.ledger-rows thead { display:none; }
  table.ledger-rows tr { display:grid; grid-template-columns:1fr auto; gap:3px 10px; padding:10px 0; border-bottom:1px solid var(--line); }
  table.ledger-rows td { border:0; padding:0; }
  table.ledger-rows td:nth-child(1) { grid-area:1 / 1; font-weight:600; }
  table.ledger-rows td:nth-child(4), table.ledger-rows td:nth-child(5) { grid-area:1 / 2; font-weight:600; font-size:15px; }
  table.ledger-rows tbody td:nth-child(4):not(:empty)::after { content:var(--dr-word); font-size:11px; color:var(--muted); }
  table.ledger-rows tbody td:nth-child(5):not(:empty)::after { content:var(--cr-word); font-size:11px; color:var(--muted); }
  table.ledger-rows td:nth-child(2) { grid-area:2 / 1 / 3 / 3; }
  table.ledger-rows td:nth-child(6) { grid-area:3 / 1; text-align:left; color:var(--muted); }
  table.ledger-rows td:nth-child(7) { grid-area:3 / 2; }
  table.ledger-rows tfoot td:nth-child(4), table.ledger-rows tfoot td:nth-child(5) { display:none; }
  table.ledger-rows tfoot td:nth-child(6) { color:var(--ink); font-size:16px; }
  .simple-page { padding-bottom:72px; }
  .simple-page nav.tabs { position:fixed; left:0; right:0; bottom:0; z-index:20; justify-content:space-around; padding:4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top:1px solid var(--line); border-bottom:0; overflow:visible; }
  .simple-page nav.tabs a { flex:1; flex-direction:column; gap:2px; padding:6px 0; font-size:12px; text-align:center; }
  .simple-page nav.tabs a span { font-size:20px; line-height:1; }
  .simple-page .flash { bottom:80px; }
  table.vlines thead { display:none; }
  table.vlines tbody tr { display:grid; grid-template-columns:1fr 1fr auto; gap:6px; padding:8px 0; border-bottom:1px solid var(--line); }
  table.vlines tbody td { border:0; padding:0; }
  table.vlines tbody td:first-child { grid-column:1 / -1; }
  .flash { left:12px; right:12px; bottom:12px; text-align:center; }
}

/* ===== detailed-mode shell: sidebar + top bar (index.html) ===== */
:root { --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100; --s5:#e87ba4; --crit:#d03b3b; --good:#0ca30c; --neutral:#a8b0bc; --side:88px; }
.side { position:fixed; inset:0 auto 0 0; width:var(--side); background:#f1f3f6; border-right:1px solid var(--line); display:flex; flex-direction:column;
  align-items:stretch; padding:10px 6px; gap:2px; z-index:20; overflow-y:auto; }
.side .brand { width:40px; height:40px; margin:2px auto 10px; border-radius:50%; background:#1a7f37; color:#fff; display:grid; place-items:center;
  font-weight:800; font-size:20px; text-decoration:none; }
.side-btn { display:flex; flex-direction:column; align-items:center; gap:3px; padding:8px 2px; border-radius:10px; background:none; color:var(--ink);
  font-size:11.5px; text-decoration:none; text-align:center; min-height:0; }
.side-btn svg { width:24px; height:24px; }
.side-btn:hover { background:#e4e8ee; }
.side-btn.on { background:#14213d; color:#fff; }
.side-gap { flex:1; }
.mob-only { display:none !important; }
.topbar { position:sticky; top:0; z-index:15; margin-left:var(--side); display:flex; align-items:center; gap:24px; padding:10px 24px; background:#fff; border-bottom:1px solid var(--line); }
.topbar b { font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:30%; }
.search { position:relative; flex:1; max-width:720px; }
:root { --dr-word:' Dr'; --cr-word:' Cr'; }
html[lang="hi"] { --dr-word:' नामे'; --cr-word:' जमा'; } /* i18n.js sets lang */
/* simple mode page tabs: under the header on a computer, a bottom bar on phones */
nav.tabs a { display:inline-flex; align-items:center; gap:6px; font-weight:500; }
nav.tabs a.on { background:#e8f0fe; color:var(--brand); }
.acts { display:flex; flex-wrap:wrap; gap:2px 6px; justify-content:flex-end; }
details.interest { margin-top:14px; border:1px solid var(--line); border-radius:8px; padding:10px 12px; background:#fafbfc; }
details.interest > summary { font-weight:600; color:var(--brand); }
details.interest .row { margin-top:10px; }
.drop { border:2px dashed #c9d0db; border-radius:10px; padding:18px; text-align:center; background:#fafbfc; }
.steps { margin:0 0 8px; padding-left:20px; } .steps li { margin:4px 0; }
.lang-btn { min-height:0; padding:6px 10px; border-radius:16px; background:#eef1f5; color:var(--ink); font-weight:600; white-space:nowrap; }
header .lang-btn { background:rgba(255,255,255,.15); color:#fff; }
.book-pick select { min-height:0; padding:5px 8px; font-weight:600; max-width:180px; }
.book-name { font-size:13px; color:var(--muted); }
header .book-pick, header .book-name { color:#fff; } header .book-name { opacity:.85; }
.me-btn { margin-left:auto; width:38px; height:38px; min-height:0; padding:0; border-radius:50%; background:#2a78d6; color:#fff; font-weight:700; flex:0 0 38px; }
header .user-bar { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
header .user-bar a, button.link.light { color:#cfe0ff; }
.search > svg { position:absolute; left:12px; top:50%; width:18px; height:18px; transform:translateY(-50%); color:var(--muted); }
.search input { width:100%; padding:9px 12px 9px 38px; border:0; border-radius:8px; background:#f1f3f6; }
#qRes { position:absolute; top:calc(100% + 4px); left:0; right:0; background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:0 10px 30px rgba(0,0,0,.15);
  max-height:60vh; overflow:auto; padding:6px; z-index:30; }
.q-group { font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); padding:8px 10px 4px; }
.q-hit { display:flex; justify-content:space-between; gap:12px; width:100%; background:none; color:var(--ink); text-align:left; padding:8px 10px; border-radius:6px; }
.q-hit:hover, .q-hit:focus { background:#eef4ff; }
nav.subnav { margin-left:var(--side); border-bottom:1px solid var(--line); padding:0 24px; gap:0; overflow-x:auto; flex-wrap:nowrap; }
nav.subnav a { border-radius:0; padding:12px 14px; border-bottom:3px solid transparent; white-space:nowrap; }
nav.subnav a.on, nav.subnav a:hover { background:none; color:var(--ink); border-bottom-color:#1a7f37; font-weight:600; }
.side ~ main { margin-left:calc(var(--side) + 16px); margin-right:16px; max-width:1240px; }
@media (min-width:1360px) { .side ~ main { margin-left:auto; margin-right:auto; padding-left:var(--side); max-width:calc(1240px + var(--side)); } }

/* menus */
.menu-dlg { width:min(640px, calc(100vw - 24px)); }
.menu-head { display:flex; justify-content:space-between; align-items:center; } .menu-head h2 { margin:0; }
.menu-body { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:8px 20px; margin-top:12px; }
.menu-col h3 { font-size:12px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin:6px 0; }
.menu-item { display:block; width:100%; text-align:left; background:none; color:var(--ink); padding:9px 10px; border-radius:6px; }
.menu-item:hover { background:#eef4ff; color:var(--brand); }

/* ===== home ===== */
.hello { text-align:center; font-size:34px; font-weight:500; margin:24px 0 20px; }
.hubs { display:flex; flex-wrap:wrap; justify-content:center; gap:10px; margin-bottom:24px; }
.hub { display:inline-flex; align-items:center; gap:10px; padding:6px 18px 6px 6px; border:1px solid var(--line); border-radius:40px; background:#fff;
  color:var(--ink); text-decoration:none; font-weight:600; white-space:nowrap; }
.hub:hover { border-color:#9aa3b0; box-shadow:0 2px 8px rgba(0,0,0,.06); }
.hub-ic { width:38px; height:38px; border-radius:50%; display:grid; place-items:center; color:#fff; }
.hub-ic svg { width:20px; height:20px; }
.actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom:24px; }
.actions-h { font-size:17px; font-weight:500; margin-right:6px; }
.pill { background:#fff; color:var(--ink); border:1.5px solid #8d95a1; border-radius:24px; padding:7px 16px; font-weight:500; white-space:nowrap; }
.pill:hover { border-color:var(--ink); }
button.link.strong { font-weight:600; font-size:15px; }
.glance { font-size:19px; font-weight:500; margin:0 0 14px; }
.widgets { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:20px; margin-bottom:24px; }
.widget { background:var(--card); border:1px solid #d4d7dc; border-radius:10px; padding:20px 22px; min-width:0; display:flex; flex-direction:column; gap:8px; }
.widget.span2 { grid-column:span 2; } .widget.span3 { grid-column:1 / -1; }
.w-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:4px; }
.w-head h3 { margin:0; font-size:15px; font-weight:500; text-transform:uppercase; letter-spacing:.4px; }
select.w-period { border:0; background:none; padding:2px; font-size:13px; color:var(--ink); min-height:0; cursor:pointer; }
.big { font-size:32px; font-weight:400; font-variant-numeric:tabular-nums; line-height:1.15; }
.big.neg { color:var(--bad); }
.delta { font-size:14px; font-weight:600; } .delta.up { color:#116329; } .delta.down { color:var(--bad); } .delta .muted { font-weight:400; font-size:14px; }
.w-lead { font-size:18px; font-weight:600; margin:4px 0; }
.w-empty { display:grid; place-items:center; flex:1; min-height:90px; } .w-empty svg { width:64px; height:64px; padding:16px; border-radius:50%; background:#eef1f5; color:var(--ink); }
.w-foot { margin-top:auto; padding-top:8px; color:var(--brand); text-decoration:none; }
.w-row { display:flex; justify-content:space-between; gap:12px; padding:6px 0; border-top:1px solid var(--line); font-size:13px; }
.good { color:#116329; }
.wide-pill { width:100%; margin-top:auto; border-radius:6px; }
.todo { display:flex; flex-direction:column; }
.todo-item { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 0; border-top:1px solid var(--line); color:var(--ink); text-decoration:none; }
.todo-item:first-child { border-top:0; }
.todo-item b { display:block; font-weight:600; } .todo-item > span:last-child { font-size:22px; color:var(--muted); }
.plbar { margin-top:10px; display:grid; grid-template-columns:110px 1fr; align-items:end; gap:12px; }
.plbar b { display:block; font-size:18px; font-weight:500; }
.track { display:block; height:30px; } .fill { display:block; height:100%; border-radius:0 4px 4px 0; }
.donut-wrap { display:flex; align-items:center; gap:16px; margin-top:6px; }
.donut { width:140px; height:140px; flex:0 0 140px; } .donut circle { fill:none; stroke-width:26; }
.donut-legend { display:flex; flex-direction:column; gap:7px; min-width:0; flex:1; font-size:13px; }
.donut-legend div { display:flex; align-items:center; gap:6px; } .lg-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; flex:0 0 10px; margin-right:4px; vertical-align:middle; }
.legend { display:flex; gap:16px; flex-wrap:wrap; font-size:13px; color:var(--muted); } .legend b { color:var(--ink); font-weight:600; }
.stack { display:flex; gap:2px; height:22px; margin:6px 0 2px; } .stack > span { border-radius:4px; min-width:4px; }
.accts > div { display:flex; align-items:center; gap:10px; padding:8px 0; border-top:1px solid var(--line); }
.accts > div > span:nth-child(2) { flex:1; min-width:0; } .accts b { display:block; font-weight:600; }
.acct-ic { width:32px; height:32px; border-radius:50%; background:#eef1f5; display:grid; place-items:center; flex:0 0 32px; }
.cols { position:relative; display:flex; align-items:flex-end; gap:2px; height:150px; border-bottom:1px solid #9aa3b0; padding-top:18px; margin-top:6px; }
.cols .col { flex:1; display:flex; align-items:flex-end; height:100%; cursor:default; }
.cols .col > span { display:block; width:100%; border-radius:4px 4px 0 0; background:var(--s1); }
.cols .col:hover > span { background:#1c5cab; }
.cols-max { position:absolute; top:0; left:0; font-size:11px; color:var(--muted); }
.col-labels { display:flex; gap:2px; font-size:11px; color:var(--muted); } .col-labels span { flex:1; text-align:center; }
table.mini td { padding:5px 4px; font-size:13px; }
.recent > div { display:flex; align-items:center; gap:12px; padding:9px 0; border-top:1px solid var(--line); font-size:13px; }
.recent > div:first-child { border-top:0; }
.rc-what { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
details summary { cursor:pointer; color:var(--brand); }
#tip { position:fixed; pointer-events:none; background:#1d2433; color:#fff; padding:6px 10px; border-radius:6px; font-size:12px; z-index:60; display:none; white-space:nowrap; }
.side-btn:focus-visible, .hub:focus-visible, .pill:focus-visible, .todo-item:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }

@media (max-width:1100px) { .widgets { grid-template-columns:repeat(2, minmax(0, 1fr)); } .widget.span2 { grid-column:1 / -1; } }

/* phones: sidebar becomes a bottom tab bar */
@media (max-width:700px) {
  .side { inset:auto 0 0 0; width:auto; height:64px; flex-direction:row; padding:4px 4px calc(4px + env(safe-area-inset-bottom)); border-right:0; border-top:1px solid var(--line);
    overflow:visible; justify-content:space-around; background:#fff; }
  .side .brand, .side-gap, .side [data-hub="reports"], .side [data-hub="tax"], .side [data-hub="accounting"], .side [data-hub="settings"], .side a[href="simple.html"] { display:none; }
  .mob-only { display:flex !important; }
  .side-btn { flex:1; padding:6px 0; font-size:11px; border-radius:8px; min-height:0; }
  .side [data-create] { order:2; color:var(--brand); }
  .side [data-hub="home"] { order:0; } .side [data-hub="sales"] { order:1; } .side [data-hub="expenses"] { order:3; } .side [data-more] { order:4; }
  .topbar, nav.subnav, .side ~ main { margin-left:0; }
  .side ~ main { margin:12px auto 0; padding:0 12px 84px; max-width:none; }
  .topbar { flex-wrap:wrap; gap:8px; padding:10px 12px; position:static; }
  .topbar b { max-width:100%; }
  .search { flex-basis:100%; max-width:none; }
  nav.subnav { padding:0 4px; }
  .flash { bottom:76px; }
  .hello { font-size:24px; margin:8px 0 14px; }
  .hubs, .actions { flex-wrap:nowrap; overflow-x:auto; justify-content:flex-start; scrollbar-width:none; padding:0 12px 4px; margin-left:-12px; margin-right:-12px; }
  .hub { padding-right:14px; } .hub-ic { width:32px; height:32px; }
  .actions-h { display:none; }
  .widgets { grid-template-columns:1fr; gap:12px; }
  .widget { padding:16px; }
  .big { font-size:28px; }
  .plbar { grid-template-columns:90px 1fr; }
  .donut { width:120px; height:120px; flex-basis:120px; }
  .col-labels span:nth-child(even) { visibility:hidden; }
  .recent > div { flex-wrap:wrap; gap:4px 10px; } .rc-what { flex-basis:100%; order:3; white-space:normal; }
}
