/* Bismillah Dokan — silver theme. Green is only for money received, amber only for money due. */
:root {
  --bg: #F2F3F5;
  --surface: #FFFFFF;
  --surface-2: #F8F9FA;
  --ink: #1C1F24;
  --ink-2: #3F454D;
  --muted: #5D636B;
  --line: #DFE2E6;
  --line-soft: #ECEEF1;
  --input-line: #C8CDD3;
  --primary: #2E3440;          /* graphite */
  --primary-ink: #FFFFFF;
  --nav-on: #E4E7EB;
  --received: #0F6B4F;
  --due: #9A4A08;
  --due-bg: #FFF8F1;
  --due-line: #F3D9BF;
  --bdt-bg: #E6ECF7;
  --bdt-ink: #1F3F7A;
  --silver: linear-gradient(135deg, #FBFBFC 0%, #D9DDE2 40%, #F4F5F7 55%, #A9B0B8 100%);
  --radius: 12px;
  --font: "Inter", "Noto Sans Bengali", system-ui, sans-serif;
  --font-brand: "Cinzel", Georgia, serif;
}
html[lang="bn"] { --font: "Noto Sans Bengali", "Inter", system-ui, sans-serif; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--primary); }
a:hover { color: #000; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.received { color: var(--received); font-weight: 600; }
.due { color: var(--due); font-weight: 700; }

/* Shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 220px; max-width: 260px; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.content { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 22px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; text-decoration: none; color: var(--ink); }
.brand-tile { width: 36px; height: 36px; border-radius: 9px; background: var(--silver); border: 1px solid #B8BEC6; color: var(--primary); display: flex; align-items: center; justify-content: center; font-family: var(--font-brand); font-weight: 700; font-size: 15px; }
.brand-name { font-family: var(--font-brand); font-weight: 700; font-size: 15px; letter-spacing: 0.04em; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--nav-on); color: var(--ink); font-weight: 600; }

.userbox { margin-top: auto; padding: 12px; border-radius: 10px; background: var(--bg); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.lang { display: flex; gap: 6px; }
.lang button { font: inherit; font-size: 12px; min-width: 40px; height: 32px; border-radius: 6px; border: 1px solid var(--input-line); background: var(--surface); color: var(--ink); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card.due-card { background: var(--due-bg); border-color: var(--due-line); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--input-line); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1C1F24; color: #fff; }

.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--primary); color: #fff; }
.pill.bdt { background: var(--bdt-bg); color: var(--bdt-ink); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { font: inherit; font-size: 15px; font-weight: 400; height: 44px; border: 1px solid var(--input-line); border-radius: 8px; padding: 0 12px; background: var(--surface); color: var(--ink); width: 100%; }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.errorlist { margin: 0; padding: 0; list-style: none; color: #A11A1A; font-size: 13px; }

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { padding: 12px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }

table.ledger { border-collapse: collapse; width: 100%; font-size: 14px; }
table.ledger th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.ledger td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
table.ledger .num { text-align: right; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* Layout helpers */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.card.flush { padding: 16px 8px 6px; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 12px 8px; }
.card-head a { font-size: 13px; font-weight: 500; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.back { font-size: 13px; font-weight: 500; text-decoration: none; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-danger { border-color: #E3B4B4; color: #8E1B1B; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--input-line); border-radius: 8px; padding: 0 12px; height: 44px; flex: 1 1 260px; max-width: 420px; }
.search input { border: 0; outline: 0; font: inherit; font-size: 14px; flex: 1; background: transparent; min-width: 0; }
.search:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Chips and tabs */
.chip { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--input-line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--primary); }

/* Entry type badges */
.k { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #ECEEF1; color: var(--ink-2); }
.k-pay { background: #E3EFE9; color: #0A4D39; }
.k-trans { background: #FFF1E2; color: #7A3E0A; }
.k-adj { background: #EEE9F7; color: #4A2F7A; }
.k-open { background: var(--bdt-bg); color: var(--bdt-ink); }
tr.void td { color: var(--muted); text-decoration: line-through; }
tr.void td.keep { text-decoration: none; }
.flag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: #FDECEC; color: #8E1B1B; }

/* Segmented radio (entry type) */
.seg { display: flex; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; height: 42px; padding: 0 14px; border: 1px solid var(--input-line); margin-left: -1px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg label:first-child span { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg label:last-child span { border-radius: 0 8px 8px 0; }
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; position: relative; z-index: 1; }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: start; }
.form-grid > .btn { align-self: end; }
.actions { flex: 1 1 420px; justify-content: flex-end; }
.field textarea { height: auto; padding: 10px 12px; }
.field .help { font-weight: 400; font-size: 12px; color: var(--muted); }

table.ledger tfoot td { font-weight: 700; border-bottom: 0; background: var(--surface-2); }
table.ledger tr.year-row td { background: var(--surface-2); font-weight: 600; }
table.ledger a.rowlink { color: inherit; text-decoration: none; }
table.ledger a.rowlink:hover { text-decoration: underline; }

/* Print: just the statement */
@media print {
  .sidebar, .no-print, .messages { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; }
  .card, .table-wrap { border-color: #bbb; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* Login */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 760px) {
  /* Phone: the sidebar becomes a compact top bar with a sideways-scrolling menu. */
  .sidebar { max-width: none; flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line);
             padding: 10px 12px 0; gap: 8px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { flex: 1 1 auto; min-width: 0; padding: 0; }
  .brand-name { font-size: 13px; }
  .brand-sub { display: none; }
  .brand-tile { width: 30px; height: 30px; font-size: 13px; }
  .userbox form { display: flex; gap: 4px; }
  .userbox { order: 2; margin: 0; padding: 0; background: none; flex-direction: row; align-items: center; gap: 6px; }
  .userbox > div:first-child { display: none; }
  .userbox .btn { height: 32px !important; width: auto !important; padding: 0 10px; font-size: 12px; }
  .lang button { min-width: 34px; height: 32px; }
  .sidebar, .nav { min-width: 0; }
  .nav { order: 3; flex-basis: 100%; flex-direction: row; overflow-x: auto; gap: 2px; padding-bottom: 6px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .content { padding: 18px 16px; }
}
