/**
 * dist/css/savedee-theme.css
 * SaveDee Driver School Management — UI Design System Implementation
 * Based on DESIGN.md (Version 1.0)
 * Non-destructive override layer for AdminLTE 3
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Brand Colors */
    --color-brand-900: #071A33;
    --color-brand-800: #0B2447;
    --color-brand-700: #123A67;
    --color-brand-600: #194B82;

    /* Primary Palette */
    --color-primary-700: #075FCC;
    --color-primary-600: #0D6EFD;
    --color-primary-500: #2F80ED;
    --color-primary-100: #EAF3FF;
    --color-primary-50:  #F4F8FF;

    /* Brand gradient bar (section banners / modal headers) */
    --gradient-brand-bar: linear-gradient(120deg, #0B2447 0%, #14539B 55%, #2F80ED 100%);

    /* Semantic Status */
    --color-success-text: #15803D;
    --color-success-bg:   #EAF8EF;
    --color-success-border: #BBF7D0;

    --color-warning-text: #B45309;
    --color-warning-bg:   #FFF7E6;
    --color-warning-border: #FDE68A;

    --color-danger-text:  #C62828;
    --color-danger-bg:    #FDECEC;
    --color-danger-border: #FECACA;

    --color-info-text:    #0369A1;
    --color-info-bg:      #E8F6FC;
    --color-info-border:  #BAE6FD;

    /* Surfaces & Borders */
    --surface-page:       #F4F7FB;
    --surface-card:       #FFFFFF;
    --surface-subtle:     #F8FAFC;
    --border-default:     #DCE3EC;
    --border-strong:      #C6D0DC;

    /* Text Colors - High Contrast for iPad / Mobile & Desktop readability */
    --text-primary:       #0F172A;
    --text-secondary:     #334155;
    --text-muted:         #475569;
    --text-inverse:       #FFFFFF;
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 14px 32px rgba(15, 23, 42, 0.12);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;
}

/* ==========================================================================
   1. Typography & Global Resets
   ========================================================================== */
body, .main-sidebar, .main-header, .content-wrapper, h1, h2, h3, h4, h5, h6, input, button, select, textarea {
    font-family: 'Noto Sans Thai', 'Kanit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    text-rendering: optimizeLegibility;
}

body {
    background-color: var(--surface-page) !important;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.55;
}

.text-muted, p.text-muted, span.text-muted, small.text-muted {
    color: var(--text-muted) !important;
    font-weight: 500;
}

.content-header p, .content-header small {
    color: var(--text-secondary) !important;
    font-size: 13.5px !important;
    font-weight: 500;
}

.content-wrapper {
    background-color: var(--surface-page) !important;
    padding-bottom: 2rem;
}

/* ==========================================================================
   2. Top Bar (Navbar)
   ========================================================================== */
 .main-header.navbar,
 .main-header {
     background-color: #FFFFFF !important;
     border-bottom: 1px solid var(--border-default) !important;
     box-shadow: var(--shadow-sm) !important;
     height: 64px;
     padding: 0 1.5rem;
     position: sticky !important;
     top: 0 !important;
     z-index: 1035 !important;
 }

.main-header .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    transition: color 0.2s ease;
}

.main-header .nav-link:hover {
    color: var(--color-primary-600) !important;
}

/* Home / Pushmenu Toggle Button */
.main-header [data-widget="pushmenu"] {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    padding: 0 0.75rem !important;
}

.main-header [data-widget="pushmenu"] i.fa-home {
    font-size: 40px !important;
    line-height: 1 !important;
    transition: transform 0.15s ease, color 0.15s ease;
}

.main-header [data-widget="pushmenu"]:hover i.fa-home {
    color: var(--color-primary-600) !important;
    transform: scale(1.05);
}

/* User Profile Dropdown Pill */
.main-header .dropdown-toggle::after {
    display: none;
}

.main-header .nav-item.dropdown > a.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    padding: 6px 14px !important;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary) !important;
    transition: all 0.2s ease;
}

.main-header .nav-item.dropdown > a.nav-link:hover {
    background: var(--color-primary-50);
    border-color: var(--color-primary-500);
}

.main-header .dropdown-menu {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-default) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 8px 0;
}

.main-header .dropdown-item {
    font-size: 13.5px;
    padding: 10px 18px;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}

.main-header .dropdown-item:hover {
    background-color: var(--color-primary-50);
    color: var(--color-primary-700);
}

/* ==========================================================================
   3. Sidebar (SaveDee Brand-800 Deep Slate Navy)
   ========================================================================== */
.main-sidebar, .sidebar-dark-primary {
    background-color: var(--color-brand-800) !important;
    box-shadow: 2px 0 12px rgba(11, 36, 71, 0.12) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-link {
    background-color: var(--color-brand-900) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 1rem 1rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
}

.brand-link img {
    max-height: 42px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

/* Sidebar Menu Items */
.nav-sidebar .nav-item {
    margin-bottom: 3px;
}

.nav-sidebar .nav-link {
    border-radius: var(--radius-md) !important;
    color: #C6D0DC !important;
    font-size: 13.5px;
    font-weight: 500;
    padding: 10px 14px;
    transition: all 0.2s ease;
}

.nav-sidebar .nav-link:hover {
    background-color: var(--color-brand-700) !important;
    color: #FFFFFF !important;
}

.nav-sidebar .nav-link.active {
    background-color: var(--color-primary-600) !important;
    color: #FFFFFF !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3) !important;
}

.nav-sidebar .nav-icon {
    font-size: 15px !important;
    margin-right: 10px !important;
    opacity: 0.9;
}

/* Brand palette hues (single source for sidebar icons, report card icons and buttons) */
.palette-blue    { --palette-hue: #3B82F6; }
.palette-indigo  { --palette-hue: #6366F1; }
.palette-violet  { --palette-hue: #8B5CF6; }
.palette-purple  { --palette-hue: #A855F7; }
.palette-fuchsia { --palette-hue: #D946EF; }
.palette-pink    { --palette-hue: #EC4899; }
.palette-rose    { --palette-hue: #F43F5E; }
.palette-red     { --palette-hue: #EF4444; }
.palette-orange  { --palette-hue: #F97316; }
.palette-amber   { --palette-hue: #F59E0B; }
.palette-yellow  { --palette-hue: #EAB308; }
.palette-lime    { --palette-hue: #84CC16; }
.palette-green   { --palette-hue: #22C55E; }
.palette-emerald { --palette-hue: #10B981; }
.palette-teal    { --palette-hue: #14B8A6; }
.palette-cyan    { --palette-hue: #06B6D4; }
.palette-sky     { --palette-hue: #0EA5E9; }
.palette-slate   { --palette-hue: #94A3B8; }
.palette-light   { --palette-hue: #CBD5E1; }

/* Sidebar menu icons */
.nav-sidebar .nav-icon[class*="palette-"] {
    color: var(--palette-hue);
}
.nav-sidebar .nav-link.active .nav-icon {
    color: #FFFFFF !important;
}
/* เมนูหลักที่มีเมนูย่อย: คงสีของไอคอนไว้แม้กำลังเปิดอยู่ (ไอคอนที่มี palette-* มีเฉพาะเมนูหลัก)
   ผสมสีขาวเข้าไปด้วยเพราะพื้น active เป็นน้ำเงินเข้ม #0D6EFD ใช้สีล้วนแล้วcontrast ต่ำเกินไป */
.nav-sidebar .nav-link.active .nav-icon[class*="palette-"] {
    color: color-mix(in srgb, var(--palette-hue) 45%, #FFFFFF) !important;
}

/* Soft tinted icon wrapper (report cards) */
.stat-icon[class*="palette-"] {
    background-color: #F1F5F9;
    background-color: color-mix(in srgb, var(--palette-hue) 14%, #FFFFFF);
    color: var(--palette-hue);
}

/* Solid palette buttons */
.btn-palette {
    background-color: var(--palette-hue);
    border-color: var(--palette-hue);
    background-color: color-mix(in srgb, var(--palette-hue) 60%, #000000);
    border-color: color-mix(in srgb, var(--palette-hue) 60%, #000000);
    color: #FFFFFF !important;
}
.btn-palette:hover,
.btn-palette:focus {
    background-color: var(--palette-hue);
    border-color: var(--palette-hue);
    background-color: color-mix(in srgb, var(--palette-hue) 60%, #000000);
    border-color: color-mix(in srgb, var(--palette-hue) 60%, #000000);
    filter: brightness(0.9);
    color: #FFFFFF !important;
}

.nav-treeview {
    background-color: rgba(7, 26, 51, 0.35) !important;
    border-radius: var(--radius-md);
    margin: 4px 0 4px 10px;
    padding: 4px 0;
}

.nav-treeview .nav-link {
    font-size: 13px !important;
    padding-left: 20px !important;
}

/* ==========================================================================
   4. Cards, Containers & Panels
   ========================================================================== */
.card {
    background-color: var(--surface-card) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md) !important;
}

.card-header {
    background-color: #FFFFFF !important;
    border-bottom: 1px solid var(--border-default) !important;
    padding: 1rem 1.25rem;
    border-top-left-radius: var(--radius-lg) !important;
    border-top-right-radius: var(--radius-lg) !important;
}

.card-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
}

.card-body {
    padding: 1.25rem;
}

/* ==========================================================================
   5. Modernized KPI Statistics Cards (Dashboard)
   ========================================================================== */
.small-box, .stats-card {
    border-radius: var(--radius-xl) !important;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    padding: 1.25rem 1.5rem;
    background: #FFFFFF;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.small-box:hover, .stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.small-box .inner h3, .stats-card .number {
    font-size: 30px !important;
    font-weight: 700 !important;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
    font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', sans-serif !important;
}

/* Default label for uncolored cards */
.small-box:not([class*="bg-"]) .inner p,
.stats-card .label {
    font-size: 13.5px !important;
    color: var(--text-secondary) !important;
    font-weight: 500;
    margin-bottom: 0;
}

/* Modern Gradient KPI Highlights */
.small-box.bg-info, .small-box.bg-primary {
    background: linear-gradient(135deg, #0D6EFD 0%, #075FCC 100%) !important;
    color: #FFFFFF !important;
    border: none;
}

.small-box.bg-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    color: #FFFFFF !important;
    border: none;
}

.small-box.bg-warning {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%) !important;
    color: #FFFFFF !important;
    border: none;
}

.small-box.bg-danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%) !important;
    color: #FFFFFF !important;
    border: none;
}

/* High Contrast: Ensure ALL text inside colored KPI cards is crisp pure white */
.small-box[class*="bg-"],
.small-box[class*="bg-"] .inner,
.small-box[class*="bg-"] .inner h3,
.small-box[class*="bg-"] .inner h3 *,
.small-box[class*="bg-"] .inner p,
.small-box.bg-info .inner p,
.small-box.bg-primary .inner p,
.small-box.bg-success .inner p,
.small-box.bg-warning .inner p,
.small-box.bg-danger .inner p {
    color: #FFFFFF !important;
}

.small-box[class*="bg-"] .inner p,
.small-box.bg-info .inner p,
.small-box.bg-primary .inner p,
.small-box.bg-success .inner p,
.small-box.bg-warning .inner p,
.small-box.bg-danger .inner p {
    font-size: 14px !important;
    font-weight: 500 !important;
    opacity: 0.95;
    margin-bottom: 0;
    letter-spacing: 0.2px;
}

.small-box .icon {
    color: rgba(255, 255, 255, 0.25) !important;
    top: 14px !important;
    right: 18px !important;
}

.small-box-footer {
    background: rgba(0, 0, 0, 0.08) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 12.5px !important;
    font-weight: 600;
    padding: 6px 0 !important;
}

/* ==========================================================================
   6. Buttons & Interactive Controls
   ========================================================================== */
.btn {
    border-radius: var(--radius-md) !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    padding: 7px 16px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.18s ease;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(1px);
}

/* Touch target 44px (iPad/mobile) for primary action buttons */
.btn-touch {
    min-height: 44px;
}

.btn-primary {
    background-color: var(--color-primary-600) !important;
    border-color: var(--color-primary-600) !important;
    color: #FFFFFF !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--color-primary-700) !important;
    border-color: var(--color-primary-700) !important;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25) !important;
}

.btn-success {
    background-color: #10B981 !important;
    border-color: #10B981 !important;
    color: #FFFFFF !important;
}

.btn-success:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}

.btn-danger {
    background-color: #EF4444 !important;
    border-color: #EF4444 !important;
}

.btn-danger:hover {
    background-color: #DC2626 !important;
    border-color: #DC2626 !important;
}

.btn-info {
    background-color: #0284C7 !important;
    border-color: #0284C7 !important;
    color: #FFFFFF !important;
}

.btn-default, .btn-secondary {
    background-color: #FFFFFF !important;
    border-color: var(--border-default) !important;
    color: var(--text-primary) !important;
}

.btn-default:hover, .btn-secondary:hover {
    background-color: var(--surface-subtle) !important;
    border-color: var(--border-strong) !important;
}

/* ==========================================================================
   7. Form Inputs & Select Controls
   ========================================================================== */
.form-control, .custom-select, select.form-control {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-default) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    height: 40px;
    padding: 8px 12px;
    background-color: #FFFFFF !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

select.form-control, .custom-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 10px !important;
    padding-right: 36px !important;
    cursor: pointer;
}

.form-control:focus, .custom-select:focus, select.form-control:focus {
    border-color: var(--color-primary-600) !important;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15) !important;
    outline: none;
}

label {
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    margin-bottom: 6px;
}

/* 7.1 Form Section Banner — shared colored tab header */
.form-section-banner {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    margin: 0 0 1.25rem;
    border-radius: 12px;
    background: var(--gradient-brand-bar);
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.20);
}

.form-section-banner > i:first-child,
.form-section-banner > div:first-child > i:first-child {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    color: #DBEAFE;
    font-size: 14px;
    margin-right: 10px;
}

/* ==========================================================================
   8. DataTables & Tables Styling
   ========================================================================== */
.table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    color: var(--text-primary) !important;
    width: 100% !important;
}

.table thead th {
    background-color: var(--surface-subtle) !important;
    border-top: none !important;
    border-bottom: 2px solid var(--border-default) !important;
    color: #1E293B !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    text-transform: none;
    padding: 12px 14px !important;
}

.table tbody td {
    border-top: 1px solid var(--border-default) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    padding: 12px 14px !important;
    vertical-align: middle !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    font-size: 13.5px !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
}

/* Single-line DataTables "แสดง [25] รายการ" & "ค้นหา:" on iPad and all devices */
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    white-space: nowrap !important;
    margin-bottom: 0.5rem !important;
    font-weight: 500 !important;
}

.dataTables_wrapper .dataTables_length select {
    width: auto !important;
    min-width: 72px !important;
    display: inline-block !important;
    margin: 0 4px !important;
}

.dataTables_wrapper .dataTables_filter input {
    width: auto !important;
    min-width: 180px;
    display: inline-block !important;
    margin-left: 6px !important;
}

.table-hover tbody tr:hover {
    background-color: var(--color-primary-50) !important;
}

/* DataTables Pagination Pills */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-md) !important;
    padding: 4px 10px !important;
    font-size: 13px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--color-primary-600) !important;
    border-color: var(--color-primary-600) !important;
    color: #FFFFFF !important;
}

/* ==========================================================================
   8.1 Table Action Buttons & Single-Line iPad Standard
   ========================================================================== */
.table td .btn + .btn,
.table td .btn + .dropdown,
.table td .dropdown + .btn,
.table td .btn + .btn-group,
.table td .btn-group + .btn {
    margin-left: 4px !important;
}

.table td .d-inline-flex,
.table td .d-flex {
    gap: 6px;
}

/* Enforce single-line action buttons in table cells (iPad & Desktop) */
.table td:last-child,
.table td.table-action {
    white-space: nowrap !important;
}

.table td:last-child .d-inline-flex,
.table td:last-child .d-flex,
.table td.table-action .d-inline-flex,
.table td.table-action .d-flex {
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.table td:last-child .d-inline-flex > .btn,
.table td:last-child .d-flex > .btn,
.table td .btn-group > .btn {
    margin-left: 0 !important;
}

/* Ensure buttons in table actions are rounded, compact, and single-line */
.table td .btn-group > .btn,
.table td .btn {
    border-radius: var(--radius-md, 8px) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.table td .btn-sm {
    padding: 6px 12px !important;
    font-size: 13px !important;
    min-height: 36px;
}

.table td .btn-group > .btn:not(:first-child) {
    margin-left: 4px !important;
}

.table td .btn-group > .btn:not(:last-child) {
    margin-right: 2px !important;
}

/* Modal Table Inputs & Selects Spacing & Legibility */
#studentListModal .table td {
    padding: 10px 12px !important;
    vertical-align: middle !important;
}

#studentListModal .custom-select,
#studentListModal .form-control {
    border-radius: var(--radius-sm, 6px);
    border-color: var(--border-default, #CBD5E1);
    padding: 6px 10px;
    font-size: 13.5px;
    color: var(--text-primary, #0F172A);
}

#studentListModal .custom-select {
    padding-right: 28px !important;
}

#studentListModal .custom-select:focus,
#studentListModal .form-control:focus {
    border-color: var(--color-primary-500, #3B82F6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ==========================================================================
   9. Status Badges & Chips
   ========================================================================== */
.badge {
    border-radius: var(--radius-pill) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    padding: 4px 10px !important;
    letter-spacing: 0.2px;
}

.badge-success {
    background-color: var(--color-success-bg) !important;
    color: var(--color-success-text) !important;
    border: 1px solid var(--color-success-border) !important;
}

.badge-warning {
    background-color: var(--color-warning-bg) !important;
    color: var(--color-warning-text) !important;
    border: 1px solid var(--color-warning-border) !important;
}

.badge-danger {
    background-color: var(--color-danger-bg) !important;
    color: var(--color-danger-text) !important;
    border: 1px solid var(--color-danger-border) !important;
}

.badge-info {
    background-color: var(--color-info-bg) !important;
    color: var(--color-info-text) !important;
    border: 1px solid var(--color-info-border) !important;
}

/* ==========================================================================
   10. Modals
   ========================================================================== */
.modal-content {
    border-radius: var(--radius-xl) !important;
    border: 1px solid var(--border-default) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.modal-header {
    background-color: #FFFFFF !important;
    border-bottom: 1px solid var(--border-default) !important;
    padding: 1.25rem 1.5rem !important;
}

.modal-title {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
}

/* หัว modal แบบแถบสีน้ำเงิน ใช้กับ modal ที่ต้องการเน้น (ปฏิทิน / บันทึกงาน) */
.modal-header-brand {
    background: var(--gradient-brand-bar) !important;
    border-bottom: none !important;
}

.modal-header-brand .modal-title,
.modal-header-brand .modal-title i,
.modal-header-brand .close {
    color: #FFFFFF !important;
    text-shadow: none !important;
    opacity: 1;
}

.modal-footer {
    background-color: var(--surface-subtle) !important;
    border-top: 1px solid var(--border-default) !important;
    padding: 1rem 1.5rem !important;
}

/* Keep the action buttons reachable when the modal body scrolls (iPad / mobile) */
.modal-dialog-scrollable .modal-body > .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
}

/* The 7-column work calendar needs the full tablet width (iPad-first) */
#teacherDayWorkModal .modal-dialog {
    max-width: min(1100px, calc(100% - 1rem));
}

/* ==========================================================================
   11. Unified Table Standards (Clean & Lean)
   ========================================================================== */
.table, .table-savedee {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    color: var(--text-primary) !important;
    width: 100% !important;
}

.table thead th, .table-savedee thead th {
    background-color: var(--surface-subtle) !important;
    border-top: none !important;
    border-bottom: 2px solid var(--border-default) !important;
    color: #1E293B !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    text-transform: none;
    padding: 12px 14px !important;
    vertical-align: middle !important;
}

.table tbody td, .table-savedee tbody td {
    border-top: 1px solid var(--border-default) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    padding: 12px 14px !important;
    vertical-align: middle !important;
}

.table tfoot th, .table-savedee tfoot th {
    background-color: var(--surface-subtle) !important;
    border-top: 1px solid var(--border-default) !important;
    color: #1E293B !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    padding: 10px 14px !important;
    vertical-align: middle !important;
}

.table td.table-action, .table td:last-child {
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: #F8FAFC !important;
}

/* ==========================================================================
   12. Standard KPI Statistics Widgets
   ========================================================================== */
.stat-widget {
    background: #FFFFFF;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-widget:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-widget.stat-widget-clickable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.stat-widget.stat-widget-clickable:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #93C5FD;
}

.stat-widget.stat-widget-clickable.active {
    border-color: #0D6EFD !important;
    background-color: #EFF6FF !important;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25) !important;
}

.stat-widget.stat-widget-clickable.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 11px;
    color: #0D6EFD;
    background: rgba(13, 110, 253, 0.12);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.stat-icon-sm {
    width: 36px;
    height: 36px;
    font-size: 16px;
}

.stat-icon.stat-icon-lg {
    width: 52px;
    height: 52px;
    font-size: 24px;
}

.stat-widget .stat-icon {
    margin-right: 12px;
}
.stat-widget .stat-content {
    min-width: 0;
}

.stat-widget .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 600;
}

.stat-widget .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-widget .stat-desc {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* Ensure no colored left borders anywhere on KPI widgets (Savedee Standard) */
.stat-widget,
.expense-stat-card,
.exam-stat-card {
    border-left: 1px solid var(--border-default) !important;
}

/* ==========================================================================
   12.1 Report Menu Card Metric Line (used on report.php cards)
   ========================================================================== */
.report-card-metric {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.3;
}

.report-card-metric .rcm-scope {
    color: var(--text-muted);
    font-weight: 500;
}

.report-card-metric .rcm-count {
    color: var(--text-primary);
    font-weight: 700;
    white-space: nowrap;
}

.report-card-metric .rcm-amount {
    color: #16A34A;
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto;
}

/* Subtle KPI Icon Backgrounds */
.bg-primary-subtle   { background-color: #E0F2FE !important; color: #0284C7 !important; }
.bg-success-subtle   { background-color: #DCFCE7 !important; color: #16A34A !important; }
.bg-info-subtle      { background-color: #E0E7FF !important; color: #4338CA !important; }
.bg-warning-subtle   { background-color: #FEF3C7 !important; color: #D97706 !important; }
.bg-danger-subtle    { background-color: #FEE2E2 !important; color: #DC2626 !important; }
.bg-secondary-subtle { background-color: #F1F5F9 !important; color: #64748B !important; }
.bg-purple-subtle    { background-color: #F3E8FF !important; color: #7E22CE !important; }
.text-purple        { color: #6F42C1 !important; }
.btn-purple {
    color: #FFFFFF !important;
    background-color: #6F42C1 !important;
    border-color: #6F42C1 !important;
}
.btn-purple:hover, .btn-purple:focus {
    color: #FFFFFF !important;
    background-color: #5A32A3 !important;
    border-color: #512D93 !important;
}

/* ==========================================================================
   13. Standard Tab Navigation (Pill Tabs)
   ========================================================================== */
.nav-pills .nav-link {
    border-radius: var(--radius-md);
    padding: 7px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.nav-pills .nav-link:hover {
    color: var(--color-primary-600);
    background-color: rgba(13, 110, 253, 0.05);
}

.nav-pills .nav-link.active {
    background-color: var(--color-primary-600) !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.28) !important;
}

.nav-pills .nav-link .badge {
    transition: background-color 0.15s ease;
}

.nav-pills .nav-link.active .badge {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: #FFFFFF !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* ==========================================================================
   14. Standard Indicators, Pills & Badges
   ========================================================================== */
.color-dot, .teacher-color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px #FFFFFF, 0 1px 4px rgba(0, 0, 0, 0.22);
}

.item-pill, .course-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    word-break: keep-all;
    transition: all 0.15s ease;
    background: #F8FAFC;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 12px;
    padding: 3px 8px;
    line-height: 1.4;
}

.item-pill:hover, .course-pill:hover {
    background: #F1F5F9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.badge-purple {
    background-color: #6F42C1 !important;
    color: #FFFFFF !important;
}

.badge-indigo {
    background-color: #6610F2 !important;
    color: #FFFFFF !important;
}

/* Datetimepicker modal fix */
.xdsoft_datetimepicker {
    z-index: 99999 !important;
}

/* Tempus Dominus — iPad/touch: make calendar cells tappable */
.bootstrap-datetimepicker-widget [data-action],
.bootstrap-datetimepicker-widget td,
.bootstrap-datetimepicker-widget th,
.bootstrap-datetimepicker-widget span {
    touch-action: manipulation !important;
    cursor: pointer !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}
.bootstrap-datetimepicker-widget table td[data-action],
.bootstrap-datetimepicker-widget table th[data-action],
.bootstrap-datetimepicker-widget table td.day,
.bootstrap-datetimepicker-widget table td.month,
.bootstrap-datetimepicker-widget table td.year,
.bootstrap-datetimepicker-widget table td.decade {
    min-width: 36px !important;
    min-height: 36px !important;
    line-height: 36px !important;
    font-size: 14px !important;
}
/* iPad: ช่องวันที่ถูกล็อก readonly (กันคีย์บอร์ดลอย) ทำให้ Tempus Dominus ใส่คลาส -readonly
   แล้วปิด pointer-events ของช่องวันทั้งหมด → เปิดคืน ให้แตะเลือกวันได้ (input ยัง readonly อยู่) */
.bootstrap-datetimepicker-widget.bootstrap-datetimepicker-widget-readonly table td.day:not(.disabled),
.bootstrap-datetimepicker-widget.bootstrap-datetimepicker-widget-readonly table td.hour:not(.disabled),
.bootstrap-datetimepicker-widget.bootstrap-datetimepicker-widget-readonly table td.minute:not(.disabled),
.bootstrap-datetimepicker-widget.bootstrap-datetimepicker-widget-readonly table td.second:not(.disabled),
.bootstrap-datetimepicker-widget.bootstrap-datetimepicker-widget-readonly table td:not(.disabled) [data-action] {
    pointer-events: auto !important;
}

/* Tempus Dominus Bootstrap 4 Datetimepicker styling & iPad touch enhancement */
.bootstrap-datetimepicker-widget,
.bootstrap-datetimepicker-widget.dropdown-menu,
.datepicker-dropdown,
.tempus-dominus-widget {
    font-family: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: auto !important;
    min-width: 288px !important;
    max-width: calc(100vw - 20px) !important;
    background-color: #ffffff !important;
    z-index: 9999 !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* ป้องกัน CSS ตารางหลักในหน้ารบกวนโครงสร้างและ cell ของปฏิทิน */
.bootstrap-datetimepicker-widget table,
.datepicker-dropdown table,
.tempus-dominus-widget table {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-collapse: separate !important;
    border-spacing: 2px !important;
    border: none !important;
    background-color: transparent !important;
}

.bootstrap-datetimepicker-widget .datepicker-days table,
.datepicker-dropdown .datepicker-days table,
.tempus-dominus-widget .datepicker-days table {
    table-layout: fixed !important;
    width: 100% !important;
}

.bootstrap-datetimepicker-widget table th,
.bootstrap-datetimepicker-widget table td,
.datepicker-dropdown table th,
.datepicker-dropdown table td,
.tempus-dominus-widget table th,
.tempus-dominus-widget table td {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    text-align: center !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    background: none;
}

.bootstrap-datetimepicker-widget table th {
    font-weight: 600;
    color: #4a5568;
    height: 36px;
    font-size: 0.875rem;
    padding: 0 !important;
}

.bootstrap-datetimepicker-widget .datepicker-days table th.dow {
    font-size: 0.85rem;
    color: #64748b;
    height: 32px;
    line-height: 32px;
    font-weight: 600;
    padding: 0 !important;
}

.bootstrap-datetimepicker-widget table td {
    height: 36px;
    line-height: 36px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #1e293b;
    min-width: 0 !important;
    width: auto !important;
    padding: 0 !important;
}

.bootstrap-datetimepicker-widget .datepicker-days table td.day {
    height: 36px;
    line-height: 36px;
    width: auto !important;
    min-width: 0 !important;
    cursor: pointer;
    border-radius: 6px;
    padding: 0 !important;
}

.bootstrap-datetimepicker-widget table td.day:hover,
.bootstrap-datetimepicker-widget table td.hour:hover,
.bootstrap-datetimepicker-widget table td.minute:hover,
.bootstrap-datetimepicker-widget table td.second:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.bootstrap-datetimepicker-widget table td.old,
.bootstrap-datetimepicker-widget table td.new {
    color: #94a3b8 !important;
}

.bootstrap-datetimepicker-widget table td.active,
.bootstrap-datetimepicker-widget table td.active:hover {
    background-color: var(--primary, #007bff) !important;
    color: #fff !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
}

.bootstrap-datetimepicker-widget table td.today {
    font-weight: 700;
}

.bootstrap-datetimepicker-widget table td.today:before {
    border-bottom-color: var(--primary, #007bff) !important;
}

.bootstrap-datetimepicker-widget table td.active.today:before {
    border-bottom-color: #fff !important;
}

.bootstrap-datetimepicker-widget table th.picker-switch {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
    width: auto !important;
    min-width: 120px !important;
    cursor: pointer;
    border-radius: 6px;
}

.bootstrap-datetimepicker-widget table th.picker-switch:hover {
    background-color: #f1f5f9 !important;
}

.bootstrap-datetimepicker-widget table th.prev,
.bootstrap-datetimepicker-widget table th.next {
    font-size: 0.9rem;
    color: #4a5568;
    width: 36px !important;
    cursor: pointer;
    border-radius: 6px;
}

.bootstrap-datetimepicker-widget table th.prev:hover,
.bootstrap-datetimepicker-widget table th.next:hover {
    background-color: #f1f5f9 !important;
}

.bootstrap-datetimepicker-widget .timepicker a.btn,
.bootstrap-datetimepicker-widget .datepicker a.btn,
.bootstrap-datetimepicker-widget [data-action] {
    padding: 6px 12px;
    border-radius: 6px;
    color: #4a5568;
    transition: all 0.15s ease;
}

.bootstrap-datetimepicker-widget [data-action]:hover {
    background-color: #f1f5f9;
    color: var(--primary, #007bff);
}

@media (pointer: coarse) {
    input.datetimepicker-input,
    input.form-control.datetimepicker-input {
        font-size: 16px;
    }
}

/* jQuery UI Autocomplete in modals */
.ui-autocomplete {
    z-index: 1060 !important;
}

/* Chart container styles */
.chart-container {
    position: relative;
    margin: auto;
    height: 350px;
    width: 100%;
}

/* ==========================================================================
   15. Tablet & iPad Readability Optimization
   ========================================================================== */
@media (max-width: 1024px) {
    body {
        font-size: 14.5px !important;
        -webkit-text-size-adjust: 100%;
    }
    .table:not(.bootstrap-datetimepicker-widget table) thead th, .table-savedee thead th {
        font-size: 14px !important;
        padding: 12px 10px !important;
    }
    .table:not(.bootstrap-datetimepicker-widget table) tbody td, .table-savedee tbody td {
        font-size: 14px !important;
        padding: 12px 10px !important;
    }
    /* iPad: ป้องกัน Datepicker โดน padding ของ table ทั่วไปเบียด */
    .bootstrap-datetimepicker-widget table th,
    .bootstrap-datetimepicker-widget table td {
        padding: 0 !important;
        font-size: 0.875rem !important;
    }
    .stat-widget .stat-label {
        font-size: 13.5px;
    }
    .stat-widget .stat-value {
        font-size: 22px;
    }
    .form-control, select.form-control, .btn {
        font-size: 14px !important;
    }
    .content-header h1 {
        font-size: 22px !important;
    }
}
/* ==========================================================================
   16. Global Solid Button Override (Remove outline/transparent buttons)
   ========================================================================== */
.btn-outline-primary,
a.btn-outline-primary,
button.btn-outline-primary {
    background-color: #0D6EFD !important;
    border-color: #0D6EFD !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active,
.btn-outline-primary.active {
    background-color: #0B5ED7 !important;
    border-color: #0A58CA !important;
    color: #FFFFFF !important;
}

.btn-outline-danger,
a.btn-outline-danger,
button.btn-outline-danger {
    background-color: #DC3545 !important;
    border-color: #DC3545 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-outline-danger:active,
.btn-outline-danger.active {
    background-color: #BB2D3B !important;
    border-color: #B02A37 !important;
    color: #FFFFFF !important;
}

.btn-outline-info,
a.btn-outline-info,
button.btn-outline-info {
    background-color: #17A2B8 !important;
    border-color: #17A2B8 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-info:hover,
.btn-outline-info:focus,
.btn-outline-info:active,
.btn-outline-info.active {
    background-color: #138496 !important;
    border-color: #117A8B !important;
    color: #FFFFFF !important;
}

.btn-outline-success,
a.btn-outline-success,
button.btn-outline-success {
    background-color: #28A745 !important;
    border-color: #28A745 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-success:hover,
.btn-outline-success:focus,
.btn-outline-success:active,
.btn-outline-success.active {
    background-color: #218838 !important;
    border-color: #1E7E34 !important;
    color: #FFFFFF !important;
}

.btn-outline-warning,
a.btn-outline-warning,
button.btn-outline-warning {
    background-color: #FFC107 !important;
    border-color: #FFC107 !important;
    color: #212529 !important;
    font-weight: 600 !important;
}
.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-warning:active,
.btn-outline-warning.active {
    background-color: #FFCA2C !important;
    border-color: #FFC720 !important;
    color: #212529 !important;
}

.btn-outline-secondary,
a.btn-outline-secondary,
button.btn-outline-secondary {
    background-color: #6C757D !important;
    border-color: #6C757D !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active,
.btn-outline-secondary.active {
    background-color: #5C636A !important;
    border-color: #565E64 !important;
    color: #FFFFFF !important;
}

.btn-outline-dark,
a.btn-outline-dark,
button.btn-outline-dark {
    background-color: #212529 !important;
    border-color: #212529 !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}
.btn-outline-dark:hover,
.btn-outline-dark:focus,
.btn-outline-dark:active,
.btn-outline-dark.active {
    background-color: #1C1F23 !important;
    border-color: #1A1E21 !important;
    color: #FFFFFF !important;
}

/* ==========================================================================
   Full-Width Clean Layout: No Mini-Sidebar Strip (No "ยืดหด") Across All Screens
   Press Home icon (รูปบ้าน) in Navbar to Show Menu Drawer on Every Page
   ========================================================================== */

/* 1. Closed state (Default on all pages/screens): Hide sidebar completely off-screen */
body.sidebar-collapse .main-sidebar,
body.sidebar-collapse .main-sidebar::before,
body.sidebar-mini.sidebar-collapse .main-sidebar,
body.sidebar-mini.sidebar-collapse .main-sidebar::before {
    margin-left: -250px !important;
    width: 250px !important;
}

/* 2. Full-width content, header, and footer when closed (No 74px mini-strip) */
body.sidebar-collapse .content-wrapper,
body.sidebar-collapse .main-footer,
body.sidebar-collapse .main-header,
body.sidebar-mini.sidebar-collapse .content-wrapper,
body.sidebar-mini.sidebar-collapse .main-footer,
body.sidebar-mini.sidebar-collapse .main-header {
    margin-left: 0 !important;
    width: 100% !important;
}

/* 3. Disable hover-expand ("ยืดหด") completely so hovering doesn't stretch */
body.sidebar-collapse .main-sidebar:hover,
body.sidebar-mini.sidebar-collapse .main-sidebar:hover,
body.sidebar-mini-md.sidebar-collapse .main-sidebar:hover,
body.sidebar-mini-xs.sidebar-collapse .main-sidebar:hover {
    width: 250px !important;
    margin-left: -250px !important;
}

/* 4. Open state: When user clicks Home button, sidebar slides out as overlay drawer */
body:not(.sidebar-collapse) .main-sidebar,
body:not(.sidebar-collapse) .main-sidebar::before,
body.sidebar-open .main-sidebar,
body.sidebar-open .main-sidebar::before {
    margin-left: 0 !important;
    width: 250px !important;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.25) !important;
    z-index: 1050 !important;
    transition: margin-left 0.3s ease-in-out !important;
}

/* Content wrapper keeps full width and does not shift */
body:not(.sidebar-collapse) .content-wrapper,
body:not(.sidebar-collapse) .main-header,
body:not(.sidebar-collapse) .main-footer {
    margin-left: 0 !important;
    width: 100% !important;
}

/* 5. Show dark backdrop overlay when menu is open so clicking outside closes it */
body:not(.sidebar-collapse) #sidebar-overlay,
body.sidebar-open #sidebar-overlay {
    display: block !important;
    z-index: 1040 !important;
    background-color: rgba(0, 0, 0, 0.35) !important;
    cursor: pointer;
}

/* Ensure container-fluid has maximum breathing room */
.content-wrapper > .content > .container-fluid {
    padding-left: 10px !important;
    padding-right: 10px !important;
}
 
 /* Hide navbar and non-printable elements in print mode */
 @media print {
     .main-header,
     .main-sidebar,
     .no-print {
         display: none !important;
     }
 }

/* Quotation financial documents follow the student receipt print layout. */
@page quotation-financial { size: A4; margin: 15mm; }
body.sd-financial-print {
    page: quotation-financial;
    box-sizing: border-box;
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 20px;
    color: #000;
    background: #fff !important;
    font-family: 'Sarabun', sans-serif !important;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
}
.sd-financial-print *, .sd-financial-print *::before, .sd-financial-print *::after { box-sizing: border-box; }
.sd-financial-print .print-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}
.sd-financial-print .print-actions .btn { border: 1px solid; cursor: pointer; text-decoration: none; }
.sd-financial-print .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}
.sd-financial-print .print-logo { max-width: 160px; max-height: 80px; width: auto; height: auto; object-fit: contain; }
.sd-financial-print .company-info { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.sd-financial-print .document-no { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.sd-financial-print .company-name { font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.sd-financial-print .company-address { font-size: 10px; }
.sd-financial-print .document-date { white-space: nowrap; }
.sd-financial-print .print-customer { margin-bottom: 20px; overflow-wrap: anywhere; }
.sd-financial-print .print-references { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 12px; }
.sd-financial-print .print-table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sd-financial-print .print-items { width: 100%; min-width: 650px; border-collapse: collapse; table-layout: fixed; }
.sd-financial-print .print-items .col-sequence { width: 8%; }
.sd-financial-print .print-items .col-description { width: 47%; }
.sd-financial-print .print-items .col-quantity,
.sd-financial-print .print-items .col-price,
.sd-financial-print .print-items .col-amount { width: 15%; }
.sd-financial-print .print-items th, .sd-financial-print .print-items td { border: 1px solid #c0c0c0; padding: 8px; vertical-align: top; }
.sd-financial-print .print-items th { background: #f0f0f0; text-align: center; font-weight: 400; white-space: nowrap; }
.sd-financial-print .print-items .center { text-align: center; }
.sd-financial-print .print-items .amount { text-align: right; }
.sd-financial-print .numeric { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sd-financial-print .highlight { background: #f5f5f5; }
.sd-financial-print .item-description, .sd-financial-print .print-note { overflow-wrap: anywhere; }
.sd-financial-print .item-description p, .sd-financial-print .print-note p { margin: 0 0 4px; }
.sd-financial-print .item-description img, .sd-financial-print .print-note img { max-width: 100%; height: auto; }
.sd-financial-print .item-description table, .sd-financial-print .print-note table { width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse; }
.sd-financial-print .print-bank { margin-top: 10px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.sd-financial-print .print-note { margin-top: 8px; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.sd-financial-print .print-signatures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 30px; font-size: 13px; }
.sd-financial-print .signature-row { display: grid; grid-template-columns: auto 220px auto; align-items: end; gap: 8px; justify-content: start; }
.sd-financial-print .signature-row > span:first-child { white-space: nowrap; }
.sd-financial-print .signature-line { border-bottom: 1px dotted #000; height: 1.5em; min-width: 220px; }
.sd-financial-print .signature-name, .sd-financial-print .signature-date { margin-left: 42px; margin-top: 4px; overflow-wrap: anywhere; }
@media screen and (max-width: 600px) {
    body.sd-financial-print { padding: 16px; }
    .sd-financial-print .print-header { flex-direction: column; gap: 12px; }
    .sd-financial-print .company-info { text-align: left; }
    .sd-financial-print .print-signatures { grid-template-columns: 1fr; }
}
@media print {
    body.sd-financial-print { max-width: none; padding: 0; }
    .sd-financial-print .print-table-scroll { overflow: visible; }
    .sd-financial-print .print-items { min-width: 0; }
    .sd-financial-print .print-items thead { display: table-header-group; }
    .sd-financial-print .print-items tr,
    .sd-financial-print .print-header,
    .sd-financial-print .print-bank,
    .sd-financial-print .print-note,
    .sd-financial-print .signature-block { break-inside: avoid; }
}

/* ==========================================================================
   Standard UI Filter & Shortcut Navigation (รูปแบบหลัก UI ตัวกรอง/ปุ่มทางลัด)
   Standardized UI Component inspired by course_shortcut_nav
   ========================================================================== */
.course-shortcut-nav-wrapper,
.app-filter-strip-wrapper,
.setting-group-nav-wrapper {
    margin-bottom: 1.15rem;
}
.course-shortcut-grid,
.app-filter-grid,
.setting-group-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.course-shortcut-grid.grid-cols-1, .app-filter-grid.grid-cols-1, .setting-group-grid-5.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.course-shortcut-grid.grid-cols-2, .app-filter-grid.grid-cols-2, .setting-group-grid-5.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.course-shortcut-grid.grid-cols-3, .app-filter-grid.grid-cols-3, .setting-group-grid-5.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.course-shortcut-grid.grid-cols-4, .app-filter-grid.grid-cols-4, .setting-group-grid-5.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.course-shortcut-grid.grid-cols-5, .app-filter-grid.grid-cols-5, .setting-group-grid-5.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.course-shortcut-card,
.app-filter-card,
.setting-nav-card {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none !important;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}
.course-shortcut-card:hover,
.app-filter-card:hover,
.setting-nav-card:hover {
    background: #f8faff;
    border-color: #3b82f6;
    color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.course-shortcut-card.active,
.app-filter-card.active,
.setting-nav-card.active {
    background: linear-gradient(135deg, #0d6efd 0%, #0952c4 100%) !important;
    border-color: #0d6efd !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.3) !important;
    cursor: default;
}
.course-shortcut-card .shortcut-step-badge,
.app-filter-card .filter-step-badge,
.setting-nav-card .nav-step-badge {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    line-height: 1;
    transition: all 0.2s ease;
}
.course-shortcut-card:hover .shortcut-step-badge,
.app-filter-card:hover .filter-step-badge,
.setting-nav-card:hover .nav-step-badge {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #bfdbfe;
}
.course-shortcut-card.active .shortcut-step-badge,
.app-filter-card.active .filter-step-badge,
.setting-nav-card.active .nav-step-badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}
.course-shortcut-card .shortcut-icon-wrap,
.app-filter-card .filter-icon-wrap,
.setting-nav-card .nav-icon-wrap {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-right: 10px;
    background: #eff6ff;
    color: #2563eb;
    transition: all 0.2s ease;
}
.course-shortcut-card:hover .shortcut-icon-wrap,
.app-filter-card:hover .filter-icon-wrap,
.setting-nav-card:hover .nav-icon-wrap {
    background: #dbeafe;
    color: #1d4ed8;
    transform: scale(1.05);
}
.course-shortcut-card.active .shortcut-icon-wrap,
.app-filter-card.active .filter-icon-wrap,
.setting-nav-card.active .nav-icon-wrap {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.course-shortcut-card .shortcut-info,
.app-filter-card .filter-info,
.setting-nav-card .nav-body {
    min-width: 0;
    flex: 1;
    padding-right: 14px;
}
.course-shortcut-card .shortcut-name,
.app-filter-card .filter-title,
.setting-nav-card .nav-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.course-shortcut-card.active .shortcut-name,
.app-filter-card.active .filter-title,
.setting-nav-card.active .nav-title {
    color: #ffffff !important;
}
.course-shortcut-card .shortcut-sub,
.app-filter-card .filter-desc,
.setting-nav-card .nav-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    line-height: 1.2;
}
.course-shortcut-card:hover .shortcut-sub,
.app-filter-card:hover .filter-desc,
.setting-nav-card:hover .nav-sub {
    color: #2563eb;
}
.course-shortcut-card.active .shortcut-sub,
.app-filter-card.active .filter-desc,
.setting-nav-card.active .nav-sub {
    color: rgba(255, 255, 255, 0.88) !important;
    font-weight: 500;
}
.course-shortcut-card .active-dot,
.app-filter-card .active-dot,
.setting-nav-card .active-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
    margin-right: 4px;
    flex-shrink: 0;
}
@media (max-width: 991.98px) {
    .course-shortcut-grid,
    .app-filter-grid,
    .setting-group-grid-5 {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        gap: 8px;
        scrollbar-width: thin;
    }
    .course-shortcut-grid::-webkit-scrollbar,
    .app-filter-grid::-webkit-scrollbar,
    .setting-group-grid-5::-webkit-scrollbar {
        height: 4px;
    }
    .course-shortcut-grid::-webkit-scrollbar-thumb,
    .app-filter-grid::-webkit-scrollbar-thumb,
    .setting-group-grid-5::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
    .course-shortcut-card,
    .app-filter-card,
    .setting-nav-card {
        min-width: 175px !important;
        flex: 0 0 auto !important;
    }
}

/* ==========================================================================
   Schedule Button (ปุ่มเลือกวันเรียน) - High Contrast Indigo
   ========================================================================== */
.btn-schedule {
    background-color: #4f46e5 !important;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    border-color: #4338ca !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.28) !important;
    transition: all 0.15s ease-in-out;
}
.btn-schedule:hover,
.btn-schedule:focus {
    background-color: #4338ca !important;
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%) !important;
    border-color: #312e81 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.38) !important;
    transform: translateY(-1px);
}
.btn-schedule:active {
    background-color: #3730a3 !important;
    transform: translateY(0);
}
/* Schedule Button Outline (เลือกวันเรียนครบแล้ว) - Outline Indigo */
.btn-outline-schedule {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border: 1.5px solid #4f46e5 !important;
    color: #4f46e5 !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.1) !important;
    transition: all 0.15s ease-in-out;
}
.btn-outline-schedule:hover,
.btn-outline-schedule:focus {
    background-color: #4f46e5 !important;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    border-color: #4338ca !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.28) !important;
    transform: translateY(-1px);
}
.btn-outline-schedule:active {
    background-color: #3730a3 !important;
    transform: translateY(0);
}

/* ==========================================================================
   Modern DateRangePicker UI Enhancements (SaveDee Theme)
   ========================================================================== */
.daterangepicker {
    font-family: 'Noto Sans Thai', 'Kanit', sans-serif !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    box-shadow: 0 14px 35px -5px rgba(15, 23, 42, 0.18), 0 8px 12px -6px rgba(15, 23, 42, 0.12) !important;
    padding: 10px !important;
    background-color: #ffffff !important;
    z-index: 3050 !important;
}
.daterangepicker::before,
.daterangepicker::after {
    border-bottom-color: #ffffff !important;
}
.daterangepicker .drp-calendar {
    max-width: 320px !important;
    padding: 6px !important;
}
.daterangepicker .drp-calendar.left {
    padding: 6px !important;
}
.daterangepicker .calendar-table {
    border: none !important;
    background: transparent !important;
}
.daterangepicker .calendar-table table {
    border-collapse: separate !important;
    border-spacing: 2px !important;
}
.daterangepicker .calendar-table th,
.daterangepicker .calendar-table td {
    width: 38px !important;
    height: 36px !important;
    line-height: 36px !important;
    text-align: center !important;
    border-radius: 8px !important;
    font-size: 13.5px !important;
    border: none !important;
    transition: all 0.12s ease-in-out;
}
.daterangepicker .calendar-table th {
    font-weight: 600 !important;
    color: #64748b !important;
    font-size: 12.5px !important;
}
.daterangepicker th.month {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    padding: 6px 0 !important;
}
.daterangepicker select.monthselect,
.daterangepicker select.yearselect {
    padding: 4px 8px !important;
    height: 32px !important;
    border-radius: 6px !important;
    border: 1px solid #cbd5e1 !important;
    background-color: #f8fafc !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    font-size: 13px !important;
    margin: 0 3px !important;
    cursor: pointer !important;
    outline: none !important;
}
.daterangepicker select.monthselect:focus,
.daterangepicker select.yearselect:focus {
    border-color: #0d6efd !important;
    background-color: #ffffff !important;
}
.daterangepicker td.available:hover {
    background-color: #eff6ff !important;
    color: #0d6efd !important;
    font-weight: 600 !important;
}
.daterangepicker td.today:not(.active) {
    position: relative;
    font-weight: 700 !important;
    color: #0d6efd !important;
}
.daterangepicker td.active,
.daterangepicker td.active:hover,
.daterangepicker td.active.today,
.daterangepicker td.active.today:hover {
    background-color: #0d6efd !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.4) !important;
}
.daterangepicker td.off,
.daterangepicker td.off.in-range,
.daterangepicker td.off.start-date,
.daterangepicker td.off.end-date {
    color: #cbd5e1 !important;
    background-color: transparent !important;
}
.daterangepicker .drp-buttons {
    border-top: 1px solid #f1f5f9 !important;
    padding: 8px 4px 4px 4px !important;
    text-align: right !important;
}
.daterangepicker .drp-buttons .btn {
    font-size: 13px !important;
    padding: 5px 14px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
}
.daterangepicker .drp-buttons .applyBtn {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.3) !important;
}
.daterangepicker .drp-buttons .applyBtn:hover {
    background-color: #0b5ed7 !important;
}
.daterangepicker .drp-buttons .cancelBtn {
    background-color: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    color: #64748b !important;
}
.daterangepicker .drp-buttons .cancelBtn:hover {
    background-color: #e2e8f0 !important;
    color: #334155 !important;
}
.daterangepicker th.prev span,
.daterangepicker th.next span {
    border-color: #475569 !important;
}

/* ==========================================================================
   DataTables Multi-Device & iPad Responsive Standard (AGENTS.md)
   ========================================================================== */
.table-responsive:has(> .dataTables_wrapper) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.dataTables_wrapper .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 0.5rem;
    border-radius: 8px;
}

.dataTables_wrapper .dt-buttons {
    display: inline-flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: center !important;
    margin-bottom: 0.5rem !important;
}

.dataTables_wrapper .dt-buttons.btn-group > .btn,
.dataTables_wrapper .dt-buttons > .btn {
    border-radius: 8px !important;
    font-weight: 600 !important;
    min-height: 38px !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 38px !important;
    border-radius: 8px !important;
}

.dataTables_wrapper .dataTables_paginate ul.pagination {
    flex-wrap: wrap !important;
    gap: 3px !important;
    justify-content: flex-end;
}

@media (max-width: 991.98px) {
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
        width: 100%;
    }
    .dataTables_wrapper .dataTables_filter label {
        width: 100% !important;
        display: flex !important;
    }
    .dataTables_wrapper .dataTables_filter input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
    }
    .dataTables_wrapper .dataTables_paginate ul.pagination {
        justify-content: center !important;
        margin-top: 6px !important;
    }
}

/* ==========================================================================
   23. Segmented Filter Buttons / Button Group Separators
   ========================================================================== */
.btn-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
}

.btn-filter-group .btn {
    border-radius: var(--radius-md, 8px) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 6px 14px !important;
    min-height: 36px;
    border: 1px solid var(--border-default, #CBD5E1) !important;
    background-color: #FFFFFF !important;
    color: var(--text-secondary, #334155) !important;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.05)) !important;
    transition: all 0.18s ease;
}

.btn-filter-group .btn:hover {
    background-color: var(--surface-subtle, #F8FAFC) !important;
    border-color: var(--border-strong, #94A3B8) !important;
    color: var(--text-primary, #0F172A) !important;
}

.btn-filter-group .btn.active {
    background-color: var(--color-primary-600, #0D6EFD) !important;
    border-color: var(--color-primary-600, #0D6EFD) !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.25) !important;
}

/* ==========================================================================
   24. iPad-First Table Enhancements & Single-Line Utility
   ========================================================================== */
.text-nowrap {
    white-space: nowrap !important;
}

@media (min-width: 768px) and (max-width: 1024px) {
    /* Ensure table responsiveness on iPad screens */
    .table td, .table th {
        vertical-align: middle !important;
    }

    /* Course / Description cells expand generously */
    .table td.col-expand,
    .table th.col-expand {
        min-width: 240px !important;
    }
}

/* ==========================================================================
   25. iPad-First & Multi-Device SweetAlert2 Modal Standards
   ========================================================================== */
.swal2-container.ipad-friendly-swal {
    padding: 12px !important;
}

.swal2-container.ipad-friendly-swal .swal2-popup {
    border-radius: var(--radius-lg, 16px) !important;
    max-width: 95vw !important;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2) !important;
    font-family: inherit !important;
}

.swal2-container.ipad-friendly-swal .swal2-html-container {
    margin: 0.5rem 0.25rem !important;
    overflow-x: hidden !important;
}

@media (max-width: 767.98px) {
    .swal2-container.ipad-friendly-swal .swal2-popup {
        width: 100% !important;
        padding: 16px 12px !important;
    }
}

/* ==========================================================================
   26. Receipt Preview, Thumbnail & Lightbox (iPad-First Standard)
   ========================================================================== */
.receipt-preview-card {
    background: #F8FAFC;
    border: 1px dashed #CBD5E1;
    border-radius: var(--radius-md, 8px);
    padding: 10px 14px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.receipt-thumb-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    background: #E2E8F0;
    border: 1px solid #CBD5E1;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.receipt-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}
.receipt-thumb-wrap:hover img {
    transform: scale(1.08);
}
.receipt-thumb-wrap .thumb-zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 14px;
}
.receipt-thumb-wrap:hover .thumb-zoom-overlay {
    opacity: 1;
}
.receipt-preview-meta {
    flex-grow: 1;
    min-width: 0;
}
.receipt-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    background: #0f172a;
}

/* ==========================================================================
   Month Calendars (Teaching & Work) — iPad-first 7-column grid
   ========================================================================== */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.cal-nav-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: #FFFFFF;
    color: var(--color-brand-700);
    font-size: 14px;
}

.cal-nav-btn:hover {
    background: var(--surface-subtle);
    color: var(--color-primary-700);
    text-decoration: none;
}

.cal-today-btn {
    width: auto;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
}

.cal-title {
    font-size: 17px;
    font-weight: 700;
    color: #1E293B;
    min-width: 140px;
    text-align: center;
}

.cal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.cal-filters .form-control {
    width: auto;
    min-width: 130px;
    height: 38px;
    font-size: 13px;
    font-weight: 600;
}

.cal-count {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-info-text);
    background: var(--color-info-bg);
    border: 1px solid var(--color-info-border);
    padding: 6px 12px;
    border-radius: 999px;
}

.cal-grid {
    width: 100%;
    min-width: 840px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.cal-grid th {
    background: var(--surface-subtle);
    padding: 9px 4px;
    font-size: 12.5px;
    font-weight: 700;
    color: #1E293B;
    text-align: center;
    border-bottom: 1px solid var(--border-default);
}

.cal-grid th.cal-head-sun { color: #DC2626; }
.cal-grid th.cal-head-sat { color: #6D28D9; }

.cal-grid td.cal-day {
    border: 1px solid var(--border-default);
    padding: 6px;
    vertical-align: top;
    height: 104px;
    background: #FFFFFF;
}

.cal-day-empty { background: var(--surface-subtle) !important; }

.cal-day-today {
    background: var(--color-primary-50) !important;
    box-shadow: inset 0 0 0 2px var(--color-primary-500);
}

.cal-day-num {
    font-size: 13px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 4px;
}

.cal-day-today .cal-day-num { color: var(--color-primary-700); }

.cal-chip {
    border-left: 3px solid #64748B;
    background: var(--surface-subtle);
    border-radius: 6px;
    padding: 3px 6px;
    margin-bottom: 4px;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
}

.cal-chip-time {
    display: block;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
}

.cal-chip-course {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #1E293B;
}

.cal-chip-teacher {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #475569;
}

.cal-chip-1 { border-left-color: #0284C7; background: #E0F2FE; }
.cal-chip-2 { border-left-color: #059669; background: #D1FAE5; }
.cal-chip-3 { border-left-color: #D97706; background: #FEF3C7; }
.cal-chip-4 { border-left-color: #DC2626; background: #FEE2E2; }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: #475569;
}

.cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cal-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.cal-note-btn {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 86px;
    text-align: left;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    cursor: pointer;
}

.cal-note-btn:focus { outline: none; }
.cal-note-btn:focus-visible {
    outline: 2px solid var(--color-primary-500);
    border-radius: 6px;
}

.cal-note-text {
    font-size: 11.5px;
    color: #334155;
    white-space: pre-line;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cal-note-empty {
    font-size: 11px;
    color: #94A3B8;
    opacity: .55;
}

.cal-note-btn:hover .cal-note-empty {
    opacity: 1;
    color: var(--color-primary-600);
}

.cal-note-btn:hover .cal-note-text { color: var(--color-primary-700); }

.cal-note-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: auto;
    padding-top: 4px;
    font-size: 10.5px;
    color: #64748B;
}

.cal-note-flags:empty { display: none; }

.cal-flag-repeat,
.cal-flag-attach {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--surface-subtle);
    line-height: 1.6;
}

.cal-flag-repeat { color: var(--color-primary-700); }

.doc-file-chip.doc-file-pending { background: var(--color-warning-bg); border-color: var(--color-warning-border); }

/* Work Calendar Visibility Selector */
.visibility-box {
    border-radius: var(--radius-md, 8px);
    transition: all 0.15s ease-in-out;
}
.visibility-box.active {
    box-shadow: 0 0 0 2px var(--color-primary-500, #007bff);
}
.badge-primary-subtle {
    background-color: #E0F2FE;
    color: #0369A1;
}
.badge-warning-subtle {
    background-color: #FEF3C7;
    color: #92400E;
}
.badge-info-subtle {
    background-color: #F0FDF4;
    color: #15803D;
}

/* Calendars embedded in a modal (student registration page) */
#calendarModal .modal-body { padding: 0; }

#calendarFrame {
    display: block;
    width: 100%;
    height: calc(100vh - 140px);
    min-height: 460px;
    border: 0;
    background: #FFFFFF;
}

.calendar-embed .main-footer { display: none; }
.calendar-embed .content { padding-top: 12px; }

@media (max-width: 991.98px) {
    .cal-filters { margin-left: 0; width: 100%; }
    .cal-filters .form-control { flex: 1 1 140px; }
    .cal-count { margin-left: 0; }
}

@media (max-width: 767.98px) {
    .cal-grid td.cal-day { height: 88px; padding: 4px; }
    .cal-chip { font-size: 10px; padding: 2px 4px; }
    .cal-title { min-width: 120px; font-size: 15px; }
    .cal-note-btn { min-height: 76px; }
    .cal-note-text { -webkit-line-clamp: 4; }
}


/* ==========================================================================
   Teacher card attachments & profile photo
   ========================================================================== */
.license-doc-col {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.license-doc-col .doc-file-list { min-width: 0; }

.license-doc-col .btn-attach-doc {
    min-height: 38px;
    white-space: nowrap;
}

.doc-file-thumb {
    width: 22px;
    height: 22px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* Wider teacher edit modal so each card row fits on one line */
@media (min-width: 768px) {
    #editteacherModal .modal-dialog.modal-xl {
        max-width: min(1140px, calc(100vw - 2rem));
    }
}

.doc-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.doc-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    background: var(--color-primary-50);
    font-size: 12px;
    line-height: 1.4;
}

.doc-file-chip a {
    color: var(--text-primary);
    text-decoration: none;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-file-chip a:hover { color: var(--color-primary-600); text-decoration: underline; }

.doc-file-chip .btn-remove-doc {
    border: 0;
    background: transparent;
    color: var(--color-danger-text);
    padding: 0 2px;
    line-height: 1;
}

.teacher-photo-preview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 16px;
    border: 3px solid var(--border-default);
    background: #F1F5F9;
    cursor: zoom-in;
}

.teacher-list-photo {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--border-default);
    background: #F1F5F9;
    cursor: zoom-in;
}

/* Lightbox รูปภาพ (ใช้ร่วมกันทุกหน้า) */
.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.92);
}

.image-lightbox[hidden] { display: none; }

.image-lightbox img {
    width: auto;
    height: auto;
    min-width: min(480px, 100%);
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.image-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 575.98px) {
    .teacher-photo-preview { width: 96px; height: 96px; }
}

@media (max-width: 991.98px) {
    .license-doc-col { flex: 1 1 100%; }
    .doc-file-chip a { max-width: 60vw; }
}

/* ==========================================================================
   School document alert bar (shared navbar)
   ========================================================================== */
.school-doc-alert-bar {
    background: var(--color-warning-bg);
    border-bottom: 1px solid var(--color-warning-border);
    color: var(--color-warning-text);
    font-size: 13.5px;
    position: relative;
    z-index: 1030;
}

.school-doc-alert-bar .close {
    color: var(--color-warning-text);
    text-shadow: none;
    opacity: .75;
}

.school-doc-alert-bar .close:hover { opacity: 1; }

@media (max-width: 575.98px) {
    .school-doc-alert-bar { font-size: 12.5px; }
    .school-doc-alert-bar .ml-auto { margin-left: 0 !important; margin-top: 4px; }
}

/* ==========================================================================
   Select2 vehicle dropdown — readable option list on tablet/touch screens
   ========================================================================== */
.select2-container--bootstrap4 .select2-dropdown.select2-car-dropdown .select2-results > .select2-results__options {
    max-height: min(50vh, 360px);
    -webkit-overflow-scrolling: touch;
}

.select2-container--bootstrap4 .select2-dropdown.select2-car-dropdown .select2-results__option {
    padding: 10px 12px;
    line-height: 1.5;
}

/* 16px keeps iOS from zooming the page when the search box gets focus */
.select2-car-dropdown .select2-search__field {
    font-size: 16px;
    padding: 8px 10px;
}

/* ==========================================================================
   Modal loading overlay (receipt preview and other in-modal previews)
   ========================================================================== */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10;
    color: #fff;
}

.modal-loading-overlay.is-hidden { display: none; }


/* ==========================================================================
   Amount fields (read-only totals on quotation/invoice forms)
   ========================================================================== */
.amount-field {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.quotation-amount-row .item-grand-amount {
    font-weight: 700;
}

/* ==========================================================================
   Tooltip suppression on open modals (iPad / Touch Devices fix)
   ========================================================================== */
body.modal-open .tooltip,
.modal.show ~ .tooltip {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ==========================================================================
   Teacher Slot Matrix & Per-Slot Close/Open Controls (iPad-First Standard)
   ========================================================================== */
.schedule-matrix-table {
    table-layout: fixed !important;
    min-width: 960px !important;
    width: 100% !important;
}

.schedule-matrix-table th,
.schedule-matrix-table td {
    box-sizing: border-box !important;
    padding: 6px 4px !important;
    overflow: hidden;
}

.schedule-matrix-table td .teacher-slot-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-height: 90px;
}

.schedule-matrix-table td .teacher-slot-row {
    display: flex !important;
    align-items: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 6px !important;
    box-sizing: border-box !important;
}

.schedule-matrix-table td .teacher-slot-row:last-child {
    margin-bottom: 0 !important;
}

.schedule-matrix-table td .teacher-slot-row .btn-teacher-slot {
    flex: 1 1 0% !important;
    flex-shrink: 1 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    min-height: 40px !important;
    padding: 6px 6px !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
}

.schedule-matrix-table td .teacher-slot-row .btn-teacher-slot .teacher-slot-name {
    max-width: none !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: left !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.schedule-matrix-table td .teacher-slot-row .btn-slot-close {
    flex: 0 0 32px !important;
    width: 32px !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    border: 1px solid #FCA5A5 !important;
    background: #FFF5F5 !important;
    color: #DC2626 !important;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.schedule-matrix-table td .teacher-slot-row .btn-slot-close:hover {
    background: #DC2626 !important;
    border-color: #DC2626 !important;
    color: #FFFFFF !important;
}

.schedule-matrix-table td .teacher-blocked-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    min-height: 40px;
    padding: 5px 6px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: #FEF2F2;
    border: 1px dashed #EF4444;
    box-sizing: border-box;
    overflow: hidden;
}

.schedule-matrix-table td .teacher-blocked-card:last-child {
    margin-bottom: 0;
}

.schedule-matrix-table td .teacher-blocked-card .btn-slot-open {
    flex: 0 0 auto !important;
    min-height: 30px !important;
    margin: 0 !important;
    padding: 3px 7px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

@media (max-width: 1024px) {
    .schedule-matrix-table {
        min-width: 980px !important;
    }
    .schedule-matrix-table td .teacher-slot-row .btn-slot-close {
        flex: 0 0 36px !important;
        width: 36px !important;
        min-height: 42px !important;
    }
    .schedule-matrix-table td .teacher-slot-row .btn-teacher-slot {
        min-height: 42px !important;
    }
    .schedule-matrix-table td .teacher-blocked-card .btn-slot-open {
        min-height: 34px !important;
        padding: 4px 8px !important;
    }
}

/* SweetAlert2 interactive fixes over Bootstrap modals (iPad / Mobile compatibility) */
.swal2-container {
    z-index: 99999 !important;
}

.swal2-input,
.swal2-textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
}
