/* ═══════════════════════════════════════════════════════════════════════════
   ระบบรายงานความปลอดภัยในสถานศึกษา — ระบบดีไซน์ "Aurora UI · Mesh Gradients"
   เขียนเองทั้งหมด ไม่มี build step ไม่มี CDN (ข้อกำหนดการ deploy บน shared hosting)

   ★ กฎของธีมนี้
     1. พื้นหลังตาข่ายคือตัวเอก — ชั้นกระจกฝ้าโปร่งเพื่อให้แสงเหนือโชว์ผ่าน
     2. ความโปร่งแสงเป็น "การตกแต่ง" ไม่ใช่ "ข้อมูล" — ทุกอย่างต้องอ่านออกเมื่อปิดเอฟเฟกต์
     3. ป้ายระดับความรุนแรงและแถบเหตุวิกฤต ใช้พื้นทึบเสมอ ห้าม vibrancy
        (สีที่จางลงเพราะพื้นหลังโปร่ง = อ่านผิดระดับ = ตัดสินใจผิดในสถานการณ์จริง)
     4. รองรับ prefers-reduced-transparency / prefers-contrast / prefers-reduced-motion
     5. สี 60-30-10 — ผืนผ้าใบออโรร่า 60% · กระจกฝ้า 30% · จุดเน้นแบรนด์/วิกฤต 10%
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. โทเคนของระบบ ─────────────────────────────────────────────────────── */
:root {
    /* จุดเน้น 10% — ครามออโรร่าที่ยังเป็นทางการ */
    --navy-900: #1e1b4b;
    --navy-800: #312e81;
    --navy-700: #3730a3;
    --brand: #4f46e5;
    --brand-2: #22d3ee;
    --brand-3: #a78bfa;
    --brand-soft: #e0e7ff;
    --brand-rgb: 79, 70, 229;

    --aurora-1: rgba(165, 180, 252, 0.55);
    --aurora-2: rgba(34, 211, 238, 0.32);
    --aurora-3: rgba(244, 114, 182, 0.22);

    /* ระดับความรุนแรง — ต้องตรงกับค่า color ในตาราง severity_levels */
    --sev-normal: #10b981;
    --sev-minor: #f59e0b;
    --sev-moderate: #f97316;
    --sev-critical: #e11d48;

    --ink: #1e1b4b;
    --ink-2: #334155;
    --ink-3: #64748b;
    --ink-4: #94a3b8;
    --line: rgba(148, 163, 184, 0.35);
    --bg: #e8eefc;
    --surface: #ffffff;

    /* กระจกฝ้า 3 ชั้น — ยิ่งใกล้ผู้ใช้ยิ่งทึบ เพื่อให้ออโรร่าโชว์แต่ตัวอักษรอ่านได้ */
    --glass-1: rgba(255, 255, 255, 0.42);
    --glass-2: rgba(255, 255, 255, 0.58);
    --glass-3: rgba(255, 255, 255, 0.78);
    --blur-1: saturate(180%) blur(36px);
    --blur-2: saturate(170%) blur(24px);
    --blur-3: saturate(150%) blur(16px);
    --stroke: rgba(255, 255, 255, 0.72);
    --hairline: rgba(148, 163, 184, 0.28);

    --shadow-sm: 0 1px 2px rgba(79, 70, 229, 0.05);
    --shadow: 0 1px 1px rgba(79, 70, 229, 0.04), 0 10px 40px rgba(30, 27, 75, 0.08);
    --shadow-lg: 0 2px 8px rgba(30, 27, 75, 0.06), 0 28px 80px rgba(79, 70, 229, 0.14);

    --r-sm: 10px;
    --r: 16px;
    --r-lg: 22px;
    --r-xl: 32px;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    --font: "Kanit", "Sarabun", "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Kanit", "Sarabun", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: "Sarabun", "Kanit", "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, sans-serif;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --sidebar-w: 268px;
    --topbar-h: 68px;
    --nav-bottom-h: 64px;

    --color-60: var(--bg);
    --color-30: var(--glass-2);
    --color-10: var(--brand);
    --color-10-impact: var(--sev-critical);
}

[data-theme="navy"] {
    --navy-900: #0f172a;
    --navy-800: #1e3a8a;
    --navy-700: #1d4ed8;
    --brand: #1e3a8a;
    --brand-2: #38bdf8;
    --brand-3: #60a5fa;
    --brand-soft: #dbeafe;
    --brand-rgb: 30, 58, 138;
    --ink: #0f172a;
    --bg: #eef4ff;
    --aurora-1: rgba(96, 165, 250, 0.48);
    --aurora-2: rgba(56, 189, 248, 0.32);
    --aurora-3: rgba(129, 140, 248, 0.22);
}

[data-theme="teal"] {
    --navy-900: #134e4a;
    --navy-800: #0f766e;
    --navy-700: #0d9488;
    --brand: #0f766e;
    --brand-2: #2dd4bf;
    --brand-3: #5eead4;
    --brand-soft: #ccfbf1;
    --brand-rgb: 15, 118, 110;
    --ink: #134e4a;
    --bg: #f0fdfa;
    --aurora-1: rgba(45, 212, 191, 0.42);
    --aurora-2: rgba(56, 189, 248, 0.28);
    --aurora-3: rgba(52, 211, 153, 0.22);
}

[data-theme="emerald"] {
    --navy-900: #064e3b;
    --navy-800: #047857;
    --navy-700: #059669;
    --brand: #047857;
    --brand-2: #34d399;
    --brand-3: #6ee7b7;
    --brand-soft: #d1fae5;
    --brand-rgb: 4, 120, 87;
    --ink: #064e3b;
    --bg: #ecfdf5;
    --aurora-1: rgba(52, 211, 153, 0.42);
    --aurora-2: rgba(16, 185, 129, 0.28);
    --aurora-3: rgba(125, 211, 252, 0.2);
}

[data-theme="sky"] {
    --navy-900: #0c4a6e;
    --navy-800: #0369a1;
    --navy-700: #0284c7;
    --brand: #0369a1;
    --brand-2: #38bdf8;
    --brand-3: #7dd3fc;
    --brand-soft: #e0f2fe;
    --brand-rgb: 3, 105, 161;
    --ink: #0c4a6e;
    --bg: #f0f9ff;
    --aurora-1: rgba(56, 189, 248, 0.45);
    --aurora-2: rgba(125, 211, 252, 0.32);
    --aurora-3: rgba(165, 180, 252, 0.2);
}

[data-theme="violet"] {
    --navy-900: #4c1d95;
    --navy-800: #6d28d9;
    --navy-700: #7c3aed;
    --brand: #6d28d9;
    --brand-2: #c4b5fd;
    --brand-3: #a78bfa;
    --brand-soft: #ede9fe;
    --brand-rgb: 109, 40, 217;
    --ink: #4c1d95;
    --bg: #f5f3ff;
    --aurora-1: rgba(167, 139, 250, 0.48);
    --aurora-2: rgba(196, 181, 253, 0.32);
    --aurora-3: rgba(244, 114, 182, 0.2);
}

[data-theme="rose"] {
    --navy-900: #881337;
    --navy-800: #be123c;
    --navy-700: #e11d48;
    --brand: #be123c;
    --brand-2: #fb7185;
    --brand-3: #fda4af;
    --brand-soft: #ffe4e6;
    --brand-rgb: 190, 18, 60;
    --ink: #881337;
    --bg: #fff1f2;
    --aurora-1: rgba(251, 113, 133, 0.42);
    --aurora-2: rgba(244, 114, 182, 0.28);
    --aurora-3: rgba(253, 164, 175, 0.22);
}

[data-theme="amber"] {
    --navy-900: #78350f;
    --navy-800: #b45309;
    --navy-700: #d97706;
    --brand: #b45309;
    --brand-2: #fbbf24;
    --brand-3: #f59e0b;
    --brand-soft: #fef3c7;
    --brand-rgb: 180, 83, 9;
    --ink: #78350f;
    --bg: #fffbeb;
    --aurora-1: rgba(251, 191, 36, 0.42);
    --aurora-2: rgba(245, 158, 11, 0.28);
    --aurora-3: rgba(253, 186, 116, 0.22);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #eef2ff;
        --ink-2: #c7d2fe;
        --ink-3: #94a3b8;
        --ink-4: #64748b;
        --line: rgba(148, 163, 184, 0.22);
        --bg: #07091a;
        --surface: #12162a;
        --glass-1: rgba(15, 18, 40, 0.42);
        --glass-2: rgba(18, 22, 48, 0.58);
        --glass-3: rgba(16, 20, 42, 0.78);
        --stroke: rgba(255, 255, 255, 0.1);
        --hairline: rgba(255, 255, 255, 0.1);
        --brand-soft: #1e1b4b;
        --shadow: 0 1px 1px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.35), 0 28px 80px rgba(79, 70, 229, 0.28);
    }
}

/* ── 2. รากฐาน ───────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    background: var(--color-60);
    color-scheme: light dark;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink);
    background: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
}

p,
.sub,
.lead,
.field-hint,
.panel-b,
td,
th,
.textarea,
.auth-legal {
    font-family: var(--font-body);
}

html.sb-open,
body.sb-open {
    overflow: hidden;
}

/* พื้นหลังตาข่ายออโรร่า — ตัวเอกของทั้งระบบ */
.stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(70rem 50rem at 8% -8%, var(--aurora-1), transparent 58%),
        radial-gradient(55rem 45rem at 92% 4%, var(--aurora-2), transparent 55%),
        radial-gradient(50rem 40rem at 48% 108%, var(--aurora-3), transparent 58%),
        linear-gradient(165deg, var(--bg) 0%, var(--bg) 42%, #eef7f6 100%);
}

@media (prefers-color-scheme: dark) {
    .stage {
        background:
            radial-gradient(70rem 50rem at 8% -8%, rgba(99, 102, 241, 0.42), transparent 58%),
            radial-gradient(55rem 45rem at 92% 4%, rgba(34, 211, 238, 0.22), transparent 55%),
            radial-gradient(50rem 40rem at 48% 108%, rgba(244, 114, 182, 0.16), transparent 58%),
            linear-gradient(165deg, #07091a 0%, #0b1024 50%, #10162e 100%);
    }
}

.aurora {
    position: absolute;
    border-radius: 50%;
    filter: blur(72px);
    opacity: 0.72;
    mix-blend-mode: multiply;
    will-change: transform;
    animation: aurora-drift 26s var(--ease) infinite alternate;
}

@media (prefers-color-scheme: dark) {
    .aurora {
        mix-blend-mode: screen;
        opacity: 0.5;
    }
}

.aurora-a {
    width: 42vw;
    height: 42vw;
    min-width: 280px;
    min-height: 280px;
    background: #a5b4fc;
    top: -12%;
    left: -8%;
}

.aurora-b {
    width: 38vw;
    height: 38vw;
    min-width: 240px;
    min-height: 240px;
    background: #67e8f9;
    top: -6%;
    right: -10%;
    animation-delay: -7s;
}

.aurora-c {
    width: 46vw;
    height: 34vw;
    min-width: 280px;
    min-height: 220px;
    background: #f9a8d4;
    bottom: -16%;
    left: 18%;
    animation-delay: -13s;
    opacity: 0.55;
}

.aurora-d {
    width: 28vw;
    height: 28vw;
    min-width: 180px;
    min-height: 180px;
    background: #6ee7b7;
    top: 38%;
    left: 42%;
    animation-delay: -19s;
    opacity: 0.5;
}

.aurora-e {
    width: 32vw;
    height: 32vw;
    min-width: 200px;
    min-height: 200px;
    background: #fde68a;
    bottom: 8%;
    right: -6%;
    animation-delay: -4s;
    opacity: 0.42;
}

@keyframes aurora-drift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(5%, -4%, 0) scale(1.12);
    }
}

/* เกล็ดฝุ่นบาง ๆ กันไล่สีเป็นแถบ (banding) บนจอ 8 บิต */
.stage::after {
    content: "";
    position: absolute;
    inset: -50%;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 var(--sp-3);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 17px;
}

p {
    margin: 0 0 var(--sp-3);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 3px solid rgba(129, 140, 248, 0.7);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ข้ามไปเนื้อหาหลัก — จำเป็นสำหรับผู้ใช้แป้นพิมพ์และโปรแกรมอ่านหน้าจอ */
.skip-link {
    position: absolute;
    left: -999px;
    top: var(--sp-2);
    z-index: 100;
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow);
}

.skip-link:focus {
    left: var(--sp-4);
}

/* ── 3. พื้นผิวกระจก ─────────────────────────────────────────────────────── */
.glass {
    background-color: var(--glass-2);
    backdrop-filter: var(--blur-2);
    -webkit-backdrop-filter: var(--blur-2);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow), inset 0 1px 0 var(--stroke);
    border-radius: var(--r-lg);
}

.glass-1 {
    background-color: var(--glass-1);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
}

.glass-3 {
    background-color: var(--glass-3);
    backdrop-filter: var(--blur-3);
    -webkit-backdrop-filter: var(--blur-3);
}

/**
 * ★ ทางถอยที่ห้ามขาด — เครื่อง/ผู้ใช้ที่ปิดความโปร่งใสหรือขอความคมชัดสูง
 *   ต้องยังอ่านทุกอย่างได้ 100% (ประกาศ WCAG + ผู้ใช้สูงอายุจำนวนมากในหน่วยงาน)
 */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    .glass,
    .glass-1,
    .glass-3,
    .sidebar,
    .topbar,
    .panel,
    .kpi,
    .stat,
    .auth,
    .auth-card,
    .auth-side,
    .bottom-nav,
    .app-grid,
    .user-chip,
    .dash-hero,
    .alert,
    .input,
    .select,
    .textarea {
        background-color: var(--surface);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-color: var(--line);
    }

    .stage .aurora,
    .aurora-wave {
        display: none;
    }

    .stage {
        background: var(--bg);
    }

    body {
        background: var(--bg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .aurora-wave {
        display: none;
    }
}

/* ── 4. โครงหน้าจอ ───────────────────────────────────────────────────────── */
.shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    background-color: var(--glass-1);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border-right: 1px solid var(--hairline);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2);
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    background: linear-gradient(145deg, var(--brand-2), var(--brand) 48%, var(--brand-3));
    box-shadow: 0 8px 22px rgba(var(--brand-rgb), 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sb-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 2px 12px;
    border-bottom: 1px solid var(--hairline);
}

.sb-head-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sb-head-top .brand {
    flex: 1;
    min-width: 0;
    padding: 0;
}

.sb-close {
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    flex: 0 0 36px;
    border-radius: 10px;
}

.sb-clock {
    margin: 0;
    padding: 0 4px;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.14em;
    color: var(--ink-3);
}

.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(var(--brand-rgb), 0.06);
    border: 1px solid var(--hairline);
}

.sb-user .meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sb-user .meta strong {
    font-size: 13.5px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-user .meta span.role-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-logout {
    margin-top: auto;
}

.nav-item.is-soon {
    opacity: 0.45;
    cursor: default;
}

.nav-item-logout {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--sev-critical);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.sb-badge {
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 20px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    font-style: normal;
    font-weight: 700;
    font-size: 10.5px;
    line-height: 19px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sb-badge-info { background: #dbeafe; color: #1e3a8a; }
.sb-badge-warn { background: #fef3c7; color: #92400e; }
.sb-badge-danger { background: var(--sev-critical); color: #fff; }
.sb-badge-soon { background: rgba(148, 163, 184, 0.35); color: var(--ink-2); }

.nav-item.is-active .sb-badge {
    background: rgba(255, 255, 255, 0.28);
    color: var(--brand);
}

.brand-text strong {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
    line-height: 1.25;
}

.brand-text span {
    font-size: 12px;
    color: var(--ink-3);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group {
    margin-top: var(--sp-4);
    padding: 0 var(--sp-3);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.nav > .nav-group:first-child {
    margin-top: 2px;
}

.nav-group::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 8px;
    border-radius: 50%;
    background: linear-gradient(145deg, #67e8f9, var(--brand));
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.45);
}

.nav-group-overview::before { background: linear-gradient(145deg, #67e8f9, #6366f1); }
.nav-group-daily::before { background: linear-gradient(145deg, #34d399, #0ea5e9); }
.nav-group-watch::before { background: linear-gradient(145deg, #fbbf24, #f97316); }
.nav-group-report::before { background: linear-gradient(145deg, #a78bfa, #6366f1); }
.nav-group-master::before { background: linear-gradient(145deg, #94a3b8, #64748b); }
.nav-group-govern::before { background: linear-gradient(145deg, #22d3ee, #2563eb); }
.nav-group-system::before { background: linear-gradient(145deg, #fb7185, #6366f1); }

.tnum {
    font-variant-numeric: tabular-nums;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 9px var(--sp-3);
    border-radius: 11px;
    color: var(--ink-2);
    font-size: 14px;
    transition: background-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.nav-item:hover {
    background: rgba(148, 163, 184, 0.16);
    text-decoration: none;
}

.nav-item:active {
    transform: scale(0.985);
}

.nav-item.is-active {
    background: rgba(var(--brand-rgb), 0.12);
    color: var(--brand);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand);
}

.nav-item .ico {
    width: 18px;
    text-align: center;
    opacity: 0.85;
}

.nav-badge {
    margin-left: auto;
    background: var(--sev-critical);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--topbar-h);
    height: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 18px;
    background-color: var(--glass-1);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border-bottom: 1px solid var(--hairline);
}

.nav-start {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.nav-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(145deg, var(--brand-2), var(--brand) 48%, var(--brand-3));
    box-shadow: 0 6px 16px rgba(var(--brand-rgb), 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.nav-title {
    min-width: 0;
    flex: 1;
}

.nav-title h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.nav-title p {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-3);
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

.nav-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s ease infinite;
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

.nav-clock {
    font-size: 13px;
    color: var(--ink-2);
    white-space: nowrap;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.nav-apps,
.nav-pwa,
.nav-bell,
.nav-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
    color: var(--navy-900);
}

.nav-apps .ico,
.nav-pwa .ico,
.nav-bell .ico,
.nav-toggle .ico {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
}

.nav-apps {
    color: #4338ca;
}

.nav-pwa {
    color: #0f766e;
}

.nav-bell {
    color: #9a3412;
}

.nav-apps[aria-expanded="true"] {
    color: var(--brand);
    background: rgba(79, 70, 229, 0.12);
}

.nav-apps-wrap {
    position: relative;
}

.app-launcher[hidden],
.nav-pwa[hidden] {
    display: none !important;
}

.app-launcher {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    width: min(360px, calc(100vw - 24px));
    padding: 14px;
    border-radius: 20px;
    background: var(--glass-3);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow-lg);
}

.app-launcher-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--ink-3);
}

.app-launcher-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-height: 360px;
    overflow: auto;
}

.app-launch-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 84px;
    padding: 10px 6px;
    border-radius: 16px;
    color: var(--ink);
    text-decoration: none;
    background: var(--glass-2);
}

.app-launch-tile:hover,
.app-launch-tile.is-active {
    color: var(--brand);
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.28);
}

.app-launch-ico {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #67e8f9, #6366f1);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.app-launch-ico .ico {
    width: 22px;
    height: 22px;
}

.app-launch-ico-overview { background: linear-gradient(145deg, #67e8f9, #4f46e5); }
.app-launch-ico-daily { background: linear-gradient(145deg, #5eead4, #0284c7); }
.app-launch-ico-watch { background: linear-gradient(145deg, #fde68a, #ea580c); }
.app-launch-ico-report { background: linear-gradient(145deg, #c4b5fd, #6366f1); }
.app-launch-ico-master { background: linear-gradient(145deg, #cbd5e1, #475569); }
.app-launch-ico-govern { background: linear-gradient(145deg, #7dd3fc, #2563eb); }
.app-launch-ico-system { background: linear-gradient(145deg, #fda4af, #7c3aed); }

.app-launch-name {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1.25;
}

.logo-upload {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.label-text {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 10px;
    border-radius: 16px;
    cursor: pointer;
    background: var(--glass-2);
    border: 1px solid var(--hairline);
}

.theme-swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-swatch.is-on,
.theme-swatch:has(:checked) {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.22);
}

.theme-swatch strong {
    font-size: 13px;
    line-height: 1.2;
}

.theme-swatch small {
    font-size: 11px;
    color: var(--ink-3);
    line-height: 1.3;
}

.theme-swatch-preview {
    display: flex;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
}

.theme-swatch-preview i {
    flex: 1;
    display: block;
}

.theme-swatch[data-tone="indigo"] .theme-swatch-preview i:nth-child(1) { background: #4f46e5; }
.theme-swatch[data-tone="indigo"] .theme-swatch-preview i:nth-child(2) { background: #22d3ee; }
.theme-swatch[data-tone="indigo"] .theme-swatch-preview i:nth-child(3) { background: #a78bfa; }
.theme-swatch[data-tone="navy"] .theme-swatch-preview i:nth-child(1) { background: #1e3a8a; }
.theme-swatch[data-tone="navy"] .theme-swatch-preview i:nth-child(2) { background: #38bdf8; }
.theme-swatch[data-tone="navy"] .theme-swatch-preview i:nth-child(3) { background: #60a5fa; }
.theme-swatch[data-tone="teal"] .theme-swatch-preview i:nth-child(1) { background: #0f766e; }
.theme-swatch[data-tone="teal"] .theme-swatch-preview i:nth-child(2) { background: #2dd4bf; }
.theme-swatch[data-tone="teal"] .theme-swatch-preview i:nth-child(3) { background: #5eead4; }
.theme-swatch[data-tone="emerald"] .theme-swatch-preview i:nth-child(1) { background: #047857; }
.theme-swatch[data-tone="emerald"] .theme-swatch-preview i:nth-child(2) { background: #34d399; }
.theme-swatch[data-tone="emerald"] .theme-swatch-preview i:nth-child(3) { background: #6ee7b7; }
.theme-swatch[data-tone="sky"] .theme-swatch-preview i:nth-child(1) { background: #0369a1; }
.theme-swatch[data-tone="sky"] .theme-swatch-preview i:nth-child(2) { background: #38bdf8; }
.theme-swatch[data-tone="sky"] .theme-swatch-preview i:nth-child(3) { background: #7dd3fc; }
.theme-swatch[data-tone="violet"] .theme-swatch-preview i:nth-child(1) { background: #6d28d9; }
.theme-swatch[data-tone="violet"] .theme-swatch-preview i:nth-child(2) { background: #c4b5fd; }
.theme-swatch[data-tone="violet"] .theme-swatch-preview i:nth-child(3) { background: #a78bfa; }
.theme-swatch[data-tone="rose"] .theme-swatch-preview i:nth-child(1) { background: #be123c; }
.theme-swatch[data-tone="rose"] .theme-swatch-preview i:nth-child(2) { background: #fb7185; }
.theme-swatch[data-tone="rose"] .theme-swatch-preview i:nth-child(3) { background: #fda4af; }
.theme-swatch[data-tone="amber"] .theme-swatch-preview i:nth-child(1) { background: #b45309; }
.theme-swatch[data-tone="amber"] .theme-swatch-preview i:nth-child(2) { background: #fbbf24; }
.theme-swatch[data-tone="amber"] .theme-swatch-preview i:nth-child(3) { background: #f59e0b; }

.logo-preview {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    object-fit: cover;
    background: var(--glass-2);
    border: 1px solid var(--hairline);
}

.aurora-wave {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    pointer-events: none;
}

.sidebar .nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.nav-bell,
.bottom-nav-ico {
    position: relative;
}

.nav-bell .nav-badge,
.bottom-nav-ico .nav-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    margin: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    font-size: 10px;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--surface);
}

.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.role-chip-super_admin { background: linear-gradient(135deg, #fecaca, #ef4444); color: #7f1d1d; }
.role-chip-area_admin { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #78350f; }
.role-chip-area_executive { background: linear-gradient(135deg, #ddd6fe, #a78bfa); color: #4c1d95; }
.role-chip-area_officer { background: linear-gradient(135deg, #bfdbfe, #60a5fa); color: #1e3a8a; }
.role-chip-school_admin { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #78350f; }
.role-chip-school_director { background: linear-gradient(135deg, #ddd6fe, #a78bfa); color: #4c1d95; }
.role-chip-safety_teacher { background: linear-gradient(135deg, #a7f3d0, #34d399); color: #065f46; }
.role-chip-teacher { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #334155; }

.topbar .spacer {
    display: none;
}

.content {
    padding: var(--sp-5);
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.page-head {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
}

.page-head .sub {
    color: var(--ink-3);
    font-size: 14px;
    margin: 0;
}

.page-head .actions {
    margin-left: auto;
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* ── 5. ปุ่ม ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 40px;
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid var(--hairline);
    background: var(--glass-2);
    backdrop-filter: var(--blur-3);
    -webkit-backdrop-filter: var(--blur-3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), background-color 0.16s var(--ease);
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--stroke);
}

.btn:hover {
    text-decoration: none;
    box-shadow: var(--shadow);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(180deg, #818cf8, var(--brand));
    border-color: transparent;
    color: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-danger {
    background: linear-gradient(180deg, #f43f5e, var(--sev-critical));
    border-color: transparent;
    color: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 6px 18px rgba(225, 29, 72, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.16);
    box-shadow: none;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 13px 22px;
    font-size: 15px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 9px;
}

/* ── 6. ฟอร์ม ────────────────────────────────────────────────────────────── */
.field {
    margin-bottom: var(--sp-4);
}

.field > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.field .req {
    color: var(--sev-critical);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 15px;
    color: var(--ink);
    background: var(--glass-2);
    backdrop-filter: var(--blur-3);
    -webkit-backdrop-filter: var(--blur-3);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.7);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.16);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
    border-color: var(--sev-critical);
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
}

.textarea {
    min-height: 110px;
    resize: vertical;
}

.field-hint {
    font-size: 12.5px;
    color: var(--ink-3);
    margin-top: 6px;
}

.field-error {
    font-size: 12.5px;
    color: var(--sev-critical);
    margin-top: 6px;
    font-weight: 500;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input {
    padding-left: 42px;
}

.input-group .ico-lead {
    position: absolute;
    left: 14px;
    color: var(--ink-4);
    pointer-events: none;
    font-size: 16px;
}

.input-group .btn-inline {
    position: absolute;
    right: 6px;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 13px;
}

.input-group .btn-inline:hover {
    background: rgba(148, 163, 184, 0.18);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 14px;
    color: var(--ink-2);
    cursor: pointer;
}

.check input {
    width: 17px;
    height: 17px;
    accent-color: var(--brand);
}

/* ── 7. การ์ดและแผง ──────────────────────────────────────────────────────── */
.panel {
    background-color: var(--glass-2);
    backdrop-filter: var(--blur-2);
    -webkit-backdrop-filter: var(--blur-2);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow), inset 0 1px 0 var(--stroke);
    overflow: hidden;
}

.panel-h {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--hairline);
}

.panel-h h2,
.panel-h h3 {
    margin: 0;
    font-size: 16px;
}

.panel-h .actions {
    margin-left: auto;
    display: flex;
    gap: var(--sp-2);
}

.panel-b {
    padding: var(--sp-5);
}

.grid {
    display: grid;
    gap: var(--sp-4);
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* การ์ดตัวเลขสรุป */
.stat {
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--r-lg);
    background-color: var(--glass-2);
    backdrop-filter: var(--blur-2);
    -webkit-backdrop-filter: var(--blur-2);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow), inset 0 1px 0 var(--stroke);
    position: relative;
    overflow: hidden;
}

.stat .label {
    font-size: 13px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat .value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat .foot {
    font-size: 12.5px;
    color: var(--ink-3);
}

.stat::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -28px;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--accent, rgba(59, 130, 246, 0.16));
    filter: blur(6px);
}

/* ── แดชบอร์ด: hero + KPI + กราฟ ─────────────────────────────────────────── */
.dash-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
    padding: var(--sp-5) var(--sp-6);
    border-radius: var(--r-xl);
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.22)),
        radial-gradient(36rem 18rem at 100% -10%, rgba(165, 180, 252, 0.45), transparent 55%);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow), inset 0 1px 0 var(--stroke);
}

.dash-hero-eye {
    margin: 0 0 6px;
    font-size: 12px;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--brand);
}

.dash-hero h1 {
    margin: 0 0 6px;
    font-size: 26px;
    line-height: 1.3;
    color: var(--ink);
}

.dash-hero p {
    margin: 0;
    color: var(--ink-2);
    font-size: 14.5px;
}

.dash-hero-actions {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.dash-hero-actions .btn {
    min-height: 44px;
}

.dash-hero-actions .btn-primary {
    background: linear-gradient(180deg, #818cf8, var(--brand));
    color: #fff;
    border-color: transparent;
}

@media (prefers-color-scheme: dark) {
    .dash-hero {
        background:
            linear-gradient(135deg, rgba(18, 22, 48, 0.62), rgba(18, 22, 48, 0.28)),
            radial-gradient(36rem 18rem at 100% -10%, rgba(129, 140, 248, 0.38), transparent 55%);
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.kpi {
    position: relative;
    overflow: hidden;
    padding: var(--sp-4);
    border-radius: var(--r-lg);
    background-color: var(--glass-2);
    backdrop-filter: var(--blur-2);
    -webkit-backdrop-filter: var(--blur-2);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow), inset 0 1px 0 var(--stroke);
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    color: #fff;
    margin-bottom: 10px;
}

.kpi-blue .kpi-icon { background: linear-gradient(145deg, #67e8f9, #4f46e5); }
.kpi-green .kpi-icon { background: linear-gradient(145deg, #6ee7b7, #059669); }
.kpi-orange .kpi-icon { background: linear-gradient(145deg, #fdba74, #c2410c); }
.kpi-red .kpi-icon { background: linear-gradient(145deg, #fb7185, #e11d48); }
.kpi-navy .kpi-icon { background: linear-gradient(145deg, #a5b4fc, #312e81); }
.kpi-teal .kpi-icon { background: linear-gradient(145deg, #5eead4, #0f766e); }

.kpi-label {
    margin: 0;
    font-size: 13px;
    color: var(--ink-3);
}

.kpi-value {
    margin: 2px 0;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.kpi-foot {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-3);
}

.chart-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.chart-line {
    width: 100%;
    height: 88px;
    color: var(--brand);
}

.chart-line circle {
    fill: var(--brand);
}

.chart-line-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 6px;
}

.donut-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.chart-donut {
    width: 112px;
    height: 112px;
    flex: 0 0 112px;
}

.donut-track,
.donut-slice {
    fill: none;
    stroke-width: 10;
    transform: rotate(-90deg);
    transform-origin: 48px 48px;
}

.donut-track {
    stroke: rgba(148, 163, 184, 0.28);
}

.donut-slice {
    stroke-linecap: butt;
}

.donut-total {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    fill: var(--ink);
}

.donut-unit {
    font-size: 8px;
    fill: var(--ink-3);
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    margin-bottom: 6px;
}

.donut-legend b {
    margin-left: auto;
}

.swatch {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 9px;
}

.swatch-draft { background-color: #94a3b8; }
.swatch-open { background-color: #3b82f6; }
.swatch-follow_up { background-color: #f59e0b; }
.swatch-closed { background-color: #10b981; }
.swatch-cancelled { background-color: #cbd5e1; }

.bar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bar-list li {
    margin-bottom: 10px;
}

.bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 4px;
}

.bar-track {
    display: block;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #67e8f9, var(--brand));
}

.recent-list,
.ready-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-list li + li,
.ready-list li + li {
    border-top: 1px solid var(--hairline);
}

.recent-list a {
    display: block;
    padding: 10px 0;
    text-decoration: none;
    color: inherit;
}

.recent-list a:hover {
    color: var(--brand);
}

.recent-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.recent-list p {
    margin: 0;
    font-size: 13.5px;
}

.recent-meta {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-3);
}

.ready-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 14px;
}

/* ── 8. ป้ายและสถานะ ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

/**
 * ★ ป้ายระดับความรุนแรง = พื้นทึบเสมอ ห้ามโปร่ง
 *   ความรุนแรงคือข้อมูลที่ใช้ตัดสินใจ ไม่ใช่การตกแต่ง — สีต้องเท่ากันทุกพื้นหลัง
 */
.sev,
.alert-critical {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.sev {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    background: var(--ink-3);
}

.sev-normal {
    background: var(--sev-normal);
}

.sev-minor {
    background: var(--sev-minor);
    color: #402a02;
}

.sev-moderate {
    background: var(--sev-moderate);
}

.sev-critical {
    background: var(--sev-critical);
}

.b-ok {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
}

.b-warn {
    background: rgba(245, 158, 11, 0.18);
    color: #92400e;
}

.b-danger {
    background: rgba(225, 29, 72, 0.15);
    color: #9f1239;
}

.b-info {
    background: rgba(59, 130, 246, 0.15);
    color: #1e40af;
}

.b-muted {
    background: rgba(148, 163, 184, 0.18);
    color: var(--ink-2);
}

/* แถบเตือนเหตุวิกฤต — พื้นทึบ อ่านได้แม้ปิดเอฟเฟกต์ทั้งหมด */
.alert-critical {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r);
    background: var(--sev-critical);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(225, 29, 72, 0.3);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r);
    border: 1px solid var(--hairline);
    background: var(--glass-3);
    margin-bottom: var(--sp-4);
}

.alert-success {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.12);
}

.alert-error {
    border-color: rgba(225, 29, 72, 0.4);
    background: rgba(225, 29, 72, 0.1);
}

/* ── 9. ตาราง ────────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.tbl th,
table.tbl td {
    padding: 11px var(--sp-4);
    text-align: left;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}

table.tbl th {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-3);
    text-transform: none;
    white-space: nowrap;
    background: rgba(148, 163, 184, 0.08);
}

table.tbl tbody tr {
    transition: background-color 0.14s var(--ease);
}

table.tbl tbody tr:hover {
    background: rgba(148, 163, 184, 0.1);
}

table.tbl td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── 10. สถานะว่าง / กำลังโหลด ───────────────────────────────────────────── */
.empty {
    text-align: center;
    padding: var(--sp-7) var(--sp-4);
    color: var(--ink-3);
}

.empty .ico {
    font-size: 40px;
    opacity: 0.4;
    display: block;
    margin-bottom: var(--sp-3);
}

.skeleton {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.12) 25%, rgba(148, 163, 184, 0.22) 37%, rgba(148, 163, 184, 0.12) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--r-sm);
    height: 14px;
}

@keyframes shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

/* ── 11. หน้าเข้าสู่ระบบ — Premium Split ─────────────────────────────────── */
.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: transparent;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.auth-mobile-brand {
    display: none;
    align-items: center;
    gap: var(--sp-3);
    flex: 0 0 auto;
    min-width: 0;
    padding: max(12px, env(safe-area-inset-top, 0px)) var(--sp-5) 0;
    color: var(--ink);
}

.auth-mobile-brand .brand-text {
    min-width: 0;
}

.auth-mobile-brand .brand-text strong {
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-mobile-brand .brand-text span {
    display: block;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth {
    display: grid;
    grid-template-columns: minmax(280px, 1.05fr) minmax(300px, 1fr);
    flex: 1 1 auto;
    margin: 18px 18px 0;
    min-height: 0;
    min-width: 0;
    border-radius: var(--r-xl);
    overflow: hidden;
    background-color: var(--glass-1);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow-lg), inset 0 1px 0 var(--stroke);
}

.auth-shell > .app-footer {
    flex: 0 0 auto;
    margin: 0 18px max(18px, env(safe-area-inset-bottom, 0px));
    border-radius: 0 0 18px 18px;
}

.auth-side {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: clamp(20px, 4vh, var(--sp-7)) clamp(20px, 3vw, var(--sp-7));
    color: #fff;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background:
        linear-gradient(155deg, rgba(30, 27, 75, 0.72) 0%, rgba(79, 70, 229, 0.45) 52%, rgba(14, 165, 233, 0.28) 100%);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
}

/* ก้อนแสงลอย — ให้ชั้นกระจกด้านขวามีอะไรให้หักเหจริง ๆ */
.auth-side .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(48px);
    opacity: 0.62;
    animation: float 18s var(--ease) infinite alternate;
}

.auth-side .orb-1 {
    width: 380px;
    height: 380px;
    background: #67e8f9;
    top: -80px;
    left: -60px;
}

.auth-side .orb-2 {
    width: 300px;
    height: 300px;
    background: #c4b5fd;
    bottom: -60px;
    left: 30%;
    animation-delay: -6s;
}

.auth-side .orb-3 {
    width: 260px;
    height: 260px;
    background: #f9a8d4;
    top: 35%;
    right: -70px;
    animation-delay: -12s;
    opacity: 0.45;
}

@keyframes float {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(40px, -30px, 0) scale(1.12);
    }
}

.auth-side .inner {
    position: relative;
    z-index: 1;
    max-width: 520px;
}

.auth-side h1 {
    font-size: clamp(22px, 2.2vw + 12px, 34px);
    line-height: 1.3;
    margin-bottom: var(--sp-4);
}

.auth-side p {
    color: rgba(255, 255, 255, 0.82);
    font-size: clamp(14px, 0.35vw + 13px, 15.5px);
}

.auth-brand {
    padding: 0;
    margin-bottom: var(--sp-6);
}

.auth-brand .brand-text strong {
    color: #fff;
}

.auth-brand .brand-text span {
    color: rgba(255, 255, 255, 0.7);
}

.auth-highlights {
    display: grid;
    gap: 10px;
    margin-top: var(--sp-5);
}

.auth-highlights article {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.auth-highlights strong {
    display: block;
    font-size: 14.5px;
    margin-bottom: 2px;
}

.auth-highlights span {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 400;
}

.auth-legal {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

.auth-main {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(16px, 3vh, var(--sp-6)) clamp(16px, 3vw, var(--sp-6));
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@supports (align-items: safe center) {
    .auth-main {
        align-items: safe center;
    }
}

.auth-card {
    width: min(440px, 100%);
    min-width: 0;
    padding: clamp(18px, 3vh, var(--sp-6)) clamp(16px, 3vw, var(--sp-6));
    border-radius: var(--r-xl);
    background-color: var(--glass-3);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border: 1px solid var(--stroke);
    box-shadow: var(--shadow-lg), inset 0 1px 0 var(--stroke);
    animation: rise 0.5s var(--ease-spring) both;
}

.auth-card h2 {
    margin: 0 0 4px;
    font-size: clamp(22px, 2vw + 14px, 28px);
}

.auth-card .input {
    font-size: 16px;
}

.auth-card .input-group:has(.btn-inline) .input {
    padding-right: 58px;
}

.auth-card .btn-inline {
    min-height: 44px;
    min-width: 44px;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.auth-card .lead {
    color: var(--ink-3);
    font-size: 14px;
    margin-bottom: var(--sp-5);
}

.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
}

.auth-forgot {
    font-size: 13px;
    color: var(--ink-3);
}

[data-login-submit] {
    min-height: 44px;
}

[data-login-submit] [data-state-label] {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

[data-login-submit][data-state="idle"] [data-state-label="idle"],
[data-login-submit][data-state="load"] [data-state-label="load"],
[data-login-submit][data-state="ok"] [data-state-label="ok"],
[data-login-submit][data-state="err"] [data-state-label="err"] {
    display: inline-flex;
}

[data-login-submit][data-state="load"] .ico {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.demo-box {
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px dashed var(--hairline);
}

.demo-box-title {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 16px;
}

.demo-box-lead {
    margin: 0 0 var(--sp-3);
    font-size: 12.5px;
    color: var(--ink-3);
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.demo-grid > * {
    min-width: 0;
}

.demo-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--hairline);
    background: var(--glass-3);
    color: var(--ink);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    touch-action: manipulation;
}

.demo-btn:hover {
    border-color: var(--brand-2);
    box-shadow: var(--shadow);
}

.demo-btn .meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.demo-btn strong,
.demo-btn .meta span,
.demo-btn em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-btn strong {
    font-size: 13px;
    line-height: 1.3;
}

.demo-btn .meta span {
    font-size: 12px;
    color: var(--ink-2);
}

.demo-btn em {
    font-size: 11px;
    font-style: normal;
    color: var(--ink-3);
}

@media (min-width: 1101px) {
    .auth-shell {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }
}

@media (min-width: 1101px) and (max-height: 760px) {
    .auth-side h1 {
        font-size: 26px;
        margin-bottom: var(--sp-3);
    }

    .auth-highlights article:nth-child(n + 3) {
        display: none;
    }
}

@media (min-width: 1101px) and (max-height: 640px) {
    .auth-highlights {
        display: none;
    }

    .auth-side p {
        display: none;
    }
}

/* ── 12. เชิงหน้าและอื่น ๆ ───────────────────────────────────────────────── */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--hairline);
    font-size: 12.5px;
    color: var(--ink-3);
}

.app-footer.light {
    background: transparent;
}

.app-footer.dark {
    background: rgba(15, 18, 40, 0.42);
    backdrop-filter: var(--blur-3);
    -webkit-backdrop-filter: var(--blur-3);
    color: #e0e7ff;
    border-top-color: rgba(255, 255, 255, 0.12);
}

.ft-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.ft-version {
    background: linear-gradient(135deg, #67e8f9, var(--brand));
    color: #fff;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.ft-dev {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.ft-dev small {
    display: block;
    font-size: 10.5px;
    opacity: 0.75;
}

.ft-dev b {
    display: block;
    font-size: 12.5px;
}

.ft-dev img,
.ft-dev-mark {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex: 0 0 36px;
    object-fit: cover;
}

.ft-dev-mark {
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(145deg, #67e8f9, #6366f1 48%, #a78bfa);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12), 0 0 14px rgba(103, 232, 249, 0.4);
}

@media (max-width: 640px) {
    .app-footer {
        flex-direction: column-reverse;
        text-align: center;
    }

    .ft-left,
    .ft-dev {
        justify-content: center;
    }
}

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: 999px;
    background: var(--glass-3);
    border: 1px solid var(--hairline);
}

.nav-tools .user-chip {
    background: transparent;
    border: 0;
    padding: 2px 4px 2px 2px;
}

@media (max-width: 1180px) {
    .nav-clock,
    .nav-pill {
        display: none;
    }
}

@media (max-width: 980px) {
    .nav-tools .user-chip .meta {
        display: none;
    }
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(145deg, #67e8f9, #6366f1 48%, #a78bfa);
    flex: 0 0 34px;
}

.user-chip .meta strong {
    display: block;
    font-size: 13.5px;
    line-height: 1.2;
}

.user-chip .meta span {
    font-size: 11.5px;
    color: var(--ink-3);
}

.muted {
    color: var(--ink-3);
}

.text-sm {
    font-size: 13px;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.row {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    flex-wrap: wrap;
}

/* ── 13. จอเล็ก ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .nav-clock {
        display: none;
    }

    .auth-mobile-brand {
        display: flex;
    }

    .auth {
        grid-template-columns: 1fr;
        overflow: visible;
        margin: 10px 12px 0;
        border-radius: var(--r-lg);
    }

    .auth-side {
        display: none;
    }

    .auth-main {
        display: block;
        overflow: visible;
        padding: var(--sp-4) var(--sp-4) var(--sp-5);
    }

    .auth-card {
        width: min(440px, 100%);
        margin-inline: auto;
        padding: var(--sp-5) var(--sp-4);
        border-radius: var(--r-lg);
    }

    .auth-shell > .app-footer {
        margin-left: 12px;
        margin-right: 12px;
        margin-bottom: max(12px, env(safe-area-inset-bottom, 0px));
        border-radius: 0 0 16px 16px;
    }
}

@media (max-width: 900px) {
    .btn,
    .demo-btn,
    [data-login-submit] {
        min-height: 44px;
    }
}

@media (max-width: 560px) {
    .demo-grid {
        grid-template-columns: 1fr;
    }

    .auth-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .auth-mobile-brand {
        padding-left: var(--sp-4);
        padding-right: var(--sp-4);
    }

    .auth {
        margin: 8px 10px 0;
    }

    .auth-main {
        padding: 12px 10px 16px;
    }

    .auth-card {
        padding: 18px 14px;
    }

    .demo-box-lead {
        display: none;
    }
}

@media (max-width: 380px) {
    .auth-card h2 {
        font-size: 22px;
    }

    .auth-card .lead {
        font-size: 13px;
    }

    .demo-btn em {
        display: none;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .auth-mobile-brand {
        padding-top: 8px;
        padding-bottom: 0;
    }

    .auth-mobile-brand .brand-text span {
        display: none;
    }

    .auth-main {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .auth-card {
        padding: 14px 16px;
    }

    .auth-card .lead,
    .demo-box-lead {
        display: none;
    }

    .field {
        margin-bottom: 10px;
    }

    .auth-row {
        margin-bottom: 12px;
    }
}

@media (max-width: 860px) {
    .shell {
        display: block;
        z-index: auto;
    }

    .main {
        position: relative;
        z-index: 1;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 80;
        width: min(300px, 86vw);
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        transform: translate3d(-102%, 0, 0);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.34s;
        background: var(--surface);
        background-color: #ffffff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-right: 1px solid var(--line);
        border-radius: 0 22px 22px 0;
        box-shadow: none;
        padding: max(12px, env(safe-area-inset-top)) 12px calc(var(--nav-bottom-h) + env(safe-area-inset-bottom, 0px) + 8px);
        overflow: hidden;
        opacity: 1;
        filter: none;
    }

    .sidebar.is-open {
        transform: translate3d(0, 0, 0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: 16px 0 48px rgba(15, 23, 42, 0.18);
    }

    .sidebar .nav {
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
    }

    .sidebar .nav::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar .nav::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.45);
        border-radius: 99px;
    }

    .sb-close {
        display: grid;
        place-items: center;
    }

    .scrim {
        z-index: 70;
    }

    .content {
        padding: var(--sp-4);
    }

    .nav-pill,
    .nav-clock,
    .nav-tools > form,
    .nav-tools .user-chip {
        display: none;
    }

    .nav-toggle {
        flex: 0 0 46px;
        width: 46px;
        height: 46px;
        min-width: 46px;
        min-height: 46px;
        background: #fff;
        border: 1px solid var(--hairline);
        box-shadow: 0 6px 16px rgba(30, 27, 75, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
        color: var(--navy-900);
    }

    .nav-title h1 {
        font-size: 15px;
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-apps,
    .nav-pwa,
    .nav-bell {
        width: 46px;
        height: 46px;
        min-width: 46px;
        min-height: 46px;
        background: #fff;
        border: 1px solid var(--hairline);
        box-shadow: 0 6px 16px rgba(30, 27, 75, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    }

    .nav-tools {
        padding: 0;
        gap: 6px;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .app-launcher {
        position: fixed;
        top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px);
        right: 12px;
        left: 12px;
        width: auto;
        max-height: min(70vh, 480px);
    }

    .dash-hero {
        padding: var(--sp-4);
    }

    .dash-hero h1 {
        font-size: 22px;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s var(--ease), visibility 0.28s;
}

.scrim.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (max-width: 860px) and (prefers-color-scheme: dark) {
    .sidebar {
        background: #12162a;
        background-color: #12162a;
    }

    .nav-toggle,
    .nav-apps,
    .nav-pwa,
    .nav-bell {
        background: #1a2040;
        border-color: rgba(148, 163, 184, 0.22);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
        color: #eef2ff;
    }
}

@media (min-width: 861px) {
    .nav-toggle {
        display: none;
    }

    .nav-tools {
        padding: 4px 6px 4px 10px;
        border-radius: 999px;
        background: var(--glass-2);
        border: 1px solid var(--hairline);
        box-shadow: inset 0 1px 0 var(--stroke);
        gap: 6px;
    }
}

/* ── หน้าแรกแบบแอปบนมือถือ — สลับด้วย CSS เท่านั้น ห้าม JS ตรวจขนาดจอ ── */
.app-head-user,
.app-grid,
.bottom-nav {
    display: none;
}

.impact-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 var(--sp-4);
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--color-10-impact);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(225, 29, 72, 0.28);
}

.impact-banner:hover,
.impact-banner:focus-visible {
    color: #fff;
    text-decoration: none;
}

.impact-banner strong,
.impact-banner small {
    display: block;
}

.impact-banner small {
    margin-top: 2px;
    opacity: 0.92;
    font-size: 12.5px;
}

.impact-ico {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.18);
}

.impact-banner > span:nth-child(2) {
    flex: 1;
    min-width: 0;
}

.impact-go {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #fff;
    color: var(--color-10-impact);
}

.app-head-user {
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-head-user .meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.app-head-user small {
    font-size: 11px;
    color: var(--ink-3);
    line-height: 1.2;
}

.app-head-user strong {
    font-size: 14px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-grid-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 10px;
    justify-items: center;
}

.app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    max-width: 108px;
    min-height: 0;
    padding: 6px 4px 4px;
    border: 0;
    border-radius: 22px;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    text-align: center;
}

.app-tile:hover,
.app-tile:focus-visible {
    color: var(--ink);
    text-decoration: none;
}

.app-tile:active {
    transform: scale(0.96);
}

.app-tile.is-active {
    background: rgba(79, 70, 229, 0.08);
}

.app-tile.is-soon {
    opacity: 0.42;
    cursor: default;
}

.app-tile-ico {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #67e8f9, #4f46e5);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.app-tile-ico .ico {
    width: 30px;
    height: 30px;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.18));
}

.app-tile-ico-home { background: linear-gradient(145deg, #67e8f9, #4f46e5); box-shadow: 0 12px 24px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-file-plus { background: linear-gradient(145deg, #93c5fd, #2563eb); box-shadow: 0 12px 24px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-list { background: linear-gradient(145deg, #7dd3fc, #0284c7); box-shadow: 0 12px 24px rgba(2, 132, 199, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-inbox { background: linear-gradient(145deg, #5eead4, #0f766e); box-shadow: 0 12px 24px rgba(13, 148, 136, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-alert { background: linear-gradient(145deg, #fb7185, #e11d48); box-shadow: 0 12px 24px rgba(225, 29, 72, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-life-buoy { background: linear-gradient(145deg, #fdba74, #ea580c); box-shadow: 0 12px 24px rgba(234, 88, 12, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-clock { background: linear-gradient(145deg, #c4b5fd, #7c3aed); box-shadow: 0 12px 24px rgba(124, 58, 237, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-chart { background: linear-gradient(145deg, #a78bfa, #4f46e5); box-shadow: 0 12px 24px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-school { background: linear-gradient(145deg, #67e8f9, #0369a1); box-shadow: 0 12px 24px rgba(3, 105, 161, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-users { background: linear-gradient(145deg, #818cf8, #4338ca); box-shadow: 0 12px 24px rgba(67, 56, 202, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-book { background: linear-gradient(145deg, #cbd5e1, #475569); box-shadow: 0 12px 24px rgba(71, 85, 105, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-shield { background: linear-gradient(145deg, #6ee7b7, #059669); box-shadow: 0 12px 24px rgba(5, 150, 105, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-check { background: linear-gradient(145deg, #86efac, #16a34a); box-shadow: 0 12px 24px rgba(22, 163, 74, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-bell { background: linear-gradient(145deg, #fcd34d, #d97706); box-shadow: 0 12px 24px rgba(217, 119, 6, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-search { background: linear-gradient(145deg, #93c5fd, #1d4ed8); box-shadow: 0 12px 24px rgba(29, 78, 216, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }
.app-tile-ico-settings { background: linear-gradient(145deg, #fda4af, #7c3aed); box-shadow: 0 12px 24px rgba(124, 58, 237, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.42); }

.app-tile-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--sev-critical);
    color: #fff;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--surface);
}

.app-tile-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    min-height: var(--nav-bottom-h);
    padding: 6px 6px env(safe-area-inset-bottom, 0px);
    background: var(--glass-3);
    backdrop-filter: var(--blur-1);
    -webkit-backdrop-filter: var(--blur-1);
    border-top: 1px solid var(--stroke);
    box-shadow: 0 -10px 40px rgba(79, 70, 229, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--ink-3);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus-visible {
    color: var(--color-10);
    text-decoration: none;
}

.bottom-nav-item.is-active,
.bottom-nav-item[aria-current="page"],
.bottom-nav-item[aria-expanded="true"],
.bottom-nav-item.is-open {
    color: var(--color-10);
    font-weight: 600;
}

.bottom-nav-item small {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .aurora {
        filter: blur(56px);
    }

    .app-grid {
        display: block;
        margin-bottom: var(--sp-5);
        padding: 20px 14px 16px;
        border-radius: 28px;
        background: var(--glass-3);
        backdrop-filter: var(--blur-1);
        -webkit-backdrop-filter: var(--blur-1);
        border: 1px solid var(--stroke);
        box-shadow: var(--shadow);
    }

    .bottom-nav {
        display: grid;
    }

    .app-head-user {
        display: none;
    }

    body.is-home .app-head-user {
        display: flex;
        flex: 1;
        min-width: 0;
    }

    body.is-home .nav-icon,
    body.is-home .nav-title,
    body.is-home .nav-pill,
    body.is-home .nav-clock,
    body.is-home .user-chip {
        display: none;
    }

    .topbar {
        gap: 8px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: 8px;
    }

    .nav-start {
        gap: 8px;
    }

    .nav-toggle,
    .nav-apps,
    .nav-pwa,
    .nav-bell,
    .topbar .btn,
    .btn,
    .demo-btn,
    [data-login-submit] {
        min-height: 46px;
        min-width: 46px;
        border-radius: 15px;
    }

    .nav-toggle .ico,
    .nav-apps .ico,
    .nav-pwa .ico,
    .nav-bell .ico {
        width: 24px;
        height: 24px;
    }

    .content {
        padding-bottom: 16px;
    }

    .app-footer {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        padding-bottom: calc(12px + var(--nav-bottom-h) + env(safe-area-inset-bottom, 0px));
    }

    body.auth-body .app-footer {
        padding-bottom: 16px;
    }

    .sidebar {
        z-index: 80;
        padding-bottom: calc(var(--nav-bottom-h) + env(safe-area-inset-bottom, 0px) + 12px);
    }

    .scrim {
        z-index: 70;
    }

    body.is-home .dash-hero {
        padding: 16px 18px;
        margin-bottom: 16px;
        border-radius: 20px;
        align-items: stretch;
    }

    body.is-home .dash-hero-eye {
        display: none;
    }

    body.is-home .dash-hero h1 {
        font-size: 18px;
    }

    body.is-home .dash-hero p {
        font-size: 13px;
    }

    body.is-home .dash-hero-actions {
        width: 100%;
    }

    body.is-home .dash-hero-actions .btn {
        flex: 1 1 calc(50% - 6px);
        font-weight: 600;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .kpi {
        padding: 14px;
        background-color: var(--glass-2);
        backdrop-filter: var(--blur-2);
        -webkit-backdrop-filter: var(--blur-2);
    }

    .kpi-value {
        font-size: 24px;
    }

    .panel {
        background-color: var(--glass-2);
    }
}

/* ── 14. พิมพ์เอกสาร ─────────────────────────────────────────────────────── */
@media print {
    .sidebar,
    .topbar,
    .bottom-nav,
    .app-grid,
    .stage,
    .aurora,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    body.print-doc {
        background: #fff;
        color: #111;
    }

    .stage {
        display: none;
    }

    .panel,
    .glass {
        box-shadow: none;
        border: 1px solid #ccc;
        background: #fff;
        backdrop-filter: none;
    }
}

/* ── 15. รายการเหตุ / ฟอร์ม / ยืนยัน ─────────────────────────────────────── */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-3);
    align-items: end;
}

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    margin: var(--sp-5) 0 var(--sp-3);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 14px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-2);
}

.meta-list {
    margin: 0 0 var(--sp-4);
}

.meta-list > div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: var(--sp-2);
    padding: 6px 0;
    border-bottom: 1px solid var(--hairline);
}

.meta-list dt {
    color: var(--ink-3);
    font-weight: 600;
}

.meta-list dd {
    margin: 0;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2px solid var(--hairline);
}

.timeline li {
    padding: 0 0 var(--sp-3) var(--sp-4);
    position: relative;
}

.timeline li::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-2);
}

.workflow-form {
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--hairline);
}

.pager {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

.notice-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notice-list li {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--hairline);
}

.notice-list li.is-unread {
    background: rgba(59, 130, 246, 0.06);
    margin: 0 calc(var(--sp-3) * -1);
    padding-left: var(--sp-3);
    padding-right: var(--sp-3);
    border-radius: var(--r-sm);
}

.victim-row {
    margin-bottom: var(--sp-3);
}

.note {
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--hairline);
}

.modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    place-items: center;
    background: rgba(11, 27, 51, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-scrim.is-open {
    display: grid;
}

.modal-card {
    width: min(420px, calc(100% - 32px));
    padding: var(--sp-5);
    border-radius: var(--r-lg);
    background: var(--glass-3);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow-lg);
}

.modal-card p {
    margin-top: 0;
}

@media (max-width: 720px) {
    table.cards-on-mobile thead {
        display: none;
    }

    table.cards-on-mobile tr {
        display: block;
        margin-bottom: var(--sp-3);
        border: 1px solid var(--hairline);
        border-radius: var(--r);
        overflow: hidden;
    }

    table.cards-on-mobile td {
        display: flex;
        justify-content: space-between;
        gap: var(--sp-3);
        border-bottom: 1px solid var(--hairline);
    }

    table.cards-on-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--ink-3);
    }
}

/* ── 24. รหัสผ่านเริ่มต้นที่แจ้งผู้สร้างบัญชี ───────────────────────────────
   ★ ต้องอ่านง่ายและคัดลอกถูกตัว — ใช้ฟอนต์ความกว้างคงที่ ไม่งั้น l/1/I และ O/0 แยกไม่ออก
   ★ ห้ามใช้สีอ่อนบนพื้นโปร่ง — ค่านี้ผู้ใช้ต้องอ่านออกในห้องที่แสงจ้าและบนจอโปรเจกเตอร์ */
.form-note {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border: 1px dashed var(--hairline);
    border-radius: var(--r);
    background: var(--glass-3);
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.65;
}

.cred .cred-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
    flex: 1;
}

.cred-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.cred-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cred-label {
    font-size: 12px;
    color: var(--ink-3);
}

.cred-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    padding: 6px 12px;
    user-select: all;
    overflow-wrap: anywhere;
}

.cred-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
}

.cred-note {
    font-size: 13px;
    color: var(--ink-2);
    line-height: 1.6;
    flex: 1 1 260px;
}

@media print {
    .cred-actions .btn {
        display: none;
    }
}
