/* SPS Ledger — small, mobile-first stylesheet. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5b6675;
  --line: #d9dee5;
  --accent: #1d5fbf;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok-bg: #e7f6ec;
  --ok-text: #14532d;
  --err-bg: #fdecea;
  --err-text: #7a1a12;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --card: #1b212a;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --line: #2e3744;
    --accent: #5b9bff;
    --accent-text: #0b1220;
    --danger: #ff7b72;
    --ok-bg: #12301f;
    --ok-text: #b7f0c9;
    --err-bg: #3a1714;
    --err-text: #ffc9c3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Nirmala UI", sans-serif;
  overflow-wrap: anywhere;
}
/* Bengali script has tall vowel signs: give lines a little more room. */
html:lang(bn) body { line-height: 1.7; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.4rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 0.75rem; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.top > * { min-width: 0; max-width: 100%; }
.logout { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
.logout button { flex: 0 0 auto; }
.who { color: var(--muted); font-size: 0.9rem; }
.lang { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem; color: var(--muted); }
.lang a, .lang strong {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
  border-radius: 6px;
}
.lang strong { color: var(--text); }
.lang a:hover, .lang a:focus-visible { background: var(--bg); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.nav a {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  text-decoration: none;
  white-space: normal;
}
.nav a:hover, .nav a:focus-visible { background: var(--bg); }

main { min-width: 0; max-width: 1100px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  max-width: 640px;
}
.card > * { min-width: 0; }
.card.narrow { max-width: 380px; }
label { display: grid; min-width: 0; gap: 0.25rem; font-weight: 600; font-size: 0.95rem; }
label.check { display: flex; align-items: center; min-height: 44px; gap: 0.5rem; font-weight: 400; }
input, select {
  font: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
input[type="checkbox"] { flex: 0 0 1.25rem; width: 1.25rem; height: 1.25rem; min-height: 1.25rem; margin: 0; }
button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button.small { padding: 0.45rem 0.75rem; font-size: 1rem; }
button.danger { background: var(--danger); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0.45rem 0.5rem; }
form.inline { display: inline-flex; flex-wrap: wrap; min-width: 0; max-width: 100%; gap: 0.5rem; align-items: center; margin: 0; }
form.inline input:not([type="hidden"]) { flex: 1 1 12rem; width: 12rem; min-width: 0; padding: 0.45rem 0.5rem; }
.scroll form.inline { width: 14rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 1rem; }
.filters label { flex: 1 1 10rem; max-width: 100%; }
.filters label.check { flex: 0 1 auto; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.actions a, .actions strong { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 6px; }
.actions a:hover { background: var(--card); }
.actions strong { background: var(--card); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 0.75rem; }
.stat { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: 0.8rem; }

.scroll { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.scroll:focus-visible { outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: normal; }
th { background: var(--bg); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Wrap translated headings, never truncate or wrap the financial amounts. */
th.num { min-width: 7.5rem; white-space: normal; }
/* first column is a date or period (YYYY-MM-DD) in ledger tables: keep it on one line */
td:first-child { white-space: nowrap; }
.names-first td:first-child { min-width: 10rem; max-width: 18rem; white-space: normal; overflow-wrap: anywhere; }
td.text { min-width: 12rem; max-width: 24rem; overflow-wrap: anywhere; }
td a { display: inline-block; min-height: 44px; max-width: 100%; padding-block: 0.5rem; }
td.neg { color: var(--danger); }
td.details { min-width: 16rem; max-width: 28rem; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }
.tag { font-size: 0.75rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 0.3rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.flash { background: var(--ok-bg); color: var(--ok-text); padding: 0.6rem 0.8rem; border-radius: 6px; }
.error { background: var(--err-bg); color: var(--err-text); padding: 0.6rem 0.8rem; border-radius: 6px; }

@media (max-width: 600px) {
  main { padding: 0.75rem; }
  .top, .nav { padding-inline: 0.75rem; }
  .logout { flex-basis: 100%; justify-content: space-between; }
  .who { flex: 1 1 10rem; min-width: 0; }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 1.2rem; }
  .stat .value { font-size: 1.15rem; }
  .filters label, .filters label.check { flex-basis: 100%; }
  .filters > button { width: 100%; }
  .actions a, .actions strong { flex: 1 1 10rem; }
}
