:root {
    --navy: #0b2e59;
    --navy-dark: #081f3d;
    --blue: #1a5da6;
    --gold: #f0a500;
    --bg: #f1f4f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Source Sans 3", "Source Sans Pro", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Poppins", "Segoe UI", sans-serif;
}

a { text-decoration: none; color: var(--blue); }

.admin-wrap { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--navy-dark);
    color: #cbd5e1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 3px;
    flex-shrink: 0;
}
.sidebar-brand-text { font-family: "Poppins", sans-serif; line-height: 1.2; }
.sidebar-brand-text span { color: var(--gold); }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 20px;
    color: #cbd5e1;
    font-size: 14.5px;
    border-left: 3px solid transparent;
}
.sidebar .nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.85;
}
.sidebar nav a.active .nav-icon,
.sidebar nav a:hover .nav-icon { opacity: 1; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active {
    background: rgba(240, 165, 0, 0.12);
    color: var(--gold);
    border-left-color: var(--gold);
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--navy);
    cursor: pointer;
}
.sidebar-toggle svg { width: 22px; height: 22px; }
.sidebar-toggle:hover { background: #f1f5f9; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 31, 61, 0.5);
    z-index: 90;
}

/* Content column: topbar + main */
.admin-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.admin-welcome {
    font-size: 15px;
    color: var(--muted);
}
.admin-welcome strong {
    color: var(--navy);
    font-weight: 700;
}

.admin-user-menu { position: relative; }
.admin-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 14px 6px 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
}
.admin-user-btn:hover { background: #eef2f7; }
.admin-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.admin-user-name { font-weight: 600; color: var(--navy); }
.admin-caret { color: var(--muted); font-size: 11px; }

.admin-user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(8, 31, 61, 0.14);
    overflow: hidden;
    z-index: 50;
}
.admin-user-dropdown.show { display: block; }
.admin-user-meta {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.admin-user-meta strong {
    display: block;
    color: var(--navy);
    font-size: 14.5px;
}
.admin-user-meta span {
    display: block;
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 2px;
}
.admin-user-dropdown a,
.admin-user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 11px 16px;
    color: var(--text);
    font-size: 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-family: inherit;
}
.admin-user-dropdown a:hover,
.admin-user-dropdown button:hover {
    background: #f1f5f9;
    color: var(--navy);
}
.admin-user-dropdown a.active {
    color: var(--navy);
    font-weight: 600;
    background: #eef2ff;
}
.admin-user-dropdown form { margin: 0; }
.admin-user-dropdown button { color: #b91c1c; }
.admin-user-dropdown button:hover { background: #fef2f2; color: #991b1b; }

.admin-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 14px 32px;
}
.admin-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
}
.admin-footer-inner strong { color: var(--navy); font-weight: 600; }

/* Main */
.main { flex: 1; padding: 28px 32px; min-width: 0; }
.page-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-head h1 { font-size: 24px; color: var(--navy); }

.table-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 18px;
}
.table-filters .filter-search {
    flex: 1 1 280px;
}
.table-filters .form-control {
    width: auto;
    min-width: 150px;
}
.table-filters .filter-search .form-control {
    width: 100%;
}
.table-filters .btn {
    white-space: nowrap;
}

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--blue); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn .btn-icon {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
}
.btn-light { background: #e2e8f0; color: var(--text); }
.btn-light:hover { background: #cbd5e1; }

/* Cards / stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: 10px; padding: 18px 20px;
}
.stat-card b { display: block; font-size: 28px; color: var(--navy); }
.stat-card span { font-size: 13.5px; color: var(--muted); }

/* Dashboard */
.dash-hero {
    background: linear-gradient(120deg, var(--navy-dark) 0%, var(--blue) 70%, #2e7dc9 100%);
    border-radius: 14px;
    padding: 26px 30px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    color: #fff;
    box-shadow: 0 14px 34px rgba(8, 31, 61, 0.25);
}
.dash-hero h1 { font-size: 24px; margin-bottom: 6px; color: #fff; }
.dash-hero p { font-size: 14.5px; color: #cfe0f3; }
.btn-gold-dash {
    background: var(--gold);
    color: var(--navy-dark);
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 8px;
    white-space: nowrap;
}
.btn-gold-dash:hover { background: #ffb81f; color: var(--navy-dark); }

.stats-colorful { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stats-colorful .stat-card {
    position: relative;
    border: none;
    color: #fff;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stats-colorful .stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(8, 31, 61, 0.22);
}
.stats-colorful .stat-card b { color: #fff; font-size: 30px; }
.stats-colorful .stat-card span { color: rgba(255, 255, 255, 0.88); }
.stat-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-blue   { background: linear-gradient(135deg, #1a5da6, #3b82f6); }
.stat-purple { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.stat-orange { background: linear-gradient(135deg, #c2410c, #f97316); }
.stat-green  { background: linear-gradient(135deg, #047857, #10b981); }
.stat-pink   { background: linear-gradient(135deg, #be185d, #ec4899); }
.stat-teal   { background: linear-gradient(135deg, #0e7490, #06b6d4); }

.quick-actions-panel h2 { margin-bottom: 14px; }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.quick-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    transition: filter 0.15s ease, transform 0.15s ease;
}
.quick-action:hover { color: #fff; filter: brightness(1.12); transform: translateY(-1px); }
.quick-action .btn-icon { width: 14px; height: 14px; }
.qa-blue   { background: #1a5da6; }
.qa-orange { background: #ea580c; }
.qa-green  { background: #059669; }
.qa-purple { background: #7c3aed; }

.dash-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 24px;
}
.dash-panels .panel { margin-bottom: 0; }
.panel-accent { border-top: 4px solid var(--blue); }
.panel-accent-pink { border-top-color: #ec4899; }
.panel-accent-orange { border-top-color: #f97316; }

.panel {
    background: #fff; border: 1px solid var(--border);
    border-radius: 10px; padding: 24px; margin-bottom: 24px;
}
.panel h2 { font-size: 17px; color: var(--navy); margin-bottom: 16px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.table th {
    background: var(--navy); color: #fff;
    text-align: left; padding: 12px 14px;
    font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.table .actions { display: flex; gap: 8px; justify-content: center; }
.table th:last-child { text-align: center; }
.thumb { width: 60px; height: 40px; object-fit: cover; border-radius: 4px; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #e2e8f0; color: #475569; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--navy); }
.form-control {
    width: 100%; padding: 10px 13px;
    border: 1px solid #cbd5e1; border-radius: 6px;
    font-size: 14.5px; font-family: inherit; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,93,166,.14); }
textarea.form-control { min-height: 120px; resize: vertical; }
textarea.form-control.tall { min-height: 300px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.permission-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.permission-module {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}
.permission-module h3 {
    padding: 10px 14px;
    background: #eef2f7;
    color: var(--navy);
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.permission-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
}
.permission-check { font-weight: 400; cursor: pointer; }
.form-hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.alert { padding: 13px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }

.pagination-wrap { margin-top: 20px; }

/* Login */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--blue) 100%);
    padding: 20px;
}
.login-box {
    background: #fff; border-radius: 12px;
    padding: 40px; width: 100%; max-width: 400px;
    box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.login-logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    display: block;
    margin: 0 auto 14px;
}
.login-box h1 { font-size: 22px; color: var(--navy); margin-bottom: 4px; text-align: center; }
.login-box > p { text-align: center; }
.login-box p { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        width: 260px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .sidebar-toggle { display: inline-flex; }
    .form-row { grid-template-columns: 1fr; }
    .main { padding: 20px 16px; }
    .admin-topbar { padding: 0 16px; }
    .admin-user-name { display: none; }
    .admin-welcome { display: none; }
    .admin-footer { padding: 14px 16px; }
    .admin-footer-inner { justify-content: center; text-align: center; }
    .table-filters { align-items: stretch; }
    .table-filters .filter-search,
    .table-filters .form-control,
    .table-filters .btn { width: 100%; min-width: 0; }
    .dash-panels { grid-template-columns: 1fr; }
    .dash-hero { padding: 20px; }
}
