@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,700&display=swap');

:root {
    /* Backgrounds & Canvas */
    --bg-primary: #f1f5f9;
    --bg-page: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 35%, #fdf2f8 70%, #f0fdf4 100%);
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.94);
    --bg-glass: rgba(255, 255, 255, 0.85);
    
    /* Borders & Outlines */
    --border-color: rgba(99, 102, 241, 0.16);
    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(236, 72, 153, 0.6);
    --border-active: rgba(99, 102, 241, 0.8);
    
    /* Typography Colors */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Vibrant Primary & Brand Gradients */
    --primary: #4f46e5;          /* Royal Indigo */
    --primary-blue: #2563eb;     /* Vivid Blue */
    --primary-pink: #ec4899;     /* Vibrant Pink / Magenta */
    --primary-purple: #7c3aed;   /* Electric Purple */
    --primary-hover: #4338ca;
    
    --primary-glow: rgba(79, 70, 229, 0.18);
    --pink-glow: rgba(236, 72, 153, 0.22);
    --blue-glow: rgba(37, 99, 235, 0.20);
    
    /* Multi-Color Gradients */
    --gradient-brand: linear-gradient(135deg, #2563eb 0%, #7c3aed 45%, #ec4899 100%);
    --gradient-blue-pink: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
    --gradient-purple-pink: linear-gradient(135deg, #7c3aed 0%, #d946ef 100%);
    --gradient-blue-cyan: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    --gradient-emerald-teal: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
    --gradient-amber-orange: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #fbbf24 100%);
    --gradient-rose-coral: linear-gradient(135deg, #e11d48 0%, #f43f5e 50%, #fb7185 100%);
    --gradient-rainbow: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #f59e0b, #10b981, #06b6d4);
    
    /* Semantic Colors */
    --success: #10b981;          /* Emerald */
    --success-glow: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;          /* Amber */
    --warning-glow: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;           /* Rose */
    --danger-glow: rgba(239, 68, 68, 0.15);
    
    --info: #0284c7;             /* Sky Cyan */
    --info-glow: rgba(2, 132, 199, 0.15);
    
    --accent: #d946ef;           /* Fuchsia */
    
    /* Layout Tokens */
    --sidebar-width: 315px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows & Glows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 6px -1px rgba(99, 102, 241, 0.08), 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 16px -2px rgba(99, 102, 241, 0.10), 0 3px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 14px 28px -4px rgba(99, 102, 241, 0.12), 0 6px 12px -2px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.28);
    --shadow-pink: 0 0 25px rgba(236, 72, 153, 0.28);
    --shadow-emerald: 0 0 25px rgba(16, 185, 129, 0.25);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables & Modern Styling */
body.light-theme {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.94);
    --border-color: rgba(99, 102, 241, 0.16);
    --border-hover: rgba(236, 72, 153, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --primary-glow: rgba(79, 70, 229, 0.16);
    --success-glow: rgba(16, 185, 129, 0.14);
    --warning-glow: rgba(245, 158, 11, 0.14);
    --danger-glow: rgba(239, 68, 68, 0.14);
}

body.light-theme input[type="text"],
body.light-theme input[type="number"],
body.light-theme input[type="date"],
body.light-theme select,
body.light-theme textarea {
    background: #ffffff;
    border-color: rgba(99, 102, 241, 0.2);
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

body.light-theme input:focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

body.light-theme th,
body.light-theme thead th {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    color: #1e293b;
    font-weight: 700;
    border-bottom: 2px solid rgba(99, 102, 241, 0.18);
}

body.light-theme td {
    background: #ffffff;
    color: #0f172a;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

body.light-theme tr:hover td {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05), rgba(236, 72, 153, 0.03)) !important;
}

body.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(99, 102, 241, 0.15);
    box-shadow: 4px 0 25px rgba(99, 102, 241, 0.06);
}

body.light-theme .brand-title {
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 50%, #db2777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

body.light-theme .nav-label {
    color: #6366f1;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
}

body.light-theme .nav-item a {
    color: #334155;
    font-weight: 600;
}

body.light-theme .nav-item a:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(236, 72, 153, 0.06));
    color: #4338ca;
}

body.light-theme .sidebar-footer {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(236, 72, 153, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.22);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.06);
}

body.light-theme .user-panel {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(236, 72, 153, 0.06) 100%);
    border: 1px solid rgba(99, 102, 241, 0.22);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.05);
}

body.light-theme .user-name {
    color: #0f172a;
    font-weight: 700;
}

body.light-theme .header-title h1 {
    background: linear-gradient(135deg, #1e293b 0%, #4338ca 60%, #db2777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

body.light-theme .modal-box {
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.22);
    box-shadow: 0 25px 60px -10px rgba(99, 102, 241, 0.25);
}

body.light-theme .modal-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.07) 0%, rgba(236, 72, 153, 0.04) 100%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.14);
}

body.light-theme .modal-footer {
    background: #f8fafc;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
}

body.light-theme .checklist-section,
body.light-theme .itemized-table-section {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95));
    border: 1px solid rgba(99, 102, 241, 0.16);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.04);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

*, select, select option, optgroup, input, textarea, button {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'IBM Plex Sans Thai', 'Sarabun', sans-serif !important;
    -webkit-font-smoothing: antialiased;
}

select option {
    font-family: 'IBM Plex Sans Thai', 'Sarabun', sans-serif !important;
    font-size: 1.05rem;
    padding: 8px 12px;
    background: #ffffff;
    color: #0f172a;
}

body {
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 35%, #fdf2f8 70%, #f0fdf4 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    font-size: 1.05rem;
    line-height: 1.55;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.6);
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #818cf8, #c084fc);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6366f1, #a855f7);
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

/* Layout */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 1.15rem 0.65rem;
    border-right: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 4px 0 25px rgba(99, 102, 241, 0.06);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

body.sidebar-mobile-locked {
    overflow: hidden !important;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100vw - var(--sidebar-width));
    min-width: 0;
    box-sizing: border-box;
    flex-grow: 1;
    min-height: 100vh;
    padding: 0 1.25rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sticky Pinned Topbar with Rainbow Accent Bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    margin: 0 -1.25rem 1.25rem -1.25rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.90) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    box-shadow: 0 4px 25px rgba(99, 102, 241, 0.08);
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-rainbow);
    opacity: 0.9;
}

/* Sidebar Toggle (Hamburger) Button */
.sidebar-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(236, 72, 153, 0.08));
    color: #4f46e5;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
    padding: 0;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.15));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Sidebar Close Button */
.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    background: #ef4444;
    color: #ffffff;
    transform: scale(1.05);
}

.sidebar-close-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Pinned Top Brand Header */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.15rem;
    padding: 0 0.4rem;
    flex-shrink: 0;
}

/* Scrollable Middle Navigation Container */
.sidebar-nav-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.sidebar-nav-container::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav-container::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav-container::-webkit-scrollbar-thumb {
    background: rgba(129, 140, 248, 0.4);
    border-radius: 999px;
}
.sidebar-nav-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-pink);
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #ec4899 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(236, 72, 153, 0.45);
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.brand-logo:hover {
    transform: scale(1.06) rotate(4deg);
}

.brand-logo svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.brand-title {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 50%, #db2777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* User Profile Switcher / Panel */
.user-panel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(236, 72, 153, 0.06));
    border: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.04);
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #ec4899);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.user-info {
    flex-grow: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-select {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    width: 100%;
    font-weight: 600;
}

.user-role-select option {
    background: #ffffff;
    color: #0f172a;
}

.user-role-select optgroup {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #f1f5f9;
}

/* Navigation Links */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.70rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    margin: 0.1rem 0.15rem;
}

.nav-item a svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
    opacity: 0.9;
    transition: transform 0.2s ease;
}

.nav-item a:hover {
    color: var(--primary);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(236, 72, 153, 0.06));
    transform: translateX(3px);
}

.nav-item a:hover svg {
    transform: scale(1.1);
}

.nav-item.active a {
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 55%, #ec4899 100%);
    box-shadow: 0 5px 18px rgba(124, 58, 237, 0.38);
    font-weight: 700;
}

.nav-item.active a svg {
    opacity: 1;
    fill: #ffffff;
}

/* Nav Group (collapsible parent) */
.nav-group-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    white-space: nowrap;
}

.nav-group-label svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

.nav-group-label:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-group-label .chevron {
    margin-left: auto;
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.nav-group.open .nav-group-label .chevron {
    transform: rotate(180deg);
}

.nav-group.open .nav-group-label {
    color: var(--primary);
    font-weight: 700;
}

/* Sub-menu */
.nav-sub-menu {
    list-style: none;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 0.5rem;
}

.nav-group.open .nav-sub-menu {
    max-height: 500px;
}

.nav-sub-item a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem 0.55rem 1.2rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.92rem;
    transition: var(--transition);
    border-left: 2px solid transparent;
    font-weight: 500;
}

.nav-sub-item a:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    border-left-color: var(--primary);
    padding-left: 1.35rem;
}

.nav-sub-item.active a {
    color: #4f46e5;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.08));
    border-left-color: #ec4899;
    font-weight: 700;
}

.nav-sub-item .sub-badge {
    margin-left: auto;
    font-size: 0.8rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: #ffffff;
    font-weight: 700;
    flex-shrink: 0;
}

/* Sidebar Footer & Fiscal Year Badge */
.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 0.85rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(236, 72, 153, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    text-align: center;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.05);
}

.sidebar-school-text {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.35;
    letter-spacing: 0.01em;
}

.sidebar-fy-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #ec4899 100%);
    color: #ffffff;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-fy-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.45);
}

.sidebar-fy-badge svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
    flex-shrink: 0;
}

.sidebar-fy-badge strong,
.sidebar-fy-badge #sidebar-fiscal-year {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.03em;
}

/* Header Section */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h1 {
    font-size: 1.85rem;
    font-weight: 800;
    background: linear-gradient(135deg, #1e293b 0%, #4338ca 60%, #db2777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-title p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Dashboard Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.35rem;
}

.metric-card {
    border-radius: 20px;
    padding: 1.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 20px -2px rgba(99, 102, 241, 0.08);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-brand);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px -4px rgba(99, 102, 241, 0.16);
    border-color: var(--border-hover);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.metric-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.metric-icon.indigo { background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(124, 58, 237, 0.18)); color: #4f46e5; }
.metric-icon.emerald { background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(5, 150, 105, 0.18)); color: #059669; }
.metric-icon.amber { background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.18)); color: #d97706; }
.metric-icon.cyan { background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(2, 132, 199, 0.18)); color: #0284c7; }
.metric-icon.pink { background: linear-gradient(135deg, rgba(236, 72, 153, 0.18), rgba(219, 39, 119, 0.18)); color: #db2777; }
.metric-icon.purple { background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(124, 58, 237, 0.18)); color: #7c3aed; }

.metric-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-footer {
    font-size: 0.88rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
}

/* Dashboard Visuals & Section Cards */
.dash-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dash-layout {
        grid-template-columns: 1fr;
    }
}

.section-card {
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 20px -2px rgba(99, 102, 241, 0.06);
    position: relative;
    overflow: hidden;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forms styling */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-group.full-width {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .form-group.full-width {
        grid-column: span 1;
    }
}

label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 11pt;
    outline: none;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

input:focus,
select:focus,
textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.35rem;
    border-radius: 9999px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    user-select: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #ec4899 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 50%, #db2777 100%);
    box-shadow: 0 6px 22px rgba(236, 72, 153, 0.45);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.08), rgba(236, 72, 153, 0.08));
    border-color: rgba(99, 102, 241, 0.4);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.35);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #be123c 0%, #e11d48 100%);
    box-shadow: 0 6px 20px rgba(244, 63, 94, 0.45);
    transform: translateY(-2px);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.45rem 0.95rem;
    font-size: 0.88rem;
}

/* Table Action Buttons Pill Styling */
.btn-action-group {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: auto;
    min-width: 100px;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 9999px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1.2;
    box-sizing: border-box;
    white-space: nowrap;
    text-align: center;
    border: 1px solid transparent;
}

.btn-action-edit {
    background: linear-gradient(135deg, #fdf2f8, #fce7f3);
    color: #db2777;
    border-color: #fbcfe8;
    box-shadow: 0 2px 6px rgba(236, 72, 153, 0.12);
}
.btn-action-edit:hover {
    background: linear-gradient(135deg, #ec4899, #f43f5e);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.4);
    transform: translateY(-2px);
}

.btn-action-print {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    border-color: #bfdbfe;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.12);
}
.btn-action-print:hover {
    background: linear-gradient(135deg, #2563eb, #0284c7);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transform: translateY(-2px);
}

.btn-action-word {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #047857;
    border-color: #a7f3d0;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.12);
}
.btn-action-word:hover {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.btn-action-del {
    background: linear-gradient(135deg, #fff1f2, #ffe4e6);
    color: #e11d48;
    border-color: #fecdd3;
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.12);
}
.btn-action-del:hover {
    background: linear-gradient(135deg, #e11d48, #f43f5e);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.4);
    transform: translateY(-2px);
}

/* Tables styling */
.table-container {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.05);
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th, thead th {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    color: #1e293b;
    padding: 0.95rem 1.15rem;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    border-bottom: 2px solid rgba(99, 102, 241, 0.18);
}

td {
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    color: var(--text-primary);
    background: #ffffff;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05), rgba(236, 72, 153, 0.03)) !important;
}

/* Radiant Status Badges */
.badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap !important;
    word-break: keep-all !important;
    flex-shrink: 0 !important;
}

.badge-draft {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge-pending {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
    border: 1px solid #fcd34d;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.badge-success {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
    border: 1px solid #6ee7b7;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: linear-gradient(135deg, #ffe4e6, #fecdd3);
    color: #be123c;
    border: 1px solid #fda4af;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.badge-info {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0369a1;
    border: 1px solid #7dd3fc;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.2);
}

.badge-pink {
    background: linear-gradient(135deg, #fdf2f8, #fce7f3);
    color: #be185d;
    border: 1px solid #fbcfe8;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.2);
}

.badge-purple {
    background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
    color: #6b21a8;
    border: 1px solid #d8b4fe;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2);
}

.badge-blue-pink {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #ec4899 100%);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.35);
}

/* Tabs container logic */
.tab-content {
    display: none;
    animation: fadeIn 0.35s ease;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Checklist form sections */
.checklist-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.35rem;
    margin-bottom: 1.15rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.04);
}

.checklist-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checklist-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding-left: 2rem;
    opacity: 0.5;
    pointer-events: none;
    transition: var(--transition);
}

.checklist-row.checked .checklist-inputs {
    opacity: 1;
    pointer-events: auto;
}

.chk-input-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chk-input-inline input[type="number"] {
    width: 90px;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
}

/* Dynamic Itemized Budget Table (ผง.03 editor) */
.itemized-table-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.35rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.04);
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
    border-radius: 9999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal Popup layout */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active,
.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 24px;
    width: 100%;
    max-width: 850px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px -10px rgba(99, 102, 241, 0.25);
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
    from { transform: scale(0.95) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.35rem 1.75rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.14);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.07) 0%, rgba(236, 72, 153, 0.04) 100%);
    backdrop-filter: blur(10px);
    z-index: 99;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.modal-body {
    padding: 1.75rem;
}

.modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #f8fafc;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

/* Signatures list */
.sig-col-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}
@media (max-width: 600px) {
    .sig-col-grid {
        grid-template-columns: 1fr;
    }
}

/* Custom Checkbox Design */
.custom-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 22px;
    width: 22px;
    background-color: #ffffff;
    border: 2px solid rgba(99, 102, 241, 0.35);
    border-radius: 8px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.custom-checkbox:hover input ~ .checkmark {
    border-color: #4f46e5;
    background-color: rgba(99, 102, 241, 0.08);
}

.custom-checkbox input:checked ~ .checkmark {
    background: linear-gradient(135deg, #2563eb, #ec4899);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

.checkmark:after {
    content: "";
    display: none;
    width: 5px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* Custom Searchable Multi-Select Component */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.custom-multiselect-box {
    min-height: 42px;
    max-height: 90px;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 5px 8px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    background: #ffffff;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    cursor: text;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-multiselect-box:focus-within {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.custom-multiselect-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.custom-multiselect-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
    animation: fadeIn 0.15s ease;
}

.custom-multiselect-chip .chip-remove {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.custom-multiselect-chip .chip-remove:hover {
    opacity: 1;
    transform: scale(1.2);
}

.custom-multiselect-input {
    border: none !important;
    background: transparent !important;
    color: var(--text-primary) !important;
    font-size: 0.95rem;
    outline: none !important;
    box-shadow: none !important;
    flex: 1;
    min-width: 120px;
    padding: 3px 0;
}

.custom-multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 14px;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.18);
    display: none;
    margin-top: 5px;
}

.custom-multiselect-dropdown.show {
    display: block;
}

.custom-multiselect-option {
    padding: 7px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    line-height: 1.3;
    transition: background 0.15s;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.custom-multiselect-option:last-child {
    border-bottom: none;
}

.custom-multiselect-option:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05));
    color: #4f46e5;
}

.custom-multiselect-option.selected {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.08));
    color: #4f46e5;
    font-weight: 700;
}

.custom-multiselect-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.custom-multiselect-footer {
    padding: 7px 12px;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
}

/* User Account Status Toggle Button */
.status-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
    user-select: none;
}

.status-toggle-btn.active {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
    border-color: #6ee7b7;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

.status-toggle-btn.active:hover {
    background: linear-gradient(135deg, #a7f3d0, #6ee7b7);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.status-toggle-btn.inactive {
    background: linear-gradient(135deg, #ffe4e6, #fecdd3);
    color: #be123c;
    border-color: #fda4af;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

.status-toggle-btn.inactive:hover {
    background: linear-gradient(135deg, #fecdd3, #fda4af);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.row-inactive {
    opacity: 0.65;
    background: rgba(239, 68, 68, 0.02);
}
.row-inactive:hover {
    opacity: 0.9;
}

/* ==========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM (DESKTOP, TABLET, MOBILE)
   ========================================================================== */

/* Utility container for responsive topbar left section */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    flex: 1;
}

/* ── Tablets & Below (<= 992px) ── */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 290px;
    }

    body {
        font-size: 1rem;
    }

    .sidebar-toggle-btn {
        display: inline-flex !important;
    }

    .sidebar-close-btn {
        display: inline-flex !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: var(--sidebar-width) !important;
        max-width: 86vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        transform: translateX(-105%) !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.28) !important;
        padding: 1rem 0.75rem !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 1rem 1.5rem 1rem !important;
    }

    .topbar {
        margin: 0 -1rem 1.25rem -1rem !important;
        padding: 0.75rem 1rem !important;
        gap: 0.75rem;
    }

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

    .topbar-title h1 {
        font-size: 1.18rem !important;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-title p {
        font-size: 0.80rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-actions {
        gap: 0.6rem !important;
        flex-shrink: 0;
    }

    .topbar-user {
        padding: 0.35rem 0.65rem !important;
        gap: 0.5rem !important;
    }

    .dash-layout {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* DMC Calculator Responsive Navigation */
    .dmc-tier1-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .dmc-tier2-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ── Small Tablets & Large Phones (<= 768px) ── */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .main-content {
        padding: 0 0.75rem 1.25rem 0.75rem !important;
        gap: 1rem !important;
    }

    .topbar {
        margin: 0 -0.75rem 1rem -0.75rem !important;
        padding: 0.65rem 0.75rem !important;
    }

    .topbar-pos {
        display: none !important;
    }

    .topbar-name {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.82rem !important;
    }

    .btn-logout {
        padding: 0.45rem 0.75rem !important;
        font-size: 0.82rem !important;
        border-radius: 10px !important;
    }

    .content-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .header-title h1 {
        font-size: 1.45rem !important;
    }

    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .metric-card {
        padding: 1.15rem !important;
        border-radius: 16px !important;
    }

    .metric-value {
        font-size: 1.55rem !important;
    }

    .section-card {
        padding: 1.15rem !important;
        border-radius: 16px !important;
        gap: 1rem !important;
    }

    .section-header {
        padding: 0.85rem 1rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.6rem !important;
    }

    .section-body {
        padding: 1rem !important;
    }

    .section-title {
        font-size: 1.1rem !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.9rem !important;
    }

    .form-group.full-width {
        grid-column: span 1 !important;
    }

    /* Modal dialogs */
    .modal-overlay {
        padding: 0.65rem !important;
        align-items: flex-end !important;
    }

    .modal-box {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1rem 1.25rem !important;
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
    }

    .modal-title {
        font-size: 1.15rem !important;
    }

    .modal-body {
        padding: 1.15rem !important;
        max-height: calc(90vh - 130px) !important;
        max-height: calc(90dvh - 130px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .modal-footer {
        padding: 0.85rem 1.25rem !important;
        flex-wrap: wrap !important;
        gap: 0.6rem !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* Tables */
    .table-container {
        border-radius: 14px !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        overflow-x: auto !important;
    }

    table {
        min-width: 580px;
    }

    th, thead th {
        padding: 0.70rem 0.75rem !important;
        font-size: 0.78rem !important;
        white-space: nowrap;
    }

    td {
        padding: 0.70rem 0.75rem !important;
        font-size: 0.88rem !important;
    }

    .btn-action-group {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        min-width: unset !important;
    }

    .btn-action {
        padding: 5px 10px !important;
        font-size: 0.80rem !important;
    }

    /* Form Checklist */
    .checklist-section {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    .checklist-header-row {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        margin-bottom: 0.6rem !important;
    }

    .checklist-inputs {
        padding-left: 0 !important;
        gap: 0.6rem !important;
    }

    .chk-input-inline {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .chk-input-inline input[type="number"] {
        width: 120px !important;
    }

    /* Multi-select */
    .custom-multiselect-dropdown {
        max-height: 160px !important;
    }

    .assignments-grid {
        grid-template-columns: 1fr !important;
    }

    .sig-col-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* DMC Calculator on tablets/mobiles */
    .dmc-tier1-grid {
        grid-template-columns: 1fr !important;
    }

    .dmc-tier2-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #dmc-top-actions-container {
        width: 100%;
        justify-content: flex-start;
    }

    #dmc-top-actions-container .btn {
        flex: 1 1 calc(50% - 0.5rem);
        justify-content: center;
        font-size: 0.80rem !important;
    }

    .dmc-sem-btn {
        flex: 1 1 100% !important;
        min-width: 100% !important;
    }
}

/* ── Mobile Phones (<= 576px) ── */
@media (max-width: 576px) {
    html {
        font-size: 14.5px;
    }

    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
        padding: 0.65rem 0.85rem !important;
    }

    .topbar-actions .topbar-user {
        padding: 0.25rem 0.45rem !important;
    }

    .topbar-name {
        max-width: 70px;
    }

    .topbar-title h1 {
        font-size: 1.05rem !important;
    }

    .topbar-title p {
        display: none !important;
    }

    .btn-logout span {
        display: none;
    }

    .btn-logout {
        padding: 0.5rem 0.65rem !important;
    }

    .dmc-tier2-grid {
        grid-template-columns: 1fr !important;
    }

    .dmc-tier2-grid button {
        padding: 0.55rem 0.35rem !important;
        font-size: 0.82rem !important;
    }

    #dmc-top-actions-container .btn {
        flex: 1 1 100%;
    }

    .btn-action-group {
        width: 100%;
    }

    .btn-action {
        flex: 1 1 auto;
    }
}

/* ── Section 4 PDCA Activity Steps ── */
.act-step-row {
    transition: all 0.2s ease;
}
.act-step-row:hover {
    border-color: rgba(99, 102, 241, 0.35) !important;
}

@media (max-width: 768px) {
    .act-step-header {
        display: none !important;
    }
    .act-step-main-grid {
        grid-template-columns: 1fr !important;
        gap: 0.45rem !important;
    }
    .act-step-row {
        padding: 0.75rem !important;
        margin-bottom: 0.65rem !important;
    }
}



