:root {
    --bg: #E8F0F3;
    --bg-2: #D7E6EC;
    --card: #FFFFFF;
    --ink: #0C1A22;
    --ink-2: #2A4150;
    --muted: #4E6876;
    --line: #D3E0E6;
    --brand: #0B6E6A;
    --brand-2: #12B3A8;
    --brand-3: #5EEAD4;
    --brand-ink: #043734;
    --brand-soft: #DDF7F4;
    --brand-glow: rgba(18, 179, 168, .28);
    --accent: #E8670A;
    --info: #1578A8;
    --info-soft: #E4F3FA;
    --violet: #5A4CB8;
    --violet-soft: #EEEAFB;
    --danger: #C53434;
    --danger-soft: #FDECEC;
    --success: #0D8A5C;
    --success-soft: #E3F7EE;
    --warning: #C47A00;
    --warning-soft: #FFF3D6;
    --purple: #5A4CB8;
    --chart-1: #12B3A8;
    --chart-2: #1578A8;
    --chart-3: #C47A00;
    --chart-4: #5A4CB8;
    --sidebar: #061318;
    --sidebar-2: #0E2530;
    --sidebar-line: rgba(255,255,255,.08);
    --radius: 18px;
    --tap: 44px;
    --shadow: 0 10px 28px rgba(12, 26, 34, .07);
    --shadow-lg: 0 22px 50px rgba(12, 26, 34, .12);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow-wrap: break-word;
    word-break: keep-all;
    line-break: loose;
    hyphens: none;
    -webkit-text-size-adjust: 100%;
}

body.admin-body,
body.login-body {
    font-family: "Noto Sans Thai", "Sarabun", "Segoe UI", sans-serif;
    color: var(--ink);
    line-height: 1.55;
    min-height: 100dvh;
}

body.admin-body {
    background:
        radial-gradient(900px 420px at 0% -8%, rgba(18, 179, 168, .16), transparent 55%),
        radial-gradient(700px 380px at 100% 0%, rgba(21, 120, 168, .12), transparent 50%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

img { max-width: 100%; }
svg { max-width: 100%; overflow: visible; }
button, input, select, textarea { font-family: inherit; }

.th-text,
.th-keep,
td, th, p, h1, h2, h3, label, a, button, .btn, .badge, .nav-link {
    word-break: keep-all;
    overflow-wrap: break-word;
    line-break: loose;
    hyphens: none;
}

.th-keep,
th, .badge, .btn, .stat-label, .nav-link span, .tab-btn, .bottom-nav span {
    overflow-wrap: normal;
}

.th-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: keep-all;
}

.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-size, 1.05em);
    font-size: var(--icon-size, 1.05em);
    line-height: 1;
    flex-shrink: 0;
}
.muted { color: var(--muted); }
.desktop-only { display: none; }

.num,
.cell-num,
.stat-card .number,
td[data-label="ID"],
td[data-label="ผู้เข้าร่วม"],
td[data-label="ผู้โดยสาร"],
td[data-label="ความจุ"],
td[data-label="โทร"],
td[data-label="จำนวน"],
td[data-label="คงเหลือ"],
.qty-badge {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
}

.cell-place,
td[data-label="ห้อง"],
td[data-label="ชื่อห้อง"],
td[data-label="รถ"] {
    min-width: 10.5rem;
    word-break: keep-all;
}

.app-shell { min-height: 100dvh; }
.sidebar { display: none; }

.app-main { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 10px 14px;
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(211,224,230,.8);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 1.08rem; font-weight: 800; line-height: 1.3; letter-spacing: -.01em; }
.topbar-title p { font-size: .8rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page {
    padding: 16px 16px 108px;
    width: 100%;
    max-width: none;
}

.icon-btn {
    width: var(--tap);
    height: var(--tap);
    border: 0;
    border-radius: 14px;
    background: #F4F8FA;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 16px rgba(12,26,34,.08); }
.icon-btn:active { transform: scale(.96); }

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(18,179,168,.16);
}
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: #F4F8FA;
    max-width: 220px;
}

.stats, .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card, .stat {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #FFFFFF 0%, #F7FBFC 100%);
    border: 1px solid rgba(211,224,230,.9);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: rise-in .4s ease both;
    transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card::after, .stat::after {
    content: "";
    position: absolute;
    inset: auto -20% -40% auto;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--brand-glow), transparent 70%);
    pointer-events: none;
}
.stat-card:hover, .stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(12,26,34,.1), 0 0 0 1px var(--brand-glow);
}
.stat-card .stat-icon, .stat .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--brand-2), var(--brand));
    box-shadow: 0 8px 16px var(--brand-glow);
    flex-shrink: 0;
}
.stat-card.blue .stat-icon { background: linear-gradient(145deg, #38BDF8, var(--info)); box-shadow: 0 8px 16px rgba(21,120,168,.28); }
.stat-card.purple .stat-icon { background: linear-gradient(145deg, #8B7CF6, var(--violet)); box-shadow: 0 8px 16px rgba(90,76,184,.28); }
.stat-card.orange .stat-icon, .stat-card.accent .stat-icon { background: linear-gradient(145deg, #FBBF24, var(--warning)); box-shadow: 0 8px 16px rgba(196,122,0,.25); }
.stat-card.rose .stat-icon { background: linear-gradient(145deg, #FB7185, var(--danger)); box-shadow: 0 8px 16px rgba(197,52,52,.22); }
.stat-card .stat-body { min-width: 0; flex: 1; }
.stat-card .number, .stat .num, .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.03em;
    color: var(--ink);
}
.stat-card .label, .stat .label, .stat-label {
    font-size: .8rem;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 600;
}
.stat-meta {
    margin-top: 6px;
    font-size: .72rem;
    color: var(--ink-2);
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.mini-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
    animation: rise-in .42s ease both;
    transition: transform .2s ease, box-shadow .2s ease;
}
.mini-stat:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(12,26,34,.08); }
.mini-stat .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--brand);
    background: var(--brand-soft);
    flex-shrink: 0;
}
.mini-stat .number { font-size: 1.2rem; font-weight: 800; line-height: 1.1; }
.mini-stat .label { font-size: .74rem; color: var(--muted); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }

.panel {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FCFD 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    min-width: 0;
    animation: rise-in .4s ease both;
}
.panel h2, .panel-header h2, .section-title {
    font-size: 1.02rem;
    font-weight: 800;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.table-wrap, .table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table, .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
th {
    background: #F3F8FA;
    text-align: left;
    font-weight: 700;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
td {
    padding: 12px;
    border-bottom: 1px solid #EEF4F6;
    vertical-align: top;
}
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #F4FBFA; }

.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--tap);
    padding: 10px 14px;
    border: 0;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    box-shadow: 0 8px 18px var(--brand-glow);
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,.28) 45%, transparent 70%);
    transform: translateX(-120%);
    transition: transform .45s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn:hover::after { transform: translateX(120%); }
.btn:active { transform: scale(.98); }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: .82rem; }
.btn-primary, .btn-toggle, .btn-save, .btn-teal, .btn-purple { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; }
.btn-approve, .btn-success { background: linear-gradient(135deg, #34D399, var(--success)); box-shadow: 0 8px 16px rgba(13,138,92,.22); color: #fff; }
.btn-reject, .btn-danger { background: linear-gradient(135deg, #FB7185, var(--danger)); box-shadow: 0 8px 16px rgba(197,52,52,.2); color: #fff; }
.btn-warning, .btn-orange { background: linear-gradient(135deg, #FBBF24, var(--warning)); box-shadow: 0 8px 16px rgba(196,122,0,.2); color: #fff; }
.btn-cancel, .btn-gray { background: #D5DDE2; color: #1F2937; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn-link { background: linear-gradient(135deg, #38BDF8, var(--info)); color: #fff; }
.btn-history { background: linear-gradient(135deg, #8B7CF6, var(--violet)); color: #fff; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    height: auto;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 800;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    line-height: 1.2;
}
.badge-text { word-break: keep-all; }
.badge-pending { background: var(--warning-soft); color: #8A5600; }
.badge-approved, .badge-active, .badge-returned { background: var(--success-soft); color: #065F46; }
.badge-rejected, .badge-inactive, .badge-overdue, .badge-cancelled { background: var(--danger-soft); color: #991B1B; }
.badge-borrowed, .badge-returning, .badge-info { background: var(--info-soft); color: #0B4F73; }
.badge-warning { background: var(--warning-soft); color: #8A5600; }

.tabs, .tab-buttons, .tab-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.tab-btn {
    min-height: var(--tap);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, color .16s ease;
}
.tab-btn:hover { transform: translateY(-1px); }
.tab-btn.active { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; border-color: transparent; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.filters, .filter-row, .form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
}
.filters select, .filters input, .filter-row select,
.form-control, .search-box input {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-size: 16px;
}
.filters input[type="date"], .form-control[type="date"] {
    border-radius: 14px;
    min-width: 10.5rem;
}
.form-control:focus, .filters input:focus, .filters select:focus, .search-box input:focus {
    outline: 2px solid var(--brand-soft);
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-glow);
}
.form-group { margin-bottom: 12px; flex: 1; min-width: 0; }
.form-group label { display: block; font-size: .82rem; font-weight: 800; margin-bottom: 6px; }
.search-box { flex: 1; min-width: 180px; position: relative; }

.field-wrap {
    position: relative;
}
.field-wrap .field-ico {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.field-wrap .form-control { padding-left: 40px; }
.field-wrap .field-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 19, 24, .52);
    z-index: 80;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
}
.modal-overlay.active { display: flex; }
.modal, .modal-box {
    background: #fff;
    border-radius: 20px 20px 12px 12px;
    padding: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.detail-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #F1F5F9;
}
.detail-label { color: var(--muted); font-weight: 800; }
.detail-value { min-width: 0; }

.user-link { color: var(--info); font-weight: 800; text-decoration: none; }
.qty-badge { background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 10px; font-size: .75rem; font-weight: 800; }
.action-cell { display: flex; flex-wrap: wrap; gap: 6px; }
.text-truncate, .th-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.date-range { color: var(--violet); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-weight: 700;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.alert-error { background: var(--danger-soft); color: #991B1B; border: 1px solid #FECACA; }
.alert-ok { background: var(--success-soft); color: #065F46; border: 1px solid #A7F3D0; }

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + var(--safe-bottom));
}
.bottom-nav a, .bottom-nav button {
    min-height: 56px;
    min-width: 44px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .68rem;
    font-weight: 800;
}
.bottom-nav a.is-active, .bottom-nav button.is-active { color: var(--brand); }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 19, 24, .48);
    z-index: 50;
}
.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 10px 16px calc(20px + var(--safe-bottom));
    box-shadow: 0 -8px 30px rgba(0,0,0,.12);
}
.sheet-handle {
    width: 42px;
    height: 4px;
    background: #D1D5DB;
    border-radius: 99px;
    margin: 4px auto 12px;
}
.sheet h2 { font-size: 1rem; margin-bottom: 12px; }
.sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.sheet-grid a {
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    transition: transform .16s ease, box-shadow .16s ease;
}
.sheet-grid a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.sheet-ico {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    flex-shrink: 0;
}

body.drawer-open .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    background: linear-gradient(180deg, var(--sidebar) 0%, #0A1E26 100%);
    color: #fff;
    z-index: 70;
    padding: 18px 14px calc(18px + var(--safe-bottom));
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: var(--sidebar-2);
    color: #fff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: #163441; }
.topbar .sidebar-toggle {
    background: #F4F8FA;
    color: var(--ink);
    width: var(--tap);
    height: var(--tap);
    border-radius: 14px;
}
.brand-mark {
    width: 42px; height: 42px; border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    color: #fff;
    display: grid; place-items: center; font-weight: 800;
    box-shadow: 0 0 0 4px rgba(18,179,168,.18), 0 10px 20px rgba(18,179,168,.28);
}
.brand-text strong, .brand-text span { display: block; }
.brand-text span { font-size: .75rem; opacity: .7; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.nav-label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; opacity: .5; margin: 12px 8px 6px; }
.nav-link {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #D7DEE7;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 700;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-link.is-active, .nav-link:hover { background: var(--sidebar-2); color: #fff; }
.nav-link.is-active { box-shadow: inset 3px 0 0 var(--brand-2); }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-line);
}
.sidebar-user-meta { min-width: 0; flex: 1; }
.sidebar-user-meta strong, .sidebar-user-meta span { display: block; }
.sidebar-user-meta span { font-size: .75rem; opacity: .7; }
.sidebar-user .icon-btn { background: var(--sidebar-2); color: #fff; }

/* Login */
.login-body {
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(900px 480px at 8% -10%, rgba(94, 234, 212, .35), transparent 50%),
        radial-gradient(700px 360px at 110% 8%, rgba(56, 189, 248, .22), transparent 46%),
        linear-gradient(160deg, #062027 0%, #0B3B3A 42%, #0E5C57 100%);
}
.login-shell {
    width: min(100%, 980px);
    display: grid;
    gap: 18px;
    animation: rise-in .42s ease both;
}
.login-hero {
    display: none;
    color: #F0FDFA;
    padding: 36px 32px;
    border-radius: 28px;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background:
        radial-gradient(420px 220px at 92% 8%, rgba(94,234,212,.32), transparent 58%),
        radial-gradient(280px 180px at 0% 100%, rgba(21,120,168,.28), transparent 55%),
        linear-gradient(160deg, #08343A 0%, #0C5C58 58%, #0A4A46 100%);
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: 0 18px 40px rgba(6, 32, 39, .28);
}
.login-hero::before,
.login-hero::after {
    content: "";
    position: absolute;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
}
.login-hero::before {
    width: 200px;
    height: 200px;
    right: -48px;
    top: -56px;
    background: radial-gradient(circle, rgba(94,234,212,.26), transparent 70%);
}
.login-hero::after {
    width: 160px;
    height: 160px;
    left: -36px;
    bottom: -48px;
    border-radius: 42% 58% 50% 50%;
    background: radial-gradient(circle, rgba(56,189,248,.18), transparent 70%);
}
.login-hero > * { position: relative; z-index: 1; }
.login-hero h2 { font-size: 1.7rem; font-weight: 800; margin: 14px 0 8px; color: #fff; }
.login-hero p { color: #CFFAFE; max-width: 28ch; }
.login-art { margin-top: 28px; width: min(100%, 320px); filter: drop-shadow(0 10px 18px rgba(6,32,39,.22)); }
.login-card {
    width: min(100%, 440px);
    margin: 0 auto;
    background: rgba(255,255,255,.96);
    border-radius: 28px;
    padding: 28px 22px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.4);
    backdrop-filter: blur(16px);
}
.login-card h1 { font-size: 1.45rem; margin: 10px 0 6px; font-weight: 800; }
.login-card .lead { color: var(--muted); margin-bottom: 20px; }
.login-card .btn { width: 100%; }
.login-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    margin: 2px 0 16px;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand-ink);
    cursor: pointer;
    user-select: none;
    font-weight: 700;
    font-size: .88rem;
    border: 1px solid rgba(11, 110, 106, .12);
}
.login-remember input {
    width: 20px;
    height: 20px;
    accent-color: var(--brand);
    flex-shrink: 0;
    margin: 0;
}
.login-remember-ico { color: var(--brand); display: inline-flex; }
.login-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    font-weight: 800;
    color: var(--brand);
    background: var(--brand-soft);
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
}
.field-error { color: var(--danger); font-size: .82rem; margin-top: 6px; }

/* Dashboard */
.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    margin-bottom: 16px;
    border-radius: 22px;
    background:
        radial-gradient(420px 180px at 100% 0%, rgba(94,234,212,.28), transparent 55%),
        linear-gradient(135deg, #08343A 0%, #0C5C58 58%, #128F86 100%);
    color: #F0FDFA;
    box-shadow: 0 16px 36px rgba(8,52,58,.22);
    overflow: hidden;
    animation: rise-in .38s ease both;
}
.dash-hero h2 { font-size: 1.25rem; font-weight: 800; margin: 4px 0; }
.dash-hero p { color: #CFFAFE; font-size: .86rem; }
.dash-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #99F6E4;
}
.dash-hero-art { width: 92px; flex-shrink: 0; opacity: .95; }

.chart-panel { display: grid; gap: 16px; }
.chart-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: 10px;
    align-items: end;
    min-height: 188px;
    min-width: 360px;
    padding: 8px 4px 0;
    position: relative;
}
.chart::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 18px; bottom: 42px;
    background:
        repeating-linear-gradient(
            to top,
            rgba(14, 92, 88, .08) 0 1px,
            transparent 1px 25%
        );
    pointer-events: none;
    border-radius: 8px;
}
.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
    position: relative;
    z-index: 1;
}
.chart-track {
    width: 100%;
    max-width: 34px;
    height: 132px;
    display: flex;
    align-items: flex-end;
    background: #E7F2F3;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(12,26,34,.04);
}
.chart-bar {
    width: 100%;
    min-height: 8px;
    background: linear-gradient(180deg, var(--brand-3), var(--brand));
    border-radius: 999px;
    transform-origin: bottom;
    animation: bar-up .42s ease both;
    box-shadow: 0 0 16px var(--brand-glow);
    transition: filter .16s ease, transform .16s ease;
}
.chart-col:hover .chart-bar { filter: brightness(1.08); }
.chart-col strong { font-size: .8rem; font-weight: 800; }
.chart-col span { font-size: .7rem; color: var(--muted); }
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.legend-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--ink-2);
}
.legend-dot i { width: 10px; height: 10px; border-radius: 99px; display: inline-block; }
.legend-dot .d1 { background: var(--chart-1); }
.legend-dot .d2 { background: var(--chart-2); }
.legend-dot .d3 { background: var(--chart-3); }

.mix-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 8px;
}
.donut {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    flex-shrink: 0;
    background: conic-gradient(var(--chart-1) 0 var(--p1), var(--chart-2) var(--p1) var(--p2), var(--chart-3) var(--p2) 100%);
    mask: radial-gradient(circle, transparent 52%, #000 54%);
    -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
    box-shadow: 0 0 0 8px #F3FAFA;
}
.mix-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mix-list strong { font-weight: 800; }

.inspect-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.inspect-list li {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0;
    background: #fff;
    transition: transform .16s ease, box-shadow .16s ease;
}
.inspect-list li:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.inspect-list a, .inspect-list .inspect-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}
.inspect-list .inspect-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.inspect-ico {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    flex-shrink: 0;
}
.inspect-ico.warn { background: var(--warning-soft); color: var(--warning); }
.inspect-ico.danger { background: var(--danger-soft); color: var(--danger); }
.inspect-ico.info { background: var(--info-soft); color: var(--info); }
.inspect-list strong { font-size: .95rem; }
.empty-state {
    text-align: center;
    padding: 22px 12px 10px;
    color: var(--muted);
}
.empty-art { width: 88px; margin: 0 auto 8px; opacity: .9; }

.result-list { display: flex; flex-direction: column; gap: 10px; }
.result-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: #fff;
    transition: transform .16s ease, box-shadow .16s ease;
}
.result-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.result-top { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.result-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.result-card p { margin: 4px 0; }
.search-form .form-control { font-size: 16px; }
tr.hidden { display: none !important; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
@keyframes bar-up {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (min-width: 900px) {
    .desktop-only { display: inline-flex; }
    .drawer-toggle, .bottom-nav, .sheet, .overlay { display: none !important; }
    .app-shell {
        display: grid;
        grid-template-columns: 264px minmax(0, 1fr);
        width: 100%;
    }
    .sidebar {
        display: flex;
        flex-direction: column;
        position: sticky;
        top: 0;
        height: 100dvh;
        background: linear-gradient(180deg, var(--sidebar) 0%, #0A1E26 100%);
        color: #fff;
        padding: 20px 14px;
        overflow: hidden;
    }
    .sidebar-toggle { display: inline-flex; }
    .page { padding: 20px 24px 32px; }
    html.sidebar-collapsed .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
    html.sidebar-collapsed .sidebar { padding: 16px 8px; align-items: stretch; }
    html.sidebar-collapsed .sidebar-brand {
        flex-direction: column;
        justify-content: center;
        margin-bottom: 14px;
    }
    html.sidebar-collapsed .brand-text,
    html.sidebar-collapsed .nav-label,
    html.sidebar-collapsed .nav-link span,
    html.sidebar-collapsed .sidebar-user-meta {
        display: none;
    }
    html.sidebar-collapsed .nav-link {
        justify-content: center;
        padding: 10px 8px;
        gap: 0;
    }
    html.sidebar-collapsed .sidebar-user {
        justify-content: center;
        flex-wrap: wrap;
    }
    html.sidebar-collapsed .sidebar-user .icon-btn { margin-top: 8px; }
    .stats, .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mini-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .chart-panel { grid-template-columns: 1.4fr .8fr; align-items: center; }
    .login-shell { grid-template-columns: 1.05fr .95fr; align-items: stretch; }
    .login-hero { display: flex; flex-direction: column; justify-content: center; }
    .login-card { margin: 0; width: 100%; }
    .modal-overlay { align-items: center; }
    .modal, .modal-box { border-radius: 18px; }
}

@media (max-width: 768px) {
    .stack-table thead { display: none; }
    .stack-table, .stack-table tbody, .stack-table tr, .stack-table td {
        display: block;
        width: 100%;
    }
    .stack-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 14px;
        margin-bottom: 10px;
        padding: 10px 12px;
    }
    .stack-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border: 0;
        padding: 8px 0;
        min-width: 0;
    }
    .stack-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 800;
        flex: 0 0 38%;
        word-break: keep-all;
    }
    .stack-table td.action-cell { display: flex; flex-wrap: wrap; }
    .stack-table td[data-label="ห้อง"],
    .stack-table td[data-label="ชื่อห้อง"],
    .stack-table td[data-label="รถ"] { min-width: 0; }
    .booker-table tbody tr {
        display: flex;
        flex-wrap: wrap;
    }
    .booker-table td.booker-rank-cell,
    .booker-table td.booker-id-cell {
        width: auto;
        border-bottom: 1px solid var(--line);
        margin-bottom: 4px;
        padding-bottom: 12px;
        align-items: center;
    }
    .booker-table td.booker-rank-cell {
        flex: 0 0 auto;
        justify-content: flex-start;
    }
    .booker-table td.booker-id-cell {
        flex: 1 1 auto;
        justify-content: flex-start;
    }
    .booker-table td.booker-rank-cell::before,
    .booker-table td.booker-id-cell::before { display: none; }
    .booker-table td.booker-id-cell .booker-identity {
        justify-content: flex-start;
        text-align: left;
    }
    .booker-table td:not(.booker-rank-cell):not(.booker-id-cell) {
        flex: 1 1 100%;
    }
    .dash-hero-art { display: none; }
}

/* Custom select */
.cselect {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    min-width: 11rem;
    max-width: 100%;
}
.form-group .cselect,
.filters .cselect.is-block { width: 100%; min-width: 0; }
.filters .cselect { width: auto; flex: 0 1 auto; }
.cselect-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none;
    clip: rect(0, 0, 0, 0);
}
.cselect-trigger {
    min-height: var(--tap);
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: #fff;
    box-shadow: 0 1px 0 rgba(12,26,34,.04);
    cursor: pointer;
    text-align: left;
    color: var(--ink);
    font-weight: 700;
}
.form-group .cselect-trigger { border-radius: 14px; }
.cselect-trigger:hover { border-color: var(--brand-2); }
.cselect.is-open .cselect-trigger,
.cselect-trigger:focus {
    outline: 2px solid var(--brand-soft);
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-glow);
}
.cselect-label {
    flex: 1;
    min-width: 0;
    word-break: keep-all;
    overflow-wrap: break-word;
}
.cselect-ico { color: var(--brand); flex-shrink: 0; }
.cselect-chevron {
    color: var(--muted);
    transition: transform .16s ease;
    flex-shrink: 0;
}
.cselect.is-open .cselect-chevron { transform: rotate(180deg); color: var(--brand); }
.cselect-menu {
    position: absolute;
    z-index: 90;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 100%;
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    max-height: 280px;
    overflow: auto;
    display: none;
}
.cselect.is-open .cselect-menu { display: block; }
.cselect-option {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    word-break: keep-all;
    overflow-wrap: break-word;
    color: var(--ink);
    font-weight: 700;
}
.cselect-option:hover,
.cselect-option.is-active {
    background: var(--brand-soft);
    color: var(--brand-ink);
}
.cselect-option.is-selected {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    color: #fff;
}
.cselect-option i { width: 1.1em; text-align: center; flex-shrink: 0; }

/* Bookers + tables */
.booker-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
}
.booker-hero .booker-rank {
    width: 52px;
    min-height: 52px;
    border-radius: 16px;
    font-size: .85rem;
}
.booker-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    position: relative;
    background: linear-gradient(145deg, var(--brand-2), var(--brand));
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(18,179,168,.14);
}
.booker-avatar.sm { width: 40px; height: 40px; font-size: 1rem; }
.booker-avatar.lg { width: 72px; height: 72px; font-size: 1.6rem; }
.booker-avatar-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
}
.booker-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.booker-hero-body { min-width: 0; }
.booker-hero-body h2 { font-size: 1.25rem; margin-bottom: 6px; word-break: keep-all; }
.booker-meta, .booker-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.booker-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.booker-identity .user-link {
    min-width: 0;
    word-break: keep-all;
    overflow-wrap: break-word;
}
.booker-name-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}
.booker-history-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    font-weight: 700;
    color: var(--brand);
    text-decoration: none;
}
.booker-history-link:hover { text-decoration: underline; }
.booker-rank {
    width: 40px;
    min-height: 40px;
    padding: 4px 2px;
    border-radius: 12px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    font-size: .72rem;
    line-height: 1;
    word-break: keep-all;
}
.booker-rank b { font-size: .78rem; letter-spacing: -.02em; }
.booker-rank.rank-1 {
    background: linear-gradient(145deg, #F8E38A, #E0A800);
    color: #5C4300;
    box-shadow: 0 6px 14px rgba(224,168,0,.22);
}
.booker-rank.rank-2 {
    background: linear-gradient(145deg, #F1F5F8, #A8B4BE);
    color: #334155;
    box-shadow: 0 6px 14px rgba(100,116,139,.16);
}
.booker-rank.rank-3 {
    background: linear-gradient(145deg, #F3C7A0, #C67B3E);
    color: #5C3310;
    box-shadow: 0 6px 14px rgba(198,123,62,.2);
}
.booker-rank.rank-n {
    background: #EAF4F6;
    color: var(--brand-ink);
}
.booker-rank-cell { width: 1%; white-space: nowrap; }
.booker-table tbody tr.is-clickable { cursor: pointer; }
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #EAF4F6;
}
.data-table tbody tr:hover { background: #F0FBFA; }
.action-cell { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-cell .btn { white-space: nowrap; }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}
.pager-meta { font-size: .82rem; color: var(--muted); font-weight: 700; }
.pager-links { display: flex; flex-wrap: wrap; gap: 6px; }
.pager-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}
.pager-btn.is-current { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; border-color: transparent; }
.pager-btn.is-disabled { opacity: .45; }
.pager-gap { padding: 8px 4px; color: var(--muted); }

/* Chart stacked + tooltip */
.chart-col {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    font: inherit;
    color: inherit;
}
.chart-stack {
    width: 100%;
    max-width: 34px;
    display: flex;
    flex-direction: column-reverse;
    border-radius: 999px;
    overflow: hidden;
    transform-origin: bottom;
    animation: bar-up .42s ease both;
}
.chart-stack .seg { display: block; width: 100%; min-height: 3px; }
.chart-stack .s-room { background: linear-gradient(180deg, var(--brand-3), var(--chart-1)); }
.chart-stack .s-live { background: var(--chart-2); }
.chart-stack .s-car { background: var(--chart-3); }
.chart-stack .s-empty { background: #D5DEE2; }
.chart-col:hover .chart-stack { filter: brightness(1.06); }

.mix-row {
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 4px 6px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    font-weight: 700;
}
.mix-row:hover, .mix-row.is-open { background: var(--brand-soft); }
.mix-row i {
    width: 10px;
    height: 10px;
    border-radius: 99px;
    display: inline-block;
}
.mix-row .d1 { background: var(--chart-1); }
.mix-row .d2 { background: var(--chart-2); }
.mix-row .d3 { background: var(--chart-3); }

.dash-tip {
    position: fixed;
    z-index: 120;
    min-width: 196px;
    max-width: min(260px, calc(100vw - 24px));
    padding: 12px 14px;
    border-radius: 14px;
    background: #08343A;
    color: #F0FDFA;
    box-shadow: 0 16px 36px rgba(8,52,58,.28);
    pointer-events: none;
    word-break: keep-all;
    overflow-wrap: break-word;
}
.dash-tip[hidden] { display: none; }
.has-tip { cursor: help; }
.stat-card.has-tip, .mini-stat.has-tip, .donut-wrap.has-tip, .mix-row, .chart-col { cursor: pointer; }
.dash-tip-text {
    font-size: .78rem;
    color: #CFFAFE;
    margin: 0 0 8px;
    line-height: 1.45;
    word-break: keep-all;
}
.dash-tip strong { display: block; margin-bottom: 8px; font-size: .9rem; }
.dash-tip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8rem;
    margin: 4px 0;
}
.dash-tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dash-tip-total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.14);
    font-weight: 800;
    display: flex;
    justify-content: space-between;
}

@media (max-width: 640px) {
    .booker-hero { flex-direction: column; text-align: center; }
    .booker-meta, .booker-chips { justify-content: center; }
    .booker-hero-body { width: 100%; }
    .bottom-nav span { font-size: .6rem; }
}
