:root {
    --red: #B51F2E;
    --blue: #16A7D2;
    --gold: #D89B28;
    --ink: #242424;
    --soft: #F7FAFB;
    --secondary: #DDF4FA;
    --gray200: #C8C8C8;
    --gray500: #6E6E6E;
    --green: #27AE60;
    --white: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", "Noto Sans Malayalam", "Nirmala UI", Arial, sans-serif; font-size: 14px; color: var(--ink); background: var(--soft); }
#app { height: 100%; }
.boot, .page-message { padding: 40px; text-align: center; color: var(--gray500); }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #ffe9a8; padding: 8px 14px; z-index: 1000; }
#blazor-error-ui .reload { margin-left: 10px; }

button, input, select { font: inherit; }
input, select { border: 1px solid var(--gray200); border-radius: 6px; padding: 8px 10px; background: var(--white); min-height: 38px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.btn { border: 1.5px solid #fff; border-radius: 10px; padding: 8px 14px; min-height: 38px; color: #fff; background: var(--blue); cursor: pointer; font-weight: 600; box-shadow: 1px 2px 3px rgba(0,0,0,.3); white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { background: var(--gray200) !important; color: #666; cursor: default; box-shadow: none; }
.btn.white { background: #fff; color: var(--red); border-color: var(--red); }
.btn.green { background: var(--green); color: #fff; }
.btn.blue { background: #2980B9; }
.btn.grey { background: #95A5A6; }
.btn.gold { background: var(--gold); }
.btn.red { background: #E74C3C; color: #fff; }
.btn.small { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn.icon { width: 30px; min-height: 30px; padding: 0; }

/* ---------- billing screen ---------- */
.screen { display: flex; flex-direction: column; height: 100vh; padding: 10px; gap: 8px; }
.header { background: var(--red); border-radius: 8px; padding: 8px 10px; display: grid; grid-template-columns: auto 120px auto 1fr auto auto auto auto auto; gap: 8px; align-items: center; color: #fff; }
.header input { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.header input::placeholder { color: #FCE7EA; }
.header .mydate { text-align: center; font-size: 11px; font-weight: 700; line-height: 1.25; }
.header .total { font-size: 22px; font-weight: 700; text-align: right; padding: 0 6px; }
.header-sub { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; }
.header-sub .hint { color: #FCE7EA; font-style: italic; }
.periodical-banner { grid-column: 1 / -1; background: var(--gold); color: #000; font-weight: 700; font-size: 11px; display: flex; justify-content: space-between; align-items: center; padding: 2px 6px; cursor: pointer; }

.content { flex: 1; min-height: 0; display: grid; grid-template-columns: 4fr 9fr 3fr; gap: 8px; }
.panel { background: #fff; border: 1px solid var(--gray200); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; min-height: 0; }
.panel h2 { margin: 0 0 6px; font-size: 17px; display: flex; justify-content: space-between; }
.panel h2 .amt { color: var(--red); }
.panel input.search { margin-bottom: 6px; }
.list { overflow: auto; flex: 1; }
.list-row { display: grid; gap: 4px; padding: 3px 4px; cursor: pointer; font-size: 12px; font-weight: 600; align-items: center; }
.list-row:hover { background: #f0f7fa; }
.list-row.selected { background: var(--secondary); }
.seva-row { grid-template-columns: 42px 1fr 70px; }
.star-row { grid-template-columns: 34px 1fr; }
.list-row .code { color: var(--red); }
.list-row .rate { color: var(--green); text-align: right; }

.bill-grid { flex: 1; min-height: 0; overflow: auto; position: relative; }
.bill-grid::before { content: ""; position: absolute; inset: 0; background: url(../img/sopanam_logo.png) center / 320px no-repeat; opacity: .08; pointer-events: none; }
table.grid { width: 100%; border-collapse: collapse; position: relative; }
table.grid th { background: var(--secondary); text-align: left; font-size: 12px; padding: 6px; position: sticky; top: 0; z-index: 1; }
table.grid td { padding: 5px 6px; border-bottom: 1px solid #eee; vertical-align: middle; font-size: 13px; }
.num { text-align: right; }
.center { text-align: center; }
.red { color: var(--red); }
.green { color: var(--green); }
.blue-link { color: var(--blue); text-decoration: underline; cursor: pointer; font-weight: 700; }
.muted { color: var(--gray500); }
.bold { font-weight: 700; }
.empty { padding: 14px; color: var(--gray500); position: relative; }

.entry { background: #fff; border: 1px solid var(--gray200); border-radius: 8px; padding: 8px; display: grid; grid-template-columns: 170px 80px 2fr 2fr 170px 70px 90px 56px; gap: 8px; align-items: end; }
.entry label { font-size: 11px; color: var(--gray500); display: block; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry label .narr { color: var(--red); font-weight: 700; cursor: pointer; margin-left: 4px; }
.entry label .mob { color: var(--blue); font-weight: 700; margin-left: 4px; }
.entry label .mob.link { cursor: pointer; text-decoration: underline dotted; }
.entry input, .entry select { width: 100%; }
.entry .qty { text-align: center; }
.entry .rate { text-align: right; }

.status { font-size: 12px; color: var(--gray500); min-height: 16px; }

/* ---------- popups ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; z-index: 50; }
.popup { background: #fff; border: 2px solid var(--gold); border-radius: 12px; padding: 14px; width: 460px; max-width: 96vw; max-height: 94vh; overflow: auto; box-shadow: 2px 4px 14px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 8px; }
.popup.pay { border-color: var(--blue); }
.popup.receive { border-color: var(--green); }
.dev-cell { position: relative; }
.dev-suggest { position: absolute; left: 0; bottom: 100%; margin-bottom: 4px; min-width: 300px; max-width: 440px; max-height: 280px; overflow: auto; background: #fff; border: 2px solid var(--blue); border-radius: 10px; box-shadow: 2px 4px 14px rgba(0,0,0,.35); z-index: 40; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.dev-suggest-head { font-size: 11px; color: var(--gray500); padding: 0 2px 2px; }
.dev-suggest-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; background: #F4F8FF; border: 1px solid #C9D8F2; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }
.dev-suggest-item:hover { background: #E3EEFF; }
.dev-suggest-item .muted { color: var(--gray500); font-size: 12px; }
.popup.devotee { width: 640px; border-color: var(--blue); }
.dev-form { display: grid; grid-template-columns: 190px 1fr; gap: 6px 10px; align-items: center; }
.dev-form label { font-size: 12px; color: var(--gray500); }
.dev-form input, .dev-form select, .dev-form textarea { width: 100%; box-sizing: border-box; }
.dev-form textarea { align-self: start; }
.popup .field textarea { width: 100%; box-sizing: border-box; font: inherit; border: 1px solid var(--gray300, #ccc); border-radius: 6px; padding: 6px; resize: vertical; }
.dev-choices { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.dev-choice { display: flex; justify-content: space-between; gap: 8px; text-align: left; }
.dev-choice .muted { color: var(--gray500); font-size: 12px; }
.popup h3 { margin: 0; color: var(--red); font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.popup .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popup .field label { display: block; font-size: 11px; color: var(--gray500); margin-bottom: 2px; }
.popup .field input, .popup .field select { width: 100%; }
.pay-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.pay-row input { text-align: right; }
.summary { font-size: 12px; font-weight: 700; color: var(--red); }
.summary.ok { color: #1E7B43; }
.error { color: var(--red); font-size: 12px; }

/* ---------- login ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--gray200); border-radius: 12px; padding: 22px; width: 420px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.login-card h1 { margin: 0; color: var(--red); font-size: 22px; text-align: center; }
.login-card .temple { text-align: center; color: var(--gray500); font-size: 13px; margin-top: -6px; }
.login-card .field label { display: block; font-size: 11px; color: var(--gray500); margin-bottom: 2px; }
.login-card .field input, .login-card .field select { width: 100%; }
.login-card .code { font-size: 26px; letter-spacing: 12px; text-align: center; }

/* ---------- reports ---------- */
.report { padding: 10px; display: flex; flex-direction: column; gap: 8px; height: 100vh; }
.report-head { background: var(--red); color: #fff; border-radius: 8px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.report-head h1 { margin: 0; font-size: 16px; flex: 1; }
.report-head input, .report-head select { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.report-head select option { color: #000; }
.report-head label { font-size: 12px; }
.report-totals { text-align: right; font-weight: 700; }
.report-body { flex: 1; min-height: 0; overflow: auto; background: #fff; border: 1px solid var(--gray200); border-radius: 8px; padding: 8px; }
.report-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--gray500); }
.report-foot .closing { font-size: 20px; font-weight: 700; color: var(--red); }
/* The menu page: every section is a card; inside it the pages are small square tiles (Windows style), coloured per section. */
.reports-home { padding: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.reports-home .group { --g: var(--gray500); --gbg: #EEF0F2; --gfg: #444; background: var(--gbg); border: 1px solid var(--g); border-top: 5px solid var(--g); border-radius: 10px; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 92px)); justify-content: start; gap: 8px; }
.reports-home .group h2 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 16px; color: var(--gfg); }
.reports-home .group .btn { display: flex; flex-direction: column; box-sizing: border-box; aspect-ratio: 1 / 0.9; padding: 5px 6px 6px; text-align: left; text-decoration: none; font-size: 11px; font-weight: 600; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; min-width: 0; background: var(--g); color: #fff; border: 0; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.reports-home .group .btn .ti { flex: 1; display: flex; align-items: center; justify-content: center; }
.reports-home .group .btn .mi { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reports-home .group .btn:hover { filter: brightness(1.12); }
.reports-home .group .btn:active { transform: scale(.97); }
@media (max-width: 1100px) { .reports-home { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .reports-home { grid-template-columns: minmax(0, 1fr); padding: 8px; } .reports-home .group { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); } }
.reports-home .g-blue   { --g: var(--blue);  --gbg: #E3F6FC; --gfg: #126783; }
.reports-home .g-gold   { --g: var(--gold);  --gbg: #FDF1DC; --gfg: #8A6116; }
.reports-home .g-green  { --g: var(--green); --gbg: #E8F6EC; --gfg: #1E7B43; }
.reports-home .g-red    { --g: var(--red);   --gbg: #FBEAEC; --gfg: #8F1824; }
.reports-home .g-purple { --g: #6C4AB6;      --gbg: #EFEAFA; --gfg: #4B3290; }
.reports-home .g-grey   { --g: var(--gray500); --gbg: #EEF0F2; --gfg: #444; }
.bill-doc { max-width: 720px; margin: 0 auto; }
.grid tfoot .tot td { font-weight: 700; border-top: 2px solid var(--ink); background: var(--secondary); }
.group-block { margin-bottom: 14px; }
.group-block h3 { margin: 0 0 4px; padding: 5px 8px; background: var(--secondary); border-radius: 6px; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.group-block h3 .cal { font-weight: 400; font-size: 12px; color: var(--gray500); }
.group-block .para { padding: 2px 8px 6px; line-height: 1.5; }
.group-block .seva-title { font-weight: 700; padding: 4px 8px 0; }
.group-block .seva-title .count { color: var(--gray500); font-weight: 400; }

/* ---------- bill edit ---------- */
.be-info { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-bottom: 8px; }
.be-total { margin-left: auto; font-weight: 700; color: var(--red); }
.be-lines { display: flex; flex-direction: column; gap: 6px; }
.be-line { border: 1px solid var(--gray200); border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; gap: 10px; background: #fff; }
.be-line-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 4px; }
.be-add { margin-top: 12px; border: 1px dashed var(--gray200); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.be-add h3 { margin: 0; font-size: 15px; color: var(--red); }
.be-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.be-form .field label { display: block; font-size: 11px; color: var(--gray500); margin-bottom: 2px; }
.be-form .field input, .be-form .field select { width: 100%; }
.be-form .field input + select { margin-top: 4px; }
@media (max-width: 720px) { .be-form { grid-template-columns: 1fr 1fr; } .be-total { margin-left: 0; width: 100%; } }

/* ---------- date box + panchangam calendar ---------- */
.datebox { display: flex; gap: 4px; }
.datebox input { flex: 1; min-width: 0; }
.datebox .btn.icon { flex: none; width: 40px; min-height: 38px; padding: 0; display: flex; align-items: center; justify-content: center; }

/* The calendar is a full page, as in the Windows app: a red bar (< Month > Close), then big day cells. */
.overlay:has(.popup.cal) { align-items: stretch; }
.popup.cal { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border: 0; border-radius: 0; background: var(--soft); padding: 10px; gap: 8px; }
.cal-head { background: var(--red); border-radius: 8px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; }
.cal-title { flex: 1; text-align: center; font-size: 22px; font-weight: 700; color: #fff; }
.cal-nav { font-size: 24px; line-height: 1; padding: 4px 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.popup.cal > .cal-grid:not(.cal-dow) { flex: 1; min-height: 0; grid-auto-rows: minmax(80px, 1fr); overflow: auto; }
.cal-dow span { text-align: center; font-weight: 700; font-size: 13px; }
.cal-cell { padding: 4px 6px; border: 1px solid var(--gray200); border-radius: 6px; background: var(--secondary); text-align: left; display: flex; flex-direction: column; gap: 1px; overflow: hidden; cursor: pointer; font: inherit; color: var(--ink); }
.cal-cell.out { background: var(--gray200); color: var(--gray500); }
.cal-cell.today { background: #FDF1DC; border-color: var(--red); border-width: 2px; }
.cal-cell.chosen { outline: 3px solid var(--blue); outline-offset: -3px; }
.cal-cell:hover { filter: brightness(.96); }
.cal-day { font-weight: 700; font-size: 18px; text-align: center; }
.cal-star { font-size: 13px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.cal-sub { font-size: 11px; line-height: 1.2; color: var(--gray500); overflow-wrap: anywhere; }

/* ---------- print designs ---------- */
.print-page { display: grid; grid-template-columns: 380px 1fr; gap: 10px; flex: 1; min-height: 0; }
.print-list, .print-editor { background: #fff; border: 1px solid var(--gray200); border-radius: 8px; padding: 8px; overflow: auto; }
.print-list tr { cursor: pointer; }
.print-list tr.sel td { background: var(--secondary); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.print-split { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 8px; align-items: start; }
.print-editor textarea.json { width: 100%; min-height: 460px; font-family: Consolas, 'Courier New', monospace; font-size: 12px; border: 1px solid var(--gray200); border-radius: 6px; padding: 8px; resize: vertical; }
.print-preview { max-width: 100%; overflow: auto; }
.preview-frame { border: 1px solid var(--gray500); background: #fff; box-shadow: 2px 3px 8px rgba(0,0,0,.25); max-width: none; }
.problems { margin: 4px 0; padding-left: 18px; font-size: 12px; }
.problems .bad { color: var(--red); }
.problems .warn { color: #8A6116; }
.muted { color: var(--gray500); }
.muted.small, .small { font-size: 11px; }
.logo-box { margin-top: 10px; padding: 8px; border: 1px dashed var(--gray200); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.logo-prev { max-width: 120px; max-height: 160px; align-self: flex-start; background: #fff; border: 1px solid var(--gray200); }
.muted-white { color: rgba(255,255,255,.85); font-size: 12px; }
.ok-note { color: #1E7B43; font-size: 12px; font-weight: 600; }

@media (max-width: 1100px) {
    .print-page { grid-template-columns: 1fr; overflow: auto; }
    .print-split { grid-template-columns: 1fr; }
    .content { grid-template-columns: 1fr; overflow: auto; }
    .header { grid-template-columns: 1fr 1fr 1fr; }
    .entry { grid-template-columns: 1fr 1fr; }
    .reports-home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) { .reports-home { grid-template-columns: 1fr; } }

/* ---- masters pages (vazhipadu, users) ---- */
.mtabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--gray200); }
.mtab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 16px; cursor: pointer; color: var(--gray500); font-weight: 600; margin-bottom: -2px; }
.mtab.on { color: var(--red); border-bottom-color: var(--red); }
.mfilters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 8px; }
.mfilters .field { min-width: 140px; }
.mfilters .field label { display: block; font-size: 11px; color: var(--gray500); margin-bottom: 2px; }
.mfilters .grow, .mgrow { flex: 1; min-width: 200px; }
.mfilters .field input, .mfilters .field select { width: 100%; }
.mcheck { display: flex; align-items: center; gap: 6px; font-size: 13px; padding-bottom: 8px; }
.popup.wide { width: 800px; }
.popup .msub { margin: 10px 0 2px; font-size: 14px; color: var(--ink, #222); border-bottom: 1px solid var(--gray200); padding-bottom: 2px; }
.mf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 12px; }
.mf-grid .field label { display: block; font-size: 11px; color: var(--gray500); margin-bottom: 2px; }
.mf-grid .field input, .mf-grid .field select { width: 100%; }
.mf-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0; }
.mf-checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.mf-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.split-row { display: grid; grid-template-columns: 1fr 130px 34px; gap: 8px; margin-bottom: 6px; align-items: center; }
.split-row select, .split-row input { width: 100%; }
.split-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.split-total { font-weight: 700; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 2px 4px; font-size: 12px; text-decoration: underline; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #E8F0FE; color: #1A56C4; margin-right: 3px; }
.tag.green { background: #E8F6EC; color: #1E7B43; }
.tag.red { background: #FDECEA; color: #B3261E; }
.notice { background: #EAF6EE; color: #1E7B43; border: 1px solid #BFE2CB; border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-size: 13px; }
tr.off td { color: var(--gray500); }
.rights-sec { border: 1px solid var(--gray200); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.rights-sec h4 { margin: 0 0 4px; font-size: 13px; display: flex; justify-content: space-between; }
.rights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; }
.rights-grid label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
@media (max-width: 720px) {
    .split-row { grid-template-columns: 1fr 100px 34px; }
    .popup.wide { width: 98vw; }
}

/* ---------- AI report generator ---------- */
.ai-ask { background: #fff; border: 1px solid var(--gray200); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.ai-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.ai-row label { display: flex; flex-direction: column; font-size: 11px; color: var(--gray500); gap: 2px; }
.ai-input { flex: 1; min-width: 220px; }
.ai-otp { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #FFF8E6; border: 1px solid var(--gold); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.ai-code { width: 90px; font-size: 18px; letter-spacing: 6px; text-align: center; }
.ai-picked { border-top: 1px solid var(--gray200); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ai-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ai-chips .chip { border: 1px solid #6C4AB6; color: #4B3290; background: #EFEAFA; border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.ai-chips .chip.saved { display: inline-flex; padding: 0; overflow: hidden; border-color: var(--green); background: #E8F6EC; }
.ai-chips .chip.saved button { background: none; border: 0; color: #1E7B43; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.ai-chips .chip.saved .x { color: #B3261E; border-left: 1px solid var(--green); }
.ai-filter th { padding: 2px 4px; background: #fff; top: 28px; }
.ai-filter input { width: 100%; min-width: 50px; font-size: 12px; padding: 2px 4px; box-sizing: border-box; }
