/* =========================================================
   ระบบลาราชการ — สำนักงานลูกเสือแห่งชาติ
   Design: Liquid Glass · Modern · Premium
   ========================================================= */

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-300.ttf") format("truetype");
    font-style: normal;
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-400.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-500.ttf") format("truetype");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-600.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-700.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Sarabun";
    src: url("../fonts/Sarabun-800.ttf") format("truetype");
    font-style: normal;
    font-weight: 800;
    font-display: swap;
}

:root {
    --font-main: "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --text-xs:   clamp(.70rem, .66rem + .12vw, .76rem);
    --text-sm:   clamp(.78rem, .74rem + .13vw, .85rem);
    --text-base: clamp(.875rem, .84rem + .14vw, .94rem);
    --text-lg:   clamp(.96rem, .92rem + .18vw, 1.06rem);
    --text-xl:   clamp(1.08rem, .98rem + .34vw, 1.30rem);
    --text-2xl:  clamp(1.26rem, 1.06rem + .66vw, 1.72rem);

    /* Palette — Vibrant Clean */
    --ink:          #1e293b;
    --muted:        #64748b;
    --subtle:       #94a3b8;
    --line:         #e8edf5;
    --line-soft:    #f1f5fb;
    --panel:        #ffffff;
    --soft:         #f4f7fc;

    --brand:        #4361ee;
    --brand-dark:   #3451d1;
    --brand-deeper: #1e3ab8;
    --brand-soft:   #eef1ff;
    --brand-soft-2: #dde4ff;

    --teal:         #0ab39c;
    --teal-soft:    #d0f5f0;
    --amber:        #f1a32a;
    --amber-soft:   #fff3d6;
    --pink:         #f06595;
    --pink-soft:    #ffe0ec;

    --gold:         #c07a0a;
    --gold-soft:    #fff3d6;
    --navy:         #1e293b;

    --green:        #0ab39c;
    --green-soft:   #d0f5f0;
    --orange:       #f1a32a;
    --orange-soft:  #fff3d6;
    --red:          #ef4444;
    --red-soft:     #fee2e2;

    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm:  8px;

    /* Glass — subtle on white bg */
    --glass-bg:          rgba(255,255,255,.92);
    --glass-bg-strong:   #ffffff;
    --glass-border:      #e8edf5;
    --glass-border-soft: #f1f5fb;
    --glass-blur:        blur(20px) saturate(160%);
    --glass-blur-sm:     blur(10px) saturate(140%);

    --shadow-sm:    0 1px 4px rgba(30,41,59,.06), 0 2px 8px rgba(30,41,59,.04);
    --shadow-md:    0 4px 16px rgba(30,41,59,.09), 0 2px 6px rgba(30,41,59,.05);
    --shadow-lg:    0 12px 40px rgba(30,41,59,.12), 0 4px 12px rgba(30,41,59,.06);
    --shadow-glass: 0 4px 20px rgba(67,97,238,.10), 0 1px 4px rgba(30,41,59,.06);

    --nav-h: 64px;
}

/* ── Base ─────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { -webkit-text-size-adjust: 100%; width: 100%; }

body {
    background:
        radial-gradient(ellipse 80% 60% at 10% 10%, rgba(99,135,255,.13) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 90% 5%,  rgba(10,179,156,.09) 0%, transparent 50%),
        radial-gradient(ellipse 55% 45% at 80% 90%, rgba(241,163,42,.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 55% at 5%  85%, rgba(240,101,149,.08) 0%, transparent 50%),
        #eef1f9;
    background-attachment: fixed;
    color: var(--ink);
    font-family: var(--font-main);
    font-size: var(--text-base);
    line-height: 1.65;
    min-height: 100dvh;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    overflow-x: hidden;
}

img, svg, canvas, video { max-width: 100%; }

::selection { background: rgba(37,99,235,.14); }

h1, h2, h3, h4, h5, h6 { letter-spacing: -.015em; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

main.container-fluid {
    width: 100%;
    max-width: 100%;
    min-height: calc(100vh - var(--nav-h));
    padding-top: 1.25rem !important;
}

/* ── Navbar ───────────────────────────────────────────── */

.app-navbar {
    min-height: var(--nav-h);
    background: rgba(255,255,255,.72);
    border-bottom: 1px solid rgba(255,255,255,.55);
    box-shadow: 0 2px 20px rgba(30,41,59,.08);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    padding-top: calc(.45rem + env(safe-area-inset-top, 0px));
    padding-bottom: .45rem;
}

.app-navbar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-deeper) 0%, var(--brand) 50%, var(--teal) 100%);
    opacity: .9;
}

.app-navbar .nav-link {
    color: var(--muted);
    border-radius: var(--radius-sm);
    padding: .4rem .65rem;
    font-size: var(--text-sm);
    font-weight: 600;
}

.app-navbar .nav-link:hover {
    color: var(--brand);
    background: var(--brand-soft);
}

.app-brand { display: inline-flex; align-items: center; gap: .65rem; }

.app-brand-icon,
.app-menu-btn,
.nav-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 1.1rem;
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}

.app-menu-btn:hover,
.nav-icon-btn:hover {
    border-color: var(--brand-soft-2);
    background: var(--brand-soft);
    color: var(--brand);
}

.app-brand-icon {
    color: var(--ink);
    border-color: var(--line);
    background: #fff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding: 4px;
}

.app-brand-icon img { width: 100%; height: 100%; object-fit: contain; }

.app-menu-btn { margin-right: .65rem; }

.nav-icon-btn { position: relative; }

.nav-icon-btn span {
    position: absolute;
    top: -5px; right: -6px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    border: 2px solid #fff;
    background: var(--red);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    line-height: 1;
}

.app-brand span { display: flex; flex-direction: column; line-height: 1.25; }

.app-brand strong {
    color: var(--ink);
    font-size: clamp(.96rem, .88rem + .28vw, 1.08rem);
    font-weight: 800;
}

.app-brand small { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }

.profile-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 40px;
    border-radius: 999px;
    padding: .22rem .65rem .22rem .28rem;
    background: var(--brand-soft);
    border: 1px solid var(--brand-soft-2);
    color: var(--brand-dark) !important;
    font-size: .92rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.profile-chip:hover {
    background: var(--brand-soft-2);
    border-color: var(--brand);
}

.profile-chip img,
.profile-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.8);
    box-shadow: 0 0 0 1px var(--brand-soft-2);
}

.profile-avatar-lg {
    width: 108px; height: 108px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 0 0 1px var(--line), var(--shadow-md);
}

/* ── Page head ────────────────────────────────────────── */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
    padding: .1rem 0 .2rem;
}

.page-back-row { margin: -.1rem 0 .7rem; }

.page-title {
    position: relative;
    margin: 0;
    padding-left: .82rem;
    color: var(--ink);
    font-size: clamp(1.12rem, 1rem + .4vw, 1.38rem);
    font-weight: 800;
}

.page-title::before {
    content: "";
    position: absolute;
    left: 0; top: .2em; bottom: .2em;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #60c0ff 0%, var(--brand) 50%, var(--gold) 100%);
}

.page-subtitle {
    color: var(--muted);
    margin: .28rem 0 0 .82rem;
    font-size: var(--text-sm);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    justify-content: flex-end;
    align-items: center;
}

/* ── Panels & cards ───────────────────────────────────── */

.panel {
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(255,255,255,.60);
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 24px rgba(30,41,59,.07),
        inset 0 1px 0 rgba(255,255,255,.80);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
}

.panel-pad { padding: 1.1rem 1.15rem; }

.panel h2, .panel .h5 {
    color: var(--ink);
    font-size: 1rem;
    font-weight: 800;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: .9rem 1rem;
    min-height: 86px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.stat-card .label { color: var(--muted); font-size: var(--text-sm); }

.stat-card .value {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--brand);
}

/* ── Buttons ──────────────────────────────────────────── */

.btn { border-radius: var(--radius-md); font-weight: 700; }
.btn-sm { min-height: 34px; }

.btn-brand {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-deeper);
    --bs-btn-active-border-color: var(--brand-deeper);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    box-shadow: 0 2px 14px rgba(26,86,219,.32), inset 0 1px 0 rgba(255,255,255,.22);
}

.btn-brand:focus-visible { box-shadow: 0 0 0 .22rem rgba(37,99,235,.22); }

.btn-outline-secondary {
    --bs-btn-color: #334155;
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: var(--brand-soft);
    --bs-btn-hover-border-color: var(--brand-soft-2);
    --bs-btn-hover-color: var(--brand-dark);
}

.btn-outline-warning {
    --bs-btn-color: #9a3412;
    --bs-btn-border-color: #ea580c;
    --bs-btn-hover-bg: #ea580c;
    --bs-btn-hover-border-color: #c2410c;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: #c2410c;
    --bs-btn-active-border-color: #9a3412;
    background-color: #fff7ed;
    font-weight: 700;
}

.btn-icon {
    width: 36px;
    min-width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
}

.btn-outline-danger {
    --bs-btn-color: var(--red);
    --bs-btn-border-color: #fca5a5;
    --bs-btn-hover-bg: var(--red-soft);
    --bs-btn-hover-border-color: #f87171;
    --bs-btn-hover-color: #991b1b;
    --bs-btn-active-bg: var(--red);
    --bs-btn-active-border-color: var(--red);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand-soft-2);
    --bs-btn-hover-bg: var(--brand-soft);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-deeper);
    --bs-btn-active-border-color: var(--brand-deeper);
}

.btn.is-selected { box-shadow: 0 0 0 .22rem rgba(37,99,235,.18); }

.btn-loading {
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .25rem;
}

/* ── Page submit overlay ──────────────────────────────── */
.submit-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.submit-overlay.is-active { display: flex; }
.submit-overlay__spinner {
    width: 48px; height: 48px;
    border: 4px solid #e0e7ff;
    border-top-color: #4361ee;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
.submit-overlay__text {
    font-size: 15px;
    color: #4361ee;
    font-weight: 600;
    font-family: var(--font-main);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────── */

.form-label {
    color: #334155;
    font-size: var(--text-sm);
    font-weight: 650;
    margin-bottom: .36rem;
}

.form-control,
.form-select {
    min-height: 44px;
    border-color: var(--line);
    border-radius: var(--radius-md);
    background-color: #fff;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--bs-form-select-bg-img);
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    font-size: var(--text-base);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .22rem rgba(67,97,238,.15);
}

.form-text { font-size: var(--text-xs); }

.password-field-wrap { position: relative; }
.password-field-wrap .form-control { padding-right: 3rem; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: .45rem;
    width: 2.25rem;
    height: 2.25rem;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #64748b;
}
.password-toggle:hover,
.password-toggle:focus-visible { background: #f1f5f9; color: var(--brand); }

.form-section-title {
    margin-top: .2rem;
    padding: .5rem .75rem;
    border: 1px solid var(--brand-soft-2);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 750;
    font-size: var(--text-base);
}

.system-readonly-note {
    display: inline-block;
    margin-top: .45rem;
    padding: .35rem .6rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    background: #e5e7eb;
    color: #6b7280;
    font-size: var(--text-xs);
}

/* ── Login ────────────────────────────────────────────── */

.login-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(135deg, #eef1ff 0%, #f0f7ff 50%, #f4f7fc 100%);
    background-attachment: fixed;
}

.login-card {
    position: relative;
    width: min(100%, 1100px);
    min-height: 560px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(400px, .95fr);
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 24px 72px rgba(30,41,59,.14);
}

.login-card::before { content: none; }

.login-showcase {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 3rem 2.8rem;
    color: #fff;
    background: linear-gradient(145deg, #1e3ab8 0%, #3451d1 50%, #4361ee 100%);
    overflow: hidden;
}

.login-showcase::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(480px 300px at 100% 0%, rgba(255,255,255,.12), transparent 60%),
        radial-gradient(360px 260px at 0% 100%, rgba(255,255,255,.06), transparent 60%);
    pointer-events: none;
}

.login-window-dots {
    display: inline-flex;
    gap: .5rem;
    position: relative;
    z-index: 1;
}

.login-window-dots span {
    width: 12px; height: 12px;
    border-radius: 999px;
}

.login-window-dots span:nth-child(1) { background: rgba(255,255,255,.35); }
.login-window-dots span:nth-child(2) { background: rgba(255,255,255,.22); }
.login-window-dots span:nth-child(3) { background: rgba(255,255,255,.14); }

.login-showcase-icon {
    position: relative; z-index: 1;
    width: 64px; height: 64px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(255,255,255,.15);
    font-size: 1.75rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}

.login-showcase h1 {
    position: relative; z-index: 1;
    margin: 0 0 .45rem;
    font-size: clamp(1.9rem, 1.3rem + 1.5vw, 2.8rem);
    line-height: 1.12;
    font-weight: 900;
}

.login-showcase p,
.login-showcase-kicker {
    position: relative; z-index: 1;
    margin: 0;
    color: rgba(255,255,255,.8);
    font-weight: 600;
}

.login-feature-list {
    position: relative; z-index: 1;
    display: grid;
    gap: .95rem;
}

.login-feature-list div {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: .8rem;
    align-items: center;
}

.login-feature-list span {
    grid-row: span 2;
    width: 44px; height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255,255,255,.15);
    font-size: 1.1rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}

.login-feature-list strong,
.login-feature-list small { display: block; }
.login-feature-list small { color: rgba(255,255,255,.72); font-size: .84rem; }

.login-showcase-stats {
    position: relative; z-index: 1;
    margin-top: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .85rem;
}

.login-showcase-stats strong,
.login-showcase-stats small { display: block; }
.login-showcase-stats strong { font-size: 1.5rem; line-height: 1; }
.login-showcase-stats small { color: rgba(255,255,255,.7); font-size: .8rem; margin-top: .2rem; }

.login-form-panel {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255,255,255,.88);
}

.login-form-panel .login-brand { text-align: left; }

.login-form-panel .login-brand img {
    width: 58px; height: 58px;
    border-radius: 14px;
    margin: 0 0 1.1rem;
    background: var(--soft);
    padding: 4px;
    object-fit: contain;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.login-form-panel .page-title,
.login-form-panel .page-subtitle { padding-left: 0; margin-left: 0; }
.login-form-panel .page-title::before { content: none; }

.login-kicker { color: var(--gold); letter-spacing: .12em; font-size: var(--text-xs); }

/* fallback: old single-column login brand (if login-showcase absent) */
.login-brand { text-align: center; }
.login-brand img {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: #fff;
    padding: 6px;
    object-fit: contain;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

/* ── Tables ───────────────────────────────────────────── */

.table { margin-bottom: 0; }

.table thead th {
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 750;
    letter-spacing: .02em;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(248,250,252,.6);
    padding-top: .6rem;
    padding-bottom: .6rem;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    border-color: rgba(148,163,184,.12);
    padding-top: .65rem;
    padding-bottom: .65rem;
}

.table tbody tr:hover { background: rgba(239,246,255,.5); }
.table tbody tr:hover > * { --bs-table-bg-state: transparent; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: #fafbfc; }
.table .text-muted { color: var(--muted) !important; }

.table .btn-sm {
    --bs-btn-padding-y: .28rem;
    --bs-btn-padding-x: .6rem;
    --bs-btn-font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.table-action-group {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .3rem;
}

.approval-panel td:last-child,
.approval-panel th:last-child { text-align: right; }

.admin-table-panel { overflow: visible; }

.approval-reply-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
}

.approval-reply-group .btn { min-height: 40px; }
.approval-reply-group .btn-outline-success.is-selected {
    color: #fff;
    background-color: #198754;
    border-color: #198754;
}
.approval-reply-group .btn-outline-danger.is-selected {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}

/* Pagination */
.pagination {
    --bs-pagination-color: var(--brand);
    --bs-pagination-border-color: var(--line);
    --bs-pagination-border-radius: var(--radius-sm);
    --bs-pagination-hover-color: var(--brand-dark);
    --bs-pagination-hover-bg: var(--brand-soft);
    --bs-pagination-hover-border-color: var(--brand-soft-2);
    --bs-pagination-focus-color: var(--brand-dark);
    --bs-pagination-focus-bg: var(--brand-soft);
    --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(37,99,235,.14);
    --bs-pagination-active-color: #fff;
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-disabled-color: var(--subtle);
    --bs-pagination-disabled-bg: var(--soft);
    --bs-pagination-disabled-border-color: var(--line-soft);
}

.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
    color: #fff !important;
    border-color: var(--brand);
    background: var(--brand);
}

.dt-container .dt-paging .dt-paging-button:hover {
    color: var(--brand-dark) !important;
    border-color: var(--brand-soft-2);
    background: var(--brand-soft);
}

.dt-container .dt-info,
.dt-container .dt-length,
.dt-container .dt-search { color: var(--muted); font-size: var(--text-sm); }

/* ── Thai date picker ─────────────────────────────────── */

.thai-calendar {
    position: absolute;
    z-index: 2050;
    display: none;
    width: min(328px, calc(100vw - 32px));
    padding: 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.92);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-glass);
}

.thai-calendar.is-open { display: block; }

.thai-calendar-head {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.thai-calendar-title,
.thai-calendar-nav {
    height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
    color: var(--ink);
    font-weight: 750;
}

.thai-calendar-nav { color: var(--brand); }

.thai-calendar-week,
.thai-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.thai-calendar-week span {
    padding: 5px 0;
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 650;
}

.thai-calendar-grid button {
    aspect-ratio: 1;
    min-width: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font-weight: 650;
}

.thai-calendar-grid button:hover { background: var(--brand-soft); color: var(--brand-dark); }
.thai-calendar-grid button:disabled { cursor: not-allowed; opacity: .28; background: transparent; color: var(--subtle); }
.thai-calendar-grid button.is-muted { color: var(--subtle); }

.thai-calendar-grid button.is-today {
    box-shadow: inset 0 0 0 1.5px rgba(37,99,235,.4);
    color: var(--brand-dark);
}

.thai-calendar-grid button.is-selected {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,.28);
}

.thai-calendar-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}

.thai-calendar-actions .btn { min-width: 80px; border-radius: var(--radius-sm); }

/* ── Badges & status ──────────────────────────────────── */

.badge {
    font-weight: 700;
    border-radius: 999px;
    padding: .38em .75em;
}

.badge.bg-warning,   .badge.text-bg-warning   { background: var(--orange-soft) !important; color: var(--orange) !important; }
.badge.bg-info,      .badge.text-bg-info       { background: var(--brand-soft)  !important; color: var(--brand-dark) !important; }
.badge.bg-success,   .badge.text-bg-success    { background: var(--green-soft)  !important; color: var(--green) !important; }
.badge.bg-danger,    .badge.text-bg-danger     { background: var(--red-soft)    !important; color: var(--red) !important; }
.badge.bg-secondary, .badge.text-bg-secondary  { background: var(--line-soft)   !important; color: var(--muted) !important; }
.badge.bg-dark,      .badge.text-bg-dark       { background: #e8ecf0            !important; color: #334155 !important; }
.badge.bg-primary,   .badge.text-bg-primary    { background: var(--brand-soft)  !important; color: var(--brand-dark) !important; }

.timeline-marker.text-bg-warning   { background: var(--orange) !important; }
.timeline-marker.text-bg-info      { background: var(--brand)  !important; }
.timeline-marker.text-bg-success   { background: var(--green)  !important; }
.timeline-marker.text-bg-danger    { background: var(--red)    !important; }
.timeline-marker.text-bg-secondary { background: var(--subtle) !important; }
.timeline-marker.text-bg-dark      { background: #475569       !important; }

.status-flow { display: grid; gap: .4rem; min-width: 220px; }

.status-steps { display: flex; flex-wrap: wrap; gap: .3rem; }

.status-steps span {
    padding: .2rem .48rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--soft);
    color: var(--muted);
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.2;
}

.status-steps span.is-done {
    border-color: var(--brand-soft-2);
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.status-steps span.is-muted { opacity: .5; }

.status-panel { background: linear-gradient(180deg, #ffffff, var(--soft)); }

.status-timeline {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .8rem;
    padding: .4rem 0 .1rem;
}

.status-timeline::before {
    position: absolute;
    top: 24px;
    left: 16.5%; right: 16.5%;
    height: 1.5px;
    border-radius: 999px;
    background: var(--line);
    content: "";
}

.status-timeline-step {
    position: relative;
    display: grid;
    justify-items: center;
    gap: .5rem;
    color: var(--muted);
    text-align: center;
}

.status-timeline-step span {
    position: relative; z-index: 1;
    display: grid;
    width: 48px; height: 48px;
    place-items: center;
    border: 1.5px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(255,255,255,.85);
    -webkit-backdrop-filter: var(--glass-blur-sm);
    backdrop-filter: var(--glass-blur-sm);
    color: var(--muted);
    font-weight: 750;
    box-shadow: var(--shadow-sm);
}

.status-timeline-step strong { color: inherit; font-size: .88rem; font-weight: 700; }

.status-step-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    min-height: 20px;
    padding: .15rem .45rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 650;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.status-step-time i { color: var(--brand); font-size: .74rem; }

.status-timeline-step.is-done span { border-color: var(--brand); background: var(--brand); color: #fff; }
.status-timeline-step.is-done strong { color: var(--brand-dark); }
.status-timeline-step.is-current span { box-shadow: 0 0 0 4px rgba(37,99,235,.12), var(--shadow-sm); }
.status-timeline-step.is-muted { opacity: .45; }

.leave-detail-panel { overflow: hidden; }
.leave-detail-sections { display: grid; gap: .6rem; }

.leave-detail-section {
    padding: .8rem .9rem;
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    background: rgba(248,250,252,.65);
}

.leave-detail-section h3 {
    margin: 0 0 .45rem;
    color: var(--brand-dark);
    font-size: var(--text-sm);
    font-weight: 750;
}

.leave-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 .85rem;
}

.leave-detail-item {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(90px, .4fr) minmax(0, 1fr);
    gap: .4rem;
    padding: .4rem 0;
    border-bottom: 1px solid var(--line-soft);
}

.leave-detail-item small {
    display: block;
    margin: 0;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 650;
}

.leave-detail-item strong {
    display: block;
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.cancel-readonly-panel {
    padding: .85rem 1rem;
    border: 1px solid #dbe2ea;
    border-radius: var(--radius-md);
    background: #f8fafc;
}
.cancel-readonly-heading {
    padding-bottom: .7rem;
    color: #334155;
    font-size: 1.05rem;
    font-weight: 750;
    border-bottom: 1px solid #e2e8f0;
}
.cancel-readonly-heading span {
    margin-left: .35rem;
    color: #64748b;
    font-size: var(--text-xs);
    font-weight: 500;
}
.cancel-readonly-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .7rem 1rem;
    padding-top: .65rem;
}
.cancel-readonly-item { min-width: 0; }
.cancel-readonly-item small {
    display: block;
    color: #64748b;
    font-size: var(--text-xs);
    margin-bottom: .15rem;
}
.cancel-readonly-item strong {
    display: block;
    color: #0f172a;
    font-size: var(--text-sm);
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.cancel-readonly-reason { grid-column: 1 / -1; }

/* ── Quota ────────────────────────────────────────────── */

.leave-quota-panel { position: sticky; top: calc(var(--nav-h) + 16px); }

.quota-year {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: .18rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--brand-soft-2);
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 700;
    font-size: var(--text-sm);
}

.quota-list { display: grid; gap: .65rem; }

.quota-item {
    padding: .7rem .85rem;
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.75);
}

.quota-item span { color: #334155; font-size: var(--text-sm); line-height: 1.35; }
.quota-item strong { white-space: nowrap; color: var(--ink); font-size: var(--text-sm); }

.quota-bar, .type-progress-bar {
    height: 5px;
    margin-top: .5rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--line);
}

.quota-bar span, .type-progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f3090 0%, var(--brand) 50%, #60c0ff 100%);
}

.type-progress-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .7rem;
}

.type-progress-item {
    min-height: 96px;
    padding: .88rem .95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.type-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .8rem;
}

.type-progress-head > span { color: #334155; font-size: .92rem; font-weight: 650; line-height: 1.35; }

.type-progress-metrics { display: grid; gap: .1rem; min-width: 72px; text-align: right; }
.type-progress-metrics strong { white-space: nowrap; color: var(--ink); font-size: 1.02rem; font-weight: 800; }
.type-progress-metrics em { white-space: nowrap; color: var(--muted); font-size: .78rem; font-style: normal; font-weight: 600; }

.type-progress-bar { margin-top: .8rem; }

/* ── Leave timeline & attachments ─────────────────────── */

.leave-timeline { position: relative; display: grid; gap: .45rem; }

.leave-timeline::before {
    content: "";
    position: absolute;
    top: .5rem; bottom: .5rem;
    left: 7px;
    width: 1.5px;
    background: var(--line);
}

.leave-timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: .5rem;
}

.timeline-marker {
    z-index: 1;
    width: 14px; height: 14px;
    margin-top: .65rem;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--line);
}

.timeline-card {
    padding: .55rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.timeline-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
}

.timeline-card-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .1rem .65rem;
    min-width: 0;
}

.timeline-type {
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
}

.timeline-dates, .timeline-sent {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: var(--text-xs);
    color: var(--muted);
    white-space: nowrap;
}

.timeline-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .45rem;
}

.timeline-actions { display: flex; gap: .35rem; flex-shrink: 0; align-items: center; }

/* ── Leave timeline & attachments (legacy alias) ──────── */
.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .28rem .6rem;
    color: var(--muted);
    font-size: var(--text-xs);
}
.timeline-meta span { display: inline-flex; align-items: center; gap: .32rem; }

.attachment-list { display: grid; gap: .55rem; }

.attachment-item {
    display: grid;
    grid-template-columns: 40px 1fr 26px;
    align-items: center;
    gap: .75rem;
    padding: .7rem .9rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    background: var(--soft);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}

.attachment-item:hover { border-color: var(--brand-soft-2); background: var(--brand-soft); }

.attachment-icon {
    display: grid;
    width: 40px; height: 40px;
    place-items: center;
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.1rem;
}

.attachment-item strong, .attachment-item small { display: block; }
.attachment-item strong { font-weight: 700; }
.attachment-item small { color: var(--muted); }

/* ── Leave steps ──────────────────────────────────────── */

.leave-steps {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 1;
    min-width: 0;
}

.leave-steps .step-connector {
    flex: 1;
    height: 1px;
    background: var(--line);
    min-width: 10px;
    max-width: 28px;
}

.leave-step {
    display: flex;
    align-items: center;
    gap: .28rem;
    color: var(--subtle);
    font-size: var(--text-xs);
    white-space: nowrap;
}

.leave-step span {
    width: 18px; height: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--muted);
    font-size: .66rem;
    font-weight: 750;
    flex-shrink: 0;
}

.leave-step small { font-size: .7rem; }

.leave-step.is-done span {
    background: var(--brand-soft);
    color: var(--brand-dark);
    box-shadow: inset 0 0 0 1px rgba(37,99,235,.22);
}

.leave-step.is-done small { color: var(--brand-dark); font-weight: 650; }
.leave-step.is-muted { opacity: .45; }
.leave-step.is-rejected span { background: var(--red-soft); color: var(--red); }
.leave-step.is-rejected small { color: var(--red); }

/* ── Dashboard hero ───────────────────────────────────── */

.dashboard-head { display: none; }

.dashboard-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(400px, 1.8fr);
    align-items: stretch;
    gap: 1rem;
    color: #fff;
    border-radius: 20px;
    padding: 1.2rem 1.3rem;
    border: none;
    background: linear-gradient(135deg, var(--brand-deeper) 0%, var(--brand) 100%);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.dashboard-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(90deg, transparent 0%, #000 15%, #000 65%, transparent 100%);
    opacity: .2;
}

.dashboard-hero::after { content: none; }

.hero-profile { display: flex; align-items: center; gap: .85rem; margin-bottom: 0; }

.hero-avatar {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    border: 1.5px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.14);
    font-size: 1.4rem;
    font-weight: 800;
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border-radius: 999px;
    padding: .2rem .65rem;
    margin-bottom: .38rem;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.12);
    font-size: var(--text-xs);
    font-weight: 650;
}

.dashboard-hero h2 { margin: 0; font-size: clamp(1.1rem, .98rem + .44vw, 1.44rem); font-weight: 850; }
.dashboard-hero p { margin: .28rem 0 0; font-size: var(--text-sm); opacity: .8; }

.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }

.hero-stat {
    min-height: 82px;
    border-radius: var(--radius-md);
    padding: .82rem .88rem;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.1);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.hero-stat span {
    display: block;
    min-height: 2em;
    margin-bottom: .35rem;
    font-size: var(--text-xs);
    line-height: 1.25;
    opacity: .82;
}

.hero-stat strong {
    display: block;
    font-size: clamp(1.28rem, 1.05rem + .7vw, 1.72rem);
    line-height: 1;
    font-weight: 850;
}

/* Dashboard hero — full-width variant → minimal floating card */
.dashboard-hero-full {
    display: block;
    grid-template-columns: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    border-radius: 0;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
}

.dashboard-hero-full::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        radial-gradient(ellipse 50% 70% at 92% 0%,  rgba(120,190,255,.35) 0%, transparent 55%),
        radial-gradient(ellipse 40% 60% at 5%  95%, rgba(80,120,255,.20)  0%, transparent 55%);
    opacity: .85;
}

.dashboard-hero-full::after {
    content: "";
    position: absolute;
    inset: auto 1.65rem 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
    opacity: .6;
    border-radius: inherit;
}

/* ── Hero stats — iOS Liquid Glass ── */
.dashboard-hero .hero-stats,
.dashboard-hero-full .hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
    gap: .75rem;
    width: 100%;
    align-items: stretch;
}

.dashboard-hero .hero-stat,
.dashboard-hero-full .hero-stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .75rem;
    min-height: 0;
    padding: .75rem 1rem;
    border-radius: 18px;
    position: relative;
    z-index: 1;
    overflow: hidden;
    color: #fff;
    background: #4361ee;
    border: 1px solid rgba(255,255,255,.30);
    box-shadow: none;
    transition: transform .18s ease, filter .18s ease;
}

.dashboard-hero .hero-stat:hover,
.dashboard-hero-full .hero-stat:hover {
    transform: translateY(-2px) scale(1.012);
    filter: brightness(1.07);
}

/* Per-card vivid gradient */
.dashboard-hero-full .hero-stat:nth-child(1),
.dashboard-hero .hero-stat:nth-child(1) {
    background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
}
.dashboard-hero-full .hero-stat:nth-child(2),
.dashboard-hero .hero-stat:nth-child(2) {
    background: linear-gradient(135deg, #06d6a0 0%, #0ab39c 100%);
}
.dashboard-hero-full .hero-stat:nth-child(3),
.dashboard-hero .hero-stat:nth-child(3) {
    background: linear-gradient(135deg, #ff9f1c 0%, #f77f00 100%);
}
.dashboard-hero-full .hero-stat:nth-child(4),
.dashboard-hero .hero-stat:nth-child(4) {
    background: linear-gradient(135deg, #f72585 0%, #b5179e 100%);
}

/* Specular inner glare sweep */
.dashboard-hero .hero-stat::before,
.dashboard-hero-full .hero-stat::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 55%);
    pointer-events: none;
}

/* Icon bubble */
.dashboard-hero .hero-stat > i,
.dashboard-hero-full .hero-stat > i {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: rgba(255,255,255,.22);
    border: 1px solid rgba(255,255,255,.30);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Text group */
.dashboard-hero .hero-stat > div,
.dashboard-hero-full .hero-stat > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dashboard-hero .hero-stat span,
.dashboard-hero-full .hero-stat span {
    min-height: 0; margin: 0;
    color: rgba(255,255,255,.82);
    font-weight: 500;
    font-size: .78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.dashboard-hero .hero-stat strong,
.dashboard-hero-full .hero-stat strong {
    color: #fff;
    font-size: clamp(1.25rem, 1rem + .8vw, 1.65rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.02em;
    display: block;
}

.dashboard-hero .hero-stat small,
.dashboard-hero-full .hero-stat small {
    display: block;
    margin-top: .1rem;
    color: rgba(255,255,255,.62);
    font-size: .7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-recent-panel { width: 100%; overflow: visible; }
.dashboard-recent-panel .dt-container,
.dashboard-recent-panel .table-responsive { width: 100%; }

.dashboard-recent-panel .dt-layout-row:first-child {
    display: grid !important;
    grid-template-columns: minmax(180px, auto) minmax(240px, 1fr);
    align-items: center;
    gap: .7rem;
}

.dashboard-recent-panel .dt-container > .row:first-child { align-items: center; gap: .5rem 0; }
.dashboard-recent-panel .dt-layout-row:first-child .dt-layout-cell:last-child { justify-self: stretch; }
.dashboard-recent-panel .dt-search { width: 100%; text-align: right; }
.dashboard-recent-panel .dt-search input { width: min(100%, 340px); }
.dashboard-recent-panel .dt-length label,
.dashboard-recent-panel .dt-search { display: inline-flex; align-items: center; gap: .4rem; }

.dashboard-year-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(248,250,252,.65);
}

.dashboard-year-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .45rem;
    min-width: min(100%, 320px);
}

.dashboard-year-form .form-select { min-width: 110px; }
.dashboard-year-form .btn { white-space: nowrap; }

/* ── Quick stats ──────────────────────────────────────── */

.quick-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: .8rem;
}

.quick-stat-card {
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: .72rem;
    padding: .72rem .9rem;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(255,255,255,.60);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(15,23,42,.10), inset 0 1px 0 rgba(255,255,255,.14);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    color: inherit;
    text-decoration: none;
    transition: transform .18s, box-shadow .18s;
}

a.quick-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 18px rgba(15,23,42,.16), inset 0 1px 0 rgba(255,255,255,.18);
}

.quick-stat-card small,
.quick-stat-card em {
    display: block;
    color: var(--muted);
    font-size: var(--text-xs);
    font-style: normal;
    line-height: 1.3;
}

.quick-stat-card strong {
    display: block;
    color: var(--ink);
    font-size: clamp(1.1rem, .98rem + .44vw, 1.44rem);
    line-height: 1.05;
    font-weight: 850;
}

.my-leave-stat-grid { align-items: stretch; }
.leave-type-stat-card { align-items: flex-start; }
.leave-type-stat-card .lsc-body {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column; gap: .1rem;
}
.leave-type-stat-card .lsc-name {
    font-size: var(--text-xs); color: var(--muted);
    line-height: 1.35; min-height: 2.6em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.leave-type-stat-card .lsc-days {
    display: block; color: var(--ink);
    font-size: clamp(.95rem, .88rem + .3vw, 1.18rem);
    font-weight: 800; line-height: 1.15; margin-top: .25rem;
}
.leave-type-stat-card .lsc-times {
    display: block; font-size: var(--text-xs); color: var(--muted); line-height: 1.3;
}
.leave-type-stat-card .lsc-footer {
    display: block; font-size: var(--text-xs); color: var(--muted);
    line-height: 1.3; margin-top: auto; padding-top: .35rem;
}
.leave-type-stat-card .quota-bar { height: 4px; margin-top: .35rem; display: block; }

.leave-type-stat-card {
    --leave-accent: #2563eb;
    --leave-soft: #eff6ff;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: var(--ink);
    box-shadow: 0 6px 20px rgba(15, 23, 42, .07);
    align-items: center;
}
.leave-type-stat-card .quick-icon {
    width: 36px;
    height: 36px;
    background: var(--leave-soft);
    color: var(--leave-accent);
    border-color: transparent;
}
.leave-type-stat-card .lsc-name,
.leave-type-stat-card .lsc-times { color: #64748b; }
.leave-type-stat-card .lsc-days { color: #0f172a; }
.leave-theme-sick { --leave-accent: #2563eb; --leave-soft: #eff6ff; }
.leave-theme-maternity { --leave-accent: #db2777; --leave-soft: #fdf2f8; }
.leave-theme-personal { --leave-accent: #ea580c; --leave-soft: #fff7ed; }
.leave-theme-vacation { --leave-accent: #0f766e; --leave-soft: #f0fdfa; }
.leave-theme-family { --leave-accent: #7c3aed; --leave-soft: #f5f3ff; }
.leave-theme-ordination { --leave-accent: #4f46e5; --leave-soft: #eef2ff; }
.leave-theme-service { --leave-accent: #475569; --leave-soft: #f8fafc; }
.leave-theme-training { --leave-accent: #16a34a; --leave-soft: #f0fdf4; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; }
.timeline-panel { overflow: hidden; }

.quick-icon {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-size: 1rem;
    border: 1px solid rgba(255,255,255,.60);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.70);
}

.my-leave-stat-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.quick-icon.blue   { background: rgba(67,97,238,.12);  color: var(--brand); }
.quick-icon.orange { background: rgba(241,163,42,.14); color: var(--amber); }
.quick-icon.green  { background: rgba(10,179,156,.12); color: var(--teal); }
.quick-icon.red    { background: rgba(240,101,149,.12);color: var(--pink); }

/* ── Bottom navigation ────────────────────────────────── */


/* ── Leave form ───────────────────────────────────────── */

.print-area { background: #fff; }
.official-leave-form { max-width: 100%; }
.leave-form-panel {
    width: 100%;
    border-top: 4px solid var(--brand);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}
.form-workspace { border-color: var(--line); }
.official-leave-form { row-gap: 1.05rem !important; }
.official-leave-form .form-section-title {
    margin-top: .35rem;
    letter-spacing: .01em;
}
.official-leave-form .form-label { letter-spacing: .005em; }
.official-leave-form .last-leave-stat-row { margin-top: -.2rem; }
.profile-panel { max-width: 100%; width: 100%; }
.official-leave-form.leave-form-full { max-width: none; }
.leave-form-body { display: none; }
.leave-form-body.is-visible { display: block; }
.leave-form-placeholder { display: block; }
.leave-form-placeholder.is-hidden { display: none; }

.empty-state-card {
    display: grid;
    justify-items: center;
    gap: .4rem;
    padding: 2rem 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #f8fbff 0%, var(--soft) 100%);
    color: var(--muted);
    text-align: center;
}

.empty-state-card i {
    display: grid;
    width: 50px; height: 50px;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.3rem;
}

.empty-state-card strong { color: var(--ink); font-size: 1rem; }
.leave-extra { display: none; }
.leave-extra.is-visible { display: block; }

.last-leave-stat-row {
    font-size: var(--text-sm);
    padding: .45rem .75rem;
    background: var(--brand-soft);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-sm);
    color: var(--ink);
}

.ap-working-days-review {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .55rem .8rem;
    border: 1px solid #fdba74;
    border-left: 5px solid #ea580c;
    border-radius: var(--radius-md);
    background: #fff7ed;
    color: #9a3412;
}
.ap-working-days-review small,
.ap-working-days-review em {
    display: block;
    font-size: var(--text-xs);
    font-style: normal;
}
.ap-working-days-review strong {
    display: block;
    font-size: 1rem;
    line-height: 1.25;
}
.ap-working-days-review em { color: #7c2d12; margin-top: .15rem; }
.ap-working-days-review { margin: .85rem 1.1rem 0; }
.ap-working-days-review > i { font-size: 1.1rem; }

.leave-approval-days-summary {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px solid #bfdbfe;
    border-left: 5px solid #2563eb;
    border-radius: var(--radius-md);
    background: #eff6ff;
    color: #1e3a8a;
}
.leave-approval-days-summary > i { font-size: 1.45rem; color: #2563eb; }
.leave-approval-days-summary small,
.leave-approval-days-summary span { display: block; font-size: var(--text-xs); }
.leave-approval-days-summary strong { display: block; margin: .1rem 0; font-size: 1.35rem; line-height: 1.2; color: #1d4ed8; }
.leave-approval-days-summary span { color: #475569; }

/* ── Official print document ──────────────────────────── */

.official-print {
    max-width: 820px;
    margin: 0 auto;
    color: #111827;
    font-size: 1rem;
    line-height: 1.85;
}

.official-line { margin-bottom: .32rem; }
.official-paragraph { margin: 1rem 0; text-indent: 2.5rem; }

.official-signature { width: min(100%, 300px); margin: 1.5rem 0 0 auto; text-align: center; }
.signature-line { margin: 2.2rem 0 .22rem; border-bottom: 1px dotted #9ca3af; padding-bottom: .1rem; }

.official-command {
    padding: .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--soft);
}

.official-form-grid {
    display: grid;
    grid-template-columns: minmax(250px, .9fr) minmax(300px, 1.1fr);
    gap: 1rem;
    align-items: end;
    margin-top: 1.5rem;
}

.official-stat-table { width: 100%; border-collapse: collapse; font-size: .9rem; text-align: center; }
.official-stat-table th, .official-stat-table td { border: 1px solid #222; padding: .42rem .32rem; }
.official-stat-table th { font-weight: 800; }
.official-stat-table td:first-child { text-align: center; font-weight: 700; }
.official-stat-table small { font-weight: 400; }

.approval-blocks { display: grid; gap: 1rem; }

.official-sign-box,
.official-opinion-box { padding: .65rem; background: #fff; font-size: .92rem; line-height: 1.7; }

.official-sign-box { min-height: 96px; }
.official-opinion-box { min-height: 180px; }
.dotted-line { height: 1.5rem; border-bottom: 1px dotted #555; }

.official-system-note {
    padding: .7rem .88rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    background: var(--soft);
    color: #44506a;
    font-size: var(--text-sm);
}

/* ── Filters / DataTables ─────────────────────────────── */

.d-contents { display: contents; }

.server-leave-filters-wrap {
    align-items: center;
}

.server-leave-filters {
    display: contents;
}

.leave-filter-keyword { flex: 0 1 220px; min-width: 180px; max-width: 220px; }
.leave-filter-sm      { flex: 0 1 160px; min-width: 140px; }
.leave-filter-xs      { flex: 0 0 82px; min-width: 82px; text-align: center; }

.server-leave-filters .form-control,
.server-leave-filters .form-select,
.server-leave-filters-wrap .form-control,
.server-leave-filters-wrap .form-select { height: 36px; font-size: var(--text-sm); }

.btn-xs {
    padding: .22rem .55rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.server-table-loading,
.server-empty-state {
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    background: var(--soft);
}

.dt-container { font-family: var(--font-main); width: 100%; max-width: 100%; min-width: 0; }

/* DataTable inside card */
.card > .card-body.p-0 > .dt-container { padding: 0.75rem 1rem 0; }
.card > .card-body.p-0 > .dt-container .dt-layout-row:last-child { padding-bottom: 0.75rem; }
.card > .card-body.p-0 > .dt-container table.dataTable { margin-top: 0.5rem; }

.dt-container .dt-search input,
.dt-container .dt-length select {
    border-color: var(--line);
    border-radius: var(--radius-sm);
    min-height: 38px;
}

.dt-container .dt-layout-row { margin: .4rem 0; }

.dt-container > .row:first-child { align-items: center; gap: .5rem 0; }

.dt-container .dt-length label,
.dt-container .dt-search { display: inline-flex; align-items: center; gap: .4rem; }

.dt-container .dt-search { width: 100%; }
.dt-container .dt-search input { width: min(100%, 340px); }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .dt-container { min-width: 0; overflow: visible; }
.table-responsive .dt-layout-cell { overflow: visible; min-width: 0; }
.table-responsive table { min-width: max-content; }

/* Reports */
.report-stack { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.report-filter-panel { background: rgba(248,250,252,.65); }
.report-filter-form { margin: 0; }
.report-filter-form .form-select,
.report-filter-form .form-control { min-height: 40px; font-size: var(--text-sm); }
.report-year-field { min-width: 330px; }
.report-year-field .form-select { min-width: 330px; }
.report-chart-panel { overflow: hidden; }
.report-chart-grid { align-items: stretch; min-width: 0; }
.report-chart-grid > [class*="col-"] { display: flex; min-width: 0; }

.chart-box {
    width: 100%; min-width: 0; height: 100%;
    min-height: 216px;
    padding: .75rem;
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.8);
    -webkit-backdrop-filter: var(--glass-blur-sm);
    backdrop-filter: var(--glass-blur-sm);
}

.chart-box-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
    margin-bottom: .5rem;
    min-width: 0;
}

.chart-box canvas { display: block; width: 100% !important; height: 226px !important; max-height: 226px; }
.chart-box.is-expanded canvas#leaveTypeChart { height: 348px !important; max-height: 348px; }

.chart-title { color: var(--ink); font-weight: 750; margin-bottom: .4rem; font-size: var(--text-sm); min-width: 0; }

.report-table-panel { overflow: visible; min-width: 0; }
.report-table-panel .dt-container { margin-top: -.1rem; max-width: 100%; overflow: visible; }
.report-table-panel .dt-layout-cell { overflow: visible; min-width: 0; }
.report-table-panel .dt-scroll, .report-table-panel .dt-scroll-body { overflow-x: auto !important; }
.report-table-panel .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.report-summary-grid .report-table-panel { height: 100%; }

.leave-type-chip-list { display: flex; flex-wrap: wrap; gap: .3rem; max-width: 700px; }

.leave-type-chip-list span {
    display: inline-flex;
    align-items: center;
    gap: .22rem;
    padding: .22rem .56rem;
    border: 1px solid var(--brand-soft-2);
    border-radius: 999px;
    background: var(--brand-soft);
    color: #334155;
    font-size: .8rem;
    white-space: nowrap;
}

.leave-type-chip-list strong { color: var(--brand-dark); }

/* ── Alerts ───────────────────────────────────────────── */

.alert { border-radius: var(--radius-md); font-size: var(--text-sm); }
.alert-danger  { background: var(--red-soft);   border-color: #fca5a5; color: #991b1b; }
.alert-success { background: var(--green-soft);  border-color: #6ee7b7; color: #065f46; }

/* ── Table extras ─────────────────────────────────────── */

.table .table-seq {
    width: 64px; min-width: 64px;
    text-align: center;
    color: var(--muted);
    font-weight: 750;
    white-space: nowrap;
}

.report-stat-grid .stat-card { height: 100%; }

/* ── Report nav ───────────────────────────────────────── */

.report-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
}

.report-nav-card {
    min-height: 108px;
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 28px;
    align-items: center;
    gap: .85rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform .18s, box-shadow .18s, border-color .18s;
}

.report-nav-card:hover {
    border-color: var(--brand-soft-2);
    color: var(--ink);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.report-nav-icon {
    width: 50px; height: 50px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    box-shadow: 0 6px 16px rgba(67,97,238,.28);
}

.report-nav-card strong, .report-nav-card small { display: block; }
.report-nav-card strong { font-size: .98rem; font-weight: 800; }
.report-nav-card small { margin-top: .18rem; color: var(--muted); line-height: 1.35; }
.report-nav-card > .bi { color: var(--brand); font-size: 1.5rem; }

/* ── Telegram settings ────────────────────────────────── */

.telegram-setting-row {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(140px, .5fr) minmax(240px, 1fr) minmax(130px, .32fr);
    gap: .85rem;
    padding: .82rem;
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    background: rgba(248,250,252,.6);
}

/* ── SweetAlert2 ──────────────────────────────────────── */

.swal2-popup-app {
    font-family: var(--font-main) !important;
    border-radius: 20px !important;
    padding: 1.8rem 1.6rem !important;
    background: #fff !important;
    box-shadow: var(--shadow-lg) !important;
}

.swal2-popup-app .swal2-title {
    font-size: 1.12rem !important;
    font-weight: 800 !important;
    color: var(--ink) !important;
}

.swal2-popup-app .swal2-html-container {
    font-size: var(--text-sm) !important;
    color: var(--muted) !important;
}

.swal2-confirm-app,
.swal2-cancel-app {
    border-radius: var(--radius-md) !important;
    font-family: var(--font-main) !important;
    font-weight: 700 !important;
    font-size: var(--text-sm) !important;
    padding: .5rem 1.2rem !important;
}

.swal2-confirm-app { box-shadow: 0 1px 2px rgba(30,58,138,.18) !important; }

/* ── Modals ───────────────────────────────────────────── */

.modal-content {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow-lg);
}

.modal-header, .modal-footer { border-color: var(--line); }
.modal-header { background: var(--soft); border-radius: 20px 20px 0 0; }

/* ── Sidebar (desktop ≥ 992px) ────────────────────────── */

.sidebar-brand, .sidebar-user { display: flex; align-items: center; gap: .7rem; }

.sidebar-brand strong, .sidebar-brand small,
.sidebar-user strong, .sidebar-user small { display: block; }

.sidebar-brand strong, .sidebar-user strong { color: var(--ink); font-weight: 800; }
.sidebar-brand small, .sidebar-user small { color: var(--muted); font-size: .8rem; }

.sidebar-clock {
    padding: .9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    text-align: center;
}

.sidebar-clock strong { display: block; color: var(--ink); font-size: 1.5rem; line-height: 1; font-weight: 900; }
.sidebar-clock small { display: block; margin-top: .4rem; color: var(--muted); }

.sidebar-menu { display: grid; gap: .35rem; overflow-y: auto; padding-right: .15rem; }

.sidebar-menu > small { margin: .3rem .4rem; color: var(--muted); font-weight: 750; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.sidebar-group-label { margin: 1rem .4rem .15rem; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; opacity: .55; }
.sidebar-group-label:first-child { margin-top: .1rem; }

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 46px;
    padding: .6rem .72rem;
    border-radius: var(--radius-md);
    color: #475569;
    text-decoration: none;
    font-weight: 700;
    transition: background .14s, color .14s, box-shadow .14s;
}

.sidebar-menu a:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.sidebar-menu a.is-active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(67,97,238,.28);
}

.sidebar-menu a i { width: 26px; text-align: center; font-size: 1.1rem; }

.sidebar-user {
    padding: .65rem;
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    border: 1px solid var(--brand-soft-2);
    color: inherit;
    text-decoration: none;
}

.sidebar-logout {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .65rem;
    border-radius: var(--radius-md);
    color: var(--muted);
    text-decoration: none;
    font-size: .88rem;
    transition: background .15s, color .15s;
}
.sidebar-logout:hover { background: #fee2e2; color: #b91c1c; }

.sidebar-avatar {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
}

/* ── Print (A4) ───────────────────────────────────────── */

@media print {
    @page { size: A4 portrait; margin: 20mm 16mm 16mm; }

    .navbar, .no-print, .swal2-container, .app-navbar { display: none !important; }
    body::after { display: none !important; }

    html, body {
        background: #fff;
        color: #000;
        font-family: "TH Sarabun New", "Sarabun", "TH SarabunPSK", serif !important;
        font-size: 16pt;
        padding-bottom: 0;
    }

    main { padding: 0 !important; }

    .panel { padding: 0 !important; box-shadow: none; border: 0; border-radius: 0; }

    .official-print {
        max-width: none; width: 100%;
        color: #000;
        font-family: "TH Sarabun New", "Sarabun", "TH SarabunPSK", serif !important;
        font-size: 16pt;
        line-height: 1.35;
    }

    .official-print h2 { margin: 0 0 10pt; font-size: 18pt; font-weight: 700; }
    .official-line { margin-bottom: 2pt; }
    .official-paragraph { margin: 8pt 0; text-indent: 50pt; }
    .official-signature { width: 260pt; margin-top: 10pt; }
    .signature-line { margin: 26pt 0 2pt; }
    .official-command { padding: 5pt 0 0; border: 0; background: #fff; }
    .official-form-grid { grid-template-columns: .9fr 1.1fr; gap: 10pt; margin-top: 10pt; page-break-inside: avoid; }

    .official-stat-table,
    .official-sign-box,
    .official-opinion-box {
        font-family: "TH Sarabun New", "Sarabun", "TH SarabunPSK", serif !important;
        font-size: 16pt; line-height: 1.25;
    }

    .official-stat-table th,
    .official-stat-table td { padding: 3pt 4pt; border-color: #000; }
    .official-sign-box, .official-opinion-box { padding: 0; }
    .official-sign-box { min-height: 78pt; }
    .official-opinion-box { min-height: 132pt; }
    .dotted-line { height: 17pt; border-bottom-color: #000; }
}

/* ── Responsive ───────────────────────────────────────── */

/* ≤ 1199px */
@media (max-width: 1199.98px) {
    .dashboard-hero { grid-template-columns: 1fr; }
    .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .quick-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .leave-quota-panel { position: static; }
    .official-form-grid { grid-template-columns: 1fr; }
    .dashboard-hero .hero-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
}

/* ── Sidebar (all screens) ─────────────────────────────── */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1050;
    width: 260px;
    padding: 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid rgba(255,255,255,.50);
    background: rgba(255,255,255,.75);
    box-shadow: 2px 0 20px rgba(30,41,59,.08);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
}

/* Desktop: always visible */
@media (min-width: 992px) {
    body:has(.app-sidebar) { padding-left: 260px; }
    .app-sidebar { transform: translateX(0) !important; }
    .app-menu-btn { display: none !important; }
    main.container-fluid {
        max-width: none;
        padding-left: 1.8rem !important;
        padding-right: 1.8rem !important;
    }
}

/* Mobile: slide-in overlay */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 1045;
        background: rgba(15,23,42,.28);
        backdrop-filter: blur(6px) saturate(140%);
        -webkit-backdrop-filter: blur(6px) saturate(140%);
    }
    .app-navbar { min-height: auto; padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); padding-bottom: .6rem; }
    .nav-user { align-items: flex-start !important; margin-top: .7rem; }
    .page-head { align-items: flex-start; flex-direction: column; gap: .6rem; }
    .page-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }

    /* table scroll ทุก panel */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .dt-container, .dt-layout-cell { overflow: visible !important; }
    .dt-scroll-body, .dt-scroll-head { overflow-x: auto !important; }
}

/* ≤ 991px */
@media (max-width: 991.98px) {
    .app-navbar { margin-left: 0; }
}


/* ≤ 767px */
@media (max-width: 767.98px) {
    .login-shell { padding: .85rem; }

    .login-card {
        min-height: 0;
        grid-template-columns: 1fr;
        border-radius: 20px;
    }

    .login-showcase { padding: 1.4rem 1.2rem; gap: .9rem; }
    .login-feature-list { display: none; }
    .login-showcase-stats { gap: .6rem; }
    .login-form-panel { padding: 1.25rem; }
}

/* ≤ 575px */
@media (max-width: 575.98px) {
    html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

    body { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

    main.container-fluid {
        width: 100% !important; max-width: none !important;
        padding-left: .8rem !important;
        padding-right: .8rem !important;
        padding-top: 1rem !important;
        overflow-x: hidden;
    }

    .app-navbar .container-fluid {
        width: 100%; max-width: 100%;
        padding-left: .8rem !important;
        padding-right: .8rem !important;
    }

    .navbar, .app-navbar, .panel, .page-head,
    .dashboard-hero, .dashboard-year-panel, .dashboard-recent-panel,
    .form-workspace, .timeline-panel, .approval-panel, .admin-table-panel,
    .report-filter-panel, .report-chart-panel, .report-table-panel,
    .leave-detail-panel, .profile-panel {
        width: 100%; max-width: 100%; min-width: 0;
    }

    .row { max-width: 100%; margin-left: 0; margin-right: 0; }
    .row > * { min-width: 0; }

    .table-responsive { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { width: 100%; }
    .form-control, .form-select, .btn { max-width: 100%; }

    .app-brand { gap: .5rem; max-width: calc(100% - 60px); min-width: 0; }
    .app-brand-icon, .app-menu-btn, .nav-icon-btn { width: 38px; height: 38px; font-size: 1.05rem; }
    .app-menu-btn { margin-right: .45rem; }

    .app-brand strong, .app-brand small {
        max-width: min(180px, calc(100vw - 130px));
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    .profile-chip { min-height: 38px; padding: .18rem .52rem .18rem .22rem; }
    .profile-chip img { width: 28px; height: 28px; }

    .panel { border-radius: var(--radius-lg); }
    .panel-pad { padding: .88rem; }

    .page-actions > *, .page-actions .btn, .page-actions form, .page-actions .form-select { width: 100%; }

    .leave-form-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .6rem !important;
    }

    .leave-form-actions .btn {
        width: 100%;
        min-height: 44px;
        white-space: nowrap;
    }

    .dashboard-hero-full {
        width: 100%;
        margin-left: 0; margin-right: 0;
        padding: 0;
    }

    .dashboard-hero .hero-stats,
    .dashboard-hero-full .hero-stats { grid-template-columns: repeat(2, 1fr); gap: .65rem; }

    .dashboard-hero .hero-stat,
    .dashboard-hero-full .hero-stat { min-height: 90px; padding: .88rem 1rem; }

    .dashboard-recent-panel .dt-layout-row:first-child { grid-template-columns: 1fr; gap: .45rem; }
    .dashboard-recent-panel .dt-container > .row:first-child { display: grid; grid-template-columns: 1fr; margin-left: 0; margin-right: 0; }
    .dashboard-recent-panel .dt-container > .row:first-child > [class*="col-"] { width: 100%; max-width: 100%; padding-left: 0; padding-right: 0; }
    .dashboard-recent-panel .dt-layout-row:first-child .dt-layout-cell,
    .dashboard-recent-panel .dt-length,
    .dashboard-recent-panel .dt-search { width: 100%; text-align: left !important; }
    .dashboard-recent-panel .dt-search label,
    .dashboard-recent-panel .dt-length label { width: 100%; }
    .dashboard-recent-panel .dt-length label,
    .dashboard-recent-panel .dt-search { display: grid; grid-template-columns: 1fr; gap: .3rem; }
    .dashboard-recent-panel .dt-search input { width: 100%; max-width: 100%; margin-left: 0; margin-top: .3rem; }
    .dashboard-recent-panel .dt-length select { min-width: 72px; }

    .dashboard-year-panel { align-items: stretch; flex-direction: column; gap: .7rem; }
    .dashboard-year-form { width: 100%; min-width: 0; flex-direction: column; align-items: stretch; }
    .dashboard-year-form .form-select, .dashboard-year-form .btn { width: 100%; }

    .dt-container > .row:first-child { display: grid; grid-template-columns: 1fr; margin-left: 0; margin-right: 0; }
    .dt-container > .row:first-child > [class*="col-"] { width: 100%; max-width: 100%; padding-left: 0; padding-right: 0; }
    .dt-container .dt-length, .dt-container .dt-search { width: 100%; text-align: left !important; }
    .dt-container .dt-length label, .dt-container .dt-search { display: grid; grid-template-columns: 1fr; gap: .3rem; }
    .dt-container .dt-search input { width: 100%; max-width: 100%; margin-left: 0; }
    .dt-container .dt-length select { min-width: 72px; width: max-content; }

    .quick-stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
    .quick-stat-card { min-height: 76px; padding: .7rem .78rem; }
    .quick-icon { width: 38px; height: 38px; font-size: .96rem; }

    /* stat cards ใน report */
    .report-stat-grid .col-md-2,
    .report-stat-grid .col-md-3,
    .report-stat-grid .col-md-4 { flex: 0 0 50%; max-width: 50%; }

    /* section-head wrap */
    .section-head { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .section-head .btn { align-self: flex-start; }

.status-timeline { gap: .4rem; }
    .status-timeline::before { top: 21px; left: 17%; right: 17%; }
    .status-timeline-step span { width: 42px; height: 42px; font-size: .88rem; }
    .status-timeline-step strong { font-size: .76rem; }

    .leave-detail-section { padding: .68rem; }
    .leave-detail-grid { grid-template-columns: 1fr; }
    .leave-detail-item { grid-template-columns: 88px minmax(0, 1fr); gap: .38rem; padding: .38rem 0; }
    .cancel-readonly-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem .75rem; }

    .timeline-card { padding: .45rem .55rem; }
    .timeline-card-top { flex-wrap: wrap; }
    .timeline-card-bottom { flex-wrap: wrap; gap: .4rem; }
    .leave-steps { flex-wrap: nowrap; overflow-x: auto; }
    .step-connector { min-width: 6px; max-width: 14px; }

    .server-leave-filters-wrap .leave-filter-keyword,
    .server-leave-filters-wrap .leave-filter-sm,
    .server-leave-filters-wrap .leave-filter-xs {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .report-filter-form .form-select, .report-filter-form .form-control { min-width: 100%; }
    .report-year-field, .report-year-field .form-select { min-width: 100%; }

    .report-chart-panel { overflow: hidden; width: 100%; max-width: 100%; min-width: 0; }
    .report-table-panel { overflow: visible; width: 100%; max-width: 100%; min-width: 0; }
    .report-stack, .report-filter-panel, .report-stack > section { width: 100%; max-width: 100%; min-width: 0; }

    .report-chart-grid { --bs-gutter-x: 0; margin-left: 0; margin-right: 0; max-width: 100%; min-width: 0; width: 100%; }
    .report-chart-grid > [class*="col-"] { flex: 0 0 100%; max-width: 100%; min-width: 0; padding-left: 0; padding-right: 0; }

    .chart-box { padding: .6rem; min-height: 200px; max-width: 100%; overflow: hidden; }
    .chart-box * { min-width: 0; }
    .chart-box-head { align-items: flex-start; flex-direction: column; gap: .4rem; }
    .chart-expand-btn { width: 100%; }
    .chart-box canvas { height: 198px !important; max-height: 198px; max-width: 100% !important; }
    .chart-box.is-expanded canvas#leaveTypeChart { height: 300px !important; max-height: 300px; }

    .report-table-panel .dt-container,
    .report-table-panel .dt-layout-row,
    .report-table-panel .dt-layout-cell { max-width: 100%; overflow: visible; min-width: 0; }
    .report-table-panel .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .report-table-panel .dt-layout-row { display: grid !important; grid-template-columns: 1fr; gap: .45rem; }
    .report-table-panel .dt-search, .report-table-panel .dt-length { text-align: left !important; width: 100%; }
    .report-table-panel .dt-search input, .report-table-panel .dt-length select { max-width: 100%; }
    .report-summary-grid { grid-template-columns: 1fr; gap: .75rem; }

    /* admin table panels */
    .admin-table-panel .dt-container,
    .admin-table-panel .dt-layout-row,
    .admin-table-panel .dt-layout-cell { overflow: visible; min-width: 0; }
    .admin-table-panel .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .table-responsive { margin-inline: -.15rem; }
    .approval-reply-group { grid-template-columns: 1fr; }

    .report-nav-grid { grid-template-columns: 1fr; }
    .report-nav-card { grid-template-columns: 44px minmax(0, 1fr) 22px; min-height: 92px; padding: .82rem; border-radius: var(--radius-lg); }
    .report-nav-icon { width: 44px; height: 44px; border-radius: 14px; }

    .telegram-setting-row { grid-template-columns: 1fr; }
}

/* ≥ 1200px */
@media (min-width: 1200px) {
    .dashboard-hero-full .hero-stats {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        align-items: stretch;
        width: 100%;
    }

    .dashboard-hero-full .hero-stat { width: 100%; min-height: 110px; padding: 1.1rem 1.2rem; }
}

/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}

/* Mobile usability pass: keep controls readable and touch-friendly. */
@media (max-width: 575.98px) {
    .page-title { font-size: 1.28rem; line-height: 1.25; }
    .page-subtitle { font-size: .84rem; line-height: 1.45; }
    .page-head { margin-bottom: 1rem; }

    .btn,
    .form-control,
    .form-select { min-height: 42px; }
    .btn-sm { min-height: 38px; }
    .form-label { margin-bottom: .35rem; font-size: .9rem; }
    textarea.form-control { min-height: 96px; }

    .modal-dialog { margin: .5rem; }
    .modal-content { border-radius: 14px; }
    .modal-header,
    .modal-body,
    .modal-footer { padding: .85rem; }
    .modal-footer { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
    .modal-footer > * { width: 100%; margin: 0; }

    .leave-approval-days-summary { align-items: flex-start; padding: .75rem .8rem; }
    .leave-approval-days-summary strong { font-size: 1.2rem; }
    .leave-approval-days-summary span { line-height: 1.45; }

    .ap-shell { width: 100%; max-width: 100%; padding: .75rem; }
    .ap-card { width: 100%; max-width: 100%; }
    .ap-card-head { gap: .65rem; align-items: flex-start; }
    .ap-card-head .badge { white-space: normal; text-align: center; }
    .ap-leave-dates { line-height: 1.5; }
    .ap-working-days-review { margin-inline: 0; }

    .leave-detail-item small { font-size: .75rem; }
    .leave-detail-item strong { overflow-wrap: anywhere; word-break: break-word; }
    .official-system-note { overflow-wrap: anywhere; }

    .table-responsive { border-radius: 8px; }
    .table-responsive .table { margin-bottom: 0; }
    .table th, .table td { white-space: nowrap; }
    .table th:first-child, .table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface, #fff); }

    .server-leave-filters { width: 100%; }
    .server-leave-filters .form-control,
    .server-leave-filters .form-select { min-height: 40px; }

    .quick-stat-card { min-width: 0; }
    .quick-stat-card .lsc-name,
    .quick-stat-card .lsc-days,
    .quick-stat-card .lsc-times { overflow-wrap: anywhere; }

    .profile-form .row > *,
    .official-leave-form .row > * { min-width: 0; }

    .leave-view-action-group { flex-direction: column; }
    .leave-view-action-group,
    .leave-view-action-group .btn { width: 100%; }
}

/* ── File Attach UI ── */
.attach-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 1.35rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s, background .18s;
    background: #fbfdff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}
.attach-drop-zone.drag-over {
    border-color: var(--brand);
    background: rgba(67,97,238,.06);
}
.attach-drop-zone.is-invalid {
    border-color: #dc2626;
    background: rgba(220,38,38,.05);
}
.attachment-feedback:not(:empty) {
    display: block;
}
.attach-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .6rem;
    border-radius: 8px;
    font-size: var(--text-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}
.attach-row.uploading { opacity: .7; }
.attach-row.error { border-color: #fca5a5; background: #fff1f1; }
.attach-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: var(--text-xs); white-space: nowrap; }
.attach-remove { font-size: var(--text-xs) !important; line-height: 1 !important; }
