/*
 * GovFrame CSS — Template Sistem Pemerintahan/Korporat
 * Versi: 2.0.0 | Responsive + Dynamic Theme
 * Dibangun dari desain SIM Aset Sewerage
 * ============================================================
 */

/* ── GOOGLE FONTS ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700&family=DM+Sans:wght@300;400;500;600&family=Space+Grotesk:wght@400;500;600;700&family=Fraunces:ital,wght@0,400;0,700;1,400&display=swap');

/* ══════════════════════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES (TEMA)
   ══════════════════════════════════════════════════════════════ */

/* TEMA DEFAULT: Navy Gold (Pemerintahan) */
:root,
[data-theme="navy"] {
    --primary:        #0d3b6e;
    --primary-dark:   #082c54;
    --primary-light:  #1a5fa0;
    --primary-rgb:    13,59,110;
    --accent:         #c8a93e;
    --accent-light:   #e5c96b;
    --accent-dark:    #a88a28;
    --accent-rgb:     200,169,62;

    --success:        #1a8a5a;
    --success-bg:     rgba(26,138,90,0.08);
    --danger:         #c0392b;
    --danger-bg:      rgba(192,57,43,0.08);
    --warning:        #d4880e;
    --warning-bg:     rgba(212,136,14,0.08);
    --info:           #1a7bb0;
    --info-bg:        rgba(26,123,176,0.08);

    --bg:             #f0f3f8;
    --bg-card:        #ffffff;
    --bg-sidebar:     #082c54;
    --text:           #1a2744;
    --text-muted:     #6b7da0;
    --text-light:     #9aaac4;
    --border:         #d0daea;
    --border-light:   #e8eef6;

    --shadow-sm:      0 2px 8px rgba(13,59,110,0.07);
    --shadow:         0 4px 24px rgba(13,59,110,0.10);
    --shadow-lg:      0 8px 40px rgba(13,59,110,0.16);
    --shadow-xl:      0 16px 60px rgba(13,59,110,0.20);

    --radius-sm:      6px;
    --radius:         12px;
    --radius-lg:      16px;
    --radius-xl:      24px;

    --font-display:   'Playfair Display', Georgia, serif;
    --font-body:      'Plus Jakarta Sans', sans-serif;
    --nav-h:          68px;
    --sidebar-w:      260px;
    --topbar-h:       36px;
    --transition:     0.22s cubic-bezier(.4,0,.2,1);
}

/* TEMA: Emerald (Lingkungan/Kesehatan) */
[data-theme="emerald"] {
    --primary:        #064e3b;
    --primary-dark:   #022c22;
    --primary-light:  #065f46;
    --primary-rgb:    6,78,59;
    --accent:         #f59e0b;
    --accent-light:   #fbbf24;
    --accent-dark:    #d97706;
    --accent-rgb:     245,158,11;
    --bg:             #ecfdf5;
    --bg-card:        #ffffff;
    --bg-sidebar:     #022c22;
    --text:           #064e3b;
    --text-muted:     #6b7f74;
    --border:         #a7f3d0;
    --border-light:   #d1fae5;
    --shadow:         0 4px 24px rgba(6,78,59,0.10);
    --font-body:      'DM Sans', sans-serif;
}

/* TEMA: Crimson (Pemerintah Daerah / Berani) */
[data-theme="crimson"] {
    --primary:        #7f1d1d;
    --primary-dark:   #450a0a;
    --primary-light:  #991b1b;
    --primary-rgb:    127,29,29;
    --accent:         #f8c402;
    --accent-light:   #facc15;
    --accent-dark:    #ca8a04;
    --accent-rgb:     248,196,2;
    --bg:             #fff5f5;
    --bg-card:        #ffffff;
    --bg-sidebar:     #450a0a;
    --text:           #1c0a0a;
    --text-muted:     #7f4f4f;
    --border:         #fecaca;
    --border-light:   #fee2e2;
    --shadow:         0 4px 24px rgba(127,29,29,0.10);
    --font-body:      'Space Grotesk', sans-serif;
    --font-display:   'Fraunces', Georgia, serif;
}

/* TEMA: Slate (Teknologi / Modern) */
[data-theme="slate"] {
    --primary:        #1e293b;
    --primary-dark:   #0f172a;
    --primary-light:  #334155;
    --primary-rgb:    30,41,59;
    --accent:         #38bdf8;
    --accent-light:   #7dd3fc;
    --accent-dark:    #0284c7;
    --accent-rgb:     56,189,248;
    --bg:             #f1f5f9;
    --bg-card:        #ffffff;
    --bg-sidebar:     #0f172a;
    --text:           #0f172a;
    --text-muted:     #64748b;
    --border:         #cbd5e1;
    --border-light:   #e2e8f0;
    --shadow:         0 4px 24px rgba(30,41,59,0.10);
    --font-body:      'Space Grotesk', sans-serif;
    --font-display:   'Space Grotesk', sans-serif;
}

/* TEMA: Dark Mode */
[data-theme="dark"] {
    --primary:        #3b82f6;
    --primary-dark:   #1d4ed8;
    --primary-light:  #60a5fa;
    --primary-rgb:    59,130,246;
    --accent:         #f59e0b;
    --accent-light:   #fbbf24;
    --accent-dark:    #d97706;
    --accent-rgb:     245,158,11;
    --bg:             #0f172a;
    --bg-card:        #1e293b;
    --bg-sidebar:     #020617;
    --text:           #f1f5f9;
    --text-muted:     #94a3b8;
    --text-light:     #64748b;
    --border:         #334155;
    --border-light:   #1e293b;
    --shadow:         0 4px 24px rgba(0,0,0,0.40);
    --font-body:      'Space Grotesk', sans-serif;
}

/* ══════════════════════════════════════════════════════════════
   2. RESET & BASE
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
}

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

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ══════════════════════════════════════════════════════════════
   3. LAYOUT SHELL
   ══════════════════════════════════════════════════════════════ */

/* Layout with sidebar */
.app-shell {
    display: grid;
    grid-template-rows: var(--topbar-h) var(--nav-h) 1fr;
    grid-template-columns: 1fr;
    min-height: 100vh;
}
.app-shell.has-sidebar {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
}

/* ── TOPBAR ────────────────────────────────────────────────── */
.topbar {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    font-size: 0.72rem;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.03em;
    grid-column: 1 / -1;
    z-index: 200;
}
.topbar-left { display: flex; gap: 20px; align-items: center; }
.topbar-right { display: flex; gap: 16px; align-items: center; }
.topbar i { margin-right: 4px; color: var(--accent-light); font-size: 0.7rem; }

/* ── NAVBAR (horizontal) ───────────────────────────────────── */
nav.navbar {
    background: var(--primary);
    height: var(--nav-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.25);
    position: sticky;
    top: 0;
    z-index: 1000;
    grid-column: 1 / -1;
    gap: 8px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    margin-right: 24px;
    flex-shrink: 0;
}
.nav-logo {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: var(--primary-dark);
    flex-shrink: 0;
    transition: transform var(--transition);
}
.nav-logo:hover { transform: rotate(-5deg) scale(1.05); }
.nav-brand-text .app-name {
    font-size: 0.88rem; font-weight: 700; color: white; line-height: 1.2;
}
.nav-brand-text .app-sub {
    font-size: 0.62rem; color: rgba(255,255,255,0.55); line-height: 1;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-menu::-webkit-scrollbar { display: none; }

.nav-menu a {
    display: flex; align-items: center; gap: 6px;
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-menu a:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-menu a.active {
    background: var(--accent);
    color: var(--primary-dark);
    font-weight: 700;
}
.nav-menu a i { font-size: 0.85rem; }

.nav-right {
    display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0;
}
.nav-user {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 5px 12px 5px 6px;
    border-radius: 50px;
    cursor: pointer;
    transition: background var(--transition);
}
.nav-user:hover { background: rgba(255,255,255,0.18); }
.nav-avatar {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    color: var(--primary-dark);
}
.nav-user-name { color: white; font-size: 0.78rem; font-weight: 600; }

/* Hamburger (mobile) */
.nav-hamburger {
    display: none;
    background: none; border: none;
    color: white; font-size: 1.3rem;
    padding: 8px;
    border-radius: 8px;
    transition: background var(--transition);
}
.nav-hamburger:hover { background: rgba(255,255,255,0.12); }

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-sidebar);
    width: var(--sidebar-w);
    min-height: calc(100vh - var(--topbar-h));
    position: sticky;
    top: var(--topbar-h);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition), width var(--transition);
    z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    padding: 18px 20px 6px;
}
.sidebar-menu { list-style: none; padding: 4px 10px; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 10px;
    color: rgba(255,255,255,0.72);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all var(--transition);
    text-decoration: none;
}
.sidebar-menu a:hover { background: rgba(255,255,255,0.1); color: white; }
.sidebar-menu a.active {
    background: var(--accent);
    color: var(--primary-dark);
    font-weight: 700;
}
.sidebar-menu a i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-badge {
    margin-left: auto;
    background: var(--accent);
    color: var(--primary-dark);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 50px;
}
.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── MAIN CONTENT AREA ─────────────────────────────────────── */
.main-wrapper {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.main-content {
    padding: 28px 32px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}
.main-content.full-width { max-width: none; }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 24px 32px;
    color: white;
    border-bottom: 3px solid var(--accent);
    position: relative;
    overflow: hidden;
}
.page-header::after {
    content: '';
    position: absolute;
    right: -40px; top: -40px;
    width: 180px; height: 180px;
    border-radius: 50%;
    border: 40px solid rgba(255,255,255,0.04);
    pointer-events: none;
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.65rem;
    margin-bottom: 4px;
    position: relative;
}
.page-header p { color: rgba(255,255,255,0.72); font-size: 0.86rem; position: relative; }
.breadcrumb {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.55);
    margin-bottom: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    position: relative;
}
.breadcrumb a { color: var(--accent-light); text-decoration: none; }
.breadcrumb a:hover { color: white; }
.breadcrumb i { font-size: 0.6rem; }

/* ══════════════════════════════════════════════════════════════
   4. COMPONENTS
   ══════════════════════════════════════════════════════════════ */

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-hover:hover { transform: translateY(-3px); }

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card);
}
.card-header h3 {
    font-size: 0.95rem; font-weight: 700; color: var(--primary);
    display: flex; align-items: center; gap: 8px;
}
.card-header h3 i { color: var(--accent); }
.card-body { padding: 22px; }
.card-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-light);
    background: var(--bg);
    display: flex; align-items: center; justify-content: space-between;
}

/* Card variants */
.card-primary { border-top: 3px solid var(--primary); }
.card-accent   { border-top: 3px solid var(--accent); }
.card-success  { border-top: 3px solid var(--success); }
.card-danger   { border-top: 3px solid var(--danger); }

/* ── STAT CARDS ────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    display: flex; align-items: center; gap: 14px;
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }
.stat-card.accent  { border-left-color: var(--accent); }

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
    background: rgba(var(--primary-rgb),0.08);
    color: var(--primary);
}
.stat-card.success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.danger  .stat-icon { background: var(--danger-bg);  color: var(--danger); }
.stat-card.info    .stat-icon { background: var(--info-bg);    color: var(--info); }
.stat-card.accent  .stat-icon { background: rgba(var(--accent-rgb),0.12); color: var(--accent-dark); }

.stat-value { font-size: 1.85rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.76rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }
.stat-delta {
    font-size: 0.72rem; font-weight: 700; margin-top: 4px;
    display: flex; align-items: center; gap: 3px;
}
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── TABLES ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
    background: var(--primary);
    color: white;
    padding: 11px 14px;
    font-size: 0.76rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    letter-spacing: 0.04em;
    position: sticky; top: 0;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
    color: var(--text);
    vertical-align: middle;
    transition: background var(--transition);
}
tr:hover td { background: rgba(var(--primary-rgb),0.03); }
tr:nth-child(even) td { background: rgba(var(--primary-rgb),0.015); }
tr:nth-child(even):hover td { background: rgba(var(--primary-rgb),0.04); }
tr:last-child td { border-bottom: none; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    border-radius: 50px;
    font-size: 0.71rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.badge-primary { background: rgba(var(--primary-rgb),0.1); color: var(--primary); }
.badge-accent  { background: rgba(var(--accent-rgb),0.15); color: var(--accent-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gray    { background: rgba(0,0,0,0.06);  color: var(--text-muted); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1.5px solid transparent;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); color: white; }
.btn-accent  { background: var(--accent); color: var(--primary-dark); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-light); color: var(--primary-dark); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger  { background: var(--danger);  color: white; border-color: var(--danger); }
.btn-outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: rgba(var(--primary-rgb),0.07); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-lg { padding: 12px 28px; font-size: 0.92rem; border-radius: 10px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 0.79rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-hint { font-size: 0.71rem; color: var(--text-muted); margin-top: 4px; }

.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.84rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.08);
}
.form-control:invalid { border-color: var(--danger); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 80px; }

.input-group { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.9rem; pointer-events: none; }
.input-group .form-control { padding-left: 38px; }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid;
    display: flex; gap: 12px; align-items: flex-start;
    margin-bottom: 16px;
    font-size: 0.84rem;
}
.alert i { flex-shrink: 0; margin-top: 1px; }
.alert-warning { background: #fff3cd; border-color: #ffc107; color: #856404; }
.alert-danger  { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--bg-card);
    transition: all var(--transition);
}
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination a:hover:not(.active) { background: var(--bg); color: var(--primary); }

/* ── PROGRESS BARS ─────────────────────────────────────────── */
.progress { height: 8px; background: var(--border-light); border-radius: 50px; overflow: hidden; }
.progress-bar {
    height: 100%; border-radius: 50px;
    background: var(--primary);
    transition: width 0.6s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }
.progress-bar.accent  { background: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   5. UTILITY CLASSES
   ══════════════════════════════════════════════════════════════ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-4        { gap: 4px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.gap-20       { gap: 20px; }
.gap-24       { gap: 24px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.text-primary { color: var(--primary) !important; }
.text-accent  { color: var(--accent-dark) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-sm      { font-size: 0.82rem; }
.text-xs      { font-size: 0.72rem; }
.text-lg      { font-size: 1.1rem; }
.font-bold    { font-weight: 700; }
.font-600     { font-weight: 600; }
.text-center  { text-align: center; }

.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.w-full { width: 100%; }
.rounded  { border-radius: var(--radius); }
.shadow   { box-shadow: var(--shadow); }

.divider {
    height: 1px; background: var(--border-light);
    margin: 20px 0;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 12px; opacity: 0.35; }
.empty-state p { font-size: 0.9rem; }

/* ══════════════════════════════════════════════════════════════
   6. THEME SWITCHER WIDGET
   ══════════════════════════════════════════════════════════════ */
.theme-panel {
    position: fixed;
    right: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.theme-toggle-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px; height: 40px;
    border-radius: 8px 0 0 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}
.theme-toggle-btn:hover { background: var(--accent); color: var(--primary-dark); }

.theme-drawer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 12px 0 0 12px;
    padding: 16px;
    width: 220px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    gap: 12px;
}
.theme-drawer.open { display: flex; }
.theme-drawer h4 {
    font-size: 0.8rem; font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Theme swatches */
.theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
    outline: none;
}
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active { border-color: var(--text); transform: scale(1.1); }
.swatch-navy   { background: #0d3b6e; }
.swatch-emerald{ background: #064e3b; }
.swatch-crimson{ background: #7f1d1d; }
.swatch-slate  { background: #1e293b; }
.swatch-dark   { background: #0f172a; border: 2px solid #334155; }

/* Font switcher */
.font-options { display: flex; gap: 6px; flex-direction: column; }
.font-option {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 0.78rem;
    cursor: pointer;
    background: transparent;
    color: var(--text);
    text-align: left;
    transition: all var(--transition);
}
.font-option:hover { border-color: var(--primary); color: var(--primary); }
.font-option.active { border-color: var(--primary); background: rgba(var(--primary-rgb),0.07); color: var(--primary); font-weight: 700; }

/* Layout toggle */
.layout-options { display: flex; gap: 6px; }
.layout-btn {
    flex: 1; padding: 7px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.layout-btn:hover, .layout-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(var(--primary-rgb),0.07); }

/* ══════════════════════════════════════════════════════════════
   7. FOOTER
   ══════════════════════════════════════════════════════════════ */
footer.app-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.55);
    text-align: center;
    padding: 16px;
    font-size: 0.75rem;
    margin-top: auto;
}
footer.app-footer strong { color: var(--accent-light); }

/* ══════════════════════════════════════════════════════════════
   8. SIDEBAR LAYOUT (has-sidebar variant)
   ══════════════════════════════════════════════════════════════ */
.has-sidebar .topbar    { grid-column: 1 / -1; grid-row: 1; }
.has-sidebar .sidebar   { grid-column: 1; grid-row: 2; }
.has-sidebar .main-wrapper { grid-column: 2; grid-row: 2; }

/* ══════════════════════════════════════════════════════════════
   9. ANIMATIONS
   ══════════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.animate-fade-up  { animation: fadeInUp 0.4s ease both; }
.animate-fade     { animation: fadeIn 0.3s ease both; }
.animate-slide-in { animation: slideInRight 0.35s ease both; }

/* Staggered children */
.stagger > * { animation: fadeInUp 0.4s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }

/* ══════════════════════════════════════════════════════════════
   10. RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════════ */

/* Tablet: ≤1024px */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .main-content { padding: 22px 24px; }
}

/* Mobile: ≤768px */
@media (max-width: 768px) {
    :root { --nav-h: 58px; --topbar-h: 0px; }

    .topbar { display: none; }

    /* Navbar mobile */
    nav.navbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: var(--nav-h); }
    .nav-hamburger { display: flex; }
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 8px 0 12px;
        gap: 2px;
    }
    .nav-menu.open { display: flex; }
    .nav-menu a { padding: 9px 12px; font-size: 0.9rem; }
    .nav-brand-text .app-sub { display: none; }

    /* Sidebar as drawer */
    .has-sidebar { grid-template-columns: 1fr; }
    .has-sidebar .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 2000;
        width: var(--sidebar-w) !important;
        min-height: 100vh;
    }
    .has-sidebar .sidebar.open { transform: translateX(0); }
    .has-sidebar .main-wrapper { grid-column: 1; }
    .sidebar-overlay {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1999;
        display: none;
    }
    .sidebar-overlay.open { display: block; }

    /* Layout */
    .main-content { padding: 16px; }
    .page-header { padding: 18px 16px; }
    .page-header h1 { font-size: 1.3rem; }

    /* Grids */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

    /* Tables: horizontal scroll */
    .table-wrap { border-radius: var(--radius); overflow: hidden; }
    th, td { font-size: 0.78rem; padding: 8px 10px; }

    /* Theme panel */
    .theme-panel { bottom: 80px; top: auto; transform: none; }

    /* Chatbot */
    .chatbot-box { width: calc(100vw - 24px); right: 12px; bottom: 76px; }
}

/* Extra small: ≤480px */
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 1.5rem; }
    .btn { padding: 7px 14px; font-size: 0.8rem; }
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }
}

/* Print */
@media print {
    .topbar, nav.navbar, .sidebar, .theme-panel, .chatbot-toggle, .chatbot-box, .app-footer { display: none !important; }
    .main-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
