:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --brand-soft: #dcfce7;
  --danger: #dc2626;
  --wa: #25d366;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --indigo: #4f46e5; --indigo-soft: #eef2ff;
  --green: #16a34a;  --green-soft: #dcfce7;
  --blue: #2563eb;   --blue-soft: #dbeafe;
  --rose: #e11d48;   --rose-soft: #ffe4e6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
svg { flex: none; }
h1, h2, b, .statName, .entryTop b, .checkItem b { overflow-wrap: anywhere; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  font-family: "Inter", "Noto Sans Telugu", system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1em; margin: 6px 0; font-size: 14px; }
.note { color: var(--brand-dark); font-weight: 600; font-size: 14px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 9px 14px; font-weight: 600; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(.95); }
.btn.outline { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; padding: 12px; }
.ghost {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 10px; padding: 8px 12px; font-weight: 500;
}
.ghost:hover { background: #f9fafb; }
.ghost.small { padding: 5px 10px; font-size: 13px; }
.iconOnly { padding: 8px; }
.iconBtn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.iconBtn:hover { background: #f3f4f6; color: var(--text); }
.iconBtn.danger:hover { background: #fef2f2; color: var(--danger); }

input:not([type=checkbox]) {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
label > span { display: block; margin-bottom: 6px; }
label small { color: var(--muted); font-weight: 400; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #dcfce7 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #e0f2fe 0%, transparent 60%), var(--bg);
}
.loginCard {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px;
  padding: 28px; box-shadow: 0 10px 40px rgba(16, 24, 40, .08); position: relative;
}
.loginCard .langBtn { position: absolute; top: 16px; right: 16px; }
.loginLogo {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-dark); margin-bottom: 14px;
}
.loginCard h1 { font-size: 24px; }
.loginCard p.muted { margin: 4px 0 22px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: none;
  background: transparent; padding: 10px 12px; border-radius: 10px; color: #374151; font-weight: 500;
}
.nav button:hover { background: #f3f4f6; }
.nav button.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.userChip {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.userChip small { display: block; color: var(--muted); font-size: 12px; }
.userChip b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700;
}

.main { padding: 24px 28px 40px; min-width: 0; max-width: 1280px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.topbar h1 { font-size: 26px; font-weight: 700; }
.topbar p { margin: 2px 0 0; font-size: 14px; }
.topActions { display: flex; gap: 8px; }

/* ---------- Period filter ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.seg {
  display: flex; gap: 2px; background: #e9ecef; padding: 4px; border-radius: 12px;
  overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: none; background: transparent; padding: 7px 12px; border-radius: 9px; white-space: nowrap;
  font-size: 14px; font-weight: 500; color: #4b5563;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.custom { display: flex; align-items: center; gap: 8px; }
.custom input { width: auto; padding: 7px 10px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel.flush { padding: 0; overflow: hidden; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, box-shadow .15s;
  border-top: 4px solid var(--c);
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .08); }
.stat:focus-visible { outline: 3px solid rgba(22, 163, 74, .35); }
.statTop { display: flex; align-items: center; gap: 10px; }
.statName { font-weight: 600; flex: 1; }
.statValue { font-size: 28px; font-weight: 700; margin-top: 14px; letter-spacing: -.02em; color: var(--c); }
.statMeta { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--muted); }
.statMeta span { display: flex; justify-content: space-between; gap: 8px; }
.statMeta b { color: var(--text); font-weight: 600; }
.addSmall {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; color: var(--c);
}
.addSmall:hover { background: var(--cs); }

.badge {
  flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--cs); color: var(--c);
}
.indigo { --c: var(--indigo); --cs: var(--indigo-soft); }
.green  { --c: var(--green);  --cs: var(--green-soft); }
.blue   { --c: var(--blue);   --cs: var(--blue-soft); }
.rose   { --c: var(--rose);   --cs: var(--rose-soft); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid #f1f2f4; }
.list li:last-child { border-bottom: none; }
.list li[data-view] { cursor: pointer; border-radius: 8px; }
.list li[data-view]:hover { background: #f9fafb; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .grow small { color: var(--muted); font-size: 13px; }
.list .value { font-weight: 700; white-space: nowrap; }
.list .empty, td.empty { color: var(--muted); justify-content: center; text-align: center; padding: 28px; }

/* ---------- Book ---------- */
.bookBar { display: flex; gap: 10px; margin-bottom: 12px; }
.searchBox { position: relative; flex: 1; max-width: 420px; }
.searchBox span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.searchBox input:not([type=checkbox]) { padding-left: 38px; }
.bookBar .btn { margin-left: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--muted); }
.chip b { color: var(--text); margin-left: 4px; }

.wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 600; background: #f9fafb; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid #f1f2f4; white-space: nowrap; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }
td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.rowBtns { text-align: right; width: 1%; }

/* ---------- Reports ---------- */
.reportPanel { max-width: 760px; padding: 0; }
.step { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.step:last-of-type { border-bottom: none; }
.stepHead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stepHead h2 { margin: 0; font-size: 16px; flex: 1; }
.stepNo {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 700;
}
.stepSub { margin: -6px 0 10px 36px; }
.linkBtn { border: none; background: none; color: var(--brand-dark); font-weight: 600; font-size: 14px; padding: 4px; }
.checkList { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checkItem {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 12px; transition: border-color .15s, background .15s;
}
.checkItem.on { border-color: var(--brand); background: #f0fdf4; }
.checkItem input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); flex: none; cursor: pointer; }
.checkItem .grow { flex: 1; min-width: 0; }
.checkItem b { display: block; font-weight: 600; }
.checkItem small { color: var(--muted); font-size: 13px; font-weight: 400; }
details.msg { margin-top: 12px; }
details.msg summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; font-size: 14px; }
.reportPanel .note { padding: 0 20px 16px; margin: 0; }
.reportPanel .note:empty { display: none; }
.actionBar { display: flex; gap: 10px; max-width: 760px; margin-top: 14px; }
.actionBar .btn { flex: 1; padding: 13px; font-size: 15px; }
.actionBar .btn:disabled { opacity: .45; cursor: not-allowed; }
.drop {
  display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px dashed #d1d5db;
  border-radius: 12px; cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s;
}
.drop:hover { border-color: var(--brand); background: #f0fdf4; color: var(--brand-dark); }
.drop b { display: block; color: var(--text); }
.drop small { font-weight: 400; }
.attachList { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.attachList li {
  display: flex; align-items: center; gap: 6px; background: #f3f4f6; border-radius: 999px;
  padding: 2px 4px 2px 10px; font-size: 13px; max-width: 100%;
}
.attachList span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachList .iconBtn { width: 24px; height: 24px; }
.preview {
  white-space: pre-wrap; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 12px;
  font-size: 13px; overflow: auto; margin: 10px 0 0; font-family: inherit;
}

/* ---------- Dialog ---------- */
dialog {
  border: none; border-radius: 18px; padding: 24px; width: calc(100% - 32px); max-width: 460px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .2);
}
dialog::backdrop { background: rgba(17, 24, 39, .45); backdrop-filter: blur(2px); }
dialog h2 { font-size: 19px; margin-bottom: 18px; }
.formButtons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- Book cards (phone) ---------- */
.phoneOnly { display: none !important; }
.entryCards { flex-direction: column; gap: 10px; }
.entry {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c);
  border-radius: 12px; padding: 14px; box-shadow: var(--shadow);
}
.entryTop { display: flex; align-items: flex-start; gap: 10px; }
.entryTop .grow { flex: 1; min-width: 0; }
.entryTop b { display: block; font-size: 15px; font-weight: 600; line-height: 1.3; }
.entryTop small { color: var(--muted); font-size: 13px; }
.entryValue { text-align: right; }
.entryValue strong { display: block; font-size: 17px; font-weight: 700; color: var(--c); white-space: nowrap; }
.entryValue small { font-size: 11px; color: var(--muted); }
.entryGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--border); }
.entryGrid dt { font-size: 12px; color: var(--muted); }
.entryGrid dd { margin: 0; font-size: 14px; font-weight: 500; word-break: break-word; }
.entryBtns { display: flex; gap: 8px; margin-top: 12px; }
.entryBtns .btn { flex: 1; }
.dangerText { color: var(--danger); }
.emptyCard { text-align: center; color: var(--muted); padding: 32px 12px; background: var(--surface); border-radius: 12px; border: 1px dashed var(--border); }
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 11;
  width: 58px; height: 58px; border-radius: 50%; border: none; background: var(--brand); color: #fff;
  box-shadow: 0 8px 24px rgba(22, 163, 74, .4); place-items: center;
}

/* ---------- Lists shared by phone + computer ---------- */
.periodBtn, .bookTabs { display: none; }
.dayHead { font-size: 13px; font-weight: 600; color: var(--muted); padding: 14px 2px 6px; }
.dayHead:first-child { padding-top: 0; }
.dayGroup { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.eRow {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: none;
  background: var(--surface); padding: 12px; border-bottom: 1px solid #f1f2f4;
}
.eRow:last-child { border-bottom: none; }
.eRow:hover, .eRow:active { background: #f9fafb; }
.eRow .badge { width: 36px; height: 36px; }
.eRow .grow { flex: 1; min-width: 0; }
.eRow b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eRow small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eVal { font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--c); }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }

/* Sheets (pop-ups) */
.choiceGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px; text-align: center;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); font-weight: 600; font-size: 14px;
}
.choice:active { border-color: var(--c); background: var(--cs); }
.choice .badge { width: 48px; height: 48px; border-radius: 14px; }
.optionList { display: flex; flex-direction: column; }
.optionList button {
  display: flex; justify-content: space-between; align-items: center; border: none; background: none;
  padding: 15px 6px; font-size: 16px; border-bottom: 1px solid #f1f2f4; text-align: left;
}
.optionList button.on { color: var(--brand-dark); font-weight: 700; }
.detailHead { display: flex; align-items: center; gap: 12px; }
.detailHead .badge { width: 44px; height: 44px; }
.detailHead small { display: block; color: var(--muted); font-size: 13px; }
.detailHead b { font-size: 18px; line-height: 1.3; }
.detailValue { font-size: 30px; font-weight: 700; color: var(--c); margin: 14px 0 6px; letter-spacing: -.02em; }
.detailGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0 0 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.detailGrid dt { font-size: 12px; color: var(--muted); }
.detailGrid dd { margin: 2px 0 0; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
dialog .btn.wide { margin-top: 10px; }

/* ---------- Phone ---------- */
.bottomNav { display: none; }
@media (max-width: 860px) {
  /* Green app bar */
  .main { padding-top: 0 !important; }
  .topbar {
    position: sticky; top: 0; z-index: 8; margin: 0 -16px 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    background: var(--brand-dark); color: #fff; align-items: center;
  }
  .topbar h1 { color: #fff; }
  .topbar #showing { display: none; }
  .topbar .ghost { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }

  /* One time button instead of six */
  .seg { display: none !important; }
  .periodBtn {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 15px; text-align: left;
    box-shadow: var(--shadow);
  }
  .periodBtn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .periodBtn svg { color: var(--brand-dark); }
  .filters { margin: 0 0 14px !important; padding: 0 !important; flex-direction: column; align-items: stretch; }

  /* Home: books list */
  .bookList { flex-direction: column; padding: 6px 14px; }
  .bookList h2 { margin: 8px 0 4px; }
  .bookRow {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: none; background: none;
    padding: 14px 0; border-bottom: 1px solid #f1f2f4;
  }
  .bookRow:last-child { border-bottom: none; }
  .bookRow .badge { width: 44px; height: 44px; border-radius: 12px; }
  .bookRow .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .bookName { font-weight: 600; font-size: 15px; color: var(--text); }
  .bookValue { font-weight: 700; font-size: 22px; color: var(--c); letter-spacing: -.02em; line-height: 1.25; }
  .bookSub { font-size: 13px; color: var(--muted); }
  .chev { color: #c0c4cc; display: flex; }
  #dashboard > .panel { margin-bottom: 14px; }

  /* Book: 4 book tabs */
  .bookTabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .bookTabs button {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: 12px;
    border: 1.5px solid var(--border); background: var(--surface); color: var(--muted); font-size: clamp(11px, 3.2vw, 13px); font-weight: 600;
  }
  .bookTabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bookTabs button.active { border-color: var(--c); background: var(--cs); color: var(--c); }
  #totals { margin-bottom: 10px; }

  /* Bottom menu: Home · Entries · + Add · Reports */
  .bottomNav button.navAdd { color: var(--brand-dark); font-weight: 600; }
  .navAddCircle {
    width: 50px; height: 50px; border-radius: 50%; margin-top: -24px; display: grid; place-items: center;
    background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(22, 163, 74, .45); border: 4px solid var(--surface);
  }

  .phoneOnly { display: flex !important; }
  .fab.phoneOnly { display: grid !important; }
  .desktopOnly { display: none !important; }
  input:not([type=checkbox]) { font-size: 16px; padding: 12px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px 16px 96px; }
  .topbar h1 { font-size: clamp(19px, 5.6vw, 22px); line-height: 1.25; }
  .topbar > div:first-child { min-width: 0; }
  .topActions { flex: none; }
  .topbar { margin-bottom: 12px; }
  .topbar p { font-size: 13px; }
  .langBtn { padding: 7px 10px; font-size: 14px; }
  .filters { margin: 0 -16px 14px; padding: 0 16px; }
  .seg { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .seg button { padding: 9px 4px; font-size: clamp(12px, 3.5vw, 14px); white-space: normal; line-height: 1.2; }
  .custom { width: 100%; }
  .custom input { flex: 1; }

  /* Dashboard: 2 small cards per row */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat { padding: 12px; min-width: 0; }
  .stat:hover { transform: none; }
  /* top row: icon ... + ; name on its own line below */
  .statTop { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
  .statTop .badge { width: 34px; height: 34px; grid-column: 1; grid-row: 1; }
  .addSmall { width: 34px; height: 34px; grid-column: 3; grid-row: 1; }
  .statName { grid-column: 1 / -1; grid-row: 2; font-size: 13.5px; line-height: 1.3; margin-top: 2px; }
  .statValue { font-size: clamp(17px, 5.4vw, 22px); margin-top: 6px; overflow-wrap: anywhere; }
  .statMeta { display: none; }
  .panel { padding: 14px; }
  .list .grow b { white-space: normal; font-size: 14px; }

  /* Book */
  .bookBar #add { display: none; }
  .chip { white-space: nowrap; font-size: 13px; }
  #bookView { padding-bottom: 70px; }

  /* Reports */
  .reportPanel { padding: 0; }
  .step { padding: 16px 14px; }
  .stepSub { margin-left: 0; }
  .actionBar {
    position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 9;
    margin: 0; padding: 10px 12px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
    backdrop-filter: blur(6px);
  }
  .actionBar .btn { font-size: 14px; padding: 12px 10px; }
  .actionBar #dlSelected { flex: 0 0 auto; }
  #reportsView { padding-bottom: 80px; }

  /* Form opens from the bottom */
  dialog { margin: auto 0 0; width: 100%; max-width: none; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; }
  .formButtons .btn { flex: 1; padding: 13px; }
  .bottomNav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomNav button {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    border: none; background: transparent; color: var(--muted); font-size: clamp(11px, 3.3vw, 12.5px); padding: 6px 1px; border-radius: 10px;
  }
  .bottomNav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottomNav button.active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }
  .bookBar { flex-wrap: wrap; }
  .searchBox { max-width: none; }
}
.dayList { flex-direction: column; }

/* ---------- Dropdowns look like the other boxes ---------- */
select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  font: inherit; color: inherit; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}
select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }

/* ---------- Book page: Today / This month / Last month / Till now ---------- */
.totalsArea { margin-bottom: 14px; }
.quickBoxes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.qBox {
  text-align: left; background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; min-width: 0; display: flex; flex-direction: column;
}
.qBox:hover { border-color: var(--c); }
.qBox.on { border-color: var(--c); background: var(--cs); }
.qLabel { font-weight: 700; font-size: 16px; }
.qSub { font-size: 12.5px; color: var(--muted); min-height: 1.2em; }
.qBox b { font-size: 24px; font-weight: 800; color: var(--c); margin-top: 6px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.qBox small { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.totalsArea .hint { margin: 8px 2px 0; }

/* Home: expenses today / this month / last month */
.todayCard { margin-bottom: 18px; border-top: 4px solid var(--rose); }
.todayCard h2 { color: var(--rose); }
.todayGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tBox {
  text-align: left; border: 1.5px solid var(--border); background: #fff7f8; border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; min-width: 0; cursor: pointer;
}
.tBox:hover { border-color: var(--rose); }
.tBox span { font-weight: 700; font-size: 15px; }
.tBox b { font-size: 24px; font-weight: 800; color: var(--rose); margin: 4px 0 2px; overflow-wrap: anywhere; }
.tBox small { color: var(--muted); font-size: 12.5px; }
tr.click { cursor: pointer; }

/* ---------- Bills ---------- */
.billArea { border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 12px; margin: 4px 0 12px; }
.billTitle { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.billTitle small { color: var(--muted); font-weight: 400; }
.billBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.billBtns .btn { margin: 0; font-size: 14px; padding: 11px 8px; cursor: pointer; }
.billThumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.billThumbs:empty { display: none; }
.thumb {
  position: relative; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: #f3f4f6;
  border: 1px solid var(--border); display: grid; place-items: center; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tPdf { display: flex; flex-direction: column; align-items: center; color: var(--rose); font-weight: 700; font-size: 11px; }
.tUp { font-size: 11px; color: var(--muted); text-align: center; padding: 4px; }
.tRm {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; border: none;
  background: rgba(17, 24, 39, .7); color: #fff; display: grid; place-items: center; padding: 0;
}
.billHead { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 0 0 8px; }

/* ---------- Users ---------- */
.userList { display: grid; gap: 10px; margin-top: 12px; }
.userCard { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px; flex-wrap: wrap; }
.userCard.off { opacity: .6; }
.userCard .grow { flex: 1; min-width: 180px; }
.userCard b { display: block; }
.userCard small { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.roleTag { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #f3f4f6; color: #374151; }
.roleTag.superadmin { background: #ede9fe; color: #6d28d9; }
.roleTag.staff { background: var(--brand-soft); color: var(--brand-dark); }
.roleTag.off { background: #fee2e2; color: #b91c1c; }
.userBtns { display: flex; gap: 6px; flex-wrap: wrap; }
#usersView .stepHead h2 { flex: 1; }

@media (max-width: 860px) {
  .quickBoxes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .qBox { padding: 12px; }
  .qBox b { font-size: clamp(18px, 5.6vw, 22px); }
  .todayGrid { gap: 8px; }
  .tBox { padding: 10px; }
  .tBox span { font-size: 13.5px; }
  .tBox b { font-size: clamp(15px, 4.6vw, 20px); }
  select { font-size: 16px; padding: 12px 38px 12px 12px; }
  .userBtns { width: 100%; }
  .userBtns .btn { flex: 1; }
}

.usersTop { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.usersTop p { margin: 0; flex: 1; }
@media (max-width: 860px) { .usersTop { flex-direction: column; align-items: stretch; } }

/* ---------- Login: Google ---------- */
.googleBox { margin-bottom: 6px; }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }
.orLine { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.orLine::before, .orLine::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Banner: trial / plan ended / change password ---------- */
.banner { display: grid; gap: 8px; margin-bottom: 14px; }
.bLine { border-radius: 12px; padding: 11px 14px; font-size: 14px; font-weight: 500; line-height: 1.45; border: 1px solid; }
.bLine.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.bLine.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.bLine.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.bLine .linkBtn { color: inherit; text-decoration: underline; padding: 0 2px; font-size: 14px; }

/* Plan ended: can see and download, not add or change */
body.readonly .navAdd, body.readonly #add, body.readonly .addSmall, body.readonly #detailEdit,
body.readonly #detailDel, body.readonly .rowBtns, body.readonly #addUser, body.readonly .userBtns { display: none !important; }

/* ---------- My account ---------- */
.acctInfo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.acctInfo span { display: block; font-size: 12px; color: var(--muted); }
.acctInfo b { font-size: 14.5px; overflow-wrap: anywhere; }
#pwForm h3 { font-size: 15px; margin: 0 0 10px; }
.pwRow { display: flex; gap: 8px; }
.pwRow .btn { flex: none; }
.userChip { cursor: pointer; }

/* ---------- Clients (platform admin) ---------- */
.clientStats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.cStat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.cStat span { display: block; font-size: 13px; color: var(--muted); }
.cStat b { font-size: 26px; font-weight: 800; }
.clientsTop { margin-bottom: 14px; }
.clientList { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.clientCard { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.clientCard.off { background: #fafafa; }
.cTop { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cTop .grow { flex: 1; min-width: 0; }
.cTop b { display: block; font-size: 16px; }
.cTop small { color: var(--muted); font-size: 12.5px; }
.cRows { display: grid; gap: 8px; padding: 12px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.cRows span { display: block; font-size: 12px; color: var(--muted); }
.cRows b { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.warnText { display: block; color: #b45309; font-size: 12.5px; margin-top: 2px; }
.cBtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.roleTag.trial { background: #fef3c7; color: #92400e; }
.roleTag.paid { background: var(--brand-soft); color: var(--brand-dark); }
.roleTag.owner { background: #ede9fe; color: #6d28d9; }

@media (max-width: 860px) {
  .clientStats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .clientList { grid-template-columns: 1fr; }
  .cBtns .btn { flex: 1 1 30%; }
  body[data-page="clients"] .main { padding-bottom: 24px; }
}
