/* =====================================================
   CSS VARIABLES & THEMES
   ===================================================== */
:root {
    /* Common Layout & Brand */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
    /* Touch-friendly minimum (iPad/phone) */
    --touch-min: 44px;

    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-light: rgba(13, 110, 253, 0.12);
    --secondary: #6c757d;
    --success: #198754;
    --success-light: rgba(25, 135, 84, 0.12);
    --danger: #dc3545;
    --danger-light: rgba(220, 53, 69, 0.12);
    --warning: #ffc107;
    --warning-light: rgba(255, 193, 7, 0.15);
    --info: #0dcaf0;
    --info-light: rgba(13, 202, 240, 0.12);
    --accent: #c2185b;
    --accent-hover: #ad1457;
    --accent-light: rgba(194, 24, 91, 0.12);

    /* Light Theme (Default) */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ebebed;
    --text-primary: #1d1d1f;
    --text-secondary: #424245;
    --text-muted: #86868b;
    --border-color: #d2d2d7;
    --shadow-color: rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    color-scheme: light;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --bg-primary: #0f1114;
    --bg-secondary: #1a1d21;
    --bg-tertiary: #24282d;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #6e6e73;
    --border-color: #2d3339;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

/* Specific Light Theme override just in case data-theme="light" is explicitly set */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.08);
    color-scheme: light;
}

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

html {
    font-size: clamp(15px, 2.2vw, 16px);
    scroll-behavior: smooth;
    background-color: var(--bg-primary);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* =====================================================
   THEME TOGGLE SWITCH
   ===================================================== */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-switch {
    display: inline-block;
    height: 28px;
    min-height: var(--touch-min);
    position: relative;
    width: 50px;
}
@media (max-width: 767px) {
    .theme-switch {
        height: 32px;
        width: 56px;
    }
    .slider:before {
        height: 24px;
        width: 24px;
    }
    input:checked + .slider:before {
        transform: translateX(26px);
    }
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    background-color: white;
    bottom: 4px;
    content: "";
    height: 20px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 12px;
    color: #f1c40f;
}

/* Sun icon for light mode */
.slider:before {
    content: "\f185";
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(22px);
    content: "\f186";
    /* Moon icon for dark mode */
    color: #f1c40f;
}

.theme-label-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Theme toggle inside user dropdown */
.dropdown-item-theme {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: default;
    flex-wrap: nowrap;
}
.dropdown-item-theme .theme-label-text {
    text-transform: none;
    letter-spacing: 0;
    flex: 1;
}
.theme-switch-dropdown {
    flex-shrink: 0;
    margin-left: auto;
}
.dropdown-item-theme .theme-switch {
    width: 44px;
    height: 24px;
}
.dropdown-item-theme .slider:before {
    height: 16px;
    width: 16px;
}
.dropdown-item-theme input:checked + .slider:before {
    transform: translateX(20px);
}

/* =====================================================
   LAYOUT
   ===================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    transition: var(--transition);
}

.content-area {
    padding: 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Tablet: comfortable padding */
@media (min-width: 768px) and (max-width: 1024px) {
    .content-area {
        padding: 1.5rem 1.5rem 2rem;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .content-area {
        padding: 1.5rem 2rem 2rem;
    }
}

/* Mobile Layout */
@media (max-width: 991px) {
    .main-content {
        margin-left: 0;
    }
    .content-area {
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* =====================================================
   HEADER
   ===================================================== */
.app-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    min-height: var(--touch-min);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem 0 1.25rem;
    padding-top: env(safe-area-inset-top);
    padding-right: max(1rem, env(safe-area-inset-right));
    z-index: 100;
    transition: var(--transition);
}

@media (min-width: 768px) {
    .app-header {
        padding: 0 1.5rem;
        padding-top: env(safe-area-inset-top);
    }
}

@media (max-width: 991px) {
    .app-header {
        left: 0;
        padding-left: max(1rem, env(safe-area-inset-left));
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.35rem;
    cursor: pointer;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}
.menu-toggle:hover,
.menu-toggle:focus {
    background: var(--bg-tertiary);
    outline: none;
}

@media (max-width: 991px) {
    .menu-toggle {
        display: flex;
    }
}

.page-title {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Branch Selector */
.branch-selector {
    position: relative;
}

.branch-selector select {
    appearance: none;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 2rem 0.5rem 1rem;
    min-height: var(--touch-min);
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}
@media (max-width: 767px) {
    .branch-selector {
        max-width: 140px;
    }
    .branch-selector select {
        font-size: 0.8rem;
        padding: 0.4rem 1.75rem 0.4rem 0.75rem;
    }
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 200;
    transition: var(--transition), background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    padding-left: env(safe-area-inset-left);
}

.sidebar-header {
    height: var(--header-height);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    padding-top: env(safe-area-inset-top);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.logo i {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    min-height: var(--touch-min);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

/* Sidebar footer hint (service period / view-only) */
.sidebar-footer-hint {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}
.sidebar-hint-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sidebar-hint-text i {
    font-size: 0.65rem;
}

/* Mobile Sidebar */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* Stat Cards */
.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-icon.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-icon.accent {
    background: var(--accent-light);
    color: var(--accent);
}

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    min-height: var(--touch-min);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition), background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
@media (max-width: 767px) {
    .btn:not(.btn-icon):not(.btn-sm) {
        padding: 0.75rem 1.25rem;
    }
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

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

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

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

.btn-sm {
    padding: 0.5rem 0.875rem;
    min-height: 36px;
    font-size: 0.8rem;
}
@media (max-width: 767px) {
    .btn-sm {
        min-height: var(--touch-min);
        padding: 0.5rem 0.875rem;
    }
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    min-height: var(--touch-min);
    font-size: 16px; /* prevents zoom on iOS when focus */
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition), background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
@media (min-width: 768px) {
    .form-control {
        font-size: 0.9rem;
        min-height: auto;
        padding: 0.625rem 0.875rem;
    }
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236c757d'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 20px;
    padding-right: 2.5rem;
}

/* Form Grid */
.form-row {
    display: grid;
    gap: 1rem;
}

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

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

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

@media (max-width: 767px) {

    .form-row-2,
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   TABLES
   ===================================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.table td {
    font-size: 0.9rem;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

/* =====================================================
   BADGES & STATUS
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 50px;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: #856404;
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background: var(--info-light);
    color: #0c5460;
}

.badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* =====================================================
   DATA LIST (Mobile-friendly alternative to tables)
   ===================================================== */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.data-item-title {
    font-weight: 600;
    color: var(--text-primary);
}

.data-item-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.data-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}
.data-item-actions .btn {
    min-height: 36px;
}
@media (max-width: 767px) {
    .data-item-actions .btn {
        min-height: var(--touch-min);
        flex: 1;
        justify-content: center;
    }
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

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

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-accent {
    color: var(--accent);
}

.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.w-100 {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Grid System */
.row {
    display: grid;
    gap: 1.5rem;
}

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

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

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

@media (max-width: 991px) {
    .row-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {

    .row-2,
    .row-3,
    .row-4 {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* =====================================================
   LOADING & ALERTS
   ===================================================== */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    color: #856404;
}

.alert-info {
    background: var(--info-light);
    color: #0c5460;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

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

    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* =====================================================
   SEARCH & FILTERS
   ===================================================== */
.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    min-height: var(--touch-min);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-primary);
    font-size: 16px;
    color: var(--text-primary);
}
@media (min-width: 768px) {
    .search-box input {
        font-size: 0.875rem;
        min-height: auto;
    }
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {

    .app-sidebar,
    .app-header,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* =====================================================
   USER MENU DROPDOWN
   ===================================================== */
.user-menu-dropdown {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    min-height: var(--touch-min);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

.user-menu-toggle:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.user-info .user-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.user-info .user-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.toggle-icon {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.user-menu-dropdown.active .toggle-icon {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px var(--shadow-color);
    padding: 0.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
}

.dropdown-header strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.dropdown-header span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dropdown-header .dropdown-access-until {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.dropdown-header .dropdown-access-until i {
    font-size: 0.65rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-item.logout:hover {
    background: var(--danger-light);
    color: var(--danger);
}

@media (max-width: 575px) {
    .user-info {
        display: none;
    }
    
    .user-menu-toggle {
        padding: 0.5rem;
    }
}

/* =====================================================
   STAT GRID
   ===================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-grid .stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

@media (max-width: 991px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Quick actions (dashboard): stack on small screens for easier tap */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
@media (max-width: 767px) {
    .quick-actions {
        flex-direction: column;
    }
    .quick-actions .btn {
        width: 100%;
    }
}

/* Badge Accent */
.badge-accent {
    background: var(--accent-light);
    color: var(--accent);
}

/* Justify Center */
.justify-center {
    justify-content: center;
}

/* Hidden on mobile */
@media (max-width: 767px) {
    .hidden-mobile {
        display: none !important;
    }
}