/* ────────────────────────────────────────────────────────────────────────
   Light-theme layer — split out of assets/dashboard.css.

   _nav.php injects the user's palette tokens and tags <body class="theme-light">
   on EVERY page, but these corrective rules used to live in dashboard.css, which
   only the dashboard links. So on the ~80 standalone pages (reports, admin tools,
   forms) the class did nothing: they kept painting dark-mode surfaces — black
   input tints, a #072318 gradient corner, pale-salmon error text — underneath
   the light tokens. Hence the dashboard looking different from every other page.

   Living in its own file, it can be linked everywhere. Load order matters: it
   must come AFTER both assets/dashboard.css and any page-local <style>.
   _nav.php links it at the top of <body>, which satisfies both, and the
   dashboard includes _nav.php too — so one link covers every page with a nav.
   ─────────────────────────────────────────────────────────────────────── */

/* ── Light theme (ขาว–ทอง / BJ) ─────────────────────────────────────────
   Added by includes/dashboard_layout.php and _nav.php (body.theme-light) when
   the chosen palette has a light background — which the default BJ white+gold
   palette does. The token model was built dark-first, so these scoped
   overrides flip the dark-mode-only assumptions (black-tinted surfaces, heavy
   shadows, pale-gold text). All colors still derive from the palette tokens.  */
body.theme-light.dash-body,
body.theme-light.qp-body {
    /* Flatten the page gradient so the bottom doesn't darken toward grey. */
    background:
        radial-gradient(ellipse 800px 500px at 80% 5%, rgba(var(--accent-rgb),0.10) 0%, transparent 70%),
        radial-gradient(ellipse 600px 700px at 5% 95%, rgba(var(--accent-rgb),0.07) 0%, transparent 70%),
        linear-gradient(160deg, var(--green-dark) 0%, var(--green-card) 100%);
}
/* Pale-gold text tokens are unreadable on white — fall back to the dark gold. */
body.theme-light { --text-gold: var(--gold-dark); }
/* Links: the lightened gold-bright is unreadable on white — use the dark gold. */
body.theme-light a:hover { color: var(--gold-dark); }

/* ── Surfaces ──────────────────────────────────────────────────────────── */
/* Cards/panels: flat card colour (BJ uses plain white cards) with a hairline
   border and a soft shadow, instead of the dark-mode translucent gradient. */
body.theme-light .dash-card,
body.theme-light .qp-card {
    background: rgb(var(--card-rgb, 255,255,255));
    border-color: rgba(var(--border-rgb, var(--accent-rgb)),0.9);
    box-shadow: 0 6px 24px rgba(160,126,24,.08);
}
/* Inputs/selects: white fields, not the dark-mode black tint. */
body.theme-light .qp-input,
body.theme-light .qp-select,
body.theme-light .dash-select,
body.theme-light .dcc-select,
body.theme-light .theme-combo-search,
body.theme-light .dash-imp-form .dash-select,
body.theme-light .dash-imp-filters .dash-select {
    background: rgb(var(--card-rgb, 255,255,255));
    border-color: rgba(var(--border-rgb, var(--accent-rgb)),0.9);
}
body.theme-light .qp-select option,
body.theme-light .dash-select option { background: rgb(var(--card-rgb, 255,255,255)); color: var(--text-primary); }
body.theme-light .qp-input::placeholder { color: var(--text-dim); }
/* Panels that sat on a black tint. */
body.theme-light .dash-tabs,
body.theme-light .dash-setlogin-form,
body.theme-light .dcc-bar,
body.theme-light .theme-combo-panel,
body.theme-light .fc .fc-list-empty {
    background: rgba(var(--accent-rgb),0.06);
    border-color: rgba(var(--border-rgb, var(--accent-rgb)),0.9);
}
/* Dim pills: the white-tint background vanishes on a light page — use an accent tint. */
body.theme-light .dash-pill--dim {
    background: rgba(var(--accent-rgb),0.08);
    border-color: rgba(var(--accent-rgb),0.18);
}

/* ── Side / bottom nav (tokens declared in _nav.php) ───────────────────── */
body.theme-light {
    --nav-bg: rgb(var(--card-rgb, 255,255,255));
    --nav-border: rgba(var(--border-rgb, var(--accent-rgb)),0.9);
    --nav-text: var(--text-muted);
    --nav-text-active: var(--gold-dark);
}
body.theme-light .qp-bottomnav,
body.theme-light .qp-mobile-sheet { box-shadow: 0 -8px 20px -10px rgba(160,126,24,.25); }
body.theme-light .qp-mobile-sheet .nav-item {
    background: rgba(var(--accent-rgb),0.06);
    border-color: rgba(var(--border-rgb, var(--accent-rgb)),0.9);
}
body.theme-light .qp-sidenav .logout a,
body.theme-light .qp-mobile-sheet .logout a { color: var(--error-fg); }

/* ── Calendar ──────────────────────────────────────────────────────────── */
/* Dark event text reads better than light gold on the gold/pastel fills. */
body.theme-light .fc { --fc-event-text-color: #ffffff; --fc-neutral-bg-color: rgba(var(--accent-rgb),0.06); }
body.theme-light .fc .fc-daygrid-day { background: rgba(var(--bg-rgb-deep),0.06); }
body.theme-light .fc .fc-day-sat,
body.theme-light .fc .fc-day-sun { background: rgba(var(--accent-rgb),0.06); }
body.theme-light .fc .fc-day-other { background: rgba(var(--bg-rgb-deep),0.10); }
body.theme-light .fc .fc-day-disabled { background: rgba(var(--bg-rgb-deep),0.12) !important; }
body.theme-light .fc .fc-event { text-shadow: none; color: var(--cta-text, #fff); box-shadow: 0 2px 6px -2px rgba(160,126,24,.35); }
/* The toolbar title / today chip use a hard-coded pale-gold gradient. */
body.theme-light .fc .fc-toolbar-title {
    background: linear-gradient(180deg, var(--gold-mid) 0%, var(--gold-dark) 100%);
    -webkit-background-clip: text; background-clip: text;
}
body.theme-light .fc .fc-day-today .fc-daygrid-day-number {
    background: linear-gradient(180deg, var(--gold-mid), var(--gold-dark));
    color: #fff;
}
body.theme-light .fc .fc-button-primary { box-shadow: 0 2px 0 rgba(160,126,24,.20), inset 0 1px 0 rgba(255,255,255,0.6); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
body.theme-light .btn--danger { background: rgba(182,68,74,0.10); border-color: rgba(182,68,74,0.35); }
body.theme-light .btn--cta { color: var(--cta-text, #fff); }

/* ── Text that uses the mid gold ────────────────────────────────────────
   Mid gold reads at ~2.4:1 on a white page. Anything using it as *text*
   (labels, table headers, calendar day names) drops to the dark gold — the
   same tone BJ uses for its headings — while borders/accents keep mid gold. */
body.theme-light .text-label,
body.theme-light .qp-label,
body.theme-light .dash-table th,
body.theme-light .dash-setlogin-form label,
body.theme-light .fc .fc-col-header-cell-cushion,
body.theme-light .fc .fc-monthtag,
body.theme-light .fc .fc-daygrid-more-link { color: var(--gold-dark); }
/* Active tab is a gold fill — its label needs the on-button text colour. */
body.theme-light .dash-tab.is-active { color: var(--cta-text, #fff); }

/* ── Sunken surfaces in page-local styles ───────────────────────────────
   Legacy pages tint panels/fields with rgba(0,0,0,α); that reads as a black
   box on a light page. They now use rgba(var(--sunken-rgb),α) so the tint
   follows the theme. Dark palettes keep the original black. (Box shadows are
   left as real black in both themes.) */
:root { --sunken-rgb: 205,199,185; }
body:not(.theme-light) { --sunken-rgb: 0,0,0; }

/* ── Legacy per-page token aliases (light theme only) ───────────────────
   The 80-odd standalone pages declare their own :root with extra token names
   the theme system doesn't emit (--err-fg, --warn-fg, --ok, --info, …), baked
   to the dark palette. Pale mint/lemon/salmon on a white page is unreadable,
   so remap them here. Scoped to .theme-light, so dark palettes keep the
   values their pages declare. */
body.theme-light {
    /* Mid gold is ~2.4:1 on white. Page styles paint text with --gold-text,
       which resolves to --gold-mid on dark palettes and to the darker gold
       here. Borders and fills keep the mid gold. */
    --gold-text: var(--gold-dark);
    --err-fg:    var(--error-fg);
    --err:       var(--error-fg);
    --bad:       var(--error-fg);
    --err-bg:    var(--error-bg);
    --ok:        var(--ok-fg);
    --ok-bg:     rgba(var(--accent-rgb),0.10);
    --warn-fg:   var(--gold-dark);
    --warn:      var(--gold-dark);
    --warn-bg:   rgba(var(--accent-rgb),0.12);
    --gold:      var(--gold-dark);
    --gold-dim:  var(--gold-mid);
    --text:      var(--text-primary);
    --dim:       var(--text-dim);
    /* Categorical status hues, darkened for a white background (BJ uses the
       same blue for its manufacturing badge). */
    --info:      #3b76c9;
    --info-fg:   #3b76c9;
    --blue-soft: #3b76c9;
    --pink-soft: #b4568c;
    /* Page styles write the dark-theme status text as
       color:var(--ok-text, #b5e8c8), var(--warn-text, #f5e16a), … — one token
       per pastel family (green/red/yellow/orange/blue/purple/pink). Unset on
       dark palettes, so the pastel fallback still applies there; here each
       becomes the same hue dark enough for white and the pages' pale tints
       (≥6.5:1 on white, ≥5:1 on a 20% tint). */
    --ok-text:     #166534;
    --bad-text:    #b91c1c;
    --warn-text:   #854d0e;
    --orange-text: #9a3412;
    --w-text:      #5B2E91;
    --info-text:   #1d4ed8;
    --purple-text: #6b21a8;
    --pink-text:   #9d174d;
}

/* Same pastels, but built at runtime: PHP that picks the colour per row
   ('<span style="color:' . $c . '">', the R13 ใช่/ไม่ใช่ cells, R16-1 grade
   chips, status label maps) and JS that sets el.style.color, which the
   browser writes back as rgb(). Inline styles only lose to !important.
   The hex lists mirror the families above — add a pastel to both. */
body.theme-light [style*="color:#b5e8c8"],
body.theme-light [style*="color: #b5e8c8"],
body.theme-light [style*="color: rgb(181, 232, 200)"],
body.theme-light [style*="color:#9be8b8"],
body.theme-light [style*="color: #9be8b8"],
body.theme-light [style*="color: rgb(155, 232, 184)"],
body.theme-light [style*="color:#9be7bd"],
body.theme-light [style*="color: #9be7bd"],
body.theme-light [style*="color: rgb(155, 231, 189)"],
body.theme-light [style*="color:#7fe0a0"],
body.theme-light [style*="color: #7fe0a0"],
body.theme-light [style*="color: rgb(127, 224, 160)"],
body.theme-light [style*="color:#8ee0ad"],
body.theme-light [style*="color: #8ee0ad"],
body.theme-light [style*="color: rgb(142, 224, 173)"],
body.theme-light [style*="color:#7ee0a4"],
body.theme-light [style*="color: #7ee0a4"],
body.theme-light [style*="color: rgb(126, 224, 164)"],
body.theme-light [style*="color:#86efac"],
body.theme-light [style*="color: #86efac"],
body.theme-light [style*="color: rgb(134, 239, 172)"],
body.theme-light [style*="color:#22c55e"],
body.theme-light [style*="color: #22c55e"],
body.theme-light [style*="color: rgb(34, 197, 94)"],
body.theme-light [style*="color:#4cb87f"],
body.theme-light [style*="color: #4cb87f"],
body.theme-light [style*="color: rgb(76, 184, 127)"] { color: var(--ok-text) !important; }
body.theme-light [style*="color:#fca5a5"],
body.theme-light [style*="color: #fca5a5"],
body.theme-light [style*="color: rgb(252, 165, 165)"],
body.theme-light [style*="color:#f0a0a0"],
body.theme-light [style*="color: #f0a0a0"],
body.theme-light [style*="color: rgb(240, 160, 160)"],
body.theme-light [style*="color:#fecaca"],
body.theme-light [style*="color: #fecaca"],
body.theme-light [style*="color: rgb(254, 202, 202)"],
body.theme-light [style*="color:#ffd0d0"],
body.theme-light [style*="color: #ffd0d0"],
body.theme-light [style*="color: rgb(255, 208, 208)"],
body.theme-light [style*="color:#f5a5a5"],
body.theme-light [style*="color: #f5a5a5"],
body.theme-light [style*="color: rgb(245, 165, 165)"],
body.theme-light [style*="color:#f87171"],
body.theme-light [style*="color: #f87171"],
body.theme-light [style*="color: rgb(248, 113, 113)"],
body.theme-light [style*="color:#ee8899"],
body.theme-light [style*="color: #ee8899"],
body.theme-light [style*="color: rgb(238, 136, 153)"] { color: var(--bad-text) !important; }
body.theme-light [style*="color:#f5e16a"],
body.theme-light [style*="color: #f5e16a"],
body.theme-light [style*="color: rgb(245, 225, 106)"],
body.theme-light [style*="color:#f0e090"],
body.theme-light [style*="color: #f0e090"],
body.theme-light [style*="color: rgb(240, 224, 144)"],
body.theme-light [style*="color:#f5d98a"],
body.theme-light [style*="color: #f5d98a"],
body.theme-light [style*="color: rgb(245, 217, 138)"],
body.theme-light [style*="color:#fcd34d"],
body.theme-light [style*="color: #fcd34d"],
body.theme-light [style*="color: rgb(252, 211, 77)"],
body.theme-light [style*="color:#fbbf24"],
body.theme-light [style*="color: #fbbf24"],
body.theme-light [style*="color: rgb(251, 191, 36)"],
body.theme-light [style*="color:#f5c451"],
body.theme-light [style*="color: #f5c451"],
body.theme-light [style*="color: rgb(245, 196, 81)"],
body.theme-light [style*="color:#fff5d2"],
body.theme-light [style*="color: #fff5d2"],
body.theme-light [style*="color: rgb(255, 245, 210)"] { color: var(--warn-text) !important; }
body.theme-light [style*="color:#f0b86a"],
body.theme-light [style*="color: #f0b86a"],
body.theme-light [style*="color: rgb(240, 184, 106)"],
body.theme-light [style*="color:#f5c187"],
body.theme-light [style*="color: #f5c187"],
body.theme-light [style*="color: rgb(245, 193, 135)"],
body.theme-light [style*="color:#f0c890"],
body.theme-light [style*="color: #f0c890"],
body.theme-light [style*="color: rgb(240, 200, 144)"],
body.theme-light [style*="color:#ffcf7a"],
body.theme-light [style*="color: #ffcf7a"],
body.theme-light [style*="color: rgb(255, 207, 122)"],
body.theme-light [style*="color:#ffb74d"],
body.theme-light [style*="color: #ffb74d"],
body.theme-light [style*="color: rgb(255, 183, 77)"],
body.theme-light [style*="color:#ffc49a"],
body.theme-light [style*="color: #ffc49a"],
body.theme-light [style*="color: rgb(255, 196, 154)"],
body.theme-light [style*="color:#f0b8a0"],
body.theme-light [style*="color: #f0b8a0"],
body.theme-light [style*="color: rgb(240, 184, 160)"],
body.theme-light [style*="color:#f08c74"],
body.theme-light [style*="color: #f08c74"],
body.theme-light [style*="color: rgb(240, 140, 116)"],
body.theme-light [style*="color:#f59e0b"],
body.theme-light [style*="color: #f59e0b"],
body.theme-light [style*="color: rgb(245, 158, 11)"],
body.theme-light [style*="color:#c98a00"],
body.theme-light [style*="color: #c98a00"],
body.theme-light [style*="color: rgb(201, 138, 0)"] { color: var(--orange-text) !important; }
body.theme-light [style*="color:#7ec5e8"],
body.theme-light [style*="color: #7ec5e8"],
body.theme-light [style*="color: rgb(126, 197, 232)"],
body.theme-light [style*="color:#a5d9f0"],
body.theme-light [style*="color: #a5d9f0"],
body.theme-light [style*="color: rgb(165, 217, 240)"],
body.theme-light [style*="color:#bcd8ff"],
body.theme-light [style*="color: #bcd8ff"],
body.theme-light [style*="color: rgb(188, 216, 255)"],
body.theme-light [style*="color:#bcd6f5"],
body.theme-light [style*="color: #bcd6f5"],
body.theme-light [style*="color: rgb(188, 214, 245)"],
body.theme-light [style*="color:#93c5fd"],
body.theme-light [style*="color: #93c5fd"],
body.theme-light [style*="color: rgb(147, 197, 253)"],
body.theme-light [style*="color:#9fcaf0"],
body.theme-light [style*="color: #9fcaf0"],
body.theme-light [style*="color: rgb(159, 202, 240)"],
body.theme-light [style*="color:#dbeafe"],
body.theme-light [style*="color: #dbeafe"],
body.theme-light [style*="color: rgb(219, 234, 254)"],
body.theme-light [style*="color:#cfe0ff"],
body.theme-light [style*="color: #cfe0ff"],
body.theme-light [style*="color: rgb(207, 224, 255)"],
body.theme-light [style*="color:#9fb8e8"],
body.theme-light [style*="color: #9fb8e8"],
body.theme-light [style*="color: rgb(159, 184, 232)"],
body.theme-light [style*="color:#c3cdf5"],
body.theme-light [style*="color: #c3cdf5"],
body.theme-light [style*="color: rgb(195, 205, 245)"] { color: var(--info-text) !important; }
body.theme-light [style*="color:#c9b2f0"],
body.theme-light [style*="color: #c9b2f0"],
body.theme-light [style*="color: rgb(201, 178, 240)"],
body.theme-light [style*="color:#e2d6fa"],
body.theme-light [style*="color: #e2d6fa"],
body.theme-light [style*="color: rgb(226, 214, 250)"],
body.theme-light [style*="color:#c4b8ff"],
body.theme-light [style*="color: #c4b8ff"],
body.theme-light [style*="color: rgb(196, 184, 255)"] { color: var(--purple-text) !important; }
body.theme-light [style*="color:#f0c6d8"],
body.theme-light [style*="color: #f0c6d8"],
body.theme-light [style*="color: rgb(240, 198, 216)"],
body.theme-light [style*="color:#ffc9e4"],
body.theme-light [style*="color: #ffc9e4"],
body.theme-light [style*="color: rgb(255, 201, 228)"],
body.theme-light [style*="color:#e8a6c8"],
body.theme-light [style*="color: #e8a6c8"],
body.theme-light [style*="color: rgb(232, 166, 200)"],
body.theme-light [style*="color:#e87ec5"],
body.theme-light [style*="color: #e87ec5"],
body.theme-light [style*="color: rgb(232, 126, 197)"],
body.theme-light [style*="color:#f3c6dd"],
body.theme-light [style*="color: #f3c6dd"],
body.theme-light [style*="color: rgb(243, 198, 221)"] { color: var(--pink-text) !important; }

/* ── Score chips (10 / 7 / 5 / 4 / 0 / —) ──────────────────────────────────
   .marks label.mN (the R08 / SR08 / R16-1 / R05 score pickers) and
   .rollup-display.mN (the rolled-up parent score) are styled per page with
   pastel TEXT meant for the dark theme — #b5e8c8 mint, #fca5a5 pink, #f5c187
   peach, gold-bright. On white those read as white-on-pale-green, and the
   picked chip then runs filter:brightness(1.35), which bleaches it into a
   neon blob where the "10" disappears. Light theme: dark text on the tint
   while unpicked; a solid fill with white text (≥4.5:1) once picked, so the
   chosen score is the most legible thing in the row instead of the least. */
body.theme-light .marks label.m10,
body.theme-light .rollup-display.m10 { color: #14532d; }
body.theme-light .marks label.m7,
body.theme-light .rollup-display.m7  { color: #713f12; }
body.theme-light .marks label.m5,
body.theme-light .rollup-display.m5  { color: #7c2d12; }
body.theme-light .marks label.m4,
body.theme-light .marks label.m0,
body.theme-light .rollup-display.m4,
body.theme-light .rollup-display.m0  { color: #7f1d1d; }
body.theme-light .marks label.na {
    color: #374151; background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.18);
}

body.theme-light .marks label.is-picked { filter: none; color: #fff; }
body.theme-light .marks label.m10.is-picked { background: #15803d; border-color: #15803d; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #15803d, 0 2px 10px rgba(21,128,61,.35); }
body.theme-light .marks label.m7.is-picked  { background: #a16207; border-color: #a16207; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #a16207, 0 2px 10px rgba(161,98,7,.35); }
body.theme-light .marks label.m5.is-picked  { background: #c2410c; border-color: #c2410c; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #c2410c, 0 2px 10px rgba(194,65,12,.35); }
body.theme-light .marks label.m4.is-picked,
body.theme-light .marks label.m0.is-picked  { background: #b91c1c; border-color: #b91c1c; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #b91c1c, 0 2px 10px rgba(185,28,28,.35); }
body.theme-light .marks label.na.is-picked  { background: #4b5563; border-color: #4b5563; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #4b5563; }
