/* ---------------------------------------------------------------------------
 * Theme tokens. Light is the default; dark applies when the OS prefers dark
 * (unless the user picked Light) or when the user picked Dark via the toggle
 * in the menu bar (stored in localStorage, applied as <html data-theme>).
 * Every colour in the app should come from these tokens.
 * ------------------------------------------------------------------------- */
:root {
    color-scheme: light;
    --navy: #1b3a5c;
    --navy-dark: #122943;
    --heading: #1b3a5c;
    --accent: #1f6f43;
    --accent-hover: #175735;
    --accent-light: #eaf6ef;
    --debit: #7a1f1f;
    --credit: #14532d;
    --border: #c9d3dc;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef2f5;
    --row-alt: #f0f4f8;
    --text: #202a33;
    --muted: #5a6b7a;
    --faint: #7a8896;
    --th-bg: #1b3a5c;
    --input-bg: #ffffff;
    --locked-bg: #eef1f3;
    --locked-text: #9aa5ad;
    --shadow: rgba(27, 58, 92, 0.12);
    --shadow-strong: rgba(0, 0, 0, 0.2);
    --btn-secondary: #6c7a89;
    --btn-secondary-hover: #55616d;
    --btn-disabled: #b6bfc7;
    --success-bg: #e2f6ea; --success-text: #1a5f36; --success-border: #b6e6c9;
    --danger-bg: #fbe4e4;  --danger-text: #7a1f1f;  --danger-border: #f0bdbd;
    --mark-bg: #fff1a8;
    --card-slate: #6c7a89;
    --card-steel: #3d5a73;
    --card-ink: #2c3e50;
    --tone-blue-bg: #e6eef7;   --tone-blue: #1b3a5c;
    --tone-green-bg: #e2f3e9;  --tone-green: #1f6f43;
    --tone-teal-bg: #e0f2f1;   --tone-teal: #0f6b64;
    --tone-purple-bg: #eee8f6; --tone-purple: #5b3a8c;
    --tone-amber-bg: #fbf0dc;  --tone-amber: #94600d;
    --tone-red-bg: #f9e5e5;    --tone-red: #8a2a2a;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --navy: #142235;
        --navy-dark: #0c1622;
        --heading: #9cc3e8;
        --accent: #2f9a62;
        --accent-hover: #3aae72;
        --accent-light: #1b3027;
        --debit: #f08a8a;
        --credit: #6fd39a;
        --border: #2f3d4b;
        --bg: #0f151c;
        --surface: #17202a;
        --surface-muted: #202b37;
        --row-alt: #1b2530;
        --text: #dde4ea;
        --muted: #93a3b2;
        --faint: #7d8c9a;
        --th-bg: #1f3348;
        --input-bg: #111922;
        --locked-bg: #222c37;
        --locked-text: #6c7a87;
        --shadow: rgba(0, 0, 0, 0.45);
        --shadow-strong: rgba(0, 0, 0, 0.6);
        --btn-secondary: #4a5866;
        --btn-secondary-hover: #5a6977;
        --btn-disabled: #3a4652;
        --success-bg: #15301f; --success-text: #8fdcaf; --success-border: #245a3c;
        --danger-bg: #3a1c1c;  --danger-text: #f3a5a5;  --danger-border: #6b2c2c;
        --mark-bg: #5a4a12;
        --card-slate: #3b4855;
        --card-steel: #2a4158;
        --card-ink: #1e2b38;
        --tone-blue-bg: #1c2d41;   --tone-blue: #8fb9e3;
        --tone-green-bg: #18322a;  --tone-green: #6fd39a;
        --tone-teal-bg: #153330;   --tone-teal: #6dd0c6;
        --tone-purple-bg: #2a2340; --tone-purple: #bba2e6;
        --tone-amber-bg: #3a2c12;  --tone-amber: #e9b860;
        --tone-red-bg: #3a1e1e;    --tone-red: #f0a0a0;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --navy: #142235;
    --navy-dark: #0c1622;
    --heading: #9cc3e8;
    --accent: #2f9a62;
    --accent-hover: #3aae72;
    --accent-light: #1b3027;
    --debit: #f08a8a;
    --credit: #6fd39a;
    --border: #2f3d4b;
    --bg: #0f151c;
    --surface: #17202a;
    --surface-muted: #202b37;
    --row-alt: #1b2530;
    --text: #dde4ea;
    --muted: #93a3b2;
    --faint: #7d8c9a;
    --th-bg: #1f3348;
    --input-bg: #111922;
    --locked-bg: #222c37;
    --locked-text: #6c7a87;
    --shadow: rgba(0, 0, 0, 0.45);
    --shadow-strong: rgba(0, 0, 0, 0.6);
    --btn-secondary: #4a5866;
    --btn-secondary-hover: #5a6977;
    --btn-disabled: #3a4652;
    --success-bg: #15301f; --success-text: #8fdcaf; --success-border: #245a3c;
    --danger-bg: #3a1c1c;  --danger-text: #f3a5a5;  --danger-border: #6b2c2c;
    --mark-bg: #5a4a12;
    --card-slate: #3b4855;
    --card-steel: #2a4158;
    --card-ink: #1e2b38;
    --tone-blue-bg: #1c2d41;   --tone-blue: #8fb9e3;
    --tone-green-bg: #18322a;  --tone-green: #6fd39a;
    --tone-teal-bg: #153330;   --tone-teal: #6dd0c6;
    --tone-purple-bg: #2a2340; --tone-purple: #bba2e6;
    --tone-amber-bg: #3a2c12;  --tone-amber: #e9b860;
    --tone-red-bg: #3a1e1e;    --tone-red: #f0a0a0;
}

* { box-sizing: border-box; }

/* Form controls don't inherit the page font or spacing by default; make them follow it (and the admin font / spacing settings). */
input, select, textarea, button { font-family: inherit; line-height: inherit; letter-spacing: inherit; word-spacing: inherit; }

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
}

.text-muted { color: var(--muted); }
.text-debit { color: var(--debit); }

.topbar {
    background: var(--navy);
    color: #fff;
    font-size: calc(1rem * var(--menu-scale, 1));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.brand { font-size: 1.2em; font-weight: 600; }
.brand span { color: #9fd8b8; font-weight: 400; font-size: 0.75em; }

nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
nav > a, nav .dropdown > a {
    color: #fff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
}
nav > a:hover, nav .dropdown > a:hover, .dropdown:hover > a { background: var(--navy-dark); }

.dropdown { position: relative; }
.dropdown-content {
    display: none;
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    min-width: 240px;
    box-shadow: 0 8px 20px var(--shadow-strong);
    border-radius: 6px;
    overflow: hidden;
    z-index: 20;
}
.dropdown-content a { color: var(--heading); padding: 10px 14px; display: block; text-decoration: none; font-size: 0.92em; }
.dropdown-content a:hover { background: var(--accent-light); }
.dropdown:hover .dropdown-content { display: block; }

.theme-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px; padding: 6px 10px; margin-left: 8px; cursor: pointer; font: inherit; font-size: 0.88em;
}
.theme-toggle:hover { background: var(--navy-dark); }
.theme-toggle > span { display: inline-flex; align-items: center; gap: 6px; }
[hidden] { display: none !important; }

.container { max-width: 1180px; margin: 24px auto; padding: 0 20px 40px; }

footer { text-align: center; color: var(--faint); font-size: 0.82rem; padding: 20px; }
footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; }
.footer-install {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer;
    color: var(--accent); background: var(--accent-light); border: 1px solid transparent; border-radius: 999px; padding: 6px 14px;
}
.footer-install:hover { border-color: var(--accent); }
.footer-install .icon { width: 16px; height: 16px; vertical-align: 0; }
/* "Add to Home Screen" help (wwwroot/js/install.js) when the browser has no install prompt to show. */
.install-dialog {
    width: min(440px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px; padding: 22px;
    background: var(--surface); color: var(--text); box-shadow: 0 20px 60px var(--shadow-strong);
}
.install-dialog::backdrop { background: rgba(10, 20, 30, 0.55); }
.install-dialog-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.install-dialog-head img { border-radius: 12px; flex: none; }
.install-dialog h2 { margin: 0 0 2px; font-size: 1.15rem; }
.install-dialog-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.install-dialog ol { margin: 0 0 8px; padding-left: 22px; display: grid; gap: 8px; line-height: 1.45; }
.install-note { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.install-dialog .btn-row { justify-content: flex-end; }

h1, h2, h3 { color: var(--heading); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.panel-title {
    background: var(--navy);
    color: #fff;
    padding: 10px 16px;
    border-radius: 6px 6px 0 0;
    margin: -20px -20px 16px -20px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

table { border-collapse: collapse; width: 100%; font-size: calc(0.92rem * var(--table-scale, 1)); }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
th { background: var(--th-bg); color: #fff; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--accent-light); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dr { color: var(--debit); }
.cr { color: var(--credit); }

.table-scroll { overflow-x: auto; }

.grid-input { width: 100%; border: 1px solid transparent; background: transparent; color: inherit; padding: 4px; font-size: calc(0.9rem * var(--table-scale, 1)); }
.grid-input:focus { border-color: var(--heading); background: var(--input-bg); outline: none; }
select.grid-input option { background: var(--surface); color: var(--text); }

.row-delete-btn {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: transparent; color: var(--faint); font-size: 1.05rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.row-delete-btn:hover { background: var(--danger-bg); color: var(--debit); }

tr.locked-row td { background: var(--surface-muted); }
.permission-note { background: var(--surface-muted); color: var(--muted); border: 1px dashed var(--border); }
.grid-input.locked, input.grid-input[readonly] {
    background: var(--locked-bg);
    color: var(--locked-text);
    cursor: not-allowed;
}

/* ---- Searchable Account Name (see entrygrid.js) ---- */
.ac-combo { display: block; }
.ac-select { display: none; }
.ac-search::placeholder { color: var(--faint); }
.ac-list {
    position: fixed; z-index: 50;
    max-height: 260px; overflow-y: auto;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 10px 24px var(--shadow-strong);
    font-size: calc(0.9rem * var(--table-scale, 1)); padding: 4px 0;
}
.ac-item { padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.ac-item:hover { background: var(--surface-muted); }
.ac-item.active { background: var(--accent-light); color: var(--heading); }
.ac-item mark { background: var(--mark-bg); color: inherit; font-weight: 600; padding: 0; }
.ac-empty { padding: 8px 12px; color: var(--muted); font-style: italic; }

form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 4px; color: var(--heading); font-size: 0.88rem; }
form input[type=text], form input[type=number], form input[type=date], form input[type=email], form input[type=password], form select, form textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.95rem;
    background: var(--input-bg); color: var(--text);
}
/* Entry-grid cells inside a form follow the table text size, not the form-field size. */
form input.grid-input, form select.grid-input { font-size: calc(0.95rem * var(--table-scale, 1)); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 24px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 24px; }

.btn {
    display: inline-block;
    background: var(--navy);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.92rem;
}
.btn:hover { background: var(--navy-dark); }
.btn:disabled, .btn:disabled:hover { background: var(--btn-disabled); cursor: not-allowed; opacity: 0.8; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-print { background: #c2410c; } /* orange; dark enough for white text in both themes */
.btn-print:hover { background: #9a3412; }
.btn-danger { background: #8a2626; }
.btn-danger:hover { background: #6b1b1b; }
.btn-secondary { background: var(--btn-secondary); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .field { margin-bottom: 0; }

.summary-box {
    display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.summary-card {
    background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 6px; min-width: 160px;
}
.summary-card .label { font-size: 0.78rem; opacity: 0.8; }
.summary-card .value { font-size: 1.25rem; font-weight: 700; }
.summary-card.accent { background: var(--accent); }
.summary-card.slate { background: var(--card-slate); }
.summary-card.steel { background: var(--card-steel); }
.summary-card.ink { background: var(--card-ink); }
/* Debit/credit-coloured figures sit on dark cards in both themes. */
.summary-card .value.dr { color: #ffb3b3; }
.summary-card .value.cr { color: #9fe8bd; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.92rem; }
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-dr { background: var(--danger-bg); color: var(--debit); }
.badge-cr { background: var(--success-bg); color: var(--credit); }

.total-row td { font-weight: 700; background: var(--accent-light) !important; }

a.link { color: var(--heading); font-weight: 600; text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* ---- Icons (inline SVG, see Helpers/Icons.cs) ---- */
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }
nav > a, nav .dropdown > a { display: inline-flex; align-items: center; gap: 6px; }
.topbar .icon { width: 1.125em; height: 1.125em; }
.dropdown-content a { display: flex; align-items: center; gap: 10px; }
.dropdown-content a .icon { color: var(--accent); }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-icon { width: 22px; height: 22px; color: var(--accent); }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.menu-card {
    display: flex; align-items: flex-start; gap: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px;
    text-decoration: none; color: var(--heading);
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.menu-card:hover { box-shadow: 0 8px 20px var(--shadow); transform: translateY(-2px); border-color: var(--faint); }
.menu-card h3 { margin: 0 0 6px 0; font-size: 1.02rem; }
.menu-card p { margin: 0; color: var(--muted); font-size: 0.86rem; }

.menu-icon {
    width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.menu-icon .icon { width: 24px; height: 24px; vertical-align: 0; }
.menu-card:hover .menu-icon { filter: saturate(1.3); }
.tone-blue   { background: var(--tone-blue-bg);   color: var(--tone-blue); }
.tone-green  { background: var(--tone-green-bg);  color: var(--tone-green); }
.tone-teal   { background: var(--tone-teal-bg);   color: var(--tone-teal); }
.tone-purple { background: var(--tone-purple-bg); color: var(--tone-purple); }
.tone-amber  { background: var(--tone-amber-bg);  color: var(--tone-amber); }
.tone-red    { background: var(--tone-red-bg);    color: var(--tone-red); }

/* ---- Home screen ---- */
.home-page > h1 small { color: var(--muted); font-size: 1rem; font-weight: 400; }
.home-intro { color: var(--muted); }
.home-page .menu-grid + .section-title { margin-top: 32px; }

/* Admin-chosen icon colour (inline --tile), readable in both themes. */
.tone-custom { background: color-mix(in srgb, var(--tile) 16%, transparent); color: var(--tile); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tone-custom { background: color-mix(in srgb, var(--tile) 30%, transparent); color: color-mix(in srgb, var(--tile) 50%, #ffffff); }
}
:root[data-theme="dark"] .tone-custom { background: color-mix(in srgb, var(--tile) 30%, transparent); color: color-mix(in srgb, var(--tile) 50%, #ffffff); }

/* ---- Admin ---- */
.dropdown-content.dropdown-right { right: 0; }
.dropdown-content form { margin: 0; }
.dropdown-info { display: block; padding: 8px 14px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.dropdown-button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: none; border: none; text-align: left; cursor: pointer;
    color: var(--heading); padding: 10px 14px; font: inherit; font-size: 0.92em;
    border-top: 1px solid var(--border);
}
.dropdown-button:hover { background: var(--accent-light); }
.dropdown-button .icon { color: var(--accent); }
.auth-panel { max-width: 460px; margin: 40px auto; }

/* ---- Sign-in page: illustration panel (wwwroot/images/login-illustration.svg) beside the form ---- */
.login-shell {
    display: grid; grid-template-columns: 1.15fr 1fr; max-width: 980px; margin: 36px auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    overflow: hidden; box-shadow: 0 18px 50px var(--shadow);
}
.login-hero {
    position: relative; display: flex; flex-direction: column; gap: 18px; padding: 34px 34px 30px;
    color: #fff; background: radial-gradient(circle at 85% 10%, rgba(255,255,255,0.12), transparent 45%),
        linear-gradient(140deg, #1b3a5c 0%, #1d4f5e 55%, #1f6f43 100%);
}
.login-hero-title { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.2px; }
.login-hero-tag { margin-top: 4px; font-size: 0.92rem; color: rgba(255,255,255,0.78); letter-spacing: 0.4px; }
.login-hero-art { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }
.login-hero-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9rem; color: rgba(255,255,255,0.88); }
.login-hero-points li { position: relative; padding-left: 22px; }
.login-hero-points li::before {
    content: ""; position: absolute; left: 0; top: 0.42em; width: 10px; height: 10px; border-radius: 50%;
    background: #f6c453; box-shadow: 0 0 0 3px rgba(246,196,83,0.25);
}
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 40px 40px 32px; }
.login-form-head { margin-bottom: 22px; }
.login-form-head h1 { margin: 12px 0 4px; font-size: 1.55rem; }
.login-form-head p { margin: 0; }
.login-lock {
    display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px;
    background: var(--accent-light); color: var(--accent);
}
.login-lock .icon { width: 24px; height: 24px; vertical-align: 0; }
.login-form input[type=text], .login-form input[type=password] { padding: 11px 12px; font-size: 1rem; }
.login-submit { width: 100%; padding: 12px; font-size: 1rem; font-weight: 600; margin-top: 6px; }
.login-help { margin: 18px 0 0; text-align: center; }

@media screen and (max-width: 760px) {
    body.login-page .container { margin: 0; padding: 0; }
    .login-shell { grid-template-columns: 1fr; margin: 0; border: none; border-radius: 0; box-shadow: none; }
    .login-hero { padding: 22px 18px 18px; gap: 12px; }
    .login-hero-title { display: none; } /* the top bar already shows the name */
    .login-hero-art { max-width: 300px; }
    .login-hero-points { display: none; }
    .login-form { padding: 24px 18px 28px; }
}
/* ---- Trial Balance options / print ---- */
.tb-options .field { min-width: 150px; }
.tb-options .ac-combo { min-width: 230px; }
.tb-table th.tb-band { text-align: center; }
.tb-group-head td { background: var(--surface-muted) !important; font-weight: 700; color: var(--heading); }
.tb-indent { padding-left: 24px; }
.tb-subtotal td { font-weight: 600; border-top: 2px solid var(--border); }
.tb-diff { color: var(--debit); font-weight: 600; margin-top: 12px; }
.print-only { display: none; }
/* Company name + financial year heading on every report (Views/Shared/_ReportHeading),
   tight to the panel top, with the report's title bar centred straight under it. */
.report-company { text-align: center; font-size: 1.35rem; line-height: 1.25; font-weight: 700; color: var(--heading); margin: -8px 0 8px; }
.report-company-hint { text-align: center; margin: -4px 0 8px; }
/* The title bar normally sits flush with the panel top (negative margin); below the company heading it must not pull up over it. */
.report-company ~ .panel-title { margin-top: 0; margin-bottom: 12px; border-radius: 0; text-align: center; padding: 8px 16px; }
/* Period line under the report header ("As on ...", "For the period ...", "from to"). */
.report-period { text-align: center; color: var(--muted); margin: 0 0 12px; }
.panel > p.no-print[data-export-subtitle] { text-align: center; margin-top: 0; }
/* Ledger: the chosen account, centred over its period line. */
.report-account { text-align: center; margin: 0 0 2px; }
/* Daybook Report: narration sits under the account name; either may run to several lines. */
.daybook-table td { vertical-align: top; }
.daybook-table td.particulars { min-width: 220px; max-width: 420px; }
.particulars-ac, .particulars-narration { white-space: pre-line; overflow-wrap: anywhere; }
.daybook-table td.day-head { text-align: center; }
.cash-closing td { color: var(--accent); border-top: none; }
.print-col-off { opacity: 0.4; } /* column ticked off for printing: still shown on screen, dimmed */
.tb-group-head .print-col-off { opacity: 1; } /* ...but keep date heading bands solid */
.particulars-narration { color: var(--muted); font-style: italic; font-size: 0.9em; padding-left: 12px; }
.audit-filters .field { min-width: 140px; }
.audit-filters .ac-combo { min-width: 170px; }
.audit-table td { vertical-align: top; }
.audit-table details summary { cursor: pointer; }
.audit-details { white-space: pre-wrap; margin: 6px 0 0; padding: 8px 10px; background: var(--surface-muted); border-radius: 4px; font-size: 0.85em; max-height: 320px; overflow: auto; }
.audit-action { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.audit-good { background: var(--success-bg); color: var(--success-text); }
.audit-bad { background: var(--danger-bg); color: var(--danger-text); }
.audit-warn { background: var(--tone-amber-bg); color: var(--tone-amber); }
.audit-info { background: var(--surface-muted); color: var(--muted); }
.validation-errors ul { margin: 0 0 14px; padding: 10px 14px 10px 30px; background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); border-radius: 6px; }
.validation-errors.validation-summary-valid { display: none; }
.link-danger { background: none; border: none; color: var(--debit); cursor: pointer; padding: 0; font: inherit; font-weight: 600; }
.link-danger:hover { text-decoration: underline; }
form label.checkbox-line { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.permission-grid .perm-col { text-align: center; width: 90px; }
.permission-grid input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.permission-grid .perm-section td { background: var(--surface-muted); font-weight: 700; color: var(--heading); }
.perm-all { background: none; border: 1px solid rgba(255,255,255,0.5); color: inherit; border-radius: 3px; font-size: 0.72rem; padding: 0 6px; cursor: pointer; margin-top: 2px; }
td .perm-all { border-color: var(--border); color: var(--muted); }
code { background: var(--surface-muted); padding: 1px 5px; border-radius: 3px; font-size: 0.88em; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 10px 20px; }
.color-row {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface);
}
.color-row input[type=color] {
    width: 44px; height: 34px; padding: 2px; flex-shrink: 0; cursor: pointer;
    border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg);
}
.color-row .menu-icon { width: 36px; height: 36px; border-radius: 8px; }
.color-row .menu-icon .icon { width: 20px; height: 20px; }
.color-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.color-text small { font-size: 0.8rem; }
form label.color-custom { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; white-space: nowrap; cursor: pointer; }
.size-row input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--accent); }
.size-value { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: 6px; }
.size-sample { margin-top: 12px; }
.size-sample table { margin-top: 6px; }

/* ---- Display Settings tabs ---- */
.settings-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.settings-tab {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; color: var(--muted); border: none; border-bottom: 3px solid transparent;
    margin-bottom: -2px; padding: 10px 16px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
    border-radius: 6px 6px 0 0;
}
.settings-tab:hover { color: var(--heading); background: var(--surface-muted); }
.settings-tab[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--accent); }
.settings-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.settings-tab .icon { color: var(--accent); }
.tab-panel > .section-title:first-child { margin-top: 0 !important; }
.settings-preview { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--border); }
.tab-reset { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--border); }
.transfer-box { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }
.preview-banner {
    position: sticky; top: 0; z-index: 40;
    background: #fff4cc; color: #5a4300; border-bottom: 2px solid #e0b400;
    padding: 10px 24px; font-size: 0.92rem; text-align: center;
}
.transfer-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.transfer-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.btn-row .btn .icon { vertical-align: -3px; margin-right: 4px; }
.preview-picker { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.preview-picker .ac-combo { min-width: 220px; }
.import-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.import-form input[type=file] { color: var(--text); font-size: 0.9rem; max-width: 100%; }
.font-row select { margin-top: 6px; }
.font-sample { display: block; margin-top: 8px; font-size: 1.05rem; color: var(--heading); }
.highlight-sample-line { display: block; margin-top: 8px; font-size: 1.05rem; color: var(--heading); }
.highlight-sample { padding: 0 0.3em; border-radius: 3px; }

/* ---- Mobile app look (pages whose body has class "mobile-app") ----
   Phones get an app-style screen: a top bar with a back button (_MobileAppBar)
   instead of the menu bar, the page's actions in a bar fixed to the bottom
   (.m-actions), lists as cards (table.m-cards, labels from data-label) and forms
   in one column. Entry screens (also "entry-screen") show their grid rows as
   cards too. Same fields and forms as on desktop, so nothing else changes. */
.mobile-appbar, .m-only { display: none; }
/* Home cards that are buttons (phone-only Dark Mode / Sign Out). */
.menu-card-button { width: 100%; font: inherit; text-align: left; cursor: pointer; }
@media screen and (max-width: 760px) {
    /* Shell: app bar, no menu bar / footer, edge-to-edge panel. */
    body.mobile-app .topbar, body.mobile-app footer { display: none; }
    body.mobile-app .container { margin: 0; padding: 0 0 84px; display: flex; flex-direction: column; }
    body.mobile-app .container > .alert { margin: 10px 12px 0; }

    body.mobile-app .mobile-appbar {
        order: -1; display: flex; align-items: center; gap: 4px;
        position: sticky; top: 0; z-index: 40;
        background: var(--navy); color: #fff;
        padding: 8px 12px 8px 4px; padding-top: max(8px, env(safe-area-inset-top));
        box-shadow: 0 2px 8px var(--shadow-strong);
    }
    .mobile-back {
        display: flex; align-items: center; justify-content: center; flex: none;
        width: 44px; height: 44px; border-radius: 50%; color: #fff; text-decoration: none;
    }
    .mobile-back:active { background: var(--navy-dark); }
    .mobile-appbar-title { min-width: 0; line-height: 1.25; }
    .mobile-appbar-title div { font-weight: 600; font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-appbar-title small { opacity: 0.8; font-size: 0.8rem; }

    body.mobile-app .panel { border: none; border-radius: 0; background: transparent; padding: 12px; margin: 0; max-width: none !important; }
    body.mobile-app .panel-title, body.mobile-app .entry-help { display: none; }
    body.mobile-app .m-only { display: block; }
    body.mobile-app .mobile-appbar.no-back { padding-left: 16px; }

    /* Home: one card per line; Administration / My Account sections (m-only) appear. */
    body.home-screen .home-page { padding: 4px 12px 0; }
    body.home-screen .home-page > h1, body.home-screen .home-intro { display: none; }
    body.home-screen .section-title { margin: 18px 0 10px; }
    body.home-screen .menu-grid { grid-template-columns: 1fr; gap: 10px; }
    body.home-screen .home-page .menu-grid + .section-title { margin-top: 18px; }
    body.home-screen .menu-card { padding: 12px 14px; gap: 12px; align-items: center; }
    body.home-screen .menu-icon { width: 40px; height: 40px; }
    body.home-screen .menu-card p { font-size: 0.82rem; }

    /* Display Settings: tabs scroll sideways in one line. */
    body.mobile-app .settings-tabs { flex-wrap: nowrap; overflow-x: auto; }
    body.mobile-app .settings-tab { flex: none; }

    /* Forms: one column, touch-sized fields; 16px text stops phones zooming in on focus. */
    body.mobile-app .form-grid, body.mobile-app .form-grid-3 { grid-template-columns: 1fr; }
    body.mobile-app form input[type=text], body.mobile-app form input[type=number], body.mobile-app form input[type=date],
    body.mobile-app form input[type=email], body.mobile-app form input[type=password], body.mobile-app form select,
    body.mobile-app form textarea, body.mobile-app .ac-search {
        font-size: 16px; min-height: 42px; border-radius: 6px;
    }
    body.mobile-app .ac-item { padding: 10px 14px; font-size: 16px; }

    /* Search bar on list screens: the box takes the full width. */
    body.mobile-app .m-search-bar, body.mobile-app .m-search { width: 100%; }
    body.mobile-app .m-search { flex-wrap: nowrap; }
    body.mobile-app .m-search .field { flex: 1; min-width: 0; }

    /* Floating "+ New" button. */
    body.mobile-app .m-fab {
        position: fixed; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 40;
        border-radius: 28px; padding: 14px 22px; font-size: 1rem; box-shadow: 0 4px 14px var(--shadow-strong);
    }

    /* Page actions fixed at the bottom; .m-hide buttons (Print, Close = Back) hidden. */
    body.mobile-app .m-actions {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0;
        display: flex; gap: 10px; flex-wrap: nowrap;
        padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px var(--shadow-strong);
    }
    body.mobile-app .m-actions .btn { flex: 1; text-align: center; padding: 12px; font-size: 1rem; border-radius: 8px; }
    body.mobile-app .m-actions .m-hide, body.mobile-app .key-hint { display: none; }

    /* Lists as cards: the .m-title cell is the card heading, the rest are labelled
       fields (empty ones hidden), .m-row-actions holds Edit / Delete. */
    body.mobile-app .table-scroll { overflow-x: auto; } /* wide tables (e.g. the role permission grid) scroll sideways */
    body.mobile-app table.m-cards, body.mobile-app table.m-cards tbody { display: block; }
    body.mobile-app table.m-cards thead { display: none; }
    body.mobile-app table.m-cards tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
        background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px var(--shadow-strong);
    }
    body.mobile-app table.m-cards td { display: block; border: none; padding: 0; background: transparent; min-width: 0; overflow-wrap: anywhere; }
    body.mobile-app table.m-cards td:empty { display: none; }
    body.mobile-app table.m-cards td[data-label]::before {
        content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 2px;
    }
    body.mobile-app table.m-cards td.num { text-align: left; }
    body.mobile-app table.m-cards td.m-wide { grid-column: 1 / -1; }
    body.mobile-app table.m-cards td.m-title { order: -1; grid-column: 1 / -1; font-size: 1.05rem; font-weight: 700; color: var(--heading); }
    body.mobile-app table.m-cards td.m-row-actions { grid-column: 1 / -1; text-align: right; border-top: 1px solid var(--border); padding-top: 8px; }
    body.mobile-app table.m-cards td.m-row-actions a, body.mobile-app table.m-cards td.m-row-actions button { display: inline-block; padding: 6px 4px; font-size: 1rem; }

    /* ---- Reports: options stacked, tables kept as tables (group / total rows
       need their columns) but compact and scrolling sideways, two-sided
       statements (Trading, P&L, Balance Sheet) one side under the other. ---- */
    body.report-screen .report-company { font-size: 1.1rem; }
    body.report-screen form.toolbar { gap: 8px; }
    body.report-screen form.toolbar .field { flex: 1 1 100%; min-width: 0; }
    body.report-screen form.toolbar .field:has(input[type=date]),
    body.report-screen form.toolbar .field:has(input[type=checkbox]) { flex: 1 1 calc(50% - 4px); }
    body.report-screen form.toolbar .btn { flex: 1 1 auto; text-align: center; padding: 11px 10px; font-size: 0.95rem; }
    body.report-screen form.toolbar select, body.report-screen form.toolbar .ac-combo { min-width: 0 !important; width: 100%; }
    body.report-screen .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px; }
    body.report-screen table { font-size: calc(0.8rem * var(--table-scale, 1)); }
    body.report-screen th, body.report-screen td { padding: 5px 6px; }
    body.report-screen td.num, body.report-screen th.num { white-space: nowrap; }
    body.report-screen .daybook-table td.particulars { min-width: 150px; }
    body.report-screen .two-sided { grid-template-columns: 1fr !important; gap: 14px !important; }

    /* ---- Entry screens (Day Book / Cash Book): grid rows as cards. ---- */
    body.entry-screen .entry-date, body.entry-screen .entry-date .field { width: 100%; }

    body.mobile-app .summary-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    body.mobile-app .summary-card { min-width: 0; padding: 8px 12px; }
    body.mobile-app .summary-card .value { font-size: 1.02rem; overflow-wrap: anywhere; }

    body.entry-screen [data-autogrow-grid], body.entry-screen [data-autogrow-grid] tbody { display: block; }
    body.entry-screen [data-autogrow-grid] thead { display: none; }
    body.entry-screen [data-autogrow-grid] tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; position: relative;
        background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 10px 12px 12px; margin-bottom: 12px; box-shadow: 0 1px 3px var(--shadow-strong);
    }
    body.entry-screen [data-autogrow-grid] tr.locked-row { background: var(--surface-muted); }
    body.entry-screen [data-autogrow-grid] td { display: block; border: none; padding: 0; background: transparent; min-width: 0; }
    body.entry-screen [data-autogrow-grid] td::before {
        content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 3px;
    }
    /* Card order: Entry no. / Account / Narration, then the amount pairs. */
    body.entry-screen [data-autogrow-grid] td.m-sl { grid-column: 1 / -1; order: 0; padding-right: 40px; color: var(--heading); font-weight: 700; }
    body.entry-screen [data-autogrow-grid] td.m-sl::before { display: inline; font-size: inherit; color: inherit; margin-right: 4px; }
    body.entry-screen [data-autogrow-grid] td.m-wide { grid-column: 1 / -1; }
    body.entry-screen [data-autogrow-grid] td[data-label="Account Name"] { order: 1; }
    body.entry-screen [data-autogrow-grid] td[data-label="Narration"] { order: 2; }
    body.entry-screen [data-autogrow-grid] td[data-label="Receipts"] { order: 3; }
    body.entry-screen [data-autogrow-grid] td[data-label="Payments"] { order: 4; }
    body.entry-screen [data-autogrow-grid] td[data-label="Debit"] { order: 5; }
    body.entry-screen [data-autogrow-grid] td[data-label="Credit"] { order: 6; }
    body.entry-screen [data-autogrow-grid] td[data-label="Inv.No"] { order: 7; }
    body.entry-screen [data-autogrow-grid] td.m-del { position: absolute; top: 6px; right: 6px; }
    body.entry-screen [data-autogrow-grid] td.m-del::before { display: none; }
    body.entry-screen .row-delete-btn { width: 36px; height: 36px; font-size: 1.4rem; }

    body.entry-screen form .grid-input {
        font-size: 16px; min-height: 42px; padding: 8px 10px;
        border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg);
    }
    body.entry-screen form .grid-input.locked, body.entry-screen form input.grid-input[readonly] { background: var(--locked-bg); }
}


/* ---- Account Transactions Summary chart (wwwroot/js/accountsummary.js) ----
   Categorical series colours, validated for colour-blind separation against
   the light (#ffffff) and dark (#17202a) surfaces; dark uses its own steps. */
:root {
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-other: #9aa5ad;
    --chart-grid: #e1e0d9;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
        --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-other: #5f6d7a;
        --chart-grid: #2c3946;
    }
}
:root[data-theme="dark"] {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-other: #5f6d7a;
    --chart-grid: #2c3946;
}
.ats-chart { position: relative; margin-bottom: 20px; }
.ats-chart h3 { margin-bottom: 8px; }
.ats-controls { margin-bottom: 8px; }
.ats-controls .field { min-width: 170px; }
.ats-caption { margin: 0 0 12px; font-size: 0.9rem; }
.s1 { --c: var(--series-1); } .s2 { --c: var(--series-2); } .s3 { --c: var(--series-3); } .s4 { --c: var(--series-4); }
.s5 { --c: var(--series-5); } .s6 { --c: var(--series-6); } .s7 { --c: var(--series-7); } .s-other { --c: var(--series-other); }

.ats-legend { display: flex; gap: 18px; margin-bottom: 10px; font-size: 0.9rem; color: var(--text); }
.ats-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ats-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }

.ats-bars { --ats-label-room: 120px; display: grid; gap: 2px; max-width: 980px; }
.ats-row { display: grid; grid-template-columns: minmax(110px, 240px) 1fr; align-items: center; gap: 12px; padding: 4px 6px; border-radius: 4px; outline: none; }
.ats-row:hover, .ats-row:focus-visible { background: var(--surface-muted); }
.ats-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.ats-name { font-size: 0.88rem; color: var(--text); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ats-track { border-left: 1px solid var(--chart-grid); display: grid; gap: 2px; }
.ats-line { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.ats-bar { display: block; height: 16px; background: var(--c); border-radius: 0 4px 4px 0; flex: none; }
.ats-paired .ats-bar { height: 10px; }
.ats-paired .ats-line { min-height: 12px; }
.ats-val { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.ats-pie { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.ats-donut { width: 240px; height: 240px; flex: none; }
.ats-slice { fill: var(--c); stroke: var(--surface); stroke-width: 2px; outline: none; cursor: default; }
circle.ats-slice { fill: none; stroke: var(--c); }
.ats-slice:hover, .ats-slice:focus-visible { opacity: 0.85; }
.ats-donut-value { fill: var(--text); font-size: 17px; font-weight: 700; }
.ats-donut-label { fill: var(--muted); font-size: 12px; }
.ats-pie-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-width: 0; flex: 1 1 300px; max-width: 520px; }
.ats-pie-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; gap: 10px; align-items: center; padding: 4px 6px; border-radius: 4px; font-size: 0.88rem; outline: none; }
.ats-pie-legend li:hover, .ats-pie-legend li:focus-visible { background: var(--surface-muted); }
.ats-legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ats-legend-value, .ats-legend-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.ats-tooltip {
    position: absolute; z-index: 20; pointer-events: none; min-width: 190px; max-width: 280px;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 4px 14px var(--shadow-strong); padding: 8px 10px; font-size: 0.85rem;
}
.ats-tooltip strong { display: block; }
.ats-tip-sub { display: block; color: var(--muted); font-size: 0.78rem; margin-bottom: 4px; }
.ats-tooltip dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; }
.ats-tooltip dt { color: var(--muted); }
.ats-tooltip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ats-pick-col { width: 1%; text-align: center; }
.ats-pick { width: 18px; height: 18px; }

@media screen and (max-width: 760px) {
    .ats-controls .field { min-width: 0; }
    .ats-bars { --ats-label-room: 92px; }
    .ats-row { grid-template-columns: minmax(80px, 34%) 1fr; gap: 8px; padding: 4px 2px; }
    .ats-name { font-size: 0.8rem; }
    .ats-val { font-size: 0.74rem; }
    .ats-pie { justify-content: center; gap: 16px; }
    .ats-donut { width: 210px; height: 210px; }
    .ats-pie-legend { flex-basis: 100%; }
}

@media print {
    /* Screens the role may not print: print a notice instead of the page (see PermissionService.CanPrintCurrent). */
    body.print-blocked > * { display: none !important; }
    body.print-blocked::before { content: "Printing this screen is not allowed for your role."; display: block; padding: 40px; font-size: 16pt; text-align: center; }
    /* Always print in light colours, whatever theme is on screen. */
    :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
        color-scheme: light;
        --heading: #1b3a5c; --text: #202a33; --muted: #5a6b7a; --faint: #7a8896;
        --bg: #ffffff; --surface: #ffffff; --surface-muted: #eef2f5; --row-alt: #f0f4f8;
        --border: #c9d3dc; --th-bg: #1b3a5c; --navy: #1b3a5c; --accent: #1f6f43; --accent-light: #eaf6ef;
        --debit: #7a1f1f; --credit: #14532d; --input-bg: #ffffff; --locked-bg: #ffffff; --locked-text: #202a33;
        --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
        --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-other: #9aa5ad; --chart-grid: #e1e0d9;
    }
    .no-print { display: none !important; }
    .ats-chart { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ats-tooltip { display: none !important; }
    .print-only { display: block !important; }
    /* Report header on paper: company line, then the title as plain centred text (the navy bar
       would print as white-on-white), no gaps. Reports with their own printed heading (title +
       options line) print that instead of the title bar. */
    .panel:has(> .report-company) { border: none; padding: 0; }
    .report-company { margin: 0 0 2px; font-size: 15pt; }
    .report-company ~ .panel-title { background: none; color: var(--heading); padding: 0; margin: 0 0 8px; font-size: 13pt; }
    .panel:has(> .tb-print-heading) > .panel-title { display: none; }
    .tb-print-heading { text-align: center; margin-bottom: 8px; }
    .tb-print-heading h2 { margin: 0 0 2px; font-size: 13pt; }
    .tb-table { font-size: 10pt; }
    .tb-table tr { break-inside: avoid; }
    .tb-table thead { display: table-header-group; }
    .tb-table .tb-group-head { break-after: avoid; } /* keep a group's subheading with its first account */
    .container { margin: 0; max-width: 100%; }
    body { background: #fff; }
    .ac-list { display: none !important; }
}

/* ---- Financial calculators (Views/Calculators, wwwroot/js/calculators.js) ---- */
.calc-intro { margin: 0 0 16px; }
.calc-badge { font-weight: 800; font-size: 0.78rem; letter-spacing: 0.2px; }
.calc-badge-long { font-size: 0.66rem; letter-spacing: 0; }
.calc-switcher { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.calc-switcher a {
    padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text);
    text-decoration: none; font-size: 0.85rem; font-weight: 600; background: var(--surface);
}
.calc-switcher a:hover { border-color: var(--accent); color: var(--accent); }
.calc-switcher a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.calc-layout { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 28px; align-items: start; }
.calc-inputs { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 10px; padding: 16px 16px 12px; }
.calc-inputs .btn-row { margin-top: 4px; }
.calc-field { margin-bottom: 14px; }
.calc-input { position: relative; }
.calc-input.has-unit input { padding-left: 28px; }
.calc-input.unit-percent input { padding-left: 10px; padding-right: 30px; }
.calc-unit { position: absolute; top: 50%; transform: translateY(-50%); left: 10px; color: var(--muted); font-weight: 600; pointer-events: none; }
.calc-input.unit-percent .calc-unit { left: auto; right: 12px; }
.calc-input input { width: 100%; box-sizing: border-box; font-variant-numeric: tabular-nums; }
.calc-range { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
.calc-copied { margin: 8px 0 0; font-size: 0.85rem; }
.calc-cf { display: grid; gap: 6px; }
.calc-cf-row { display: grid; grid-template-columns: 64px 1fr 32px; gap: 8px; align-items: center; }
.calc-cf-year { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.calc-cf-remove { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 6px; height: 32px; font-size: 1.1rem; cursor: pointer; }
.calc-cf-remove:hover { color: var(--danger-text); border-color: var(--danger-border); }
.calc-cf-actions { margin: 8px 0 4px; }
.calc-cf-actions .btn { padding: 6px 12px; font-size: 0.85rem; }

.calc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.calc-tile { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; background: var(--surface); }
.calc-tile .label { font-size: 0.8rem; color: var(--muted); }
.calc-tile .value { font-size: 1.35rem; font-weight: 700; color: var(--heading); margin-top: 2px; overflow-wrap: anywhere; }
.calc-tile.accent { background: var(--accent); border-color: var(--accent); }
.calc-tile.accent .label { color: rgba(255,255,255,0.85); }
.calc-tile.accent .value { color: #fff; }
.calc-tiles.stale, .calc-split.stale { opacity: 0.35; }
.calc-split-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin-bottom: 10px; background: var(--surface-muted); }
.calc-split-seg { display: block; height: 100%; background: var(--c); }
.calc-split-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-width: 460px; }
.calc-split-legend li { display: grid; grid-template-columns: 12px 1fr auto 64px; gap: 10px; align-items: center; font-size: 0.9rem; }
.calc-split-legend strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-split-legend em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.calc-note { margin: 14px 0 0; font-size: 0.9rem; }
.calc-error { margin-bottom: 14px; }

.calc-detail { position: relative; margin-top: 26px; }
.calc-detail h3 { margin-bottom: 10px; }
.calc-columns { margin-bottom: 16px; position: relative; }
.calc-legend { display: flex; gap: 18px; font-size: 0.88rem; margin-bottom: 8px; }
.calc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.calc-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; height: 200px; align-items: end; border-bottom: 1px solid var(--chart-grid); padding-top: 18px; }
.calc-col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; outline: none; }
.calc-col:hover .calc-stack, .calc-col:focus-visible .calc-stack { filter: brightness(1.08); }
.calc-col:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; }
.calc-stack { width: min(24px, 80%); display: flex; flex-direction: column-reverse; gap: 2px; min-height: 2px; }
.calc-seg { display: block; width: 100%; background: var(--c); }
.calc-stack .calc-seg:last-child { border-radius: 4px 4px 0 0; }
.calc-col-label { position: absolute; bottom: -20px; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.calc-col-max { position: absolute; top: 26px; left: 0; font-size: 0.72rem; color: var(--muted); }
.calc-columns .calc-cols { margin-bottom: 24px; }
.calc-tooltip dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 4px 0 0; }
.calc-disclaimer { margin: 18px 0 0; }
.calc-table td:first-child, .calc-table th:first-child { white-space: nowrap; }

/* Footer: calculator links. */
.footer-calcs { flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; align-items: center; }
.footer-calcs > span { font-weight: 600; margin-right: 4px; }
.footer-calcs a { color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 4px; }
.footer-calcs a:hover { color: var(--accent); background: var(--accent-light); }

@media screen and (max-width: 760px) {
    .calc-layout { grid-template-columns: 1fr; gap: 16px; }
    .calc-switcher { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .calc-switcher a { flex: none; }
    .calc-tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
    .calc-tile { padding: 10px 12px; }
    .calc-tile .value { font-size: 1.1rem; }
    .calc-cols { height: 160px; }
    body.calc-screen .container { padding-bottom: 24px; }
}
@media print {
    .calc-range, .calc-switcher, .calc-cf-actions, .calc-cf-remove { display: none !important; }
    .calc-layout { grid-template-columns: 1fr 1.4fr; }
    .calc-split-bar, .calc-seg, .calc-tile.accent { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Ledger Statement: interest on outstanding (Services/OutstandingInterest). */
.ledger-interest-rate input { width: 110px; }
.ledger-interest-title { margin: 22px 0 4px; }
.ledger-interest-note { margin: 0 0 10px; font-size: 0.88rem; }
.ledger-interest-table td { white-space: nowrap; }
.ledger-interest-table td:nth-child(2) { white-space: normal; min-width: 160px; }

/* Footer: Features link. */
.footer-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 600; text-decoration: none; }
.footer-link:hover { text-decoration: underline; }
.footer-link .icon { width: 15px; height: 15px; vertical-align: 0; }

/* ---- Features page (Views/Features/Index) ---- */
.features { max-width: 1100px; margin: 0 auto; width: 100%; min-width: 0; }
.features-hero {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; border-radius: 16px;
    padding: 34px 38px; color: #fff; overflow: hidden;
    background: radial-gradient(circle at 85% 10%, rgba(255,255,255,0.12), transparent 45%),
        linear-gradient(140deg, #1b3a5c 0%, #1d4f5e 55%, #1f6f43 100%);
}
.features-kicker { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 1.5px; font-size: 0.78rem; color: #f6c453; font-weight: 700; }
.features-hero h1 { margin: 0 0 10px; color: #fff; font-size: 2rem; }
.features-hero-text > p:not(.features-kicker) { margin: 0 0 20px; color: rgba(255,255,255,0.85); line-height: 1.5; }
.features-hero-art { width: 100%; max-width: 420px; height: auto; justify-self: center; }
.features-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.features-stats li { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); border-radius: 10px; padding: 8px 14px; min-width: 92px; }
.features-stats strong { display: block; font-size: 1.4rem; line-height: 1.1; }
.features-stats span { font-size: 0.78rem; color: rgba(255,255,255,0.8); }
.features-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 6px; }
.features-toc a {
    padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.features-toc a:hover { border-color: var(--accent); color: var(--accent); }
.features-section { padding-top: 26px; scroll-margin-top: 16px; }
.features-section-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.features-section-head h2 { margin: 0; font-size: 1.35rem; }
.features-section-head p { margin: 2px 0 0; color: var(--muted); }
.features-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.features-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.features-card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.features-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.features-card li { position: relative; padding-left: 20px; line-height: 1.45; font-size: 0.92rem; }
.features-card li::before {
    content: ""; position: absolute; left: 2px; top: 0.45em; width: 9px; height: 5px;
    border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg);
}
.features-cta { margin: 14px 0 0; }

@media screen and (max-width: 760px) {
    .features { padding: 0 12px 24px; box-sizing: border-box; }
    .features-hero { grid-template-columns: 1fr; padding: 22px 18px; border-radius: 0 0 14px 14px; margin: 0 -12px; }
    .features-hero h1 { font-size: 1.45rem; }
    .features-hero-art { max-width: 260px; order: -1; }
    .features-toc { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .features-toc a { flex: none; }
    .features-cards { grid-template-columns: 1fr; }
}
@media print {
    .features-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .features-card { break-inside: avoid; }
}

/* ---- Help on data entry screens (Views/Shared/_HelpButton, Help/_<topic>) ----
   Cyan with dark ink (white on cyan is too faint to read). */
:root { --help-bg: #06b6d4; --help-bg-hover: #22d3ee; --help-ink: #083344; }
.btn-help { background: var(--help-bg); color: var(--help-ink); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn-help:hover { background: var(--help-bg-hover); color: var(--help-ink); }
.btn-help .key-hint { color: var(--help-ink); opacity: 0.75; }
.help-q {
    display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
    background: var(--help-ink); color: var(--help-bg); font-weight: 800; font-size: 0.78rem; line-height: 1;
}
.help-q-lg { width: 34px; height: 34px; font-size: 1.1rem; flex: none; background: var(--help-bg); color: var(--help-ink); }
.mobile-help { display: none; }
@media screen and (max-width: 760px) {
    body.mobile-app .mobile-help {
        display: inline-flex; align-items: center; justify-content: center; margin-left: auto; flex: none;
        width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
        background: var(--help-bg); color: var(--help-ink); font-weight: 800; font-size: 1.05rem;
    }
}
.help-dialog {
    width: min(620px, calc(100vw - 24px)); max-height: min(86vh, 820px); border: 1px solid var(--border); border-radius: 14px;
    padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px var(--shadow-strong);
}
.help-dialog[open] { display: flex; flex-direction: column; }
.help-dialog::backdrop { background: rgba(10, 20, 30, 0.55); }
.help-dialog-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 3px solid var(--help-bg); }
.help-dialog-head h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.help-close { border: 0; background: none; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.help-close:hover { color: var(--text); }
.help-close:focus-visible { outline: 2px solid var(--help-bg); outline-offset: 2px; border-radius: 6px; }
.help-dialog-body { padding: 4px 20px 6px; overflow-y: auto; line-height: 1.5; font-size: 0.93rem; }
.help-dialog-body h3 { font-size: 1rem; margin: 14px 0 6px; }
.help-dialog-body p { margin: 0 0 6px; }
.help-dialog-body ul { margin: 0 0 6px; padding-left: 20px; }
.help-dialog-body li { margin-bottom: 4px; }
.help-keys { list-style: none; padding-left: 0 !important; display: grid; gap: 6px; }
.help-dialog kbd {
    display: inline-block; min-width: 28px; text-align: center; padding: 1px 6px; margin-right: 8px; border-radius: 5px;
    border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface-muted); font: 600 0.82rem/1.4 inherit;
}
.help-dialog .btn-row { justify-content: flex-end; padding: 10px 18px 14px; margin: 0; border-top: 1px solid var(--border); }

/* ---- Admin > Backup & Download ---- */
.backup-intro { margin: 0 0 6px; line-height: 1.5; }
.backup-options { display: grid; gap: 8px; }
.backup-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.backup-option:hover { border-color: var(--accent); }
.backup-option.is-fixed { cursor: default; background: var(--surface-muted); }
.backup-option.is-fixed:hover { border-color: var(--border); }
.backup-option input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.backup-option strong { color: var(--heading); }
.backup-option em { font-style: normal; font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
.backup-option small { display: block; color: var(--muted); margin-top: 2px; }
form .backup-option { font-weight: 400; color: var(--text); margin: 0; }
.backup-contents { margin: 0; padding-left: 20px; line-height: 1.7; }
.backup-contents code { font-size: 0.85rem; background: var(--surface-muted); padding: 1px 6px; border-radius: 4px; }
.backup-go { display: inline-flex; align-items: center; gap: 8px; }
.backup-note { margin: 10px 0 0; }
