/* =============================================
   การเงินและพัสดุ — Main Design System
   สไตล์ EGP+ : Sidebar สีเข้ม + Content สีขาว
   ============================================= */

/* Google Fonts - Sarabun (Thai) */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* =============================================
   CSS Variables — Design Tokens
   ============================================= */
:root {
    /* Primary Colors */
    --primary: #0d7c8f;
    --primary-dark: #095e6e;
    --primary-light: #11a3ba;
    --primary-surface: #e8f7fa;

    /* Sidebar */
    --sidebar-bg: #1a2332;
    --sidebar-hover: #243044;
    --sidebar-active: #0d7c8f;
    --sidebar-text: #a8b5c8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;

    /* Top Header */
    --header-bg: #ffffff;
    --header-height: 60px;
    --header-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    /* Background */
    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --bg-section: #f8fafc;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;

    /* Status Colors */
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;

    /* Card Stats Colors (EGP+ Style) */
    --stat-green: #2ecc71;
    --stat-blue: #3498db;
    --stat-teal: #1abc9c;
    --stat-yellow: #f1c40f;
    --stat-orange: #e67e22;
    --stat-red: #e74c3c;

    /* Border */
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 50px -5px rgba(0, 0, 0, 0.15);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Font */
    --font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* =============================================
   Reset & Base
   ============================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

img {
    max-width: 100%;
    height: auto;
}

/* =============================================
   Layout — Sidebar + Content
   ============================================= */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-normal);
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-hover) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover);
    border-radius: 4px;
}

/* Collapsed State */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-nav .nav-link span:not(.icon),
body.sidebar-collapsed .sidebar-nav .arrow,
body.sidebar-collapsed .sidebar-brand small,
body.sidebar-collapsed .badge-new {
    display: none !important;
}
body.sidebar-collapsed .nav-item.has-submenu .submenu {
    display: none !important;
}
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
body.sidebar-collapsed .sidebar-brand-icon {
    width: 32px;
    height: 32px;
}
body.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 12px 0;
}
body.sidebar-collapsed .nav-link .icon {
    margin: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand-text {
    color: var(--text-white);
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand-text small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--sidebar-text);
    margin-top: 2px;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: var(--space-md) 0;
}

.sidebar-label {
    display: block;
    padding: var(--space-sm) var(--space-lg);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--sidebar-text);
    letter-spacing: 0.5px;
    margin-top: var(--space-sm);
}

.nav-item {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-lg);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 400;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-light);
    border-radius: 0 3px 3px 0;
}

.nav-link .icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link .badge-new {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* Submenu */
.submenu {
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
    background: rgba(0, 0, 0, 0.15);
}

.submenu.open {
    max-height: 500px;
}

.submenu .nav-link {
    padding-left: 56px;
    font-size: 13px;
}

.nav-link .arrow {
    margin-left: auto;
    transition: transform var(--transition-fast);
    font-size: 12px;
}

.nav-link.expanded .arrow {
    transform: rotate(90deg);
}

/* =============================================
   Main Content Area
   ============================================= */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: var(--header-shadow);
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-section);
}

.school-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--primary-surface);
    border: 1px solid var(--primary);
    color: var(--primary-dark);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.school-badge .icon {
    font-size: 14px;
}

/* Top Header Quick Actions */
.top-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 10px;
    font-weight: 500;
    color: white;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    text-decoration: none;
    min-width: 72px;
}

.header-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white;
}

.header-btn .icon {
    font-size: 18px;
}

.header-btn-blue { background: var(--info); }
.header-btn-green { background: var(--stat-green); }
.header-btn-teal { background: var(--primary); }
.header-btn-orange { background: var(--stat-orange); }
.header-btn-red { background: var(--danger); }

/* =============================================
   Content Area
   ============================================= */
.content-area {
    padding: var(--space-lg);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.content-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Breadcrumb */
.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb span {
    color: var(--text-primary);
    font-weight: 500;
}

/* =============================================
   Budget Year Selector
   ============================================= */
.fiscal-year-selector {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--stat-green);
    color: white;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.fiscal-year-selector:hover {
    background: #27ae60;
}

.fiscal-year-selector .icon {
    font-size: 14px;
}

/* =============================================
   Cards
   ============================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-fast);
    overflow: hidden;
}

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

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-section);
}

/* =============================================
   Stat Cards (Dashboard)
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 130px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card.green { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.stat-card.blue { background: linear-gradient(135deg, #3498db, #2980b9); }
.stat-card.teal { background: linear-gradient(135deg, #1abc9c, #16a085); }
.stat-card.yellow { background: linear-gradient(135deg, #f1c40f, #f39c12); }

.stat-number {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    margin-top: var(--space-xs);
    opacity: 0.95;
}

.stat-icon {
    font-size: 24px;
    margin-top: var(--space-sm);
    opacity: 0.85;
}

/* =============================================
   Dashboard Widgets Grid
   ============================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.widget-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.widget-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.widget-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.widget-card .widget-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}

.widget-card .widget-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-card .widget-info p {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* =============================================
   Quick Menu (Dashboard)
   ============================================= */
.quick-menu-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.quick-menu-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-md);
}

.quick-menu-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: var(--text-primary);
}

.quick-menu-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    color: var(--primary);
}

.quick-menu-item .icon {
    font-size: 32px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.quick-menu-item:hover .icon {
    color: var(--primary);
}

.quick-menu-item .label {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

/* =============================================
   Section Headers (Colored Labels)
   ============================================= */
.section-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-bottom: var(--space-md);
}

.section-label.blue { background: var(--info); }
.section-label.green { background: var(--stat-green); }
.section-label.orange { background: var(--stat-orange); }
.section-label.red { background: var(--danger); }
.section-label.teal { background: var(--primary); }
.section-label.yellow { background: var(--stat-yellow); color: var(--text-primary); }

/* =============================================
   Tables
   ============================================= */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    background: var(--primary);
    color: white;
}

.data-table th {
    padding: 8px 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    font-size: 13px;
}

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--primary-surface);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table Actions */
.table-actions {
    display: flex;
    gap: var(--space-xs);
}

.btn-action {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    transition: all var(--transition-fast);
}

.btn-action:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-sm);
}

.btn-action.edit { background: var(--stat-orange); }
.btn-action.delete { background: var(--danger); }
.btn-action.view { background: var(--info); }

/* =============================================
   Badges / Status
   ============================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: #15803d; }
.badge-warning { background: var(--warning-bg); color: #a16207; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; }
.badge-primary { background: var(--info-bg); color: #1d4ed8; }
.badge-secondary { background: #f1f5f9; color: #475569; }

.badge-active {
    background: var(--success);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
}

.badge-inactive {
    background: var(--text-muted);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
}

/* =============================================
   Forms
   ============================================= */
.form-group {
    margin-bottom: 12px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 124, 143, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-success {
    background: var(--stat-green);
    color: white;
}

.btn-success:hover {
    background: #27ae60;
    color: white;
}

.btn-warning {
    background: var(--stat-orange);
    color: white;
}

.btn-warning:hover {
    background: #d35400;
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
}

.btn-secondary {
    background: var(--bg-section);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

/* =============================================
   Alerts / Flash Messages
   ============================================= */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: var(--danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-bg);
    color: #a16207;
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-bg);
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   Pagination
   ============================================= */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-lg);
    justify-content: center;
}

.page-link {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.page-link:hover {
    background: var(--primary-surface);
    border-color: var(--primary);
    color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* =============================================
   Footer
   ============================================= */
.app-footer {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-xl);
}

/* =============================================
   Utility Classes
   ============================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

/* =============================================
   Search & Toolbar
   ============================================= */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.search-box {
    position: relative;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

/* =============================================
   Modal / Dialog
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-section);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.modal-close:hover {
    background: var(--border-color);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .quick-menu-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .top-header-right {
        display: none;
    }
    .quick-menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-row-3,
    .form-row-2 {
        grid-template-columns: 1fr;
    }
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .content-area {
        padding: var(--space-md);
    }
}

/* Hide HTML5 Number Input Spinners / Up-Down Arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
input[type="number"] {
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

