/**
 * theme.css
 * Design tokens + dark theme + notification centre.
 *
 * Loaded AFTER global-hrms.css so it wins on conflicts.
 *
 * Why tokens: the original dark mode was ~34 hand-written
 * `body.dark-mode .some-card` rules with hardcoded hex values. Anything not on
 * that list stayed light, which is why the theme looked patchy. Colours are now
 * defined once as variables and flipped in a single place.
 *
 * Several cards set their background with an inline `style="..."` gradient from
 * JS, and inline styles beat stylesheet rules. Those specific selectors need
 * !important to be themeable at all -- that is deliberate, not sloppiness.
 */

:root {
    /* Surfaces, from furthest back to closest to the reader. */
    --bg-base: #f4f6f9;
    --bg-raised: #ffffff;
    --bg-sunken: #eef1f6;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Lines */
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    /* A line between rows of the same thing, quieter than a real border. */
    --border-soft: #eef2f7;

    /* Brand */
    --accent: #0891b2;
    --accent-hover: #0e7490;
    --accent-soft: #ecfeff;
    --accent-text: #0f766e;

    /* Status */
    --success: #16a34a;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #1d4ed8;
    --info-soft: #dbeafe;
    --violet: #6d28d9;
    --violet-soft: #ede9fe;
    --magenta: #a21caf;
    --magenta-soft: #fae8ff;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, .08);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, .12);

    --radius: 14px;
}

/**
 * Dark palette. Surfaces get progressively lighter as they come forward, which
 * is what gives depth -- the previous version used near-black everywhere and
 * read as flat.
 */
body.theme-dark,
body.dark-mode {
    /* Deep navy. Surfaces step lighter as they come forward so cards read as
       raised rather than flat, and the base keeps a blue cast that matches the
       AquaVida cyan instead of fighting it. */
    --bg-base: #0a1628;
    --bg-raised: #132238;
    --bg-sunken: #061020;
    --bg-input: #1a2d47;
    --bg-hover: #1e3350;

    --text-primary: #f0f6fc;
    --text-secondary: #a8bdd4;
    --text-muted: #8ba1b8;
    --text-inverse: #0a1628;

    --border: #24384f;
    --border-strong: #35506e;
    --border-soft: #1c2c3e;

    --accent: #3cc3de;
    --accent-hover: #5fd4e8;
    --accent-soft: #0e2b3a;
    --accent-text: #6ddcef;

    --success: #4ade80;
    --success-soft: #0f2e1d;
    --danger: #f87171;
    --danger-soft: #3a1a1a;
    --warning: #fbbf24;
    --warning-soft: #3a2d10;
    --info: #93c5fd;
    --info-soft: #14243f;
    --violet: #c4b5fd;
    --violet-soft: #241a3d;
    --magenta: #f0abfc;
    --magenta-soft: #331036;

    --shadow-sm: 0 1px 3px rgba(2, 8, 20, .5);
    --shadow-md: 0 6px 20px rgba(2, 8, 20, .55);
    --shadow-lg: 0 20px 50px rgba(2, 8, 20, .65);
}

/* ---------------------------------------------------------------- Base --- */

body.theme-dark,
body.dark-mode {
    background: var(--bg-base);
    color: var(--text-primary);
}

body.theme-dark .main-content,
body.dark-mode .main-content {
    background: transparent;
}

/* Surfaces. !important defeats inline gradients set from JS. */
body.theme-dark .top-header,
body.theme-dark .sidebar,
body.theme-dark .content-card,
body.theme-dark .table-container-card,
body.theme-dark .modal-content,
body.theme-dark .attendance-card,
body.theme-dark .attendance-panel,
body.theme-dark .mini-card,
body.theme-dark .dashboard-stat-card,
body.theme-dark .dashboard-soft-card,
body.theme-dark .dashboard-mini-card,
body.theme-dark .employee-form-section,
body.theme-dark .employee-side-card,
body.theme-dark .profile-card,
body.theme-dark .profile-doc-card,
body.theme-dark .employee-doc-card,
body.theme-dark .tabs-container,
body.theme-dark #employeePageIntro,
body.theme-dark .profile-hero,
body.theme-dark .employee-form-banner,
body.theme-dark .employee-self-hero {
    background: var(--bg-raised) !important;
    color: var(--text-primary);
    border-color: var(--border) !important;
    box-shadow: var(--shadow-md);
}

body.theme-dark .top-header {
    border-bottom: 1px solid var(--border);
}

/* Headings and body copy inside those surfaces. */
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3,
body.theme-dark h4, body.theme-dark strong, body.theme-dark label {
    color: var(--text-primary) !important;
}

body.theme-dark p,
body.theme-dark .attendance-subtitle,
body.theme-dark .records-page-copy,
body.theme-dark .profile-meta-line,
body.theme-dark .coords-text {
    color: var(--text-secondary) !important;
}

/* ------------------------------------------------------------- Controls --- */

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .search-input,
body.theme-dark .assignment-purpose-select {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
    color: var(--text-muted);
}

body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, .16);
    outline: none;
}

/* Date/time pickers render a black glyph on a dark field without this. */
body.theme-dark input[type="date"]::-webkit-calendar-picker-indicator,
body.theme-dark input[type="time"]::-webkit-calendar-picker-indicator,
body.theme-dark input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(.65);
}

/* ---------------------------------------------------------------- Table --- */

body.theme-dark .table-wrapper {
    background: transparent;
}

body.theme-dark .hrms-table th {
    background: var(--bg-sunken) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}

body.theme-dark .hrms-table td {
    background: var(--bg-raised) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

body.theme-dark .hrms-table tbody tr:hover td {
    background: var(--bg-hover) !important;
}

body.theme-dark .no-data {
    color: var(--text-muted) !important;
}

/* ------------------------------------------------------------- Sidebar --- */

/* Sidebar nav colours are token-driven in one place further down. */

body.theme-dark .nav-group-label {
    color: var(--text-muted);
}

/* --------------------------------------------------------------- Status --- */

body.theme-dark .status-box.success { background: var(--success-soft); border-color: var(--success); color: var(--text-primary); }
body.theme-dark .status-box.error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--text-primary); }
body.theme-dark .status-box.info    { background: var(--accent-soft);  border-color: var(--accent);  color: var(--text-primary); }

body.theme-dark .toast {
    background: var(--bg-raised);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

/* Leaflet renders a white attribution strip and white controls otherwise. */
body.theme-dark .leaflet-control-attribution {
    background: rgba(13, 20, 32, .82) !important;
    color: var(--text-muted) !important;
}
body.theme-dark .leaflet-control-attribution a { color: var(--accent-text) !important; }
body.theme-dark .leaflet-bar a {
    background: var(--bg-raised);
    color: var(--text-primary);
    border-color: var(--border);
}
body.theme-dark .leaflet-control-layers {
    background: var(--bg-raised);
    color: var(--text-primary);
    border-color: var(--border);
}

/* HR "nudge this employee" action. Amber rather than red: it is a reminder,
   not a destructive or error state. */
.btn-alert {
    border: 1px solid var(--warning);
    background: var(--warning-soft);
    color: var(--warning);
    font-weight: 700;
    font-size: 12.5px;
    padding: 9px 16px;
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s ease, color .15s ease;
}

.btn-alert:hover:not(:disabled) { background: var(--warning); color: #fff; }
.btn-alert:disabled { opacity: .6; cursor: default; }

/* ================================================== Work tracker form === */

.work-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.work-for-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 13px;
    border-radius: 10px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    font-size: 12.5px;
}

.work-for-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.work-for-chip strong { color: var(--text-primary); }

.work-type-tag {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tag-field { background: var(--warning-soft); color: var(--warning); }
.tag-office { background: var(--accent-soft); color: var(--accent-text); }

/* Numbered steps. The form previously ran fields together with no grouping,
   and the type-specific fields appeared with no explanation. */
.work-form { display: grid; gap: 18px; }

.work-step {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-sunken);
}

.work-step-head {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    margin-bottom: 13px;
}

.work-step-num {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.work-step-head strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.work-step-head span {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.work-step .form-field label {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Required vs optional stated outright rather than implied by an asterisk. */
.req, .opt {
    font-style: normal;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.req { background: var(--danger-soft); color: var(--danger); }
.opt { background: var(--bg-hover); color: var(--text-muted); }

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.work-form-actions { justify-content: flex-end; gap: 10px; }

@media (max-width: 640px) {
    .work-modal-head { flex-direction: column; }
    .work-for-chip { width: 100%; }
}

/* ================================================= Lateness indicators === */

.late-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.lop-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 11px;
    font-weight: 800;
}

/* Amber underline on a day chip that was a late arrival, so the calendar grid
   shows lateness without needing another column. */
.records-day-badge.is-late-day {
    box-shadow: inset 0 -3px 0 var(--warning);
}

/* ============================================ Office timing settings === */

.timing-list { display: grid; gap: 10px; margin-top: 16px; }

.timing-row {
    display: grid;
    grid-template-columns: minmax(180px, 220px) 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-raised);
}

.timing-row.is-global { border-left: 4px solid var(--accent); }

.timing-scope { display: grid; gap: 5px; }
.timing-scope strong { font-size: 13px; color: var(--text-primary); }

.timing-chip {
    width: max-content;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg-sunken);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.timing-chip.chip-global { background: var(--accent-soft); color: var(--accent-text); }

.timing-inactive {
    width: max-content;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--danger);
}

.timing-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.timing-facts span {
    display: grid;
    gap: 2px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.timing-facts label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.timing-actions { display: flex; gap: 12px; }

.timing-preview-card {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
}

.timing-preview-card > strong {
    display: block;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 9px;
}

.preview-line {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--text-secondary);
    padding: 3px 0;
}

.preview-line strong { color: var(--text-primary); }

.preview-line .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--success); }
.dot-late { background: var(--warning); }
.dot-half { background: #f97316; }
.dot-absent { background: var(--danger); }
.dot-lop { background: var(--text-muted); }

.timing-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12.5px;
}

.timing-check input { width: 16px; height: 16px; margin: 0; }

@media (max-width: 820px) {
    .timing-row { grid-template-columns: 1fr; }
    .timing-actions { justify-content: flex-end; }
}

/* =================================================== Notification centre === */

.notification-wrap {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 6px;
}

.notification-bell {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.notification-bell:hover {
    background: var(--bg-hover);
    color: var(--accent-text);
    border-color: var(--accent);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: grid;
    place-items: center;
    border: 2px solid var(--bg-raised);
    line-height: 1;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(380px, calc(100vw - 32px));
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
    z-index: 10010;
    overflow: hidden;
}

.notification-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notification-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sunken);
}

.notification-head strong {
    font-size: 13px;
    color: var(--text-primary);
}

.notification-readall {
    border: 0;
    background: none;
    color: var(--accent-text);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

.notification-readall:hover { background: var(--accent-soft); }

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    width: 100%;
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    text-align: left;
    cursor: pointer;
    position: relative;
    font-family: inherit;
}

.notification-item:hover { background: var(--bg-hover); }
.notification-item.unread { background: var(--accent-soft); }
.notification-item.unread:hover { background: var(--bg-hover); }

.notification-icon { font-size: 16px; line-height: 1.3; flex-shrink: 0; }

.notification-body { display: grid; gap: 3px; min-width: 0; flex: 1; }

.notification-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.notification-message {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notification-time { font-size: 10.5px; color: var(--text-muted); }

.notification-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 5px;
}

.notification-empty {
    display: grid;
    gap: 5px;
    justify-items: center;
    text-align: center;
    padding: 38px 22px;
    color: var(--text-secondary);
}

.notification-empty-icon { font-size: 26px; opacity: .45; }
.notification-empty strong { font-size: 13px; color: var(--text-primary); }
.notification-empty span { font-size: 11.5px; line-height: 1.55; }

@media (max-width: 520px) {
    .notification-panel {
        position: fixed;
        top: 60px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

/* ============================================ Scope precedence legend === */

.scope-precedence {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 11px 14px;
    margin: 14px 0 4px;
    border-radius: 10px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
}

.scope-precedence-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.scope-chain { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.scope-chain-item {
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

.scope-chain-item.is-fallback {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: transparent;
}

.scope-chain-arrow { color: var(--text-muted); font-size: 13px; }

/* Shown when a chosen target matches no active employee. */
.scope-warning {
    margin: 4px 0 10px;
    padding: 10px 13px;
    border-radius: 9px;
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    color: var(--warning);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

/* ================================================ Brandable chrome === */
/*
 * The sidebar and top header get their own tokens so a company can colour the
 * navigation independently of cards. These rules apply in BOTH themes (no
 * .theme-dark prefix) because branding.js supplies a value per theme.
 */

.top-header {
    background: var(--header-bg) !important;
    color: var(--header-text) !important;
}

.top-header h1 {
    color: var(--header-text) !important;
}

/* The profile pill is a raised surface of its own, so it keeps card text
   colours rather than the header's. */
.top-header .user-profile .user-name { color: var(--text-primary) !important; }
.top-header .user-profile .user-role-line { color: var(--text-secondary) !important; }

.sidebar {
    background: var(--sidebar-bg) !important;
    border-right: 1px solid var(--border);
}

.sidebar-nav a {
    color: var(--sidebar-text);
}

.sidebar-nav a:hover {
    background: var(--bg-hover);
    color: var(--sidebar-active-text);
}

.sidebar-nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

/* Uploaded logos sit inside the same square as the two-letter fallback. */
.logo-placeholder.has-logo {
    background: transparent;
    padding: 0;
    overflow: hidden;
}

.logo-placeholder.has-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ============================================= Branding settings UI === */

.brand-actions { display: flex; align-items: center; gap: 10px; }

.brand-dirty {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 800;
}

.brand-group {
    padding: 16px;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-sunken);
}

.brand-group-head { margin-bottom: 13px; }
.brand-group-head strong { display: block; font-size: 13px; color: var(--text-primary); }
.brand-group-head span { font-size: 11.5px; color: var(--text-secondary); }

.brand-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 10px;
}

.brand-swatch {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-raised);
    cursor: pointer;
    position: relative;
}

.brand-swatch:hover { border-color: var(--accent); }

.brand-swatch-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-swatch-meta { display: grid; gap: 2px; min-width: 0; }
.brand-swatch-label { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.brand-swatch-hex { font-size: 11px; color: var(--text-muted); font-family: monospace; text-transform: uppercase; }

/* The native colour input is the click target, laid over the whole row. */
.brand-swatch input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    padding: 0;
}

.brand-logo-row { display: flex; align-items: center; gap: 18px; margin-top: 16px; flex-wrap: wrap; }

.brand-logo-preview {
    width: 78px;
    height: 78px;
    border-radius: 14px;
    border: 1px dashed var(--border-strong);
    background: var(--bg-raised);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.brand-logo-fallback { font-size: 24px; font-weight: 800; color: var(--accent); }

.brand-logo-controls { display: grid; gap: 7px; }

.brand-logo-controls .brand-upload-btn,
.brand-upload-btn {
    /* !important is needed: the dark-theme block forces a colour on every
       <label>, and this label is a button sitting on the accent colour. */
    color: var(--text-inverse) !important;
    display: inline-flex;
    width: max-content;
    padding: 8px 16px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--text-inverse);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.brand-upload-btn:hover { background: var(--accent-hover); }

.brand-theme-switch {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.brand-theme-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.brand-theme-tabs {
    display: inline-flex;
    padding: 3px;
    border-radius: 9px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
}

.brand-theme-tab {
    padding: 6px 15px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.brand-theme-tab.active { background: var(--accent); color: var(--text-inverse); }

.brand-contrast {
    margin-top: 14px;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.6;
}

.brand-contrast strong { display: block; font-size: 12.5px; }
.brand-contrast span { display: block; margin-top: 2px; }
.brand-contrast ul { margin: 8px 0 0; padding-left: 18px; }
.brand-contrast li { margin-bottom: 2px; }

.brand-contrast.is-ok {
    background: var(--success-soft);
    border: 1px solid var(--success);
    color: var(--success);
}

.brand-contrast.is-warn {
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    color: var(--warning);
}

@media (max-width: 640px) {
    .brand-actions { width: 100%; justify-content: flex-end; }
    .brand-swatches { grid-template-columns: 1fr; }
}

/* =========================================== Collapsible sidebar === */
/*
 * Collapsed mode keeps the icons and hides the labels. The grid column is
 * driven from body.sidebar-collapsed so the main content reflows with it.
 */

/* Sidebar width + collapse layout now live in sidebar-collapse.css. */

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 2px 8px;
    border-radius: 9px;
    white-space: nowrap;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

/* Icons inherit their own token so branding can colour them separately. */
.nav-icon {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    color: var(--icon-color, currentColor);
}

.sidebar-nav a.active .nav-icon { color: var(--icon-active-color, currentColor); }

.nav-label { overflow: hidden; text-overflow: ellipsis; }

.nav-group-label,
.nav-group-label span {
    color: var(--text-secondary);
}

.nav-group-label {
    padding: 14px 22px 6px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Collapsed: centre the icons, hide labels, replace group headings with a rule. */
body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 11px 0;
    margin: 3px 10px;
}

body.sidebar-collapsed .nav-label { display: none; }

body.sidebar-collapsed .nav-group-label {
    padding: 10px 14px 6px;
}

body.sidebar-collapsed .nav-group-label span { display: none; }

body.sidebar-collapsed .nav-group-label::after {
    content: '';
    display: block;
    height: 1px;
    background: var(--border);
}

body.sidebar-collapsed .top-header h1 { display: none; }


/* The mobile hamburger owns small screens; the collapse control is desktop-only. */
@media (max-width: 900px) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
}

/* ==================================== Attendance summary tiles === */

.att-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.att-tile {
    padding: 15px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-sunken);
    border-left: 4px solid var(--border-strong);
}

.att-tile.tone-ok { border-left-color: var(--success); }
.att-tile.tone-bad { border-left-color: var(--danger); }
.att-tile.tone-warn { border-left-color: var(--warning); }
.att-tile.tone-info { border-left-color: var(--accent); }

.att-tile-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1; }

.att-tile-label {
    margin-top: 5px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* The dates behind each number, so a count never raises "which days?". */
.att-tile-dates { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.att-tile-dates span {
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.att-tile-dates span b { color: var(--warning); font-weight: 800; }
.att-tile-dates .att-more { background: transparent; border: none; color: var(--text-muted); font-style: italic; }
.att-tile-note { margin-top: 9px; font-size: 11px; color: var(--text-muted); line-height: 1.5; }

.att-policy-note {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 12px;
    line-height: 1.6;
}

.att-policy-note b { font-weight: 800; }

.dashboard-link-btn {
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.dashboard-link-btn:hover { background: var(--accent); color: var(--text-inverse); }

/* ==================================== Attendance breakdown modal === */

.chip-btn { border: none; cursor: pointer; font: inherit; }
.chip-btn:hover { filter: brightness(1.12); text-decoration: underline; }

.absent-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 11px;
    font-weight: 800;
}

.breakdown-section { margin-top: 18px; }

.breakdown-section h4 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.breakdown-count {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.breakdown-count.tone-bad { background: var(--danger-soft); color: var(--danger); }
.breakdown-count.tone-warn { background: var(--warning-soft); color: var(--warning); }
.breakdown-count.tone-info { background: var(--accent-soft); color: var(--accent-text); }

.breakdown-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }

.breakdown-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    font-size: 12.5px;
}

.breakdown-list li span { font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.breakdown-list li em { font-style: normal; color: var(--text-secondary); text-align: right; }
.breakdown-list li em b { color: var(--warning); }

.breakdown-empty { margin: 0; font-size: 12px; color: var(--text-muted); font-style: italic; }

.breakdown-policy {
    margin-top: 20px;
    padding: 13px 15px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 12px;
    line-height: 1.6;
}

.breakdown-policy strong { display: block; margin-bottom: 3px; }

.records-legend-hint { color: var(--text-muted); font-style: italic; }

/* Scope + view switches sit together in the records header. */
.records-view-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.records-scope-switch { border-color: var(--accent); }
