/* ================================================================
   Base
================================================================ */
:root {
  color-scheme: light;
  --page-bg: #f5f5f5;
  --surface: #ffffff;
  --divider: #f0f0f0;
  --text: rgba(0, 0, 0, .88);
  --muted: rgba(0, 0, 0, .45);
  --slip-sub: #595959;
  --slip-line: #d9d9d9;
  --slip-dot: #bfbfbf;
  --chart-grid: #f0f0f0;
  --chart-base: #d9d9d9;
  --chart-axis: #8c8c8c;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #000000;
  --surface: #141414;
  --divider: #303030;
  --text: rgba(255, 255, 255, .88);
  --muted: rgba(255, 255, 255, .45);
  --slip-sub: rgba(255, 255, 255, .62);
  --slip-line: #3a3a3a;
  --slip-dot: #595959;
  --chart-grid: #262626;
  --chart-base: #424242;
  --chart-axis: #8c8c8c;
}

/* Hind Siliguri, self-hosted: the stock 400/500/600 files have a malformed ১ (U+09E7); these are patched. */
@font-face { font-family: 'Hind Siliguri'; font-weight: 300; font-display: swap; src: url(/fonts/HindSiliguri-Light.ttf) format('truetype'); }
@font-face { font-family: 'Hind Siliguri'; font-weight: 400; font-display: swap; src: url(/fonts/HindSiliguri-Regular.ttf) format('truetype'); }
@font-face { font-family: 'Hind Siliguri'; font-weight: 500; font-display: swap; src: url(/fonts/HindSiliguri-Medium.ttf) format('truetype'); }
@font-face { font-family: 'Hind Siliguri'; font-weight: 600; font-display: swap; src: url(/fonts/HindSiliguri-SemiBold.ttf) format('truetype'); }
@font-face { font-family: 'Hind Siliguri'; font-weight: 700; font-display: swap; src: url(/fonts/HindSiliguri-Bold.ttf) format('truetype'); }

:root { --font: InterVariable, 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', sans-serif; }

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-optical-sizing: auto;               /* InterVariable: optical size follows font size */
  font-feature-settings: "liga" 1, "calt" 1, "tnum" 1, "cv11" 1;
  transition: background-color .2s;
}
.ant-layout { background: var(--page-bg) !important; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-spinner { width: 24px; height: 24px; border: 2px solid var(--divider); border-top-color: #1677ff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: #1677ff; color: #fff; font-size: 22px;
}
.logo.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }

/* ================================================================
   App shell
================================================================ */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface) !important; border-bottom: 1px solid var(--divider);
  height: 56px !important; line-height: normal !important; padding: 0 24px !important;
  display: flex; align-items: center;
}
.app-header-inner { max-width: 1400px; margin: 0 auto; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-sub { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.app-content { max-width: 1400px; margin: 0 auto; width: 100%; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }

.eyebrow { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .02em; margin-bottom: 4px; }

/* Page head: month title + actions */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; min-width: 0; }
.page-title .eyebrow { margin-bottom: 2px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-row .ant-tag { margin-inline-end: 0; }
.page-sub { font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions .ant-space-compact-block { width: auto; }   /* Dropdown.Button defaults to full width */

/* Main grid: bills + summary panel */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.dash-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dash-side { position: sticky; top: 80px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title .count {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--divider); border-radius: 10px; padding: 1px 8px;
}

/* Summary panel */
.summary-card .ant-card-body { padding: 20px; }
.sum-sec + .sum-sec { border-top: 1px solid var(--divider); margin-top: 18px; padding-top: 18px; }
.sum-big { font-size: 34px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; color: var(--text); }
.sum-big .cur { font-size: 22px; font-weight: 500; color: var(--muted); margin-inline-end: 4px; }
.sum-sub { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; font-size: 13px; }
.sum-form { margin-top: 8px; }
.sum-form .ant-form-item { margin-bottom: 12px; }
.sum-form .ant-form-item:last-child { margin-bottom: 0; }
.sum-form .ant-form-item-label { padding-bottom: 4px !important; }
.sum-form .ant-form-item-label > label { font-size: 13px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; }
.kv .anticon { margin-inline-end: 4px; }

/* Month trend bars */
.trend { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; }
.trend-col {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 0; border-radius: 6px; transition: background-color .15s;
}
.trend-col:hover { background: var(--divider); }
.trend-col:focus-visible { outline: 2px solid #1677ff; outline-offset: 1px; }
.trend-val { font-size: 10px; color: var(--muted); }
.trend-track { width: 100%; max-width: 28px; height: 64px; display: flex; align-items: flex-end; border-radius: 4px; background: var(--divider); overflow: hidden; }
.trend-bar { width: 100%; background: #91caff; border-radius: 4px 4px 0 0; transition: height .25s; }
.trend-col.on .trend-bar { background: #1677ff; }
.trend-col.on .trend-val, .trend-col.on .trend-lbl { color: var(--text); font-weight: 600; }
.trend-lbl { font-size: 11px; color: var(--muted); }
[data-theme="dark"] .trend-bar { background: #15325b; }
[data-theme="dark"] .trend-col.on .trend-bar { background: #1668dc; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-side { position: static; order: -1; }
  .summary-card .ant-card-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; }
  .summary-card .ant-card-body::before, .summary-card .ant-card-body::after { display: none; }   /* antd clearfix would take grid cells */
  .sum-sec + .sum-sec { border-top: 0; margin-top: 0; padding-top: 0; }
  .sum-sec:nth-child(n + 3) { border-top: 1px solid var(--divider); padding-top: 18px; }
}
@media (max-width: 640px) {
  .summary-card .ant-card-body { grid-template-columns: 1fr; gap: 0; }
  .sum-sec + .sum-sec { border-top: 1px solid var(--divider); margin-top: 18px; padding-top: 18px; }
}

.field { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.field > .ant-select, .field > .ant-input-number-group-wrapper { align-self: stretch; }
.field-label { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }

.caret { font-size: 10px; color: var(--muted); margin-inline-start: 2px; }
.month-opt { display: flex; justify-content: space-between; gap: 16px; }
.month-opt .muted { font-size: 12px; }

/* Bill cards grid */
.slip-grid-screen { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.slip-card { transition: box-shadow .2s, border-color .2s; }
.slip-card:hover { box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .12), 0 3px 6px -4px rgba(0, 0, 0, .08); }
@media (max-width: 640px) {
  .slip-grid-screen { grid-template-columns: 1fr; }
  .app-content { padding: 16px; gap: 16px; }
  .page-actions { width: 100%; }
  .app-header { padding: 0 16px !important; }
  .hide-sm { display: none !important; }
}
@media (max-width: 1100px) { .hide-md { display: none !important; } }
.slip-card .ant-card-body { padding: 18px 18px 12px; }
.slip-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--divider);
  font-size: 12px; color: var(--muted);
}
.slip-meta .err { color: #ff4d4f; }

/* ================================================================
   Bill slip (shared by screen and print)
================================================================ */
.slip { font-family: var(--font); color: var(--text); }
.slip-kicker { text-align: center; font-size: 13px; color: var(--slip-sub); }
.slip-kicker .dot { color: var(--slip-dot); margin: 0 6px; }
.slip-name { display: block; text-align: center; font-weight: 700; font-size: 18px; margin: 2px 0 10px; line-height: 1.35; }
.slip-name .ant-typography-edit { margin-inline-start: 6px; opacity: 0; transition: opacity .15s; }
.slip:hover .slip-name .ant-typography-edit { opacity: 1; }
.slip-name.ant-typography-edit-content { margin: 2px 0 10px !important; inset-inline-start: 0 !important; }
.slip-chart { border: 1px solid var(--slip-line); border-radius: 8px; padding: 6px 4px 2px; }
.slip-chart svg { display: block; width: 100%; height: auto; }
.slip-cells { display: grid; grid-template-columns: 1fr 1fr; row-gap: 12px; margin: 14px 0; }
.slip-cells .cell:nth-child(even) { border-left: 1px solid var(--slip-line); padding-left: 12px; }
.slip .lbl { font-size: 13px; color: var(--slip-sub); line-height: 1.4; }
.slip .val { font-size: 17px; line-height: 1.35; white-space: nowrap; }
.slip .val b { font-weight: 700; }
.slip-total { border: 1px solid var(--slip-line); border-radius: 8px; padding: 8px 12px; }
.slip-total .val { font-size: 19px; }

.chart-axis { fill: var(--chart-axis); font-size: 7px; font-family: var(--font); }
.chart-grid { stroke: var(--chart-grid); stroke-width: .6; }
.chart-base { stroke: var(--chart-base); stroke-width: .6; }
.chart-empty { fill: var(--slip-dot); font-size: 9px; font-family: var(--font); }

/* ================================================================
   Print — A4 portrait, 3 × 3 bills per page (matches the paper copy)
================================================================ */
/* `.paper` is the A4 sheet look, shared by printing and the PDF download.
   Paper is always light, whatever the screen theme. */
.paper {
  --text: rgba(0, 0, 0, .88); --slip-sub: #595959; --slip-line: #cfcfcf; --slip-dot: #bfbfbf;
  --chart-grid: #f0f0f0; --chart-base: #d9d9d9; --chart-axis: #8c8c8c;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 91mm;
  column-gap: 7mm; row-gap: 3mm;
  align-content: start;
  background: #fff;
}
.paper .slip { break-inside: avoid; page-break-inside: avoid; padding-top: 1mm; }
.paper .slip-kicker { font-size: 9.5pt; }
.paper .slip-name { font-size: 13pt; margin: .5mm 0 3mm; }
.paper .slip-chart { padding: 2mm 1mm 1mm; }
.paper .slip-cells { margin: 4mm 0; row-gap: 3.5mm; }
.paper .slip-cells .cell { min-width: 0; }
.paper .slip-cells .cell:nth-child(even) { padding-left: 3mm; }
.paper .lbl { font-size: 9pt; }
.paper .val { font-size: 11pt; }
.paper .slip-total { padding: 2.2mm 3mm; }
.paper .slip-total .val { font-size: 13pt; }
.paper .slip-name .ant-typography-edit { display: none; }

/* PDF pages are laid out off-screen at true A4 size, then captured */
.pdf-host { position: fixed; left: -10000px; top: 0; pointer-events: none; }
.pdf-page { width: 210mm; height: 297mm; padding: 8mm; box-sizing: border-box; }

/* Printing */
.print-root { display: none !important; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  html, body { background: #fff !important; }
  body > :not(#print-host) { display: none !important; }
  .print-root { display: grid !important; }
}
