/* =============================================================
   Student Savings — Design System v3 (HR-mirror, SaaS-grade)
   Mirrors Baiboon HR app.css layout/tokens.
   Loaded AFTER dashboard-common.css + ui-shared.css to override.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Instrument+Serif:ital@1&display=swap');

:root {
    /* Surfaces */
    --paper:    #F7F8FA;
    --card:     #FFFFFF;
    --card-alt: #F9FAFB;
    --mute:     #F4F5F7;

    /* Ink scale */
    --ink-900: #0F172A;
    --ink-800: #1E293B;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748B;
    --ink-400: #94A3B8;
    --ink-300: #CBD5E1;
    --ink-200: #E2E8F0;
    --ink-100: #F1F5F9;
    --ink-50:  #F8FAFC;

    --border:        #E5E7EB;
    --border-strong: #D1D5DB;

    /* Green */
    --green-50:  #ECFDF3;
    --green-100: #D1FADF;
    --green-200: #A6F4C5;
    --green-300: #6CE9A6;
    --green-400: #32D583;
    --green-500: #12B76A;
    --green-600: #039855;
    --green-700: #027A48;
    --green-800: #05603A;
    --green-900: #054F31;
    --green-neon: #4FFFB0;

    /* Semantic */
    --danger:     #F04438;
    --danger-50:  #FEE4E2;
    --danger-700: #B42318;
    --amber:      #F79009;
    --amber-50:   #FEF0C7;
    --amber-700:  #B54708;
    --blue:       #2E90FA;
    --blue-50:    #DBEAFE;
    --blue-700:   #1849A9;

    /* Shadows (HR exact) */
    --shadow-card: 0 1px 2px rgba(10,22,18,0.04), 0 0 0 1px rgba(10,22,18,0.04);
    --shadow-elev: 0 1px 3px rgba(10,22,18,0.06), 0 4px 16px rgba(10,22,18,0.04), 0 0 0 1px rgba(10,22,18,0.04);
    --shadow-deep: 0 24px 48px -16px rgba(10,22,18,0.15), 0 0 0 1px rgba(10,22,18,0.04);

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  18px;
    --radius-2xl: 28px;

    /* Map legacy vars */
    --bg-primary:    var(--paper);
    --bg-secondary:  var(--card-alt);
    --bg-tertiary:   var(--mute);
    --text-primary:   var(--ink-900);
    --text-secondary: var(--ink-600);
    --text-tertiary:  var(--ink-400);
    --text-inverse:   #FFFFFF;
    --border-color:    var(--border);
    --border-light:    var(--ink-100);
    --border-focus:    var(--green-500);
    --primary-500:  var(--green-500);
    --primary-600:  var(--green-600);
    --primary-700:  var(--green-700);
    --primary-50:   var(--green-50);
    --primary-100:  var(--green-100);
    --shadow-sm: var(--shadow-card);
    --shadow-md: var(--shadow-elev);
    --shadow-lg: var(--shadow-elev);
    --shadow-xl: var(--shadow-deep);
}

[data-theme="dark"] {
    /* Neutral grey palette (mirrors Claude Design bundle reference) */
    --paper:    #0A0A0A;
    --card:     #171717;
    --card-alt: #1F1F1F;
    --mute:     #262626;
    --border:        rgba(255,255,255,0.06);
    --border-soft:   rgba(255,255,255,0.04);
    --border-strong: rgba(255,255,255,0.14);

    /* Ink scale — luminance for body text on neutral dark */
    --ink-900: #FAFAFA;
    --ink-800: #E5E5E5;
    --ink-700: #D4D4D4;
    --ink-600: #A3A3A3;
    --ink-500: #737373;
    --ink-400: #525252;
    --ink-300: #404040;
    --ink-200: #262626;
    --ink-100: #171717;
    --ink-50:  #0F0F0F;
    --ink-25:  #0C0C0C;

    /* Semantic tints */
    --green-50:   rgba(34,197,94,0.10);
    --green-100:  rgba(34,197,94,0.18);
    --green-200:  rgba(34,197,94,0.28);
    --danger-50:  rgba(239,68,68,0.10);
    --amber-50:   rgba(245,158,11,0.10);
    --blue-50:    rgba(59,130,246,0.10);
    --green-400:  #4ADE80;
    --green-500:  #22C55E;
    --green-600:  #16A34A;
    --green-700:  #4ADE80;
    --green-800:  #86EFAC;
    --amber-700:  #FBBF24;
    --danger:     #F87171;
    --danger-700: #F87171;
    --blue-700:   #60A5FA;

    /* Shadows: subtle white inset highlight + drop */
    --shadow-card: 0 0 0 1px rgba(255,255,255,0.04), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-elev: 0 0 0 1px rgba(255,255,255,0.05), 0 4px 14px rgba(0,0,0,0.45);
    --shadow-deep: 0 0 0 1px rgba(255,255,255,0.06), 0 24px 48px -12px rgba(0,0,0,0.6);
}

/* Dark — minimal, no gradient overlays. Let neutral palette breathe. */
[data-theme="dark"] .card,
[data-theme="dark"] .card-elev,
[data-theme="dark"] .cd-grid-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .grid-empty,
[data-theme="dark"] .loading-state {
    background: var(--card);
    border: 1px solid var(--border);
}
[data-theme="dark"] .friday-banner {
    background: linear-gradient(135deg, #050505 0%, #0A1A12 60%, #043325 100%);
}
[data-theme="dark"] .my-class-card {
    background: var(--card);
    border-color: rgba(34,197,94,0.25);
}
[data-theme="dark"] .quick-card-dark {
    background: #050505;
    border: 1px solid rgba(255,255,255,0.05);
}
/* Tables — alt rows + hover */
[data-theme="dark"] .table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
[data-theme="dark"] .table tbody tr:hover            { background: rgba(255,255,255,0.04); }
/* Topbar */
[data-theme="dark"] .app-header {
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    border-bottom: 1px solid var(--border);
}
/* Sidebar — deeper than paper */
[data-theme="dark"] .app-sidebar {
    background: #050505;
    border-right: 1px solid rgba(255,255,255,0.05);
}
/* Sidebar active item */
[data-theme="dark"] .app-sidebar .nav-item.active {
    background: rgba(34,197,94,0.12);
    color: #6EE7B7;
    box-shadow: inset 0 0 0 1px rgba(34,197,94,0.25);
}
[data-theme="dark"] .app-sidebar .nav-item.active i { color: #6EE7B7; }
/* Inputs */
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] select.form-control,
[data-theme="dark"] textarea.form-control {
    background: #0F0F0F;
    border-color: var(--border);
    color: var(--ink-900);
}
[data-theme="dark"] .form-control:focus { border-color: var(--green-500); background: var(--card); }
[data-theme="dark"] .app-footer { border-top: 1px solid var(--border); color: var(--ink-500); }

/* =============================================================
   BASE
   ============================================================= */
*, *::before, *::after {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}
html, body {
    margin: 0; padding: 0;
    font-family: "IBM Plex Sans Thai", "IBM Plex Sans", "Sarabun", system-ui, sans-serif;
    background: var(--paper);
    color: var(--ink-800);
    font-feature-settings: "ss01", "cv01", "tnum";
    line-height: 1.55;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.num, .font-mono { font-variant-numeric: tabular-nums slashed-zero; letter-spacing: -0.02em; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.display-num {
    font-family: "IBM Plex Sans", sans-serif;
    font-feature-settings: "tnum", "ss01";
    font-weight: 500;
    letter-spacing: -0.035em;
}
.serif-accent {
    font-family: "Instrument Serif", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
}
.label-eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--ink-400);
}

/* =============================================================
   L-LAYOUT — sidebar fixed full-height + main margin-left
   ============================================================= */
.app-layout {
    display: block;
    min-height: 100vh;
}

/* SIDEBAR (left, fixed, dark) */
.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 256px;
    background: #0B0F0E;
    color: #CBD5E1;
    border-right: 1px solid rgba(255,255,255,0.04);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    z-index: 20;
}
[data-theme="dark"] .app-sidebar {
    background: #050706;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.app-sidebar .nav-section { padding-bottom: 4px; margin-bottom: 8px; }
.app-sidebar .nav-section-title {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(203,213,225,0.4);
    padding: 18px 12px 8px;
    margin: 0;
    font-weight: 600;
}
.app-sidebar .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px; font-weight: 500;
    color: #94A3B8;
    transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
.app-sidebar .nav-item i {
    width: 16px; text-align: center;
    color: #64748B;
    font-size: 14px;
    transition: color 160ms;
}
.app-sidebar .nav-item:hover { background: rgba(255,255,255,0.04); color: #F1F5F9; }
.app-sidebar .nav-item:hover i { color: #94A3B8; }
.app-sidebar .nav-item.active {
    background: rgba(18,183,106,0.12);
    color: #FFFFFF;
    box-shadow: inset 0 0 0 1px rgba(18,183,106,0.25);
}
.app-sidebar .nav-item.active i { color: var(--green-400); }

/* MAIN AREA = topbar + content, both shifted by sidebar width */
.app-main {
    margin-left: 256px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.main-content { padding: 28px 32px; max-width: 1560px; margin: 0 auto; width: 100%; }

/* TOPBAR sticky + blur */
.app-header {
    position: sticky; top: 0; z-index: 10;
    height: 60px;
    padding: 0 32px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    background: color-mix(in srgb, var(--paper) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    margin-left: 256px;
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.header-logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 600;
    color: var(--ink-900);
    font-size: 14.5px;
    letter-spacing: -0.01em;
}

.mobile-menu-toggle {
    display: none;
    background: var(--card);
    border: 1px solid var(--border);
    width: 34px; height: 34px;
    border-radius: 8px;
    align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--ink-700);
}
.theme-toggle {
    background: var(--card);
    border: 1px solid var(--border);
    width: 34px; height: 34px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink-600);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.theme-toggle:hover { background: var(--mute); color: var(--ink-800); }

/* User menu */
.user-menu { position: relative; }
.user-menu-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 3px 10px 3px 3px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    color: var(--ink-800);
    font-size: 12.5px; font-weight: 500;
}
.user-menu-trigger:hover { background: var(--mute); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--green-400), var(--green-700));
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 12px;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }
.user-menu-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-elev);
    padding: 6px;
    display: none;
    z-index: 40;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--ink-700);
}
.user-menu-item:hover { background: var(--mute); color: var(--ink-900); }
.user-menu-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* =============================================================
   PAGE HEADER (HR style — hero with eyebrow + serif accent)
   ============================================================= */
.page-header {
    margin-bottom: 28px;
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.page-header > div:first-child { min-width: 0; flex: 1; }
.page-title {
    margin: 4px 0 0;
    font-size: 28px;
    font-weight: 500;
    color: var(--ink-900);
    letter-spacing: -0.025em;
    line-height: 1.15;
}
.page-subtitle { margin: 6px 0 0; font-size: 13px; color: var(--ink-500); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* =============================================================
   CARD (HR exact)
   ============================================================= */
.card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: 20px;
}
.card-elev {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-elev);
    padding: 20px;
}
.card.mb-4 { margin-bottom: 16px; }
.border-soft { border: 1px solid var(--border); }
.divider { border-top: 1px solid var(--border); }

.hover-lift { transition: transform 200ms cubic-bezier(0.4,0,0.2,1), box-shadow 200ms; }
.hover-lift:hover { transform: translateY(-1px); box-shadow: var(--shadow-elev); }

/* =============================================================
   BUTTONS — primary = navy (HR pattern), accent = green
   ============================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 12.5px;
    font-weight: 600;
    transition: all 200ms;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
    color: var(--ink-700);
    background: var(--card);
    line-height: 1;
}
.btn i { font-size: 12px; }
.btn:hover { background: var(--mute); }

.btn-primary {
    background: var(--ink-900);
    color: #fff;
    border-color: var(--ink-900);
    box-shadow: 0 1px 2px rgba(15,23,42,0.08);
}
.btn-primary:hover { background: var(--ink-800); border-color: var(--ink-800); }
[data-theme="dark"] .btn-primary { background: linear-gradient(180deg, #404040, #262626); border-color: #262626; }

.btn-success, .btn-accent {
    background: var(--green-600);
    color: #fff;
    border-color: var(--green-600);
}
.btn-success:hover, .btn-accent:hover { background: var(--green-700); border-color: var(--green-700); }
[data-theme="dark"] .btn-success, [data-theme="dark"] .btn-accent { background: #15803D; border-color: #15803D; }

.btn-warning {
    background: var(--amber);
    border-color: var(--amber);
    color: #fff;
}
.btn-warning:hover { background: var(--amber-700); border-color: var(--amber-700); }

.btn-secondary {
    background: var(--card);
    border-color: var(--border);
    color: var(--ink-700);
}
.btn-secondary:hover { background: var(--mute); color: var(--ink-900); }

.btn-danger {
    background: var(--danger-700);
    border-color: var(--danger-700);
    color: #fff;
}
.btn-danger:hover { background: #8C1D14; border-color: #8C1D14; }

.btn-ghost {
    background: transparent;
    color: var(--ink-500);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--mute); color: var(--ink-700); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 13.5px; }

/* =============================================================
   FORMS
   ============================================================= */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-700);
    margin-bottom: 6px;
}
.form-control, input.form-control, select.form-control, textarea.form-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink-800);
    font-size: 13.5px;
    font-family: inherit;
    transition: all 200ms;
    outline: none;
}
textarea.form-control { padding: 10px 12px; height: auto; min-height: 80px; resize: vertical; line-height: 1.5; }
.form-control:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(18,183,106,0.12);
}
.form-control::placeholder { color: var(--ink-400); }
[data-theme="dark"] .form-control { background: var(--card); color: var(--ink-800); border-color: var(--border); }
[data-theme="dark"] .form-control::placeholder { color: var(--ink-500); }

.helper { font-size: 11.5px; color: var(--ink-400); margin-top: 4px; }
.helper-error { color: var(--danger); }

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--green-500);
    width: 16px; height: 16px;
    cursor: pointer;
}

/* =============================================================
   BADGES / PILLS (legacy + new)
   ============================================================= */
.badge, .pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
}
.badge-success, .pill-green { background: var(--green-50); color: var(--green-700); }
.badge-warning, .pill-amber { background: var(--amber-50); color: var(--amber-700); }
.badge-danger, .pill-red, .badge-frozen, .frozen-badge { background: var(--danger-50); color: var(--danger-700); }
.badge-info, .pill-blue { background: var(--blue-50); color: var(--blue-700); }
.badge-pending { background: var(--amber-50); color: var(--amber-700); }
.pill-ghost { background: var(--mute); color: var(--ink-600); }
.dot {
    display: inline-block; width: 6px; height: 6px;
    border-radius: 999px; background: currentColor; flex-shrink: 0;
}

/* =============================================================
   TABLES — HR-style grid header, hover, [data-label] mobile collapse
   ============================================================= */
.table-container {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table thead { background: color-mix(in srgb, var(--mute) 40%, transparent); }
.table thead th {
    padding: 11px 18px;
    text-align: left;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--ink-400);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-700);
    vertical-align: middle;
    font-size: 13px;
}
.table tbody tr { transition: background 150ms; }
.table tbody tr:hover { background: var(--mute); }
.table tbody tr:last-child td { border-bottom: none; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }
.table-actions { display: inline-flex; gap: 4px; align-items: center; }

/* =============================================================
   STAT CARD (HR-mirror — small icon badge + huge display-num)
   ============================================================= */
.stats-bar, .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    padding: 20px;
    transition: transform 200ms, box-shadow 200ms;
    animation: ds-fade-up 600ms cubic-bezier(0.4,0,0.2,1) backwards;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-elev); }
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 60ms; }
.stat-card:nth-child(3) { animation-delay: 120ms; }
.stat-card:nth-child(4) { animation-delay: 180ms; }
.stat-card:nth-child(5) { animation-delay: 240ms; }

.stat-card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stat-card-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.stat-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--mute);
    color: var(--ink-500);
}
.stat-icon.primary { background: var(--green-50);  color: var(--green-700); }
.stat-icon.success { background: var(--green-50);  color: var(--green-700); }
.stat-icon.info    { background: var(--blue-50);   color: var(--blue-700); }
.stat-icon.warning { background: var(--amber-50);  color: var(--amber-700); }
.stat-icon.danger  { background: var(--danger-50); color: var(--danger-700); }

.stat-content { min-width: 0; }
.stat-label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--ink-400);
    margin-bottom: 6px;
}
.stat-value {
    font-family: "IBM Plex Sans", sans-serif;
    font-feature-settings: "tnum", "ss01";
    font-weight: 500;
    font-size: 36px;
    letter-spacing: -0.035em;
    color: var(--ink-900);
    line-height: 1.1;
}
.stat-change {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; font-weight: 500;
    margin-top: 4px;
    color: var(--ink-400);
}
.stat-change.positive { color: var(--green-700); }
.stat-change.negative { color: var(--danger-700); }
.stat-change.neutral  { color: var(--ink-500); }

/* Override legacy nested flex */
.stat-card-content > .stat-icon { display: none; } /* HR positions icon top-right */

/* =============================================================
   TAB NAVIGATION (HR uses button group / pill toggle)
   ============================================================= */
.tabs {
    display: inline-flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    gap: 2px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab {
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: var(--ink-500);
    font-weight: 500;
    font-size: 12.5px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 160ms;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab i { font-size: 12px; }
.tab:hover { color: var(--ink-800); background: var(--mute); }
.tab.active {
    background: var(--ink-900);
    color: var(--paper);
    font-weight: 600;
}
[data-theme="dark"] .tab.active { background: var(--ink-200); color: var(--ink-900); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* =============================================================
   MODAL
   ============================================================= */
.modal {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    padding: 16px;
    animation: ds-fade-in 150ms ease;
}
.modal[style*="display: flex"],
.modal[style*="display:flex"],
.modal:not(.hidden):not([style*="display: none"]) { display: flex; }
.modal.hidden { display: none !important; }
.modal-content {
    background: var(--card);
    border-radius: 16px;
    max-width: 560px;
    width: 100%;
    max-height: 92vh;
    overflow: auto;
    box-shadow: var(--shadow-deep);
    animation: ds-pop-in 200ms cubic-bezier(0.4,0,0.2,1);
}
.modal-header {
    padding: 18px 22px 14px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink-900); }
.modal-close {
    background: none; border: none;
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink-500);
}
.modal-close:hover { background: var(--mute); color: var(--ink-700); }
.modal-body { padding: 18px 22px; }
.modal-footer {
    padding: 14px 22px 18px;
    display: flex; gap: 8px; justify-content: flex-end;
    border-top: 1px solid var(--border);
}

/* =============================================================
   ALERTS
   ============================================================= */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex; align-items: flex-start; gap: 10px;
    line-height: 1.5;
}
.alert-success { background: var(--green-50); color: var(--green-800); border-left: 4px solid var(--green-600); }
.alert-warning { background: var(--amber-50); color: var(--amber-700); border-left: 4px solid var(--amber); }
.alert-danger,
.alert-error   { background: var(--danger-50); color: var(--danger-700); border-left: 4px solid var(--danger-700); }
.alert-info    { background: var(--blue-50); color: var(--blue-700); border-left: 4px solid var(--blue); }

/* =============================================================
   SKELETON LOADER
   ============================================================= */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, var(--ink-100) 0%, var(--ink-200) 50%, var(--ink-100) 100%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
    color: transparent;
    user-select: none;
}
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, var(--ink-200) 0%, var(--ink-300) 50%, var(--ink-200) 100%);
}
@keyframes skel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skel-text { height: 14px; width: 100%; }
.skel-row td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.skel-row .skeleton { display: block; height: 14px; }

/* =============================================================
   EMPTY STATE (FA icon — no emoji)
   ============================================================= */
.empty-state-block {
    text-align: center;
    padding: 48px 24px;
    color: var(--ink-500);
}
.empty-state-block .empty-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--mute);
    color: var(--ink-400);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    font-size: 22px;
}
.empty-state-block .empty-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-800);
    margin: 0 0 4px;
}
.empty-state-block .empty-msg {
    font-size: 12.5px;
    margin: 0;
    color: var(--ink-500);
}

/* =============================================================
   SIDEBAR BADGE
   ============================================================= */
.nav-badge {
    margin-left: auto;
    background: var(--danger-700);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    line-height: 1.5;
    min-width: 18px;
    text-align: center;
}

/* =============================================================
   ANIMATIONS
   ============================================================= */
@keyframes ds-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes ds-fade-in {
    from { opacity: 0; } to { opacity: 1; }
}
@keyframes ds-pop-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
.fade-up { animation: ds-fade-up 600ms cubic-bezier(0.4,0,0.2,1) backwards; }

/* =============================================================
   HERO GREETING (section, not card)
   ============================================================= */
.hero-greeting {
    margin-bottom: 28px;
    padding: 0;
    background: none;
    border: none;
}

/* =============================================================
   UTILITIES
   ============================================================= */
.text-sm { font-size: 12px; }
.text-secondary { color: var(--ink-500); }
.text-tertiary  { color: var(--ink-400); }
.text-success { color: var(--green-700); }
.text-warning { color: var(--amber-700); }
.text-danger  { color: var(--danger-700); }
.text-info    { color: var(--blue-700); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-muted { color: var(--ink-400); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.t-900 { color: var(--ink-900); }
.t-800 { color: var(--ink-800); }
.t-700 { color: var(--ink-700); }
.t-600 { color: var(--ink-600); }
.t-500 { color: var(--ink-500); }
.t-400 { color: var(--ink-400); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex { display: flex; } .flex-1 { flex: 1; } .flex-wrap { flex-wrap: wrap; }
.grid { display: grid; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.w-full { width: 100%; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
::-webkit-scrollbar-track { background: transparent; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1024px) {
    .app-sidebar { transform: translateX(-100%); transition: transform 250ms cubic-bezier(0.4,0,0.2,1); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main, .app-header { margin-left: 0; }
    .mobile-menu-toggle { display: inline-flex; }
}

@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .app-header { padding: 0 16px; }
    .page-title { font-size: 22px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 28px; }

    .table-container { overflow: visible; background: transparent; box-shadow: none; }
    .table { display: block; }
    .table thead { display: none; }
    .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tbody tr {
        background: var(--card);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
        margin-bottom: 10px;
        padding: 14px 16px;
    }
    .table tbody tr:hover { background: var(--card); }
    .table tbody td {
        border: none; padding: 5px 0;
        display: flex; justify-content: space-between; align-items: center;
        gap: 12px; text-align: left !important;
    }
    .table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
        color: var(--ink-400); font-weight: 600; flex-shrink: 0;
    }
    .table-actions { justify-content: flex-end; }
}

/* =============================================================
   PRINT
   ============================================================= */
@media print {
    @page { size: A4; margin: 14mm; }
    html, body { background: white !important; color: black !important; font-size: 11pt; }
    .app-header, .app-sidebar, .page-actions, .no-print,
    .modal, #ui-toast-host, #ui-loading, .app-footer,
    .user-menu, .theme-toggle, .mobile-menu-toggle,
    .filter-pills, .picker-toolbar, .friday-banner, .cd-actionbar, .cd-help,
    .pagination, .pagination-row {
        display: none !important;
    }
    .app-main { margin-left: 0 !important; padding: 0 !important; }
    .main-content { padding: 0 !important; max-width: 100% !important; }
    .card, .card-elev, .stat-card { box-shadow: none !important; border: 1px solid #ccc !important; background: white !important; }
    canvas { display: none !important; }
    .table { border-collapse: collapse; }
    .table th, .table td { border: 1px solid #999; padding: 4px 6px; }
    .table thead { display: table-header-group; }
    .table tbody tr { page-break-inside: avoid; }
    .print-only { display: block !important; }
    a { color: black !important; text-decoration: none; }
}
.print-only { display: none; }

/* =============================================================
   v3.1 — SaaS-grade chrome (sidebar brand, topbar functional, footer)
   ============================================================= */

/* ----- SIDEBAR v2: brand + year chip + user pin ----- */
.app-sidebar { padding: 0; }
/* Brand stays at top via natural flow; user-pin sticks to bottom only */
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 18px 16px;
    text-decoration: none;
    color: #fff;
}
.sidebar-brand-logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; color: #fff; line-height: 1.2; }
.sidebar-brand-sub  { font-size: 10.5px; color: #94A3B8; margin-top: 2px; }

.sidebar-year-chip {
    margin: 0 12px 12px;
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-year-chip-badge {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: rgba(18,183,106,0.16);
    color: #6CE9A6;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-year-chip-text { min-width: 0; flex: 1; }
.sidebar-year-chip-title { font-size: 12px; font-weight: 500; color: #fff; line-height: 1.2; }
.sidebar-year-chip-sub   { font-size: 10.5px; color: #94A3B8; margin-top: 2px; }

.app-sidebar .nav-section { padding: 0 12px; }

.sidebar-user-pin {
    margin-top: auto;
    padding: 12px;
    display: flex; align-items: center; gap: 10px;
}
/* No borders/lines anywhere in sidebar */
.app-sidebar .nav-section,
.app-sidebar .nav-section-title {
    border: 0 !important;
    box-shadow: none !important;
}
/* Subtle scrollbar (only when needed) */
.app-sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.10) transparent; }
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 999px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
/* Remove focus outline on nav items (use active/hover bg as indicator) */
.app-sidebar .nav-item:focus,
.app-sidebar .nav-item:focus-visible {
    outline: none !important;
    box-shadow: none;
}
.app-sidebar .nav-item:focus-visible { background: rgba(255,255,255,0.06); }
.app-sidebar .nav-item.active:focus-visible {
    background: rgba(18,183,106,0.18);
    box-shadow: inset 0 0 0 1px rgba(18,183,106,0.35) !important;
}
.sidebar-user-pin .user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--green-400), var(--green-700));
    flex-shrink: 0;
}
.sidebar-user-pin .upin-meta { min-width: 0; flex: 1; }
.sidebar-user-pin .upin-name { font-size: 12.5px; font-weight: 500; color: #F1F5F9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-pin .upin-role { font-size: 10.5px; color: #94A3B8; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.sidebar-user-pin .upin-action {
    width: 28px; height: 28px;
    border-radius: 7px;
    color: #94A3B8;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 12px;
    text-decoration: none;
}
.sidebar-user-pin .upin-action:hover { background: rgba(255,255,255,0.06); color: #F1F5F9; }

/* ----- TOPBAR v2: global search, bell, lang ----- */
.app-header { padding: 0 24px; gap: 12px; }
.topbar-breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-500);
    min-width: 0;
}
.topbar-breadcrumb a { color: var(--ink-500); }
.topbar-breadcrumb a:hover { color: var(--ink-800); }
.topbar-breadcrumb .sep { color: var(--ink-300); }
.topbar-breadcrumb .current { color: var(--ink-900); font-weight: 500; }

.topbar-search {
    position: relative;
    display: inline-flex; align-items: center; gap: 8px;
    width: 320px;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    transition: all 200ms;
}
.topbar-search:focus-within {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(18,183,106,0.10);
}
.topbar-search i { color: var(--ink-400); font-size: 13px; }
.topbar-search input {
    flex: 1; min-width: 0;
    border: none; outline: none;
    background: transparent;
    font: inherit; font-size: 13px;
    color: var(--ink-800);
}
.topbar-search input::placeholder { color: var(--ink-400); }
.kbd {
    display: inline-block;
    font-family: "IBM Plex Mono", monospace;
    font-size: 10.5px; font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--mute);
    border: 1px solid var(--border);
    color: var(--ink-500);
    line-height: 1.4;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-elev);
    max-height: 400px; overflow: auto;
    z-index: 50;
    display: none;
    padding: 4px;
}
.search-dropdown.open { display: block; }
.search-section-title {
    font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
    font-weight: 600; color: var(--ink-400);
    padding: 10px 12px 4px;
}
.search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink-800);
    cursor: pointer;
    font-size: 13px;
}
.search-item:hover, .search-item.focus { background: var(--mute); }
.search-item .si-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--mute);
    color: var(--ink-500);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px;
}
.search-item .si-text { min-width: 0; flex: 1; }
.search-item .si-title { font-weight: 500; color: var(--ink-900); }
.search-item .si-sub   { font-size: 11px; color: var(--ink-500); margin-top: 2px; }
.search-item .si-meta  { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--ink-400); }
.search-empty {
    padding: 20px; text-align: center; color: var(--ink-400); font-size: 12px;
}

/* ----- BELL ----- */
.bell-button {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    width: 36px; height: 36px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink-600);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.bell-button:hover { background: var(--mute); color: var(--ink-800); }
.bell-badge {
    position: absolute;
    top: -3px; right: -3px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger-700);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--paper);
}
.bell-dropdown {
    position: absolute;
    top: calc(100% + 6px); right: 0;
    width: 360px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-elev);
    z-index: 50;
    display: none;
    overflow: hidden;
}
.bell-dropdown.open { display: block; }
.bell-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.bell-section:last-child { border-bottom: none; }
.bell-section-title {
    font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    font-weight: 600; color: var(--ink-500);
    margin-bottom: 8px;
    display: flex; align-items: center; justify-content: space-between;
}
.bell-section-title .count {
    background: var(--mute); color: var(--ink-600);
    padding: 1px 7px; border-radius: 999px; font-size: 10.5px;
}
.bell-empty { font-size: 12px; color: var(--ink-400); padding: 8px 0; }
.bell-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    text-decoration: none;
    color: var(--ink-800);
    font-size: 12.5px;
}
.bell-item:hover { color: var(--ink-900); }

/* ----- LANG TOGGLE ----- */
.lang-toggle {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 10px;
    color: var(--ink-700);
    cursor: pointer;
    font-size: 12px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 4px;
    font-family: inherit;
}
.lang-toggle:hover { background: var(--mute); }
.lang-toggle .lang-active { color: var(--ink-900); font-weight: 600; }
.lang-toggle .lang-sep { color: var(--ink-300); margin: 0 4px; }
.lang-toggle .lang-inactive { color: var(--ink-400); }

/* ----- FOOTER ----- */
.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 16px 0;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11.5px; color: var(--ink-400);
    flex-wrap: wrap; gap: 12px;
}
.app-footer .footer-left { display: flex; align-items: center; gap: 14px; }
.app-footer .footer-left a { color: var(--ink-500); }
.app-footer .footer-left a:hover { color: var(--ink-700); }
.app-footer .footer-right { display: inline-flex; align-items: center; gap: 8px; }
.pulse-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 999px;
    background: var(--green-500);
    animation: ds-pulse 2s ease-in-out infinite;
}
.pulse-dot.danger { background: var(--danger); }
.pulse-dot.amber  { background: var(--amber); }
@keyframes ds-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

/* ----- MAIN-CONTENT becomes flex column so footer sits at bottom ----- */
.main-content {
    padding: 28px 32px;
    max-width: 1560px;
    margin: 0 auto;
    width: 100%;
    min-height: calc(100vh - 60px);
    display: flex; flex-direction: column;
}
.main-content > .app-footer { margin-top: auto; }

/* ----- STAT CARD CTA link ----- */
.stat-cta {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 10px;
    font-size: 12px; font-weight: 500;
    color: var(--green-700);
    text-decoration: none;
}
.stat-cta:hover { color: var(--green-800); }

/* ----- ALERT BAR (full-width hero alert under page header) ----- */
.alert-bar {
    background: var(--green-50);
    color: var(--green-800);
    border: 1px solid var(--green-100);
    border-radius: var(--radius-xl);
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 12px;
    font-size: 13.5px;
}
.alert-bar.amber {
    background: var(--amber-50);
    color: var(--amber-700);
    border-color: rgba(245,158,11,0.20);
}
.alert-bar.danger {
    background: var(--danger-50);
    color: var(--danger-700);
    border-color: rgba(239,68,68,0.20);
}
.alert-bar-icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.5);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}
[data-theme="dark"] .alert-bar-icon { background: rgba(255,255,255,0.08); }
.alert-bar-text { flex: 1; min-width: 0; line-height: 1.45; }
.alert-bar-title { font-weight: 600; }
.alert-bar-sub   { font-size: 12px; opacity: 0.85; margin-top: 2px; font-weight: 400; }
.alert-bar a {
    color: inherit; text-decoration: underline; font-weight: 600;
}

/* ----- DARK QUICK CARD (right column on dashboard grid) ----- */
.quick-card-dark {
    background: #0B0F0E;
    color: #F1F5F9;
    border-radius: var(--radius-xl);
    padding: 22px 22px 18px;
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 280px;
}
.quick-card-dark::before {
    content: '';
    position: absolute;
    top: -80px; right: -80px;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(79,255,176,0.14) 0%, transparent 70%);
    border-radius: 50%;
}
.quick-card-dark .qc-eyebrow {
    font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    color: #94A3B8; font-weight: 500;
    position: relative; z-index: 1;
}
.quick-card-dark .qc-value {
    font-family: "IBM Plex Sans", sans-serif;
    font-weight: 500; font-size: 34px;
    letter-spacing: -0.035em;
    color: #fff;
    margin-top: 10px;
    position: relative; z-index: 1;
}
.quick-card-dark .qc-meta {
    font-size: 12px; color: #CBD5E1;
    margin-top: 4px;
    position: relative; z-index: 1;
}
.quick-card-dark .qc-cta {
    margin-top: auto;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px;
    background: rgba(255,255,255,0.10);
    color: #fff; font-size: 12.5px; font-weight: 600;
    text-decoration: none;
    align-self: flex-start;
    position: relative; z-index: 1;
    transition: all 200ms;
}
.quick-card-dark .qc-cta:hover { background: rgba(255,255,255,0.18); }

/* ----- TABLE ROW HR-style (grid-based with avatar + meta + actions) ----- */
.hr-table { display: block; }
.hr-thead, .hr-trow {
    display: grid;
    gap: 12px;
    padding: 11px 18px;
    align-items: center;
}
.hr-thead {
    background: color-mix(in srgb, var(--mute) 40%, transparent);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-400); font-weight: 500;
}
.hr-trow {
    border-bottom: 1px solid var(--border);
    font-size: 13px; color: var(--ink-700);
    transition: background 150ms;
}
.hr-trow:hover { background: var(--mute); }
.hr-trow:last-child { border-bottom: none; }
.hr-trow.needs-review {
    background: rgba(239,68,68,0.03);
    border-left: 3px solid var(--danger);
    padding-left: 15px;
}
.row-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-name .avatar { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
.row-name .rn-text { min-width: 0; }
.row-name .rn-title { font-weight: 500; color: var(--ink-900); }
.row-name .rn-sub { font-size: 11px; color: var(--ink-400); margin-top: 2px; font-variant-numeric: tabular-nums; }
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.row-act-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-500);
    cursor: pointer;
    font-size: 12px;
    transition: all 120ms;
    text-decoration: none;
}
.row-act-btn:hover {
    background: var(--mute);
    color: var(--ink-900);
    border-color: var(--border);
}

/* ----- FILTER PILLS (sticky chip toolbar above table) ----- */
.filter-pills {
    display: inline-flex; align-items: center; gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.filter-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--ink-600);
    font-size: 12.5px; font-weight: 500;
    cursor: pointer;
    transition: all 160ms;
    font-family: inherit;
}
.filter-pill:hover { background: var(--mute); }
.filter-pill.active {
    background: var(--ink-900);
    color: #fff;
    border-color: var(--ink-900);
}
[data-theme="dark"] .filter-pill.active { background: var(--ink-200); color: var(--ink-900); }
.filter-pill .pill-count {
    background: rgba(0,0,0,0.06);
    padding: 0 6px; border-radius: 999px;
    font-size: 10.5px; font-weight: 700;
}
.filter-pill.active .pill-count { background: rgba(255,255,255,0.15); color: inherit; }

/* ----- RANK LIST (Top savers) ----- */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-item {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 0;
}
.rank-num {
    width: 22px;
    text-align: right;
    font-family: "IBM Plex Sans", sans-serif;
    font-weight: 500; font-size: 14px;
    color: var(--ink-400);
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.rank-item .avatar { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
.rank-name { flex: 1; min-width: 0; }
.rank-title { font-size: 12.5px; font-weight: 500; color: var(--ink-900); }
.rank-sub   { font-size: 10.5px; color: var(--ink-400); margin-top: 2px; }
.rank-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600; font-size: 13px;
    color: var(--ink-900);
}

/* ----- PAGE-HEADER bottom adjust (with eyebrow date + pulse) ----- */
.page-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}

/* ----- Responsive tweaks for new chrome ----- */
@media (max-width: 1024px) {
    .topbar-search { width: 220px; }
    .lang-toggle { display: none; }
}
@media (max-width: 768px) {
    /* Compact mode: search collapses to icon-only; clicking expands inline. */
    .topbar-search {
        width: 38px;
        padding: 0;
        justify-content: center;
        cursor: pointer;
    }
    .topbar-search input,
    .topbar-search .kbd { display: none; }
    .topbar-search.is-expanded {
        position: absolute;
        left: 16px; right: 16px;
        top: 12px;
        width: auto;
        padding: 0 12px;
        background: var(--card);
        z-index: 50;
    }
    .topbar-search.is-expanded input { display: block; }
    .sidebar-year-chip { display: none; }
}

/* ----- Keyboard-only focus indicator (a11y) ----- */
/* Mouse clicks suppress :focus-visible; this only triggers for keyboard nav,
   so it doesn't fight existing :focus styles on form fields/search. */
:focus-visible {
    outline: 2px solid var(--green-700, #15803d);
    outline-offset: 2px;
    border-radius: 4px;
}
.btn:focus-visible,
.nav-item:focus-visible,
.tab:focus-visible,
.user-menu-trigger:focus-visible,
.theme-toggle:focus-visible,
.bell-button:focus-visible,
.lang-toggle:focus-visible,
.mobile-menu-toggle:focus-visible {
    outline-offset: 3px;
}

/* =============================================================
   v3.2 — Mobile-first polish (375px iPhone SE / 12 mini)
   ============================================================= */

/* SIDEBAR DRAWER BACKDROP — dim overlay when drawer is open on mobile */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 19;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}
@media (min-width: 1025px) {
    .sidebar-backdrop { display: none; }
}
/* Ensure drawer sits above backdrop */
@media (max-width: 1024px) {
    .app-sidebar { z-index: 20; }
}

/* Force responsive grids — covers any inline grid-template-columns on pages */
@media (max-width: 768px) {
    .dashboard-stats-row,
    .stats-bar,
    [class*="dashboard-grid"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .hr-trow {
        grid-template-columns: 1fr !important;
        row-gap: 4px;
        padding: 12px 14px;
    }
    .hr-trow > * { justify-self: start !important; text-align: left !important; }
    .hr-trow .amount-mono { font-size: 16px; }

    /* Inline 2-col / 3-col / n-col grids on filters/forms → stack */
    .form-grid-2,
    .form-row { grid-template-columns: 1fr !important; }

    /* Modal: full-width sheet */
    .modal-content,
    .ui-modal { max-width: calc(100vw - 24px) !important; width: calc(100vw - 24px); }
    .modal-header { padding: 14px 16px; }
    .modal-body   { padding: 14px 16px; max-height: 70vh; overflow-y: auto; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1; min-width: 0; }

    /* Form inputs: 44px touch target */
    .form-control, select.form-control, textarea.form-control { min-height: 44px; }

    /* Topbar: hide breadcrumb to save space */
    .topbar-breadcrumb,
    .header-left .page-name { display: none; }

    /* Quick dark card: shorter min-height so doesn't push fold */
    .quick-card-dark { min-height: 220px; padding: 18px; }

    /* Stat cards: smaller value font, tighter padding */
    .stat-card .stat-value,
    .stat-card .display-num { font-size: 28px; }

    /* Footer: wrap nicely */
    .app-footer { flex-wrap: wrap; gap: 8px; font-size: 11.5px; }
}

/* 375px ultra-compact tweaks */
@media (max-width: 420px) {
    .main-content { padding: 14px 12px; }
    .app-header { padding: 0 12px; height: 56px; }
    .page-title { font-size: 19px; }
    .sidebar-brand { padding: 16px 14px 12px; }
    .receipt { padding: 20px 14px !important; max-width: 100% !important; }
    .stat-card { padding: 14px; }
}

/* Tablet (≤1024) tweaks: ensure 2-col stat grid + chart stacking */
@media (max-width: 1024px) {
    .dashboard-stats-row,
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Chart 2/3 + dark card 1/3 → stack */
    .dashboard-grid-main,
    .dashboard-grid-lower {
        grid-template-columns: 1fr !important;
    }
}

/* PREVENT horizontal scroll on body (last-resort guard) */
html, body { overflow-x: hidden; max-width: 100vw; }

/* Touch-friendly action icons */
@media (max-width: 768px) {
    .icon-action,
    .action-icon,
    .btn-icon { min-width: 36px; min-height: 36px; }
}

/* =============================================================
   v4 — Design bundle adoptions (Class Picker, Friday banner,
        Quick-fill chips, Withdraw v2, Approval cards, Receipt)
   ============================================================= */

/* ---------- Friday banner (context strip on classroom deposit) ---------- */
.friday-banner {
    background: linear-gradient(135deg, #0B0F0E 0%, #0E2722 60%, #054F31 100%);
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 20px 26px;
    margin-bottom: 22px;
    display: flex; align-items: center; gap: 22px;
    position: relative; overflow: hidden;
}
.friday-banner::before {
    content: ''; position: absolute;
    right: -60px; top: -60px;
    width: 220px; height: 220px;
    background: radial-gradient(circle, rgba(79,255,176,0.20) 0%, transparent 70%);
    border-radius: 999px;
}
.friday-banner-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: rgba(79,255,176,0.15);
    color: #6CE9A6;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
    position: relative; z-index: 1;
}
.friday-banner-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.friday-banner-eyebrow { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #6CE9A6; font-weight: 600; }
.friday-banner-title { font-size: 22px; font-weight: 500; color: #fff; letter-spacing: -0.025em; margin: 4px 0 0; }
.friday-banner-title .accent { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-weight: 400; }
.friday-banner-sub { font-size: 12.5px; color: #CBD5E1; margin-top: 4px; }
.friday-banner-stats { display: flex; gap: 24px; align-items: center; position: relative; z-index: 1; }
.friday-banner-stats .fb-stat .lbl { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.5); font-weight: 600; }
.friday-banner-stats .fb-stat .val { font-weight: 500; font-size: 28px; color: #fff; letter-spacing: -0.03em; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.friday-banner-stats .fb-stat .val .small { font-size: 14px; color: rgba(255,255,255,0.6); font-weight: 400; }
@media (max-width: 768px) {
    .friday-banner { flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px 18px; }
    .friday-banner-stats { width: 100%; gap: 14px; flex-wrap: wrap; }
    .friday-banner-stats .fb-stat .val { font-size: 22px; }
}

/* ---------- My Class hero card ---------- */
.my-class-card {
    background: var(--card);
    border: 1px solid var(--green-300);
    border-radius: var(--radius-xl);
    padding: 22px 24px;
    margin-bottom: 24px;
    display: flex; align-items: center; gap: 22px;
    cursor: pointer;
    transition: all 200ms;
    position: relative; overflow: hidden;
}
.my-class-card::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    background: linear-gradient(180deg, var(--green-400), var(--green-700));
}
.my-class-card:hover { box-shadow: var(--shadow-elev); transform: translateY(-1px); }
.mcc-eyebrow { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--green-700); font-weight: 600; }
.mcc-label { font-weight: 500; font-size: 40px; color: var(--ink-900); letter-spacing: -0.035em; line-height: 1; margin-top: 4px; }
.mcc-teacher { font-size: 12.5px; color: var(--ink-500); margin-top: 6px; }
.mcc-stats { display: flex; gap: 24px; margin-left: auto; }
.mcc-stat .lbl { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; }
.mcc-stat .val { font-weight: 500; font-size: 26px; color: var(--ink-900); letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.mcc-stat.done .val { color: var(--green-700); }
.mcc-stat.warn .val { color: var(--amber-700); }
.mcc-cta {
    padding: 12px 18px; border-radius: 12px;
    background: var(--green-600); color: #fff;
    font-weight: 600; font-size: 13px;
    display: inline-flex; align-items: center; gap: 8px;
    margin-left: 16px;
}
.mcc-progress-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ink-100); }
.mcc-progress-fill { height: 100%; background: linear-gradient(90deg, var(--green-400), var(--green-600)); }
@media (max-width: 768px) {
    .my-class-card { flex-wrap: wrap; padding: 18px; gap: 14px; }
    .mcc-label { font-size: 30px; }
    .mcc-stats { margin-left: 0; width: 100%; gap: 14px; flex-wrap: wrap; }
    .mcc-cta { margin-left: 0; width: 100%; justify-content: center; }
}

/* ---------- Picker toolbar + search ---------- */
.picker-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.picker-search { position: relative; height: 38px; width: 280px; max-width: 100%; }
.picker-search input {
    width: 100%; height: 100%;
    padding: 0 12px 0 36px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--card);
    font-size: 13px; font-family: inherit; outline: none;
    color: var(--ink-900);
}
.picker-search input:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(18,183,106,0.10); }
.picker-search i { position: absolute; left: 12px; top: 12px; color: var(--ink-400); }

/* ---------- Grade-grouped class cards ---------- */
.grade-row { margin-bottom: 22px; }
.grade-row-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; padding-left: 4px; }
.grade-row-label { font-weight: 500; font-size: 22px; color: var(--ink-900); letter-spacing: -0.025em; line-height: 1; }
.grade-row-meta { font-size: 11px; color: var(--ink-400); letter-spacing: 0.06em; }
.grade-row-meta .strong { color: var(--green-700); font-weight: 600; }
.grade-row-meta .warn { color: var(--amber-700); font-weight: 600; }

.class-picker-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1280px) { .class-picker-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .class-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 540px)  { .class-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.class-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 14px 12px;
    cursor: pointer;
    transition: all 180ms cubic-bezier(0.4,0,0.2,1);
    position: relative; overflow: hidden; min-width: 0;
}
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-elev); border-color: var(--green-300); }
.class-card.is-done { background: linear-gradient(180deg, var(--green-50) 0%, var(--card) 50%); border-color: var(--green-200); }
.class-card.is-mine { border-color: var(--green-500); box-shadow: 0 0 0 2px rgba(18,183,106,0.15); }
.class-card .cc-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; gap: 4px; }
.class-card .cc-label { font-weight: 500; font-size: 22px; color: var(--ink-900); letter-spacing: -0.025em; line-height: 1; }
.class-card .cc-teacher { font-size: 10.5px; color: var(--ink-500); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-card .cc-progress-ring { width: 32px; height: 32px; position: relative; flex-shrink: 0; }
.class-card .cc-progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.class-card .cc-progress-ring circle { fill: none; stroke-width: 3.5; }
.class-card .cc-progress-ring .bg { stroke: var(--ink-100); }
.class-card .cc-progress-ring .fg { stroke: var(--green-500); stroke-linecap: round; transition: stroke-dashoffset 600ms ease; }
.class-card.is-done .cc-progress-ring .fg { stroke: var(--green-600); }
.class-card .cc-progress-ring .check { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--green-600); font-size: 12px; }
.class-card .cc-progress-ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; color: var(--ink-700); font-variant-numeric: tabular-nums; }
.class-card .cc-counts { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.class-card .cc-counts .filled { font-weight: 500; font-size: 20px; color: var(--ink-900); letter-spacing: -0.02em; line-height: 1; }
.class-card.is-done .cc-counts .filled { color: var(--green-700); }
.class-card .cc-counts .total { font-size: 12.5px; color: var(--ink-400); }
.class-card .cc-counts .label { font-size: 10.5px; color: var(--ink-500); margin-left: 4px; }
.class-card .cc-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ink-100); overflow: hidden; }
.class-card .cc-bar-fill { height: 100%; background: linear-gradient(90deg, var(--green-400), var(--green-600)); transition: width 600ms ease; }
.class-card .cc-mine-tag {
    position: absolute; top: 8px; right: 8px;
    background: var(--green-600); color: #fff;
    font-size: 9px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; letter-spacing: 0.06em;
}

/* ---------- Quick-fill chips above grid ---------- */
.quick-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--card); border: 1px solid var(--border);
    color: var(--ink-700);
    font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: all 120ms;
    font-variant-numeric: tabular-nums;
}
.quick-chip:hover { background: var(--green-50); border-color: var(--green-300); color: var(--green-800); }
.quick-chip:active { transform: scale(0.97); }
.quick-chip.danger:hover { background: var(--danger-50); border-color: var(--danger); color: var(--danger-700); }
.gt-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; margin-right: 4px; }

/* ---------- Withdraw v2 quick-buttons + reason grid ---------- */
.wd-amount-input {
    position: relative; display: flex; align-items: center;
    background: var(--card); border: 2px solid var(--border);
    border-radius: 12px; padding: 8px 18px; transition: all 200ms;
}
.wd-amount-input:focus-within { border-color: var(--green-500); box-shadow: 0 0 0 4px rgba(18,183,106,0.12); }
.wd-amount-input .currency-sign { font-size: 28px; font-weight: 400; color: var(--ink-400); margin-right: 12px; line-height: 1; }
.wd-amount-input input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 36px; font-weight: 500;
    font-variant-numeric: tabular-nums; letter-spacing: -0.025em;
    color: var(--ink-900); padding: 0; width: 100%;
    font-family: inherit;
}
.wd-amount-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.wd-amount-quick button {
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--card); color: var(--ink-700);
    font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit; font-variant-numeric: tabular-nums;
}
.wd-amount-quick button:hover { background: var(--mute); border-color: var(--green-300); }
.wd-amount-quick button.is-all { background: var(--green-50); border-color: var(--green-300); color: var(--green-800); }

.wd-reasons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (max-width: 540px) { .wd-reasons { grid-template-columns: 1fr; } }
.wd-reason-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--card); color: var(--ink-700);
    font-size: 12.5px; font-weight: 500;
    cursor: pointer; text-align: left; font-family: inherit;
    transition: all 120ms;
}
.wd-reason-btn:hover { background: var(--mute); border-color: var(--ink-300); }
.wd-reason-btn.active { background: var(--green-50); border-color: var(--green-500); color: var(--green-800); box-shadow: 0 0 0 3px rgba(18,183,106,0.10); }
.wd-reason-btn i {
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--mute); color: var(--ink-500);
    border-radius: 7px; font-size: 11.5px; flex-shrink: 0;
}
.wd-reason-btn.active i { background: var(--green-100); color: var(--green-700); }

.wd-approval-notice {
    margin-top: 12px; padding: 12px 14px;
    border-radius: 12px;
    background: var(--amber-50, #FEF3C7); color: var(--amber-700, #B45309);
    border: 1px solid rgba(245,158,11,0.20);
    font-size: 12.5px;
    display: flex; align-items: flex-start; gap: 10px; line-height: 1.5;
}
.wd-approval-notice i { font-size: 14px; margin-top: 1px; flex-shrink: 0; }

/* ---------- Approval cards ---------- */
.approval-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
@media (max-width: 540px) { .approval-grid { grid-template-columns: 1fr; } }
.approval-card {
    background: linear-gradient(180deg, var(--amber-50, #FEF3C7) 0%, var(--card) 30%);
    border: 1px solid rgba(245,158,11,0.22);
    border-radius: var(--radius-xl);
    padding: 16px 18px; position: relative;
    display: flex; flex-direction: column; gap: 10px;
}
.approval-card::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--amber, #F59E0B);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}
.approval-card .ap-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.approval-card .ap-who { display: flex; gap: 12px; align-items: center; }
.approval-card .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ink-100); color: var(--ink-700); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.approval-card .ap-name { font-weight: 600; font-size: 14.5px; color: var(--ink-900); }
.approval-card .ap-meta { font-size: 11.5px; color: var(--ink-500); font-family: ui-monospace, 'JetBrains Mono', monospace; }
.approval-card .ap-age {
    background: var(--amber-50, #FEF3C7); color: var(--amber-700, #B45309);
    font-size: 11px; font-weight: 600;
    padding: 3px 9px; border-radius: 999px;
    white-space: nowrap;
}
.approval-card .ap-amount {
    font-size: 28px; font-weight: 500; color: var(--ink-900);
    letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.approval-card .ap-amount .baht { font-size: 14px; color: var(--ink-500); font-weight: 400; margin-right: 4px; }
.approval-card .ap-bal { font-size: 11.5px; color: var(--ink-500); display: flex; gap: 14px; flex-wrap: wrap; }
.approval-card .ap-bal b { color: var(--ink-800); font-variant-numeric: tabular-nums; }
.approval-card .ap-reason { font-size: 12.5px; color: var(--ink-700); padding: 8px 10px; background: var(--card); border-radius: 8px; border: 1px solid var(--border); }
.approval-card .ap-actions { display: flex; gap: 8px; margin-top: 4px; }
.approval-card .ap-actions .btn { flex: 1; }

/* ---------- Receipt polish: bigger amount + monospace divider ---------- */
.receipt-amount-big { font-size: 44px; font-weight: 500; color: var(--ink-900); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.receipt-amount-big .baht-prefix { font-size: 22px; color: var(--ink-400); font-weight: 400; margin-right: 6px; }
.receipt-divider-dashed { border-top: 1.5px dashed var(--ink-300); margin: 14px 0; }

/* ---------- Reports color-coded bars ---------- */
.grade-bar-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.grade-bar-row .lbl { width: 60px; font-weight: 600; font-size: 13px; color: var(--ink-800); }
.grade-bar-row .bar { flex: 1; height: 24px; background: var(--ink-100); border-radius: 6px; overflow: hidden; position: relative; }
.grade-bar-row .bar-fill { height: 100%; transition: width 500ms ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: 11px; font-weight: 600; color: #fff; }
.grade-bar-row .bar-fill.green { background: linear-gradient(90deg, var(--green-400), var(--green-600)); }
.grade-bar-row .bar-fill.amber { background: linear-gradient(90deg, #FBBF24, #F59E0B); }
.grade-bar-row .bar-fill.danger { background: linear-gradient(90deg, #FB7185, #EF4444); }
.grade-bar-row .right { width: 110px; text-align: right; font-size: 12px; color: var(--ink-600); font-variant-numeric: tabular-nums; }

/* =============================================================
   v4.2 — Avatar (photo + initial fallback) + Pagination ellipsis
   ============================================================= */

/* AVATAR — supports both <img> photo + initial circle, sized via class */
.av {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ink-300), var(--ink-500));
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-xs { width: 22px; height: 22px; font-size: 10px; }
.av-sm { width: 28px; height: 28px; font-size: 11px; }
.av-md { width: 36px; height: 36px; font-size: 13px; }
.av-lg { width: 48px; height: 48px; font-size: 16px; }
.av-xl { width: 72px; height: 72px; font-size: 26px; }

/* Initial-letter color variants (hash-cycled by ui.js) */
.av-c1 { background: linear-gradient(135deg, #16A34A, #047857); }
.av-c2 { background: linear-gradient(135deg, #3B82F6, #1E40AF); }
.av-c3 { background: linear-gradient(135deg, #F59E0B, #B45309); }
.av-c4 { background: linear-gradient(135deg, #EF4444, #B91C1C); }
.av-c5 { background: linear-gradient(135deg, #8B5CF6, #5B21B6); }
.av-c6 { background: linear-gradient(135deg, #EC4899, #BE185D); }
.av-c7 { background: linear-gradient(135deg, #06B6D4, #0E7490); }
.av-c8 { background: linear-gradient(135deg, #84CC16, #4D7C0F); }

/* PAGINATION ELLIPSIS */
.pagination {
    display: inline-flex; align-items: center; gap: 4px;
    flex-wrap: wrap;
}
.pagination .page-btn {
    min-width: 34px; height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink-700);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    transition: all 120ms;
    display: inline-flex; align-items: center; justify-content: center;
}
.pagination .page-btn:hover:not(:disabled):not(.active) { background: var(--mute); border-color: var(--ink-300); }
.pagination .page-btn.active {
    background: var(--ink-900); color: #fff; border-color: var(--ink-900);
    cursor: default;
}
[data-theme="dark"] .pagination .page-btn.active { background: var(--ink-200); color: var(--ink-900); }
.pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-btn .fa { font-size: 11px; }
.pagination .page-gap {
    min-width: 24px; height: 34px;
    color: var(--ink-400);
    display: inline-flex; align-items: center; justify-content: center;
    user-select: none;
}
.pagination-info {
    font-size: 12.5px; color: var(--ink-500);
    margin-right: 12px;
    white-space: nowrap;
}
.pagination-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-top: 12px;
}
@media (max-width: 540px) {
    .pagination-row { flex-direction: column; align-items: stretch; }
    .pagination { justify-content: center; }
}

/* Required field indicator */
.form-label.required::after { content: ' *'; color: var(--danger, #EF4444); font-weight: 700; }

/* Frozen row visual (cross-table) */
.table tbody tr.row-frozen,
.hr-trow.row-frozen {
    background: color-mix(in srgb, var(--danger-50, #FEE2E2) 60%, transparent) !important;
    position: relative;
}
.table tbody tr.row-frozen td:first-child,
.hr-trow.row-frozen > *:first-child {
    border-left: 3px solid var(--danger, #EF4444);
}
[data-theme="dark"] .table tbody tr.row-frozen,
[data-theme="dark"] .hr-trow.row-frozen {
    background: rgba(239,68,68,0.10) !important;
}
.row-frozen .av {
    box-shadow: inset 0 0 0 2px var(--danger, #EF4444);
    opacity: 0.6;
}

/* Alert-bar danger state for dashboard when frozen count > 0 */
.alert-bar.danger { background: var(--danger-50, #FEE2E2); color: var(--danger-700, #B42318); border-color: rgba(239,68,68,0.25); }
.alert-bar.danger .alert-bar-icon { color: var(--danger-700, #B42318); }



/* =============================================================
   v4.1 — Empty / Loading / Error state framework
   ============================================================= */

/* Hero empty state — card-framed, centered, 64px icon, CTA button */
.empty-state,
.grid-empty {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 56px 24px;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    min-height: 320px;
    box-shadow: var(--shadow-card);
}
.empty-state .empty-icon,
.grid-empty .ge-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: linear-gradient(180deg, var(--green-50) 0%, color-mix(in srgb, var(--mute) 60%, var(--card)) 100%);
    color: var(--green-700);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px;
    margin-bottom: 4px;
    box-shadow: inset 0 0 0 1px var(--green-100, rgba(18,183,106,0.18));
}
.empty-state .empty-icon.muted,
.grid-empty .ge-icon { background: var(--mute); color: var(--ink-400); box-shadow: inset 0 0 0 1px var(--border); }
.empty-state .empty-icon.amber,
.grid-empty.amber .ge-icon { background: var(--amber-50, #FEF3C7); color: var(--amber-700, #B45309); }
.empty-state .empty-icon.danger,
.grid-empty.danger .ge-icon { background: var(--danger-50, #FEE2E2); color: var(--danger-700, #B42318); }

.empty-state .empty-title,
.grid-empty .ge-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink-900);
    letter-spacing: -0.01em;
    line-height: 1.3;
    max-width: 420px;
}
.empty-state .empty-sub,
.grid-empty .ge-sub {
    font-size: 13.5px;
    color: var(--ink-500);
    line-height: 1.55;
    max-width: 460px;
    margin: 0 auto;
}
.empty-state .empty-cta,
.grid-empty .btn {
    margin-top: 12px;
}

/* Loading state — centered spinner in card */
.loading-state {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 60px 24px;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px;
    min-height: 280px;
    color: var(--ink-500);
    box-shadow: var(--shadow-card);
}
.loading-state .spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--ink-100);
    border-top-color: var(--green-600);
    border-radius: 50%;
    animation: ds-spin 700ms linear infinite;
}
.loading-state .loading-text {
    font-size: 13.5px;
    color: var(--ink-500);
    font-weight: 500;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* Error state — card with danger accent + retry button */
.error-state {
    background: linear-gradient(180deg, var(--danger-50, #FEE2E2) 0%, var(--card) 30%);
    border: 1px solid rgba(239,68,68,0.20);
    border-radius: var(--radius-xl);
    padding: 48px 24px;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
    min-height: 240px;
    justify-content: center;
}
.error-state .err-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: rgba(239,68,68,0.10);
    color: var(--danger, #EF4444);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.error-state .err-title {
    font-size: 16px; font-weight: 600;
    color: var(--ink-900);
    margin-top: 4px;
}
.error-state .err-detail {
    font-size: 13px;
    color: var(--ink-500);
    max-width: 460px;
    line-height: 1.55;
    font-family: ui-monospace, 'JetBrains Mono', monospace;
    background: var(--mute);
    padding: 8px 12px;
    border-radius: 8px;
    word-break: break-word;
}

/* Inline mini empty/loading variants (use inside list/panel where full card is overkill) */
.mini-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--ink-400);
    font-size: 13px;
}
.mini-empty i { font-size: 22px; opacity: 0.5; display: block; margin-bottom: 6px; }
.mini-loading {
    padding: 24px;
    text-align: center;
    color: var(--ink-400);
    font-size: 13px;
}
.mini-loading i { animation: ds-spin 700ms linear infinite; margin-right: 4px; }

/* Empty-state-block upgrade (used in dashboard ui.js helper) */
.empty-state-block {
    padding: 48px 24px !important;
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center; gap: 10px;
}
.empty-state-block .empty-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--mute);
    color: var(--ink-400);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
    margin: 0 auto 4px;
}
.empty-state-block .empty-title { font-size: 15.5px !important; font-weight: 600 !important; color: var(--ink-800); margin: 0; }
.empty-state-block .empty-sub,
.empty-state-block .empty-msg   { font-size: 12.5px !important; color: var(--ink-500); margin: 0; line-height: 1.5; }



/* ===== Number inputs: kill spinners (all browsers) =====
   Money fields use type=number; the native spinners invite accidental
   mouse-wheel / trackpad decrements (e.g. ฿6,600 silently becoming
   ฿6,599.97 — 3 wheel ticks x step 0.01). Wheel itself is also
   neutralised in ui.js. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
