/* ============================================================
   DAR System — ISO Color Scheme: 60-30-10 Rule
   60% #EEF2F7 Cool Blue-Gray  (ความสะอาด, ความแม่นยำ)
   30% #1C3557 Deep Navy       (ความน่าเชื่อถือ, มาตรฐาน, โครงสร้าง)
   10% #2563EB ISO Blue        (การดำเนินการ, คุณภาพ, มาตรฐานสากล)
   ============================================================ */

:root {
    /* ── 10% Accent — ISO Blue ── */
    --accent:       #2563EB;
    --accent-hover: #1D4ED8;
    --accent-light: rgba(37,99,235,0.09);

    /* ── 30% Secondary — Deep Navy ── */
    --navy:         #1C3557;
    --navy-2:       #2E4F7A;
    --navy-light:   rgba(28,53,87,0.08);

    /* ── 60% Dominant — Cool Blue-Gray ── */
    --bg:           #EEF2F7;
    --surface:      #E0E9F4;
    --white:        #FFFFFF;

    /* ── Neutrals ── */
    --dark:         #0F1D35;
    --dark-2:       #3D5470;
    --gray:         #6B82A0;
    --border:       #C4D4E8;

    /* ── Legacy aliases (backward compat) ── */
    --gold:         var(--accent);
    --gold-hover:   var(--accent-hover);
    --gold-light:   var(--accent-light);
    --green-soft:   var(--surface);
    --green-border: var(--border);
    --red:          var(--accent);
    --red-hover:    var(--accent-hover);
    --red-light:    var(--accent-light);
    --dar-dark:     var(--navy);
    --dar-mid:      var(--dark);
    --dar-light:    var(--gray);
    --dar-bg:       var(--bg);
    --dar-accent:   var(--accent);
    --dar-text:     var(--dark);
    --dar-text-inv: var(--white);

    /* ── Layout ── */
    --sidebar-w:    116px;
    --topbar-h:     62px;

    /* ── Shadows ── */
    --shadow-sm:  0 1px 4px rgba(28,53,87,0.08);
    --shadow-md:  0 4px 18px rgba(28,53,87,0.13);

    /* ── Radius ── */
    --r:    0.75rem;
    --r-sm: 0.5rem;

    /* ── Typography ── */
    --fs-body:    1rem;
    --fs-sm:      0.875rem;
    --fs-xs:      0.75rem;
    --fs-h1:      1.75rem;
    --fs-h2:      1.5rem;
    --fs-h3:      1.25rem;
    --lh:         1.5;
    --fw-body:    400;
    --fw-heading: 600;
}

/* ===== Font ===== */
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-Thin.ttf'); font-weight:100; font-display:swap; }
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-Light.ttf'); font-weight:300; font-display:swap; }
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-Text.ttf'); font-weight:400; font-display:swap; }
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-Medium.ttf'); font-weight:500; font-display:swap; }
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-SemiBold.ttf'); font-weight:600; font-display:swap; }
@font-face { font-family:'Sukhumvit Set'; src:url('../fonts/sukhumvit/SukhumvitSet-Bold.ttf'); font-weight:700; font-display:swap; }

/* ===== Base =====
   overflow:hidden ตั้งใจให้ logged-in layout (scroll เกิดใน .dar-scroll-wrap)
   แต่สำหรับ anonymous user (public Master List) ที่ไม่มี .dar-main wrapper
   → body ต้องเลื่อนได้
   ใช้ :has() ตรวจว่ามี .dar-main ใน DOM ไหม:
   - มี (logged-in)  → overflow:hidden — scroll ใน .dar-scroll-wrap
   - ไม่มี (anonymous) → body scroll ตามปกติ                                */
html, body { height: 100%; }
body:has(.dar-main) { overflow: hidden; }
/* fallback สำหรับ browser ที่ไม่รองรับ :has() (~ 5% global)
   — overflow ปกติของ body คือ visible อยู่แล้ว ไม่ต้องตั้งเพิ่ม          */

/* Root font-size: ปรับจาก default 16px → 18px เพื่ออ่านสบายตามากขึ้น
   ทุก rem-based value ทั้งระบบจะขยายตาม +12.5% อัตโนมัติ
   - body 16→18, sm 14→15.75, xs 12→13.5, h1 28→31.5, h2 24→27, h3 20→22.5
   หมายเหตุ: line-height (1.5) คงเดิม → spacing scale ตามขนาดอักษร     */
html { font-size: 18px; }

/* บนมือถือ scale ลงเพื่อให้ table/UI กระชับขึ้น */
@media (max-width: 575px) {
    html { font-size: 16px; }
}

body {
    font-family: 'Sukhumvit Set','Sarabun','Segoe UI',sans-serif;
    font-size: var(--fs-body);
    font-weight: var(--fw-body);
    line-height: var(--lh);
    background: var(--bg);
    color: var(--dark);
}
h1,.h1 { font-size:var(--fs-h1); font-weight:var(--fw-heading); line-height:var(--lh); }
h2,.h2 { font-size:var(--fs-h2); font-weight:var(--fw-heading); line-height:var(--lh); }
h3,.h3 { font-size:var(--fs-h3); font-weight:var(--fw-heading); line-height:var(--lh); }
h4,.h4 { font-size:1.1rem;       font-weight:var(--fw-heading); line-height:var(--lh); }
h5,.h5 { font-size:var(--fs-body); font-weight:var(--fw-heading); line-height:var(--lh); }
h6,.h6 { font-size:var(--fs-sm);  font-weight:var(--fw-heading); line-height:var(--lh); }
small,.small { font-size:var(--fs-sm); }

/* ══════════════════════════════════════════════════
   HEADER BAR — Full-width top navigation
══════════════════════════════════════════════════ */
.dar-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 300;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0;
    box-shadow: var(--shadow-sm);
}
.dar-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 1rem;
    padding: 4px 8px;
    border-radius: 10px;
    transition: background 0.15s;
}
.dar-header-brand:hover { background: var(--navy-light); }
.dar-header-brand img {
    height: 36px;
    width: auto;
    object-fit: contain;
}
.dar-header-brand-text {
    font-size: 1rem;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.dar-header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    overflow: visible;
}
.dar-header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 8px;
    color: var(--dark-2);
    text-decoration: none;
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1;
}
.dar-header-link .bi { font-size: 0.95rem; }
.dar-header-link:hover {
    background: var(--navy-light);
    color: var(--navy);
}
.dar-header-link.active {
    background: var(--accent);
    color: var(--white);
    font-weight: 600;
}
.dar-header-link.has-active {
    background: var(--accent-light);
    color: var(--accent);
}
.dar-header-link.dropdown-toggle::after { margin-left: 4px; }
.dar-header-sep {
    width: 1px; height: 20px;
    background: var(--border);
    margin: 0 6px;
    flex-shrink: 0;
}
.dar-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.dar-header-bell {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--dark-2);
    text-decoration: none;
    font-size: 1.05rem;
    position: relative;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.dar-header-bell:hover, .dar-header-bell.active {
    background: var(--accent-light);
    color: var(--accent);
}
.dar-header-bell-badge {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: #F87171;
    border-radius: 50%;
    border: 1.5px solid var(--bg);
}
.dar-header-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px 5px 5px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
}
.dar-header-profile:hover { background: var(--navy-light); }
.dar-header-profile-info { line-height: 1.25; text-align: left; }
.dar-header-profile-name {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}
.dar-header-profile-role { font-size: 0.68rem; color: var(--gray); }
.dar-header-profile .bi-chevron-down {
    font-size: 0.6rem;
    color: var(--gray);
    margin-left: 2px;
}
/* Avatar on light header: use navy color */
.dar-header .dar-avatar-sm { background: var(--navy); }

/* ══════════════════════════════════════════════════
   SIDEBAR — Deep Navy Pill Style (30%)
══════════════════════════════════════════════════ */
.dar-sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;   /* จัดกึ่งกลางแนวตั้ง */
    position: fixed;
    top: 0; left: 0;
    z-index: 200;
    padding: 10px 8px;
    gap: 8px;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}
.dar-sidebar-inner { display: contents; }

/* Logo pill — Navy */
.dar-sidebar-logo {
    width: 56px; height: auto;
    background: var(--navy);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    flex-shrink: 0;
    padding: 12px 0;
    transition: box-shadow 0.15s;
}
.dar-sidebar-logo:hover { box-shadow: 0 6px 24px rgba(28,53,87,0.35); }

.dar-sidebar-logo-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.dar-sidebar-logo:hover .dar-sidebar-logo-icon {
    transform: scale(1.08);
}
.dar-sidebar-logo-icon img {
    width: 22px; height: 22px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.dar-sidebar-brand {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.65);
    line-height: 1;
    text-transform: uppercase;
}

/* Desktop: ซ่อน sidebar logo เพราะ topbar แสดงโลโก้แทนแล้ว */
@media (min-width: 992px) {
    .dar-sidebar-logo { display: none; }
    .dar-sidebar-logo + .dar-sidebar-divider { display: none; }
}

/* Nav pill — Navy */
.dar-sidebar-nav {
    background: var(--navy);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    gap: 8px;
    flex: 0 0 auto;            /* ไม่ยืด — พอดีกับเมนู */
    overflow: visible;
    width: 56px;
}
.dar-sidebar-nav::-webkit-scrollbar { display: none; }

.dar-sidebar-bottom {
    background: var(--navy);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    gap: 2px;
    flex-shrink: 0;
    width: 56px;
}

.dar-nav-section  { display: none; }
.dar-sidebar-divider { display: none; }

/* Nav link */
.dar-nav-link {
    width: 44px; height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: rgba(255,255,255,0.50);
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.25,0.46,0.45,0.94),
                box-shadow 0.3s ease,
                background-color 0.3s ease,
                color 0.3s ease,
                border-radius 0.3s ease;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.dar-nav-link .bi { font-size: 1.15rem; transition: transform 0.3s cubic-bezier(0.25,0.46,0.45,0.94); }
.dar-nav-link:hover {
    background: rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.95);
    border-radius: 50%;
    transform: scale(1.16);
    box-shadow: 0 4px 16px rgba(28,53,87,0.45);
    z-index: 10;
}
.dar-nav-link:hover .bi { transform: scale(1.08); }
.dar-nav-link.active {
    background: var(--accent);
    color: var(--white);
    border-radius: 50%;
    box-shadow: 0 3px 12px rgba(37,99,235,0.45);
}
.dar-nav-link.active .bi { color: var(--white); }

/* Tooltip */
.dar-sidebar-tooltip {
    position: fixed;
    background: var(--navy);
    color: var(--white);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 12px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: var(--shadow-md);
}
.dar-sidebar-tooltip.show { opacity: 1; }

/* Notification dot */
.dar-nav-badge {
    position: absolute;
    top: 7px; right: 7px;
    width: 7px; height: 7px;
    background: #F87171;
    border-radius: 50%;
    border: 1.5px solid var(--navy);
}

/* ══════════════════════════════════════════════════
   MAIN LAYOUT
══════════════════════════════════════════════════ */
.dar-main {
    margin-left: 0;
    width: 100%;
    padding-top: var(--topbar-h);
    /* 100vh บน iOS Safari = รวม URL bar → คอนเทนต์ใต้ fold ถูกบัง
       100dvh (dynamic viewport height) = ความสูงที่มองเห็นจริงตอน URL bar
       ย่อ/ขยาย → user เลื่อนถึงท้ายคอนเทนต์ได้บน iPad/iOS Safari      */
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.dar-scroll-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: none;
    /* iOS: smooth touch scrolling + กัน scroll bubble ขึ้นไป body
       ทำให้ Bootstrap modal-open ไม่ block scroll ของ container นี้      */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.dar-scroll-wrap::-webkit-scrollbar { display: none; }

/* Topbar */
.dar-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 1.5rem;
    flex-shrink: 0;
    pointer-events: none;
    z-index: 100;
    background: var(--bg);
}
.dar-toggle-btn {
    display: none;
    background: none; border: none;
    padding: 0.4rem 0.5rem;
    color: var(--dark); cursor: pointer;
    border-radius: var(--r-sm);
    font-size: 1.2rem; line-height: 1;
    flex-shrink: 0;
}
.dar-toggle-btn:hover { background: var(--surface); }
.dar-topbar-right { display:flex; align-items:center; gap:0.5rem; margin-left:auto; }

/* ══════════════════════════════════════════════════
   FLOATING TOPBAR
══════════════════════════════════════════════════ */
.dar-floatbar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: all;
}
.dar-floatbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    padding: 6px 10px;
}
.dar-floatbar-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--dark-2); text-decoration: none;
    position: relative; transition: all 0.15s; font-size: 1rem;
}
.dar-floatbar-btn:hover { background: var(--accent-light); color: var(--accent); }
.dar-floatbar-profile {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; padding: 3px 6px;
    border-radius: 10px; cursor: pointer; transition: background 0.15s;
}
.dar-floatbar-profile:hover { background: var(--accent-light); }
.dar-floatbar-profile .bi-chevron-down { font-size: 0.625rem; color: var(--gray); margin-left: 2px; }
.dar-avatar-sm {
    width: 32px; height: 32px; background: var(--navy); border-radius: 50%;
    color: var(--white); font-size: var(--fs-xs); font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; text-transform: uppercase;
}
.dar-floatbar-info { line-height: 1.25; text-align: left; }
.dar-floatbar-name { font-size: var(--fs-sm); font-weight: var(--fw-heading); color: var(--dark); }
.dar-floatbar-role { font-size: var(--fs-xs); color: var(--gray); }
.dar-floatbar-sep {
    width: 1px; height: 24px;
    background: var(--border);
    margin: 0 4px; flex-shrink: 0;
}
.dar-floatbar-logout { color: #DC2626 !important; }
.dar-floatbar-logout:hover { background: rgba(220,38,38,0.08) !important; color: #DC2626 !important; }
.dar-floatbar-btn.active { background: var(--accent); color: var(--white); }
.dar-floatbar-btn.active .bi { color: var(--white); }

/* Notification count badge */
.dar-notif-count {
    position: absolute; top: 3px; right: 3px;
    background: #EF4444; color: var(--white);
    font-size: 0.625rem; font-weight: 700; border-radius: 999px;
    padding: 1px 4px; min-width: 16px; text-align: center;
    line-height: 1.4; border: 1.5px solid var(--white);
}

/* Content */
.dar-content { padding: 1.5rem; flex: 1; }

/* Overlay */
.dar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,29,53,0.40); z-index: 180;
}
.dar-overlay.show { display: block; }

/* ══════════════════════════════════════════════════
   RESPONSIVE — Tablet (< 992px)
══════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    /* Main: full width (already set globally, kept for clarity) */
    .dar-main { margin-left: 0; width: 100%; }

    /* Tables smaller */
    .table-responsive .table { font-size: var(--fs-xs); }
    .table td, .table th { padding: 0.5rem 0.65rem; }

    /* Content padding */
    .dar-content { padding: 1.125rem 1.25rem 2rem; }
}

/* ══════════════════════════════════════════════════
   BOOTSTRAP OVERRIDES
══════════════════════════════════════════════════ */

/* Cards */
.card {
    background: var(--white);
    border-color: var(--border);
    border-radius: var(--r);
    color: var(--dark);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: var(--r) var(--r) 0 0 !important;
    padding: 0.85rem 1.25rem;
    color: var(--dark) !important;
    font-weight: 600;
}
.card-header.bg-white,
.card-header.bg-light,
.card-header.bg-transparent {
    background: var(--white) !important;
    color: var(--dark) !important;
    border-bottom: 1px solid var(--border) !important;
}
.card-header.bg-white *, .card-header.bg-light * { color: inherit; }
.card-footer {
    background: var(--bg) !important;
    border-top: 1px solid var(--border) !important;
}

/* Tables */
.table {
    color: var(--dark);
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--accent-light);
}
.table th {
    font-size: var(--fs-xs); font-weight: var(--fw-heading);
    text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--gray); border-color: var(--border);
    background: var(--surface);
}
.table td { vertical-align: middle; border-color: var(--border); font-size: var(--fs-sm); }
.table-bordered, .table-bordered th, .table-bordered td { border-color: var(--border); }
.table-light { --bs-table-bg: var(--surface); }

/* Forms */
.form-control, .form-select {
    background-color: var(--white); border-color: var(--border);
    color: var(--dark); border-radius: var(--r-sm); font-size: var(--fs-body);
}
.form-control:focus, .form-select:focus {
    background-color: var(--white); border-color: var(--accent); color: var(--dark);
    box-shadow: 0 0 0 0.18rem var(--accent-light);
}
.form-control::placeholder { color: #A0B4C8; }
.form-control[readonly], .form-control[disabled] { background: var(--bg); color: var(--gray); }
.form-label { font-size: var(--fs-sm); margin-bottom: 0.3rem; color: var(--dark); }
.form-text { color: var(--gray); }
.form-control-plaintext { color: var(--gray); background: var(--bg) !important; border-color: var(--border) !important; }
.form-check-input { background: var(--white); border-color: var(--border); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-label { color: var(--dark); }
.input-group-text { background: var(--surface); border-color: var(--border); color: var(--dark); }

/* Buttons */
.btn { border-radius: var(--r-sm); font-weight: 500; font-size: var(--fs-sm); }
.btn-sm { font-size: var(--fs-xs); }
.btn-primary {
    background: var(--accent) !important; border-color: var(--accent) !important;
    color: var(--white) !important; font-weight: 600;
}
.btn-primary:hover, .btn-primary:active {
    background: var(--accent-hover) !important; border-color: var(--accent-hover) !important;
    color: var(--white) !important;
}
.btn-secondary {
    background: var(--navy) !important; border-color: var(--navy) !important;
    color: var(--white) !important;
}
.btn-secondary:hover { background: var(--navy-2) !important; }
.btn-warning {
    background: #D97706 !important; border-color: #D97706 !important;
    color: var(--white) !important; font-weight: 600;
}
.btn-warning:hover { background: #B45309 !important; }
.btn-success {
    background: #16A34A !important; border-color: #16A34A !important; color: var(--white) !important;
}
.btn-success:hover { background: #15803D !important; }
.btn-outline-primary { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--white); }
.btn-outline-secondary { border-color: var(--border); color: var(--dark-2); }
.btn-outline-secondary:hover { background: var(--surface); border-color: var(--border); color: var(--dark); }
.btn-outline-danger { border-color: #FCA5A5; color: #DC2626; }
.btn-outline-danger:hover { background: #DC2626; color: var(--white); border-color: #DC2626; }
.btn-outline-warning { border-color: #D97706; color: #D97706; }
.btn-outline-warning:hover { background: #D97706; color: var(--white); }
.btn-outline-dark { border-color: var(--navy); color: var(--navy); }
.btn-outline-dark:hover { background: var(--navy); color: var(--white); }
.btn-link { color: var(--dark-2); }
.btn-link:hover { color: var(--accent); }

/* Badges */
.badge { font-weight: 500; letter-spacing: 0.3px; }
.badge.bg-primary  { background: var(--accent) !important; color: var(--white) !important; }
.badge.bg-warning  { background: #D97706 !important; color: var(--white) !important; }
.badge.bg-secondary{ background: var(--navy) !important; color: var(--white) !important; }
.badge.bg-light    { background: var(--surface) !important; color: var(--dark) !important; }
.badge.text-dark   { color: var(--dark) !important; }

/* Alerts */
.alert { border-radius: var(--r-sm); font-size: var(--fs-body); }
.alert-light   { background: var(--bg); border-color: var(--border); color: var(--dark); }
.alert-info    { background: rgba(37,99,235,0.07); border-color: var(--accent); color: #1E3A8A; }
.alert-warning { background: rgba(217,119,6,0.08); border-color: #D97706; color: #92400E; }
.alert-danger  { background: rgba(220,38,38,0.07); border-color: #DC2626; color: #7F1D1D; }
.alert-success { background: rgba(22,163,74,0.08); border-color: #16A34A; color: #14532D; }

/* Dropdown */
.dropdown-menu {
    background: var(--white); border-color: var(--border);
    border-radius: var(--r-sm); box-shadow: var(--shadow-md);
}
.dropdown-item { color: var(--dark); font-size: var(--fs-sm); }
.dropdown-item:hover { background: var(--accent-light); color: var(--accent); }
.dropdown-divider { border-color: var(--border); }
.dropdown-header { color: var(--gray); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; }

/* Nav tabs */
.nav-tabs { border-color: var(--border); }
.nav-tabs .nav-link { color: var(--gray); }
.nav-tabs .nav-link.active { background: var(--white); border-color: var(--border); color: var(--accent); font-weight: 600; }

/* List group */
.list-group-item { background: var(--white); border-color: var(--border); color: var(--dark); }
.list-group-item-action:hover { background: var(--accent-light); color: var(--dark); }

/* Modal */
.modal-content { background: var(--white); color: var(--dark); }
.modal-header, .modal-footer { border-color: var(--border); background: var(--surface); }
.modal-title { color: var(--dark); }

/* Pagination */
.page-link { background: var(--white); border-color: var(--border); color: var(--dark); }
.page-link:hover { background: var(--accent); border-color: var(--accent); color: var(--white); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: var(--white); }
.page-item.disabled .page-link { background: var(--bg); color: var(--gray); }

/* Text / BG utilities */
.text-muted { color: var(--gray) !important; }
.text-dark   { color: var(--dark) !important; }
.bg-white    { background: var(--white) !important; }
.bg-light    { background: var(--bg) !important; color: var(--dark) !important; }
hr { border-color: var(--border); }
.border { border-color: var(--border) !important; }
.display-6 { font-size: 2rem; }
.container-fluid { padding-bottom: 2rem; }

/* ══════════════════════════════════════════════════
   HOME DASHBOARD CARDS
══════════════════════════════════════════════════ */
.stat-card {
    border-radius: var(--r);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-card-icon {
    width: 48px; height: 48px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.stat-card-icon.red    { background: var(--accent-light); color: var(--accent); }
.stat-card-icon.dark   { background: var(--navy-light); color: var(--navy); }
.stat-card-icon.green  { background: rgba(22,163,74,0.10); color: #16A34A; }
.stat-card-icon.orange { background: rgba(217,119,6,0.10); color: #D97706; }
.stat-card-num   { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--dark); }
.stat-card-label { font-size: var(--fs-sm); color: var(--gray); margin-top: 0.2rem; }

/* Queue card */
.queue-card {
    border-radius: var(--r); overflow: hidden;
    border: 1px solid var(--border);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}
.queue-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.9rem 1.25rem; font-weight: 700; font-size: var(--fs-body);
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
/* Primary queue header — ISO Navy */
.queue-card-header.red  { background: var(--navy); color: var(--white); }
/* Secondary queue header — Dark Navy */
.queue-card-header.dark { background: var(--dark); color: var(--white); }
.queue-card-header.red  .btn-light,
.queue-card-header.dark .btn-light {
    background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.20);
    color: var(--white); font-size: var(--fs-sm);
}
.queue-card-header.red  .btn-light:hover,
.queue-card-header.dark .btn-light:hover { background: rgba(255,255,255,0.22); }
.queue-card-header .q-count {
    background: rgba(255,255,255,0.18); color: var(--white);
    font-size: var(--fs-xs); font-weight: 700;
    border-radius: 999px; padding: 2px 8px;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE — Phone (< 768px): bottom nav layout
══════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Space for fixed bottom nav */
    .dar-scroll-wrap {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
    .dar-content { padding: 0.875rem 0.875rem 1rem; }
    .dar-header { padding: 0 0.875rem; }

    /* Stat cards: always 2 per row on phone */
    [data-role-section] .col-sm-6 {
        flex: 0 0 50%; max-width: 50%; width: 50%;
    }

    /* Queue tables: hide middle columns (ประเภท/แผนก/ผู้ขอ) */
    .queue-card .table th:nth-child(3),
    .queue-card .table td:nth-child(3),
    .queue-card .table th:nth-child(4),
    .queue-card .table td:nth-child(4),
    .queue-card .table th:nth-child(5),
    .queue-card .table td:nth-child(5) { display: none; }

    /* Compact stat cards */
    .stat-card { padding: 0.875rem 1rem; gap: 0.75rem; }
    .stat-card-num { font-size: 1.5rem; }
    .stat-card-icon { width: 40px; height: 40px; font-size: 1rem; }

    /* Card spacing */
    .card-header { padding: 0.75rem 1rem; }
    .card-body { padding: 1rem; }

    /* Queue header responsive */
    .queue-card-header { padding: 0.75rem 1rem; font-size: var(--fs-sm); }
    .queue-card-header .btn-light { font-size: 0.72rem; padding: 0.2rem 0.6rem; }
    .queue-card-header .q-count { font-size: 0.65rem; padding: 1px 6px; }

    /* Role filter bar compact */
    #roleFilterBar .btn { font-size: 0.78rem !important; padding: 0.3rem 0.85rem !important; }

    /* Greeting compact */
    .mb-4 h4 { font-size: 1.15rem !important; }
}

/* ══════════════════════════════════════════════════
   TOGGLE SWITCH
══════════════════════════════════════════════════ */
.form-check.form-switch .form-check-input {
    width: 3rem; height: 1.6rem;
    cursor: pointer;
    background-color: #C4D4E8;
    border: none; border-radius: 999px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-size: 1.1rem; background-repeat: no-repeat;
    transition: background-color 0.25s ease;
    box-shadow: none; appearance: none; -webkit-appearance: none;
}
.form-check.form-switch .form-check-input:checked {
    background-color: var(--accent);
    border-color: transparent;
    background-position: right center;
}
.form-check.form-switch .form-check-input:not(:checked) { background-position: left center; }
.form-check.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem var(--accent-light); outline: none;
}
.form-check.form-switch {
    display: flex; align-items: center; gap: 0.5rem;
    padding-left: 0; min-height: unset;
}
.form-check.form-switch .form-check-input { margin: 0; flex-shrink: 0; }
.form-check.form-switch .form-check-label {
    font-size: var(--fs-body); margin: 0; cursor: pointer;
    transition: color 0.2s; color: var(--gray);
}
.form-check.form-switch .form-check-input:checked ~ .form-check-label {
    color: var(--dark); font-weight: 600;
}

/* ══════════════════════════════════════════════════
   TOPBAR — logo brand (ทุก breakpoint)
══════════════════════════════════════════════════ */
.dar-topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: all;  /* topbar มี pointer-events:none → ต้อง override */
}
.dar-topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    pointer-events: all;
}
.dar-topbar-brand-icon {
    height: 44px;
    width: auto;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.dar-topbar-brand-icon img {
    height: 44px;
    width: auto;
    object-fit: contain;
}
.dar-topbar-brand-text {
    font-size: 1rem;
    font-weight: 800;
    color: var(--navy);
    letter-spacing: 0.04em;
    white-space: nowrap;
    line-height: 1;
}

/* Hamburger button */
.dar-toggle-btn {
    display: none;
    width: 38px; height: 38px;
    border-radius: 10px;
    align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--dark-2);
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s;
}
.dar-toggle-btn:hover { background: var(--surface); }
.dar-toggle-btn:active { background: var(--navy-light); }

/* ══════════════════════════════════════════════════
   BOTTOM NAVIGATION BAR (phones < 768px only)
══════════════════════════════════════════════════ */
.dar-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--white);
    border-top: 1.5px solid var(--border);
    display: flex;
    align-items: stretch;
    z-index: 400;
    box-shadow: 0 -4px 20px rgba(28,53,87,0.12);
    /* iPhone safe area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dar-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--gray);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 500;
    padding: 6px 2px 4px;
    position: relative;
    transition: color 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.dar-bottom-nav-item .bi { font-size: 1.3rem; line-height: 1; }
.dar-bottom-nav-item span { line-height: 1.2; }
.dar-bottom-nav-item.active {
    color: var(--accent);
}
.dar-bottom-nav-item.active .bi {
    transform: translateY(-1px);
}
.dar-bottom-nav-item:active { transform: scale(0.88); opacity: 0.65; }

/* Notification count badge on bottom nav */
.dar-bottom-badge {
    position: absolute;
    top: 5px; left: calc(50% + 5px);
    background: #EF4444; color: white;
    font-size: 0.58rem; font-weight: 700;
    border-radius: 999px; padding: 1px 4px; min-width: 14px;
    text-align: center; line-height: 1.5;
    border: 1.5px solid var(--white);
    pointer-events: none;
}

/* Mobile admin offcanvas grid */
.mobile-admin-grid a { text-decoration: none; color: var(--dark-2); }
.mobile-admin-icon {
    width: 54px; height: 54px;
    background: var(--surface);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.45rem;
    margin: 0 auto 5px;
    transition: background 0.15s, transform 0.1s;
}
.mobile-admin-grid a:active .mobile-admin-icon {
    background: var(--accent-light);
    transform: scale(0.92);
}
.mobile-admin-grid .admin-label {
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
}

/* ══════════════════════════════════════════════════
   TOUCH-FRIENDLY: larger tap targets & iOS fixes
══════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    /* iOS: prevent auto-zoom when focusing inputs */
    .form-control,
    .form-select,
    textarea.form-control { font-size: 16px !important; }

    /* Larger touch areas */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .form-control,
    .form-select { min-height: 46px; }

    /* Dropdown items easier to tap */
    .dropdown-item {
        padding: 0.65rem 1rem;
        min-height: 44px;
        display: flex; align-items: center;
    }

    /* Bigger nav links */
    .dar-nav-link { width: 48px; height: 48px; }
    .dar-floatbar-btn { width: 40px; height: 40px; }
}

/* ══════════════════════════════════════════════════
   OFFCANVAS THEME OVERRIDES
══════════════════════════════════════════════════ */
.offcanvas { background: var(--white); color: var(--dark); }
.offcanvas-header { background: var(--surface); border-bottom: 1px solid var(--border) !important; }
.offcanvas-title { color: var(--dark); font-weight: 700; }

/* ══════════════════════════════════════════════════
   PAGINATION (responsive)
══════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .pagination { flex-wrap: wrap; gap: 2px; }
    .page-link { padding: 0.35rem 0.65rem; font-size: var(--fs-xs); min-height: 36px; display: flex; align-items: center; }
}

/* ══════════════════════════════════════════════════
   FILTER FORM (responsive)
══════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Filter forms: full-width inputs on phone */
    form.d-flex.flex-wrap .form-control,
    form.d-flex.flex-wrap .form-select { min-width: 0; width: 100%; flex: 1 1 100%; }
    form.row .form-control,
    form.row .form-select { width: 100%; }
}

/* ══════════════════════════════════════════════════
   DAR REGISTRY TABLE  (.dar-reg)
══════════════════════════════════════════════════ */
.dar-reg { font-size: .875rem; }

/* Header */
.dar-reg th {
    padding: 11px 14px !important;
    background: #F4F7FB !important;
    border-bottom: 2px solid var(--border) !important;
    border-top: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    white-space: nowrap;
    vertical-align: middle;
    text-align: center !important;
}

/* sticky table header ถูกถอดออกชั่วคราว — เคยทำให้แถวแรกหายและ layout เพี้ยน */
.dar-reg th .th-main {
    display: block; font-size: .8rem; font-weight: 700;
    color: var(--dark); line-height: 1.3;
}
.dar-reg th .th-sub {
    display: block; font-size: .67rem; font-weight: 500;
    color: var(--gray); line-height: 1.2; margin-top: 2px;
}

/* Body cells */
.dar-reg td { padding: 10px 14px !important; }

/* Smooth cell bg transition for hover */
.dar-reg tbody td { transition: background-color .1s ease; }

/* Continuation row (2nd+ item of same DAR) */
/* ── Item ที่ไม่ถูกอนุมัติ (returned / rejected) — ตัวอักษรเทาจาง ──
   ใช้ :not([rowspan]) เพื่อให้กระทบเฉพาะ cell ระดับ Item
   ไม่กระทบ cell ระดับ DAR (DAR No., สถานะ, ปุ่ม ที่ใช้ rowspan) */
.dar-reg tr.dar-item-unapproved td:not([rowspan]),
.dar-reg tr.dar-item-unapproved td:not([rowspan]) * {
    color: var(--gray) !important;
    opacity: .7;
}

.dar-reg .dar-cont td {
    border-top: 1px dashed #D1DDED !important;
    background-color: #FAFCFE !important;
}

/* Group hover — ไฮไลต์ทุกแถวของ DAR เดียวกันพร้อมกัน */
.dar-reg tbody tr.dar-hover td {
    background-color: var(--accent-light) !important;
}

/* ── Sticky action column (ดำเนินการ) — always visible on right ── */
/* isolation: isolate กักเก็บ z-index ไว้ใน table-responsive
   ป้องกัน sticky header ทับ filter bar ด้านบน */
.dar-reg {
    isolation: isolate;
}
.dar-reg thead th:last-child {
    position: sticky;
    right: 0;
    background: var(--surface) !important;
    z-index: 2;
    box-shadow: -3px 0 6px rgba(0,0,0,.05);
}
.dar-reg td.dar-action-col {
    position: sticky;
    right: 0;
    background: var(--white);
    z-index: 1;
    box-shadow: -3px 0 6px rgba(0,0,0,.05);
}
.dar-reg tbody tr.dar-hover td.dar-action-col {
    background: var(--accent-light) !important;
}

/* ── Navbar collapsed menu (iPad / mobile) ──
   เมื่อเมนูพับเป็น hamburger (< 1200px = xl breakpoint)
   ให้ panel เลื่อนขึ้น-ลงได้ ถ้าเมนูยาวเกินความสูง viewport
   ป้องกันรายการเมนูตกขอบหน้าจอบน iPad/มือถือ                         */
@media (max-width: 1199.98px) {
    .navbar .navbar-collapse {
        max-height: calc(100vh - 52px);
        overflow-y: auto;
        padding: .5rem 0;
    }
    /* dropdown ของ admin / โปรไฟล์: เปลี่ยนเป็น inline list
       เพื่อไม่ใช้ floating dropdown ที่อาจตกขอบ                       */
    .navbar .navbar-collapse .dropdown-menu {
        position: static;
        float: none;
        border: 0;
        box-shadow: none;
        padding-left: 1rem;
        background: rgba(255,255,255,.05);
    }
    .navbar .navbar-collapse .dropdown-menu .dropdown-item {
        color: rgba(255,255,255,.85);
    }
    .navbar .navbar-collapse .dropdown-menu .dropdown-item:hover {
        color: #fff;
        background: rgba(255,255,255,.1);
    }
    .navbar .navbar-collapse .dropdown-menu .dropdown-header {
        color: rgba(255,255,255,.5);
    }
    .navbar .navbar-collapse .dropdown-menu .dropdown-divider {
        border-color: rgba(255,255,255,.15);
    }
}

/* ── Mobile / iPad: ยกเลิก sticky action column ──
   บนหน้าจอเล็ก (< 992px) ให้ตารางเลื่อนได้ปกติทั้งซ้าย-ขวา-บน-ล่าง
   ไม่ตรึงคอลัมน์ขวาสุด เพื่อให้ตัวอักษรไม่หล่น/ไม่เคลื่อน                       */
@media (max-width: 991.98px) {
    .dar-reg thead th:last-child,
    .dar-reg td.dar-action-col {
        position: static !important;
        right: auto !important;
        box-shadow: none !important;
        z-index: auto !important;
    }
    .dar-reg tbody tr.dar-hover td.dar-action-col {
        background: var(--accent-light) !important;
    }
}

/* Sequence number circle */
.dar-seq {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface); color: var(--dark-2);
    font-weight: 700; font-size: .82rem; flex-shrink: 0;
}

/* DAR number link */
.dar-no-link {
    font-weight: 700; font-size: .9rem;
    color: var(--navy) !important; text-decoration: none !important;
    white-space: nowrap; transition: color .15s;
}
.dar-no-link:hover { color: var(--accent) !important; }
.dar-no-draft { font-size: .8rem; color: var(--gray) !important; font-style: italic; }

/* Remark truncate */
.dar-remark {
    max-width: 200px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; display: block;
}

/* Action type pill badges */
.dar-action-badge {
    display: inline-block; padding: .25em .7em;
    border-radius: 50rem; font-size: .74rem; font-weight: 600;
    white-space: nowrap; line-height: 1.4;
}
.dar-action-new     { background: #DCFCE7; color: #166534; }
.dar-action-edit    { background: #DBEAFE; color: #1E40AF; }
.dar-action-cancel  { background: #FEF9C3; color: #854D0E; }
.dar-action-destroy { background: #FEE2E2; color: #991B1B; }

/* Override touch min-height inside registry table */
@media (hover: none) and (pointer: coarse) {
    .dar-reg .btn-sm { min-height: 32px; }
}

/* ═══════════════════════════════════════════════════
   SKELETON LOADING
   ═══════════════════════════════════════════════════ */

/* ── Shimmer keyframe ── */
@keyframes skel-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

/* ── Skeleton overlay ──
   z-index 1040: คลุม navbar (sticky-top: 1020) แต่อยู่ใต้ modal-backdrop (1050)
   เพื่อไม่ให้ skeleton บังปุ่มใน modal/popup ขณะ navigation                    */
#page-skeleton {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: #f1f4f8;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
#page-skeleton.skel-hidden {
    opacity: 0;
}

/* ── Shimmer base ── */
.skel-block {
    background: linear-gradient(
        90deg,
        #e2e8f0 0%,
        #f8fafc 40%,
        #e2e8f0 80%
    );
    background-size: 600px 100%;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

/* ── Header skeleton ── */
.skel-header {
    height: 54px;
    background: #1C3557;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    flex-shrink: 0;
}
.skel-header-brand {
    width: 140px;
    height: 26px;
    background: rgba(255,255,255,.18);
    border-radius: 6px;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    background-size: 600px 100%;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,.10) 0%,
        rgba(255,255,255,.28) 40%,
        rgba(255,255,255,.10) 80%
    );
}
.skel-header-nav {
    display: flex;
    gap: 12px;
    margin-left: 24px;
}
.skel-header-nav-item {
    width: 72px;
    height: 20px;
    background: rgba(255,255,255,.12);
    border-radius: 5px;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    background-size: 600px 100%;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,.08) 0%,
        rgba(255,255,255,.22) 40%,
        rgba(255,255,255,.08) 80%
    );
}
.skel-header-right {
    margin-left: auto;
    display: flex;
    gap: 12px;
    align-items: center;
}
.skel-header-bell {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.14);
    animation: skel-shimmer 1.4s ease-in-out infinite;
    background-size: 600px 100%;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,.08) 0%,
        rgba(255,255,255,.22) 40%,
        rgba(255,255,255,.08) 80%
    );
}
.skel-header-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    animation: skel-shimmer 1.4s ease-in-out infinite;
    background-size: 600px 100%;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,.10) 0%,
        rgba(255,255,255,.28) 40%,
        rgba(255,255,255,.10) 80%
    );
}

/* ── Content skeleton ── */
.skel-content {
    flex: 1;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* ── Page title bar ── */
.skel-page-title {
    height: 28px;
    width: 220px;
    margin-bottom: 4px;
}

/* ── Stats row (home page) ── */
.skel-stat-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.skel-stat-card {
    flex: 1 1 140px;
    height: 88px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    overflow: hidden;
}

/* ── Card skeleton ── */
.skel-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    overflow: hidden;
}
.skel-card-header {
    height: 48px;
    padding: 12px 18px;
    border-bottom: 1px solid #f0f3f7;
    display: flex;
    align-items: center;
    gap: 12px;
}
.skel-card-header-title {
    height: 18px;
    width: 160px;
}
.skel-card-header-btn {
    margin-left: auto;
    height: 30px;
    width: 100px;
}
.skel-card-body {
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Table rows ── */
.skel-table-header {
    display: flex;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f3f7;
    margin-bottom: 4px;
}
.skel-th { height: 14px; }
.skel-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
}
.skel-td { height: 16px; }

/* Column width helpers */
.skel-w-sm  { width: 60px;  }
.skel-w-md  { width: 120px; }
.skel-w-lg  { width: 180px; }
.skel-w-xl  { width: 240px; }
.skel-w-full{ flex: 1;      }
.skel-w-badge{ width: 80px; height: 22px; border-radius: 50rem; }

/* ── Mobile bottom nav skeleton ── */
.skel-bottom-nav {
    height: 58px;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: none;
}
@media (max-width: 767px) {
    .skel-bottom-nav { display: block; }
    .skel-header-nav { display: none; }
}

/* ── Page fade-in ── */
/* page-reveal: ใช้ opacity-only — ห้ามใช้ transform เพราะจะสร้าง
   stacking context ใหม่ที่ทำให้ Bootstrap modal (position:fixed +
   z-index 1055) ติดอยู่ภายใน .dar-main ไม่ใช่ viewport →
   ปุ่ม CTA ใน modal ถูกบังโดย background ของหน้า                       */
body.page-ready .dar-main,
body.page-ready .dar-header {
    animation: pageReveal 0.2s ease forwards;
}
@keyframes pageReveal {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────────────
   Responsive UX/UI — มือถือและแท็บเล็ต
   ───────────────────────────────────────────────────────────────────── */

/* ── Table horizontal scroll indicator (เห็นชัดว่า scroll ได้) ──────── */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: var(--surface); border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ── Tablet (≤ 991.98px) ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* Card header กระชับขึ้น */
    .card-header h5 { font-size: 1rem; }
    .card-header { padding: .75rem 1rem; }

    /* Filter form: ให้ control แต่ละตัว full-width แล้ว stack ดู */
    #darFilterForm > *,
    #docFilterForm > * {
        flex: 1 1 calc(50% - .5rem) !important;
        min-width: 0 !important;
    }
    #darFilterForm .dropdown.dept-filter-dropdown,
    #docFilterForm .dropdown.dept-filter-dropdown { flex: 1 1 100% !important; }

    /* ลด font ของ table หลัก */
    .dar-reg { font-size: .82rem; }

    /* Action buttons compact */
    .dar-action-btn { width: 30px; height: 30px; font-size: .92rem; }
}

/* ── Mobile (≤ 575.98px) ────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    /* Card header: title + action ซ้อนแนวตั้ง */
    .card-header { flex-direction: column !important; align-items: flex-start !important; gap: .5rem !important; }
    .card-header h5 { font-size: .95rem; line-height: 1.4; }
    .card-header .badge { align-self: flex-start; }

    /* Filter form: ทุก control เต็มความกว้าง */
    #darFilterForm > *,
    #docFilterForm > * {
        flex: 1 1 100% !important;
        min-width: 100% !important;
    }
    /* วันที่ประกาศใช้ block ไม่หมุนแถว */
    #docFilterForm .d-flex.align-items-center.gap-1 { flex-wrap: wrap; }
    #docFilterForm input[type="date"] { flex: 1 1 calc(50% - 1rem); min-width: 0; }

    /* Buttons เพิ่ม touch target */
    .btn-sm { padding: .4rem .75rem; min-height: 38px; }
    .dar-action-btn { width: 34px; height: 34px; font-size: 1rem; }

    /* PDF icon ตาราง: ขนาดพอดีนิ้ว */
    .doc-view-btn i { font-size: 1.8rem !important; }

    /* ลด padding ของ container เพื่อใช้พื้นที่เต็ม */
    .container-fluid, .container { padding-left: .5rem !important; padding-right: .5rem !important; }
}
