/* ============ Tokens ============ */
:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #f7f9f6;
  --border: #e2e7e1;
  --border-strong: #ccd5cc;
  --text: #15211a;
  --text-2: #3b4840;
  --muted: #6b776f;

  --primary: #173c29;
  --primary-hover: #10301f;
  --primary-soft: #e7f0ea;
  --gold: #d7a547;
  --gold-hover: #c49234;
  --gold-soft: #fbf3e2;
  --gold-text: #8a6417;

  --ok: #1c7a45;
  --ok-soft: #e4f4ea;
  --due: #b2471c;
  --due-soft: #fdeee5;
  --danger: #b4372a;
  --danger-soft: #fcebe8;
  --info: #245a9c;
  --info-soft: #e8f0fb;

  --radius: 14px;
  --radius-sm: 10px;
  --h: 42px; /* every input, select & button */
  --h-sm: 34px; /* compact buttons in tables / toolbars */
  --shadow: 0 1px 2px rgba(21, 33, 26, 0.04), 0 6px 18px rgba(21, 33, 26, 0.04);
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1612;
    --surface: #161f1a;
    --surface-2: #1b2620;
    --border: #26332b;
    --border-strong: #34443a;
    --text: #e8eee9;
    --text-2: #c3cec6;
    --muted: #8d9a91;
    --primary: #2f7a52;
    --primary-hover: #38905f;
    --primary-soft: #1c2e24;
    --gold-soft: #2b2416;
    --gold-text: #e3bb6c;
    --ok: #5cc98a;
    --ok-soft: #173023;
    --due: #f0915f;
    --due-soft: #33211a;
    --danger: #f08070;
    --danger-soft: #33201d;
    --info: #86b2ee;
    --info-soft: #18263a;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ============ Base ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--primary);
}
@media (prefers-color-scheme: dark) {
  a {
    color: var(--ok);
  }
}
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
p {
  margin: 0;
}
img {
  max-width: 100%;
}
.muted {
  color: var(--muted);
}
.txt-ok {
  color: var(--ok);
}
.txt-due {
  color: var(--due);
}
.nowrap {
  white-space: nowrap;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.container-narrow {
  max-width: 960px;
}

/* ============ Controls (one height for all) ============ */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  height: var(--h);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
input[type="date"] {
  min-width: 0;
}
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}
select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b776f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  text-overflow: ellipsis;
}
textarea {
  height: auto;
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
input[readonly] {
  background: var(--surface-2);
}
.input-sm,
.select-sm {
  height: var(--h-sm) !important;
  font-size: 14px !important;
}
.select-sm {
  padding-right: 30px;
  background-position: right 10px center;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover,
button:hover {
  background: var(--primary-hover);
}
.btn svg {
  flex: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-gold {
  background: var(--gold);
  color: #1d1607;
}
.btn-gold:hover {
  background: var(--gold-hover);
}
.btn-whatsapp {
  background: #1fa855;
  color: #fff;
}
.btn-whatsapp:hover {
  background: #178a45;
}
.btn-sm {
  height: var(--h-sm);
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}
.btn-icon {
  width: var(--h);
  padding: 0;
}
.btn-block {
  width: 100%;
}
.link-btn {
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.link-btn:hover {
  background: none;
  text-decoration: underline;
}
@media (prefers-color-scheme: dark) {
  .link-btn {
    color: var(--ok);
  }
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Forms */
.form-stack {
  display: grid;
  gap: 14px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.field > span,
.field-label-row {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hint {
  color: var(--muted);
  font-size: 12.5px;
}
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline-form input,
.inline-form select {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
}
.add-row input {
  max-width: 380px;
}

.check-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.check-chip {
  position: relative;
  cursor: pointer;
}
.check-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.check-chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--h-sm);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.check-chip span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}
.check-chip input:checked + span {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text);
}
.check-chip input:checked + span::before {
  background: var(--primary);
  border-color: var(--primary);
}
.check-chip input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
@media (prefers-color-scheme: dark) {
  .check-chip input:checked + span::before {
    background: var(--ok);
    border-color: var(--ok);
  }
  .check-chip input:checked + span {
    border-color: var(--ok);
  }
}

/* ============ Header ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1200px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  flex: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.brand-text small {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.logo-tile {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #000, #111);
  box-shadow: inset 0 0 0 1px rgba(215, 165, 71, 0.25);
}
.logo-tile img {
  width: 78%;
  height: 78%;
  display: block;
}
.logo-lg {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
}
.nav a {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
}
.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav a.active {
  background: var(--primary-soft);
  color: var(--text);
}
.nav a.active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: 8px;
}

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.menu {
  position: relative;
}
.menu summary {
  list-style: none;
}
.menu summary::-webkit-details-marker {
  display: none;
}
.avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--h);
  padding: 0 10px 0 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface);
}
.avatar-btn:hover {
  border-color: var(--border-strong);
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-text);
  font-size: 12.5px;
  font-weight: 700;
}
.avatar-name {
  font-weight: 600;
  font-size: 13.5px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 30;
}
.menu-head {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.menu-head strong,
.menu-head small {
  display: block;
}
.menu-head small {
  color: var(--muted);
}
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  text-align: left;
  justify-content: flex-start;
}
.menu-item:hover {
  background: var(--surface-2);
}
.nav-toggle {
  display: none;
}

/* ============ Page ============ */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin: 4px 0 20px;
}
.page-head h1 {
  font-size: 26px;
  font-weight: 750;
}
.page-head p {
  color: var(--muted);
  margin-top: 4px;
  max-width: 620px;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.month-picker {
  display: flex;
  gap: 6px;
  align-items: center;
}
.month-picker select {
  width: 168px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert-success {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 20%, transparent);
}
.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 20%, transparent);
}
.alert-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 20%, transparent);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
  min-width: 0;
}
.panel-quiet {
  box-shadow: none;
  background: var(--surface-2);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: 16.5px;
  font-weight: 700;
}
.panel-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.panel-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.total-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--h-sm);
  padding: 0 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.total-pill strong {
  color: var(--text);
  font-size: 14.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.layout-side {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.form-panel {
  position: sticky;
  top: 84px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat small {
  display: block;
  color: var(--muted);
  font-weight: 550;
  font-size: 12.5px;
}
.stat strong {
  display: block;
  font-size: 24px;
  font-weight: 750;
  margin: 6px 0 2px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat span {
  color: var(--muted);
  font-size: 12.5px;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 22px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1b4632, #0f2a1c);
  color: #fff;
}
.hero-card small {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 550;
}
.hero-card strong {
  display: block;
  margin: 8px 0;
}
.hero-card strong .badge {
  font-size: 18px;
  height: 34px;
  padding: 0 14px;
}
.hero-card p {
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table th:first-child {
  border-top-left-radius: 8px;
}
.table th:last-child {
  border-top-right-radius: 8px;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.table tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.table tfoot td {
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border-bottom: 0;
}
.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-main {
  color: var(--text);
  font-weight: 600;
}
.cell-stack {
  min-width: 0;
}
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}
.user-form-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}
.cell-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed var(--border-strong);
}
.cell-link:hover {
  color: var(--primary);
  border-color: currentColor;
}
.amt-debit {
  color: var(--due);
}
.amt-credit {
  color: var(--ok);
}
.row-muted td {
  background: var(--surface-2);
}
.row-highlight td {
  background: var(--gold-soft) !important;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px !important;
}
.actions-col {
  width: 1%;
}
.actions {
  text-align: right;
  white-space: nowrap;
}
.actions > * {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 0 0 6px;
}
.actions > :first-child {
  margin-left: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-due {
  background: var(--due-soft);
  color: var(--due);
}
.badge-muted {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge-gold {
  background: var(--gold-soft);
  color: var(--gold-text);
}
.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

/* Simple lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child {
  border-bottom: 0;
}
.list strong {
  display: block;
  font-weight: 600;
}
.list small {
  color: var(--muted);
}
.list li > span {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Credential card */
.cred-card {
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.cred-head h2 {
  font-size: 17px;
}
.cred-head p {
  color: var(--text-2);
  margin-top: 4px;
}
.cred-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.cred-grid > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.cred-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.cred-grid code {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

/* Statement toolbar */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}
.share-box {
  display: flex;
  gap: 8px;
  flex: 1 1 420px;
  min-width: 0;
}
.share-box input {
  flex: 1;
  min-width: 120px;
  font-size: 13px;
}
.share-hint {
  margin-bottom: 16px;
}

/* Statement document */
.statement {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.st-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--primary);
}
@media (prefers-color-scheme: dark) {
  .st-head {
    border-color: var(--gold);
  }
}
.st-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.st-brand .logo-tile {
  width: 46px;
  height: 46px;
}
.st-brand strong {
  display: block;
  font-size: 18px;
}
.st-brand small {
  color: var(--muted);
}
.st-title {
  text-align: right;
}
.st-title h2 {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.st-title span {
  color: var(--gold-text);
  font-weight: 700;
}
.st-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.st-meta div {
  min-width: 0;
}
.st-meta dt {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.st-meta dd {
  margin: 2px 0 0;
  font-weight: 600;
}
.st-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.st-summary > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface-2);
  min-width: 0;
}
.st-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}
.st-summary strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.st-summary .is-debit strong {
  color: var(--due);
}
.st-summary .is-credit strong {
  color: var(--ok);
}
.st-summary .is-closing {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
}
.st-summary .is-closing .badge {
  margin-top: 4px;
}
.st-section {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 24px 0 10px;
}
.st-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
  color: var(--muted);
  font-size: 12.5px;
}

/* Auth pages */
.auth-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(
      circle at 20% 0%,
      color-mix(in srgb, var(--gold) 12%, transparent),
      transparent 40%
    ),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 16px 40px rgba(21, 33, 26, 0.08);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.auth-brand strong {
  display: block;
  font-size: 19px;
  font-weight: 800;
}
.auth-brand small {
  color: var(--muted);
}
.auth-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
}
.auth-card > p.muted {
  margin-bottom: 20px;
}
.auth-note {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.share-page .auth-card {
  margin-top: 10vh;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 20px 28px;
}

/* ============ Responsive ============ */
@media (max-width: 1020px) {
  .layout-side {
    grid-template-columns: 1fr;
  }
  .form-panel {
    position: static;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .user-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }
  .avatar-name {
    display: none;
  }
  .avatar-btn {
    padding: 0 4px;
    width: var(--h);
    justify-content: center;
  }
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 64px;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.08);
  }
  .nav.open {
    display: flex;
  }
  .nav a {
    height: 46px;
    font-size: 15px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .st-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  body {
    font-size: 15px;
  }
  .container {
    padding: 16px 16px 40px;
  }
  .topbar-in {
    padding: 0 16px;
    gap: 12px;
  }
  .page-head {
    margin-bottom: 16px;
  }
  .page-head h1 {
    font-size: 22px;
  }
  .page-actions,
  .month-picker {
    width: 100%;
  }
  .page-actions > .inline-form {
    width: 100%;
  }
  .month-picker select {
    flex: 1;
    width: auto;
  }
  .panel {
    padding: 16px;
    border-radius: 12px;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 14px;
  }
  .stat strong {
    font-size: 19px;
  }
  .form-row,
  .user-form {
    grid-template-columns: 1fr;
  }
  .user-form-foot .btn {
    width: 100%;
  }
  .rt .cell-stack {
    text-align: right;
  }
  .rt .cell-stack .badge {
    margin-left: auto;
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    font-size: 16px;
  } /* no iOS zoom */
  .add-row {
    flex-direction: column;
    align-items: stretch;
  }
  .add-row input {
    max-width: none;
  }
  .cred-grid {
    grid-template-columns: 1fr;
  }
  .btn-row > .btn {
    flex: 1 1 auto;
  }
  .toolbar > .btn {
    flex: 1 1 auto;
  }
  .share-box {
    flex-wrap: wrap;
    flex-basis: 100%;
  }
  .share-box input {
    flex-basis: 100%;
  }
  .share-box .btn {
    flex: 1 1 auto;
  }

  .statement {
    padding: 16px;
    border-radius: 12px;
  }
  .st-title {
    text-align: left;
  }
  .st-meta {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .st-summary strong {
    font-size: 16px;
  }

  /* Tables become cards */
  .table-wrap {
    margin: 0;
    padding: 0;
    overflow: visible;
  }
  .rt thead {
    display: none;
  }
  .rt,
  .rt tbody,
  .rt tfoot,
  .rt tr,
  .rt td {
    display: block;
    width: 100%;
  }
  .rt tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px 14px;
    margin-bottom: 10px;
    background: var(--surface);
  }
  .rt tfoot tr {
    background: var(--surface-2);
  }
  .rt td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
    background: none !important;
  }
  .rt td:last-child {
    border-bottom: 0;
  }
  .rt td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
  }
  .rt td:not([data-label])::before {
    content: none;
  }
  .rt td > div,
  .rt td > .cell-sub {
    min-width: 0;
  }
  .rt .cell-sub {
    text-align: right;
  }
  .rt tr.row-highlight {
    border-color: var(--gold);
    background: var(--gold-soft);
  }
  .rt tr.row-empty {
    border-style: dashed;
  }
  .rt td.empty {
    justify-content: center;
  }
  .rt td.actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 8px;
  }
  .rt td.actions > * {
    margin: 0;
  }
  /* first cell = card title */
  .rt tbody td:first-child:not(.empty) {
    justify-content: flex-start;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-weight: 650;
    color: var(--text);
    padding: 11px 0;
  }
  .rt tbody td:first-child:not(.empty)::before {
    content: none;
  }
  .rt td.actions .btn {
    flex: 1 1 auto;
  }
  .rt td.actions form {
    flex: 1 1 auto;
    display: flex;
  }
  .rt td .inline-form {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .rt tbody tr:hover td {
    background: none;
  }
}

@media (max-width: 420px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stat strong {
    font-size: 17px;
  }
  .st-summary {
    grid-template-columns: 1fr;
  }
  .brand-text small {
    display: none;
  }
}

/* ============ Print / PDF ============ */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #f5f6f5;
    --border: #d9dfda;
    --border-strong: #c3ccc5;
    --text: #111;
    --text-2: #222;
    --muted: #555;
    --primary: #173c29;
    --primary-soft: #eef4f0;
    --gold-text: #8a6417;
    --ok: #146c3a;
    --due: #a33d14;
    --ok-soft: #eaf6ee;
    --due-soft: #fbeee7;
    color-scheme: light;
  }
  @page {
    size: A4;
    margin: 14mm 12mm;
  }
  body {
    background: #fff;
    font-size: 12px;
  }
  .topbar,
  .footer,
  .no-print,
  .alert {
    display: none !important;
  }
  .container {
    padding: 0;
    max-width: none;
  }
  .statement {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .st-head {
    border-color: #173c29;
  }
  .st-summary {
    grid-template-columns: repeat(4, 1fr);
  }
  .st-meta {
    grid-template-columns: repeat(3, 1fr);
  }
  .table-wrap {
    overflow: visible;
  }
  .rt thead {
    display: table-header-group;
  }
  .rt {
    display: table;
  }
  .rt tbody {
    display: table-row-group;
  }
  .rt tfoot {
    display: table-footer-group;
  }
  .rt tr {
    display: table-row;
    border: 0;
    padding: 0;
    margin: 0;
  }
  .rt td {
    display: table-cell;
    width: auto;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }
  .rt td.num {
    text-align: right;
  }
  .rt td::before {
    content: none !important;
  }
  .table th {
    padding: 7px 8px;
  }
  tr {
    break-inside: avoid;
  }
  .logo-tile {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .badge,
  .st-summary > div,
  .table th,
  .table tfoot td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
