:root {
    --brand: #1e3a6e;
    --brand-dark: #12274d;
    --brand-soft: #e8eef8;
    --gold: #d4a017;
    --gold-soft: #f8efd4;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f3f5f9;
    --card: #ffffff;
    --warn: #d97706;
    --danger: #dc2626;
    --ok: #059669;
    --sidebar: #0a0a0a;
    --sidebar-2: #1e3a6e;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background:
        radial-gradient(circle at 18% 20%, rgba(212,160,23,.18), transparent 36%),
        radial-gradient(circle at 80% 12%, rgba(30,58,110,.35), transparent 32%),
        linear-gradient(145deg, #000000 0%, #0d1526 42%, #1e3a6e 100%);
}

.auth-hero {
    color: #fff;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-hero h1 {
    font-size: clamp(1.8rem, 3.6vw, 2.8rem);
    line-height: 1.15;
    margin: 0 0 14px;
    letter-spacing: -0.02em;
}

.auth-hero p { max-width: 460px; opacity: .9; font-size: 1.02rem; }
.auth-brand {
    margin-bottom: 28px;
}
.auth-brand img {
    width: min(100%, 520px);
    height: auto;
    display: block;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,.35));
}
.auth-logo-mobile {
    display: none;
    text-align: center;
    margin-bottom: 18px;
}
.auth-logo-mobile img {
    width: min(100%, 320px);
    height: auto;
}

.auth-panel {
    display: flex; align-items: center; justify-content: center;
    padding: 32px;
}
.auth-card {
    width: 100%; max-width: 460px;
    background: rgba(255,255,255,.97);
    border-radius: 24px;
    padding: 36px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(212,160,23,.2);
}
.auth-card h2 { margin: 0 0 8px; font-size: 1.7rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 40;
}
.sidebar-overlay.show { display: block; }
.sidebar {
    width: 290px; flex-shrink: 0;
    background: linear-gradient(180deg, #000000 0%, #0b1220 55%, #12274d 100%);
    color: #eef2ff; padding: 0;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 50;
}
.sidebar .logo {
    display: block;
    padding: 0;
    border-bottom: 1px solid rgba(212,160,23,.25);
    margin-bottom: 14px;
    flex-shrink: 0;
}
.sidebar .logo-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
    background: #fff;
    padding: 9px;
    object-fit: contain;
}
.sidebar .logo-meta {
    margin-top: 10px;
    padding: 0 14px;
}
.sidebar .logo-meta strong {
    display: block;
    font-size: .82rem;
    color: var(--gold);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.sidebar .logo-meta small { opacity: .75; font-size: .78rem; }
.sidebar-nav { flex: 1 1 auto; padding: 0 10px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px; margin-bottom: 6px;
    color: rgba(255,255,255,.82); transition: .2s ease;
}
.nav-link:hover, .nav-link.active {
    background: rgba(212,160,23,.16); color: #fff;
    box-shadow: inset 3px 0 0 var(--gold);
}
.nav-link i { width: 20px; text-align: center; color: var(--gold); }
.sidebar-user {
    margin: 14px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(212,160,23,.28);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}
.sidebar-user .avatar {
    width: 42px; height: 42px; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-info strong {
    display: block;
    font-size: .92rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-info small {
    display: block;
    color: rgba(255,255,255,.7);
    font-size: .75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-role {
    display: inline-block;
    margin-top: 4px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #000;
    background: var(--gold);
    padding: 2px 8px;
    border-radius: 999px;
}

.main { flex: 1; min-width: 0; }
.topbar {
    background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 14px 24px; display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
    display: none; border: 0; background: var(--brand-soft); color: var(--brand-dark);
    width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.content { padding: 24px; }

.page-title { margin: 0 0 4px; font-size: 1.65rem; letter-spacing: -.02em; }
.page-sub { color: var(--muted); margin: 0 0 22px; }
.page-head { margin-bottom: 4px; }
.page-head .page-sub { margin-bottom: 16px; }

.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px;
}
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); border: 1px solid rgba(226,232,240,.8);
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ""; position: absolute; right: -20px; top: -20px;
    width: 90px; height: 90px; border-radius: 50%;
    background: radial-gradient(circle, rgba(212,160,23,.18), transparent 70%);
}
.stat-card .label { color: var(--muted); font-size: .9rem; }
.stat-card .value { font-size: 1.9rem; font-weight: 700; margin-top: 6px; }
.stat-card .hint { margin-top: 8px; font-size: .82rem; color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.card {
    background: var(--card); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); border: 1px solid rgba(226,232,240,.8);
}
.card h3 { margin: 0 0 14px; font-size: 1.05rem; }
.chart-wrap { position: relative; height: 280px; }

.table-wrap { overflow: auto; }
table.data {
    width: 100%; border-collapse: collapse; min-width: 640px;
}
table.data th, table.data td {
    text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: .93rem;
}
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: #f8fafc; }

.badge {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px;
    font-size: .75rem; font-weight: 600;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0f2fe; color: #075985; }
.badge.role { background: var(--brand-soft); color: var(--brand-dark); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer;
    font-weight: 600; font-size: .92rem; transition: .15s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-warn { background: #fef3c7; color: #92400e; }
.btn-ok { background: #d1fae5; color: #065f46; }
.btn-sm { padding: 7px 11px; border-radius: 9px; font-size: .82rem; }
.btn-block { width: 100%; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 6px; font-size: .88rem; font-weight: 600; color: #334155; }
.form-control {
    width: 100%; border: 1px solid var(--line); border-radius: 12px;
    padding: 11px 12px; font: inherit; background: #fff; outline: none;
    height: 44px;
}
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
textarea.form-control { height: auto; min-height: 88px; resize: vertical; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.toolbar > .btn { flex: 0 0 auto; align-self: center; white-space: nowrap; height: 44px; }
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}
.filters .form-control {
    width: auto;
    min-width: 160px;
    flex: 0 1 200px;
}
.filters .form-control[name="q"],
.filters input[type="text"].form-control {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 280px;
}
.filters select.form-control {
    flex: 0 1 150px;
    min-width: 140px;
    max-width: 180px;
}
.filters .btn { height: 44px; flex: 0 0 auto; white-space: nowrap; }
.panel-toolbar {
    background: var(--card);
    border: 1px solid rgba(226,232,240,.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .avatar { width: 36px; height: 36px; font-size: .85rem; flex-shrink: 0; }
.user-cell strong { display: block; line-height: 1.2; }
.user-cell small { color: var(--muted); font-size: .78rem; }
.action-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table-wrap { padding: 0; }
.table-card table.data { min-width: 860px; }
.table-card table.data th {
    background: #f8fafc;
    padding: 14px 16px;
    position: sticky; top: 0;
}
.table-card table.data td { padding: 14px 16px; vertical-align: middle; }
.table-card .card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: #fff;
}

.alert {
    padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: .92rem;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #1e3a6e, #d4a017);
}
.dropdown { position: relative; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 48px; min-width: 180px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: block; width: 100%; text-align: left; padding: 11px 14px;
    border: 0; background: #fff; cursor: pointer; font: inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: #f8fafc; }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: #fff; width: 100%; max-width: 420px; border-radius: 18px; padding: 22px;
    box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.empty {
    text-align: center; padding: 36px 16px; color: var(--muted);
}

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: .85rem;
}
.pagination .active span { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-logo-mobile { display: block; }
    .auth-panel {
        background: linear-gradient(180deg, #000 0%, #12274d 45%, #f3f5f9 45%);
        min-height: 100vh;
        align-items: flex-start;
        padding-top: 28px;
    }
    .sidebar {
        position: fixed; left: -310px; z-index: 50; transition: .25s ease;
        box-shadow: 8px 0 30px rgba(0,0,0,.35);
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .form-grid { grid-template-columns: 1fr; }
    .toolbar { align-items: stretch; }
    .toolbar > .btn { width: 100%; }
    .filters { width: 100%; }
    .filters .form-control,
    .filters .form-control[name="q"],
    .filters input[type="text"].form-control,
    .filters select.form-control {
        flex: 1 1 100%;
        max-width: none;
        min-width: 0;
        width: 100%;
    }
    .filters .btn { width: 100%; }
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .auth-card { padding: 24px; }
}
