/* ==========================================================================
   Dtjw Classlog — Modern Design Language & System Tokens
   ========================================================================== */

/* --------------------------------------------------------------------------
   UI-A foundation — Thai webfont (self-hosted, no external requests)
   The Regular/Bold TTFs below already ship in this repository for the
   document pipeline (static/exams/fonts/sarabun), so the browser can load a
   real Thai face instead of relying on a system fallback.  "Noto Sans Thai"
   and "Anuphan" stay in the stack as optional locally-installed fallbacks.
   -------------------------------------------------------------------------- */
@font-face {
    font-family: "Sarabun";
    src: url("../../exams/fonts/sarabun/Sarabun-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Sarabun";
    src: url("../../exams/fonts/sarabun/Sarabun-Bold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Sarabun";
    src: url("../../exams/fonts/sarabun/Sarabun-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Brand & Theme Colors */
    --navy: #0f172a;
    --navy-light: #1e293b;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light: #eff6ff;
    --blue-border: #bfdbfe;
    
    --teal: #0d9488;
    --teal-dark: #0f766e;
    --teal-light: #f0fdfa;
    --teal-border: #99f6e4;
    
    --emerald: #10b981;
    --emerald-light: #ecfdf5;
    
    --amber: #d97706;
    --amber-dark: #b45309;
    --amber-light: #fffbeb;
    --amber-border: #fde68a;
    
    --rose: #e11d48;
    --rose-dark: #be123c;
    --rose-light: #fff1f2;
    --rose-border: #fecdd3;

    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    
    /* Neutral / Canvas */
    --ink: #0f172a;
    --ink-secondary: #334155;
    --muted: #64748b;
    --surface: #ffffff;
    --canvas: #f8fafc;
    --line: #e2e8f0;
    --line-subtle: #f1f5f9;

    /* Shadows & Elevations */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 10px 20px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
    
    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ------------------------------------------------------------------
       UI-A foundation tokens
       ------------------------------------------------------------------ */

    /* Typography: real Thai stack (Sarabun is self-hosted above). */
    --font-thai: "Sarabun", "Noto Sans Thai", "Anuphan", system-ui, -apple-system, "Segoe UI", sans-serif;
    --fs-page-title: 1.5rem;      /* 24px */
    --fs-section-title: 1.0625rem;/* 17px */
    --fs-table-head: 0.75rem;     /* 12px */
    --fs-body: 0.875rem;          /* 14px */
    --fs-strong: 0.875rem;        /* 14px */
    --fs-label: 0.8125rem;        /* 13px */
    --fs-caption: 0.8125rem;      /* 13px */
    --fs-status: 0.875rem;        /* 14px */
    --fs-button: 0.875rem;        /* 14px */
    --fs-control: 0.875rem;       /* 14px */
    --lh-tight: 1.3;
    --lh-heading: 1.4;
    --lh-body: 1.5;
    --lh-strong: 1.45;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* Semantic status palette (aliases the audited brand values where they
       already exist, so nothing is duplicated). */
    --status-success-fg: #065f46;
    --status-success-bg: var(--emerald-light);
    --status-success-border: #a7f3d0;
    --status-info-fg: var(--blue-dark);
    --status-info-bg: var(--blue-light);
    --status-info-border: var(--blue-border);
    --status-warning-fg: #92400e;
    --status-warning-bg: var(--amber-light);
    --status-warning-border: var(--amber-border);
    --status-danger-fg: #9f1239;
    --status-danger-bg: var(--rose-light);
    --status-danger-border: var(--rose-border);
    --status-neutral-fg: var(--ink-secondary);
    --status-neutral-bg: var(--canvas);
    --status-neutral-border: var(--line);
    --status-locked-fg: var(--navy-light);
    --status-locked-bg: #e2e8f0;
    --status-locked-border: #cbd5e1;

    /* Spacing scale (4px rhythm) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    /* Radius scale — existing values kept, xs added for compact controls. */
    --radius-xs: 6px;

    /* Icon / touch-target foundation */
    --icon-size: 1rem;
    --tap-target: 32px;
}

/* Global Reset & Base Typography */
* { box-sizing: border-box; }
html, body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-thai);
    max-width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Smooth custom scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Navbar / Topbar */
.topbar {
    background: var(--navy);
    min-height: 72px;
    color: #fff;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark {
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    line-height: 1.1;
    text-decoration: none;
    transition: transform var(--transition-fast);
}
.brand-mark:hover { color: #fff; transform: translateY(-1px); }
.brand-mark strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark small { color: #94a3b8; font-size: 0.72rem; margin-top: 0.2rem; }
.brand-icon, .auth-icon {
    align-items: center;
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    border-radius: var(--radius-md);
    display: inline-flex;
    height: 44px;
    justify-content: center;
    width: 44px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
    color: #fff;
}
.user-chip {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-pill);
    color: #f1f5f9;
    display: flex;
    gap: 0.6rem;
    padding: 0.35rem 0.85rem 0.35rem 0.4rem;
    font-size: 0.88rem;
    font-weight: 500;
}
.avatar {
    align-items: center;
    background: var(--blue);
    border-radius: 50%;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    width: 32px;
    color: #fff;
    font-size: 0.95rem;
}

/* Layout */
.app-layout { display: flex; min-height: calc(100vh - 72px); }
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 1.5rem 1rem 1rem;
    width: 256px;
    flex-shrink: 0;
}
.sidebar-label {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0.35rem 0.75rem 0.65rem;
    text-transform: uppercase;
}
.sidebar-section-label {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0.5rem 0.75rem 0.35rem;
}
.sidebar-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: #475569;
    display: flex;
    font-weight: 600;
    font-size: 0.92rem;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
    padding: 0.7rem 0.85rem;
    text-decoration: none;
    transition: all var(--transition-fast);
}
.sidebar-link:hover {
    background: #f1f5f9;
    color: var(--blue);
    transform: translateX(2px);
}
.sidebar-link.active {
    background: #eff6ff;
    color: var(--blue);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--blue);
}
.sidebar-link.disabled { color: #94a3b8; cursor: default; }
.sidebar-link.disabled:hover { background: transparent; transform: none; }
.coming-soon {
    font-size: 0.65rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-pill);
    margin-left: auto;
}
.sidebar-divider { border-top: 1px solid var(--line); margin: 1.1rem 0.75rem; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 1.1rem 0.75rem 0.5rem; }

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    max-width: 1440px;
    padding: 2rem clamp(1rem, 3vw, 2.75rem);
    width: 100%;
}
.page-heading { margin-bottom: 2rem; }
.eyebrow {
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.page-title {
    font-size: clamp(1.65rem, 3vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0.35rem 0 0.35rem;
}
.page-subtitle { color: var(--muted); font-size: 0.95rem; }

/* Modern Interactive KPI Stat Cards */
.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-height: 112px;
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-bounce), box-shadow var(--transition-normal), border-color var(--transition-fast);
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background var(--transition-fast);
}
.stat-primary::after { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-teal::after { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.stat-amber::after { background: linear-gradient(90deg, #d97706, #fbbf24); }
.stat-danger::after { background: linear-gradient(90deg, #e11d48, #f43f5e); }
.stat-purple::after { background: linear-gradient(90deg, #7c3aed, #a78bfa); }

.stat-icon {
    align-items: center;
    border-radius: var(--radius-md);
    display: flex;
    font-size: 1.45rem;
    height: 52px;
    justify-content: center;
    width: 52px;
    flex-shrink: 0;
    transition: transform var(--transition-bounce);
}
.stat-card:hover .stat-icon { transform: scale(1.08); }

.stat-primary .stat-icon { background: var(--blue-light); color: var(--blue); }
.stat-teal .stat-icon { background: var(--teal-light); color: var(--teal); }
.stat-amber .stat-icon { background: var(--amber-light); color: var(--amber); }
.stat-danger .stat-icon { background: var(--rose-light); color: var(--rose); }
.stat-purple .stat-icon { background: var(--purple-light); color: var(--purple); }
/* UI-A/UI-C: stat variants that templates already reference but that had no
   rule (info/secondary/warning/success), expressed with the semantic tokens so
   the top accent bar and the icon chip match the audited palette. */
.stat-info .stat-icon { background: var(--status-info-bg); color: var(--status-info-fg); }
.stat-warning .stat-icon { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.stat-success .stat-icon { background: var(--status-success-bg); color: var(--status-success-fg); }
.stat-secondary .stat-icon { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.stat-info::after { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.stat-warning::after { background: linear-gradient(90deg, #d97706, #fbbf24); }
.stat-success::after { background: linear-gradient(90deg, #059669, #34d399); }
.stat-secondary::after { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }

.stat-label { color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 0.15rem;
    line-height: 1.2;
}
.stat-value-sm { font-size: 1.15rem; }
.stat-value small { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

/* Content Cards */
.content-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
}
.content-card:hover { box-shadow: var(--shadow-md); }
.content-card-header {
    border-bottom: 1px solid var(--line);
    padding: 1.25rem 1.5rem;
    background: #fafbfc;
}
.section-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }

/* Timeline & Card Layout for Teacher Timetable */
.timetable-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
}
.period-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}
.period-card:hover {
    border-color: #93c5fd;
    box-shadow: var(--shadow-md);
    transform: translateX(3px);
}
.period-card.is-active-period {
    border: 2px solid var(--blue);
    background: #f8fbff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15), var(--shadow-md);
}
.period-card.is-active-period::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--blue);
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.period-badge-wrap {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.period-badge {
    align-items: center;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: var(--radius-md);
    color: var(--blue);
    display: inline-flex;
    flex-direction: column;
    height: 52px;
    justify-content: center;
    width: 52px;
    font-weight: 700;
    line-height: 1;
}
.period-badge span { font-size: 0.65rem; color: #64748b; font-weight: 500; }
.period-badge strong { font-size: 1.3rem; margin-top: 2px; }

.period-info-main { flex: 1; min-width: 240px; }
.period-subject-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.period-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }

/* Status Badges */
.status-badge {
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    font-size: var(--fs-status);      /* UI-A: audited 14px status text */
    font-weight: var(--fw-semibold);
    line-height: var(--lh-heading);
    padding: 0.35rem 0.75rem;
    white-space: nowrap;
    border: 1px solid transparent;
}
.status-done, .status-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}
.status-pending, .status-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}
.status-danger, .status-rejected {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fecdd3;
}
.status-missing, .status-incomplete {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}
.status-waiting {
    background: #f0f9ff;
    color: #075985;
    border-color: #bae6fd;
}
.status-attendance {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}
.status-attendance-pending {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}
/* UI-A: the remaining audited states, same visual language as the rules above
   (subtle background + dark readable foreground + 1px semantic border). */
.status-info {
    background: var(--status-info-bg);
    color: var(--status-info-fg);
    border-color: var(--status-info-border);
}
.status-neutral {
    background: var(--status-neutral-bg);
    color: var(--status-neutral-fg);
    border-color: var(--status-neutral-border);
}
.status-locked {
    background: var(--status-locked-bg);
    color: var(--status-locked-fg);
    border-color: var(--status-locked-border);
}

/* Pulsing Badge for Current Period */
.live-pulse-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.pulse-dot {
    width: 7px;
    height: 7px;
    background-color: #dc2626;
    border-radius: 50%;
    animation: pulseGlow 1.5s infinite;
}
@keyframes pulseGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Action Buttons & Touch Targets */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all var(--transition-fast);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}
.btn-light-primary {
    background: #eff6ff;
    color: var(--blue);
    border: 1px solid #bfdbfe;
}
.btn-light-primary:hover {
    background: #dbeafe;
    color: var(--blue-dark);
}

/* Skeleton Loading Shimmer */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Chart Canvas Wrappers */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 260px;
}

/* Tables & Schedules */
.schedule-table th {
    background: #fafbfc;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1rem 1.25rem;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.schedule-table td {
    border-color: #f1f5f9;
    padding: 1.1rem 1.25rem;
    vertical-align: middle;
}
.period-number {
    align-items: center;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: var(--radius-sm);
    color: var(--blue);
    display: inline-flex;
    font-weight: 700;
    height: 36px;
    justify-content: center;
    width: 36px;
}
.subject-code {
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Forms & Inputs */
.form-control, .form-select {
    border-color: #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.date-picker {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    box-shadow: var(--shadow-xs);
}
.date-picker > i { color: var(--blue); margin-left: 0.25rem; }
.date-picker input {
    border: 0;
    color: #334155;
    font: inherit;
    font-weight: 600;
    min-width: 145px;
    outline: 0;
}
.date-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.date-display {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: #334155;
    font-weight: 600;
    padding: 0.65rem 1rem;
    box-shadow: var(--shadow-xs);
}

/* Action & Report Cards */
.action-card {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    justify-content: center;
    min-height: 135px;
    padding: 1.25rem;
    text-align: center;
    text-decoration: none;
    transition: transform var(--transition-bounce), box-shadow var(--transition-normal);
}
.action-card:hover {
    color: var(--ink);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.action-primary { border-top: 4px solid var(--blue); }
.action-warning { border-top: 4px solid var(--amber); }
.action-teal { border-top: 4px solid var(--teal); }
.action-danger { border-top: 4px solid var(--rose); }

/* Executive Details Grid */
.executive-detail-grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.executive-detail-grid.one-column { grid-template-columns: 1fr; }
.executive-detail-grid small, .executive-record-field small { color: var(--muted); display: block; font-size: 0.78rem; font-weight: 500; }
.executive-detail-grid strong { display: block; margin-top: 0.2rem; overflow-wrap: anywhere; }
.executive-record-field { border-bottom: 1px solid var(--line); padding: 0.9rem 0; }
.executive-record-field:last-child { border-bottom: 0; }
.executive-record-field p { margin: 0.35rem 0 0; }

/* Status present/absent/late/leave */
.status-present { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status-absent { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.status-late { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.status-leave { background: #f5f3ff; color: #5b21b6; border: 1px solid #ddd6fe; }
.status-school_activity { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Responsive Mobile Optimizations */
@media (max-width: 767.98px) {
    .main-content { padding: 1.25rem 0.85rem; }
    .content-card-header { padding: 1rem; }
    .stat-card { padding: 1rem; min-height: 98px; }
    .stat-icon { height: 44px; width: 44px; font-size: 1.2rem; }
    .stat-value { font-size: 1.35rem; }
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .schedule-actions { width: 100%; }
    .schedule-actions .btn { flex: 1; min-height: 44px; }
    .period-card { padding: 1rem; }
    .period-badge { height: 44px; width: 44px; }
    .executive-detail-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 575.98px) {
    .executive-detail-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 1.5rem; line-height: 1.25; }
    .content-card-header { align-items: flex-start !important; }
}


/* ClassLog report dashboard cards (staging hotfix 2026-08-22) */
.report-card {
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 150px;
    padding: 1.35rem;
    text-decoration: none;
    transition: transform var(--transition-bounce), border-color var(--transition-fast), box-shadow var(--transition-normal);
}
.report-card:hover {
    border-color: #b5ccff;
    box-shadow: var(--shadow-md);
    color: var(--ink);
    transform: translateY(-3px);
}
.report-card i { color: var(--blue); font-size: 1.5rem; }
.report-card span { font-weight: 700; margin-top: 0.35rem; }
.report-card strong { color: var(--blue); font-size: 1.6rem; }
.report-card small { color: var(--muted); }

/* Account Management */
.account-admin-page .account-stat-card {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: .85rem;
    min-height: 88px;
    padding: 1rem 1.1rem;
}
.account-stat-card small { color: var(--muted); display: block; font-size: .78rem; }
.account-stat-card strong { color: var(--ink); display: block; font-size: 1.45rem; line-height: 1.2; margin-top: .15rem; }
.account-stat-icon { align-items: center; border-radius: var(--radius-md); display: inline-flex; flex: 0 0 42px; font-size: 1.1rem; height: 42px; justify-content: center; width: 42px; }
.account-admin-table-card { overflow: visible; }
.account-admin-table-wrap { overflow-x: auto; }
.account-admin-table { min-width: 1080px; table-layout: fixed; }
.account-admin-table .account-col-select { width: 48px; }
.account-admin-table .account-col-user { width: 270px; }
.account-admin-table .account-col-role { width: 145px; }
.account-admin-table .account-col-status { width: 150px; }
.account-admin-table .account-col-password { width: 175px; }
.account-admin-table .account-col-activation { width: 170px; }
.account-admin-table .account-col-actions { width: 170px; }
.account-admin-table thead th { background: #fafbfc; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .04em; padding: .85rem .75rem; white-space: nowrap; }
.account-admin-table tbody td { border-color: var(--line-subtle); padding: .9rem .75rem; vertical-align: middle; }
.account-admin-table tbody tr:hover { background: #fbfdff; }
.account-user-cell { align-items: center; display: flex; gap: .75rem; min-width: 0; }
.account-avatar { align-items: center; background: var(--blue-light); border: 1px solid var(--blue-border); border-radius: 50%; color: var(--blue-dark); display: inline-flex; flex: 0 0 36px; font-size: .95rem; height: 36px; justify-content: center; width: 36px; }
.account-user-copy { min-width: 0; }
.account-user-name { color: var(--ink); display: block; font-size: .95rem; font-weight: 700; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-user-username { color: var(--muted); display: block; font-size: .77rem; line-height: 1.35; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-select { accent-color: var(--blue); height: 1rem; width: 1rem; }
.account-select:focus-visible, .account-primary-action:focus-visible, .account-secondary-action:focus-visible, .account-action-menu .dropdown-item:focus-visible { outline: 3px solid rgba(37, 99, 235, .3); outline-offset: 2px; }
.account-role-list { display: flex; flex-wrap: wrap; gap: .3rem; max-width: 180px; }
.account-role-badge { background: #f1f5f9; border: 1px solid var(--line); color: var(--ink-secondary); font-size: .7rem; font-weight: 600; line-height: 1.2; padding: .35rem .5rem; }
.account-status-badge, .account-activation-state { white-space: nowrap; }
.account-password-state { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.account-password-state.is-set { color: #047857; }
.account-activation-state { color: var(--muted); }
.account-activation-active { color: var(--blue-dark); font-weight: 700; }
.account-activation-used { color: #047857; }
.account-activation-revoked, .account-activation-expired { color: var(--rose-dark); }
.account-actions-cell { white-space: nowrap; }
.account-actions { align-items: center; display: flex; gap: .45rem; justify-content: flex-end; }
.account-primary-form { flex: 0 0 auto; margin: 0; }
.account-primary-action, .account-secondary-action { align-items: center; display: inline-flex; height: 36px; justify-content: center; white-space: nowrap; }
.account-primary-action { min-width: 132px; }
.account-secondary-action { flex: 0 0 88px; min-width: 88px; }
.account-action-menu { min-width: 250px; }
.account-action-menu .dropdown-item { border-radius: .4rem; font-size: .88rem; padding: .55rem .75rem; }
.account-action-menu .dropdown-item-text { line-height: 1.45; padding: .4rem .75rem; white-space: normal; }
.account-action-menu form { margin: 0; }
.account-edit-card, .account-security-card, .account-recovery-result { overflow: hidden; }
.account-form-section { border-top: 1px solid var(--line); }
.role-grid { display: grid; gap: .65rem 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); list-style: none; margin: 0; padding: 0; }
.role-grid li { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .8rem; }
.role-grid label { color: var(--ink-secondary); font-size: .88rem; font-weight: 600; margin-left: .35rem; }
.account-result-icon { align-items: center; background: var(--blue-light); border: 1px solid var(--blue-border); border-radius: 50%; color: var(--blue); display: inline-flex; font-size: 1.5rem; height: 64px; justify-content: center; width: 64px; }
.account-recovery-result { max-width: 820px; }
.recovery-result-header { margin: 0 auto 1.5rem; max-width: 620px; }
.recovery-recipient { background: var(--blue-light); border: 1px solid var(--blue-border); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: .2rem; margin-bottom: 1rem; padding: 1rem 1.1rem; }
.recovery-section-label { color: var(--blue-dark); font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.recovery-recipient-name { color: var(--ink); font-size: 1.12rem; line-height: 1.35; }
.recovery-recipient-username { color: var(--ink-secondary); font-size: .88rem; }
.recovery-recipient-username code { color: var(--blue-dark); font-size: .9em; overflow-wrap: anywhere; }
.recovery-recipient small { color: var(--muted); margin-top: .25rem; }
.recovery-warning { font-size: .88rem; line-height: 1.55; margin-bottom: 1.25rem; }
.recovery-print-area, .recovery-message-panel { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 1rem; }
.recovery-message-panel { background: #fbfdff; margin-top: 1rem; }
.recovery-section-heading { align-items: flex-start; display: flex; gap: .75rem; justify-content: space-between; margin-bottom: .7rem; }
.recovery-section-heading h2 { color: var(--ink); font-weight: 700; }
.recovery-link-row { align-items: stretch; display: flex; gap: .65rem; }
.recovery-link-input { background: #f8fafc; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; line-height: 1.5; min-height: 72px; overflow-wrap: anywhere; resize: vertical; }
.recovery-copy-button { align-self: stretch; flex: 0 0 auto; white-space: nowrap; }
.recovery-copy-status { min-height: 1.25rem; padding-top: .35rem; }
.recovery-print-instruction { color: var(--muted); font-size: .82rem; margin: .55rem 0 0; }
.recovery-message-input { background: #fff; font-size: .88rem; line-height: 1.55; resize: vertical; }
.recovery-actions { display: flex; flex-wrap: wrap; gap: .65rem; justify-content: center; margin-top: 1.25rem; }
.activation-result-page { min-height: 100%; }
.activation-result-content { margin: 0 auto; max-width: 1180px; }
.activation-result-content.is-single { max-width: 960px; }
.activation-result-header { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; justify-content: space-between; margin-bottom: 1.75rem; }
.activation-result-header > div:first-child { min-width: 0; }
.activation-result-actions { align-items: center; display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: .65rem; }
.activation-result-actions .btn { min-height: 42px; }
.activation-result-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr)); }
.activation-card { height: 100%; }
.activation-card .card-body { padding: clamp(1.35rem, 2.2vw, 2.25rem) !important; }
.activation-message-input { background: #fbfdff; font-size: .92rem; line-height: 1.6; min-height: 168px; resize: vertical; }
.activation-message-actions { align-items: center; display: flex; flex-wrap: wrap; gap: .55rem .8rem; justify-content: space-between; margin-top: .7rem; min-height: 31px; }
.activation-message-actions [data-copy-status] { flex: 1 1 auto; min-width: 10rem; }
.password-reset-confirm .auth-card { max-width: 520px; padding: clamp(1.5rem, 4vw, 2.5rem); }
.auth-flow .auth-card { border-radius: var(--radius-xl); }
.auth-card-form { max-width: 500px; }
.auth-heading { margin-bottom: 1.75rem; }
.auth-form { margin-top: 0 !important; }
.auth-field { margin-bottom: 1.35rem; }
.auth-field .form-label { color: var(--ink-secondary); margin-bottom: .55rem; }
.auth-input-wrap { position: relative; }
.auth-input-wrap > i { color: var(--muted); left: .9rem; pointer-events: none; position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; }
.auth-input-wrap .form-control { min-height: 50px; padding-left: 2.6rem; width: 100%; }
.auth-submit { min-height: 48px; }
.auth-footer { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.15rem; }
.auth-identity { align-items: flex-start; background: #f3f8ff; border: 1px solid #cfe0f5; border-radius: var(--radius-md); display: flex; gap: .75rem; line-height: 1.5; padding: .9rem 1rem; }
.auth-identity-icon { color: var(--bs-primary); flex: 0 0 auto; font-size: 1.2rem; line-height: 1; margin-top: .15rem; }
.auth-identity strong { color: var(--ink); display: block; font-size: 1.05rem; }
.auth-confirm-note { margin: .8rem 0 0; }
.auth-actions { margin-top: 1.35rem; }
.auth-actions form { margin: 0 !important; }
.auth-actions .btn + .btn { margin-top: .55rem; }
.auth-login-link { border-top: 1px solid var(--line); color: var(--ink-secondary); display: block; font-size: .88rem; margin-top: 1.5rem; padding-top: 1.15rem; text-align: center; text-decoration: none; }
.auth-login-link:hover { color: var(--bs-primary); text-decoration: underline; }
.password-reset-field { margin-bottom: 1.35rem; }
.password-reset-field-last { margin-bottom: 1.6rem; }
.password-reset-field .form-label { color: var(--ink-secondary); font-size: .92rem; margin-bottom: .55rem; }
.password-reset-field input[name="new_password1"], .password-reset-field input[name="new_password2"] { display: block; font-size: 1rem; min-height: 50px; padding: .75rem 1rem; width: 100%; }
.password-reset-confirm .alert { border-radius: var(--radius-md); line-height: 1.55; margin-bottom: 1.25rem; padding: .85rem 1rem; }
@media (max-width: 767.98px) {
    .auth-flow { padding-left: .75rem; padding-right: .75rem; }
    .auth-card-form { max-width: none; }
    .account-admin-table-card { border-radius: var(--radius-md); }
    .account-admin-table tbody td { padding-bottom: .85rem; padding-top: .85rem; }
    .account-admin-table { min-width: 1040px; }
    .role-grid { grid-template-columns: 1fr; }
    .account-recovery-result .card-body { padding: 1.25rem !important; }
    .recovery-link-row { flex-direction: column; }
    .recovery-copy-button { min-height: 44px; width: 100%; }
    .recovery-section-heading { flex-direction: column; }
    .activation-result-content, .activation-result-content.is-single { max-width: none; }
    .activation-result-header { align-items: flex-start; flex-direction: column; gap: .9rem; }
    .activation-result-actions { width: 100%; }
    .activation-result-actions .btn { flex: 1 1 12rem; }
    .activation-message-actions { align-items: flex-start; flex-direction: column; }
    .activation-message-actions [data-copy-status] { min-width: 0; }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .activation-result-header { align-items: flex-start; }
    .activation-result-actions { flex-basis: 100%; }
}

@media print {
    body:has(.account-recovery-print-root) { background: #fff; }
    body:has(.account-recovery-print-root) .topbar,
    body:has(.account-recovery-print-root) .sidebar,
    body:has(.account-recovery-print-root) .mobile-nav-offcanvas,
    body:has(.account-recovery-print-root) .messages-container { display: none !important; }
    body:has(.account-recovery-print-root) .app-layout { display: block !important; min-height: 0; }
    body:has(.account-recovery-print-root) .main-content { padding: 0 !important; width: 100%; }
    .account-recovery-print-root { padding: 0 !important; }
    .account-recovery-result { border: 0 !important; box-shadow: none !important; max-width: none !important; }
    .account-recovery-result .card-body { padding: 0 !important; }
    .account-recovery-result .recovery-no-print { display: none !important; }
    .account-recovery-result .recovery-link-input { background: #fff !important; border-color: #111 !important; height: auto !important; min-height: 72px; overflow: visible !important; }
    .account-recovery-result .recovery-print-instruction { color: #111; }
}

/* ==========================================================================
   UI-A foundation — shared primitives for later phases
   Everything below is opt-in and class-based, except the two documented
   contrast fixes at the very end. No existing page selector is restyled.
   ========================================================================== */

/* --- Typography primitives ------------------------------------------------ */
.type-page-title { font-family: var(--font-thai); font-size: var(--fs-page-title); font-weight: var(--fw-bold); line-height: var(--lh-tight); color: var(--ink); }
.type-section-title { font-family: var(--font-thai); font-size: var(--fs-section-title); font-weight: var(--fw-bold); line-height: var(--lh-heading); color: var(--ink); }
.type-table-head { font-family: var(--font-thai); font-size: var(--fs-table-head); font-weight: var(--fw-bold); line-height: var(--lh-heading); }
.type-body { font-family: var(--font-thai); font-size: var(--fs-body); font-weight: var(--fw-regular); line-height: var(--lh-body); }
.type-strong { font-family: var(--font-thai); font-size: var(--fs-strong); font-weight: var(--fw-semibold); line-height: var(--lh-strong); }
.type-label { font-family: var(--font-thai); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.type-caption { font-family: var(--font-thai); font-size: var(--fs-caption); font-weight: var(--fw-regular); line-height: var(--lh-body); color: var(--muted); }
.type-status { font-family: var(--font-thai); font-size: var(--fs-status); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.type-button { font-family: var(--font-thai); font-size: var(--fs-button); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.type-control { font-family: var(--font-thai); font-size: var(--fs-control); font-weight: var(--fw-regular); line-height: var(--lh-strong); }
/* Numeric table / statistic columns: stable digit widths. */
.type-num, .num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* --- Button hierarchy -----------------------------------------------------
   SOLID             = workflow / state-changing primary action  -> .btn-workflow
   OUTLINE PRIMARY   = important page action (not destructive)   -> .btn-page
   OUTLINE SECONDARY = navigation / viewing / secondary          -> .btn-quiet
   Bootstrap's .btn-primary / .btn-outline-* keep working unchanged; these are
   opt-in aliases later phases adopt so the hierarchy stays consistent.
   Danger/warning colours stay reserved for real state changes, not navigation. */
.btn-workflow { background: var(--blue); border: 1px solid var(--blue); color: #fff; font-size: var(--fs-button); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.btn-workflow:hover, .btn-workflow:focus { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-page { background: var(--blue-light); border: 1px solid var(--blue-border); color: var(--blue-dark); font-size: var(--fs-button); font-weight: var(--fw-semibold); line-height: var(--lh-heading); }
.btn-page:hover, .btn-page:focus { background: #dbeafe; border-color: var(--blue-border); color: var(--blue-dark); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line); color: var(--ink-secondary); font-size: var(--fs-button); font-weight: var(--fw-medium); line-height: var(--lh-heading); }
.btn-quiet:hover, .btn-quiet:focus { background: var(--line-subtle); border-color: var(--line); color: var(--ink); }
.btn-workflow:focus-visible, .btn-page:focus-visible, .btn-quiet:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --- Icon / accessibility primitives -------------------------------------
   Standard glyphs (Bootstrap Icons 1.11.3 — already bundled, never emoji):
     allow exam ........ bi-check-circle-fill     history ....... bi-clock-history
     remedial .......... bi-arrow-repeat          returned ...... bi-arrow-counterclockwise
     repeat / negative . bi-x-octagon-fill        exec returned . bi-arrow-left-circle-fill
     locked ............ bi-lock-fill             pending ....... bi-hourglass-split
     draft ............. bi-pencil                submitted ..... bi-send-check
     reviewed .......... bi-check2-circle         approved ...... bi-patch-check-fill
     view .............. bi-eye                   print ......... bi-printer
     PDF ............... bi-file-earmark-pdf      QR ............ bi-qr-code-scan
     filter ............ bi-funnel                empty ......... bi-inbox
   Decorative icons carry aria-hidden="true"; icon-only controls carry an
   aria-label (plus a title where a tooltip helps). */
.icon-decorative { pointer-events: none; }
.icon-only {
    align-items: center; background: transparent; border: 0;
    border-radius: var(--radius-sm); color: var(--ink-secondary);
    display: inline-flex; justify-content: center;
    min-height: var(--tap-target); min-width: var(--tap-target);
}
.icon-only:hover { background: var(--line-subtle); color: var(--ink); }
.icon-only:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --- Table primitives (opt-in) ------------------------------------------- */
.table-a11y { font-family: var(--font-thai); font-size: var(--fs-body); line-height: var(--lh-body); }
.table-a11y > thead th { font-size: var(--fs-table-head); font-weight: var(--fw-bold); line-height: var(--lh-heading); }
.table-a11y th.num, .table-a11y td.num { font-variant-numeric: tabular-nums; text-align: right; }

/* --- Contrast fixes for the shared presentation --------------------------
   Bootstrap's .text-warning (#ffc107) and .text-info (#0dcaf0) fall below the
   4.5:1 threshold on light surfaces; map them onto the audited status colours.
   Only these two utilities are touched — .text-*-emphasis stays untouched. */
.text-warning { color: var(--status-warning-fg) !important; }
.text-info { color: var(--status-info-fg) !important; }

