:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1d4ed8;
    --primary-dark: #173a8f;
    --sidebar: #101a33;
    --sidebar-soft: #1a2745;
    --green: #15803d;
    --amber: #b45309;
    --red: #b91c1c;
    --violet: #7c3aed;
    --shadow: 0 14px 35px rgba(15, 23, 42, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: 276px;
    flex-direction: column;
    overflow-y: auto;
    color: #dbeafe;
    background: linear-gradient(180deg, #111b35 0%, #0d1730 100%);
    box-shadow: 12px 0 35px rgba(15, 23, 42, .16);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 22px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(145deg, #2563eb, #22c55e);
    box-shadow: 0 10px 25px rgba(37, 99, 235, .35);
    font-weight: 900;
    letter-spacing: -.5px;
}

.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { color: #fff; font-size: 15px; letter-spacing: .7px; }
.brand-copy small { color: #93c5fd; font-size: 11px; letter-spacing: .5px; }

.nav-menu { padding: 18px 13px; }

.nav-link,
.nav-group > summary {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 10px 12px;
    border-radius: 12px;
    color: #cbd5e1;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-link:hover,
.nav-group > summary:hover {
    color: #fff;
    background: rgba(255,255,255,.075);
}

.nav-link.active {
    color: #fff;
    background: linear-gradient(100deg, rgba(37,99,235,.92), rgba(29,78,216,.62));
    box-shadow: 0 8px 18px rgba(37, 99, 235, .25);
}

.nav-icon {
    display: inline-grid;
    min-width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    color: #bfdbfe;
    background: rgba(255,255,255,.06);
    font-size: 11px;
    font-weight: 800;
}

.nav-group { margin: 4px 0; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group .chevron { margin-left: auto; font-size: 15px; transition: transform .18s ease; }
.nav-group[open] .chevron { transform: rotate(180deg); }
.nav-submenu { margin: 1px 0 8px 38px; padding-left: 10px; border-left: 1px solid rgba(147,197,253,.2); }
.nav-submenu .nav-link { min-height: 37px; padding: 8px 11px; font-size: 13px; }

.sidebar-note {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: auto 16px 18px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    color: #e2e8f0;
    background: rgba(255,255,255,.05);
}

.sidebar-note div { display: flex; flex-direction: column; gap: 2px; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note small { color: #94a3b8; font-size: 10px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.12); }

.main-shell { min-height: 100vh; margin-left: 276px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 28px;
    border-bottom: 1px solid rgba(226,232,240,.9);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; line-height: 1.25; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #fff; cursor: pointer; }

.user-box { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.user-avatar { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #1d4ed8, #60a5fa); font-size: 11px; font-weight: 900; }
.user-copy { display: flex; flex-direction: column; max-width: 180px; }
.user-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.user-copy small { color: var(--muted); font-size: 10px; }
.logout-link { padding: 8px 11px; border: 1px solid #fecaca; border-radius: 10px; color: var(--red); background: #fff7f7; font-size: 11px; font-weight: 700; }

.content { padding: 26px 28px 36px; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 28px 24px; color: var(--muted); font-size: 11px; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 4px 0 16px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { position: relative; overflow: hidden; min-height: 148px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card::after { position: absolute; top: -35px; right: -35px; width: 105px; height: 105px; border-radius: 50%; background: var(--card-tint, rgba(37,99,235,.09)); content: ""; }
.metric-card .eyebrow { display: block; margin-bottom: 15px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .65px; text-transform: uppercase; }
.metric-card .metric-value { display: block; margin-bottom: 7px; font-size: 31px; font-weight: 850; letter-spacing: -1px; }
.metric-card .metric-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.metric-card.blue { --card-tint: rgba(37,99,235,.12); border-top: 4px solid #2563eb; }
.metric-card.green { --card-tint: rgba(22,163,74,.12); border-top: 4px solid #16a34a; }
.metric-card.amber { --card-tint: rgba(217,119,6,.12); border-top: 4px solid #d97706; }
.metric-card.violet { --card-tint: rgba(124,58,237,.12); border-top: 4px solid #7c3aed; }
.metric-card.red { --card-tint: rgba(220,38,38,.10); border-top: 4px solid #dc2626; }

.panel { margin-bottom: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }

.source-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.source-card { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.source-card span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.source-card strong { display: block; font-size: 23px; }
.source-card small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.search-form { display: flex; align-items: center; gap: 8px; flex: 1; }
.search-form input { width: min(420px, 100%); height: 40px; padding: 0 13px; border: 1px solid #cbd5e1; border-radius: 11px; outline: none; background: #fff; }
.search-form input:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(59,130,246,.1); }
.search-form select { height: 40px; padding: 0 11px; border: 1px solid #cbd5e1; border-radius: 11px; background: #fff; }
.btn { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 0 14px; border: 0; border-radius: 11px; color: #fff; background: var(--primary); cursor: pointer; font-weight: 750; }
.btn:hover { background: var(--primary-dark); }
.btn-light { border: 1px solid var(--line); color: var(--text); background: #fff; }
.btn-light:hover { background: #f8fafc; }
.table-info { color: var(--muted); font-size: 11px; white-space: nowrap; }

.table-scroll { overflow: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 12px 14px; border-bottom: 1px solid var(--line); color: #475569; background: #f8fafc; font-size: 10px; letter-spacing: .3px; text-align: left; text-transform: uppercase; }
.data-table td { max-width: 330px; overflow: hidden; padding: 12px 14px; border-bottom: 1px solid #eef2f7; text-overflow: ellipsis; vertical-align: top; }
.data-table tr:hover td { background: #f8fbff; }
.data-table td.wrap { white-space: normal; line-height: 1.45; }
.data-table .empty-cell { padding: 46px 20px; color: var(--muted); text-align: center; }

.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.badge-success { color: #166534; background: #dcfce7; }
.badge-warning { color: #92400e; background: #fef3c7; }
.badge-danger { color: #991b1b; background: #fee2e2; }
.badge-info { color: #1e40af; background: #dbeafe; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-top: 1px solid var(--line); }
.pagination-copy { color: var(--muted); font-size: 11px; }
.pagination-links { display: flex; align-items: center; gap: 6px; }
.pagination-links a, .pagination-links span { display: inline-grid; min-width: 35px; height: 35px; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 11px; }
.pagination-links .current { border-color: var(--primary); color: #fff; background: var(--primary); font-weight: 800; }
.pagination-links .disabled { color: #cbd5e1; background: #f8fafc; }

.alert { margin-bottom: 18px; padding: 14px 16px; border: 1px solid; border-radius: 13px; line-height: 1.55; }
.alert-danger { border-color: #fecaca; color: #991b1b; background: #fff1f2; }
.alert-info { border-color: #bfdbfe; color: #1e3a8a; background: #eff6ff; }
.alert-success { border-color: #bbf7d0; color: #166534; background: #f0fdf4; }

.placeholder { display: grid; min-height: 390px; place-items: center; padding: 30px; text-align: center; }
.placeholder-icon { display: grid; width: 76px; height: 76px; margin: 0 auto 18px; place-items: center; border-radius: 24px; color: #fff; background: linear-gradient(145deg, #2563eb, #7c3aed); box-shadow: 0 18px 35px rgba(37,99,235,.25); font-size: 30px; font-weight: 900; }
.placeholder h2 { margin: 0 0 8px; }
.placeholder p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.65; }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr); background: #fff; }
.login-visual { position: relative; display: flex; overflow: hidden; flex-direction: column; justify-content: space-between; padding: 52px; color: #fff; background: radial-gradient(circle at 20% 20%, rgba(59,130,246,.42), transparent 36%), radial-gradient(circle at 80% 75%, rgba(34,197,94,.3), transparent 33%), linear-gradient(145deg, #0b1733, #172b56); }
.login-visual::after { position: absolute; right: -120px; bottom: -150px; width: 430px; height: 430px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 60px rgba(255,255,255,.025), 0 0 0 120px rgba(255,255,255,.018); content: ""; }
.login-brand { position: relative; z-index: 2; display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark { width: 56px; height: 56px; }
.login-copy { position: relative; z-index: 2; max-width: 650px; }
.login-copy .kicker { display: inline-flex; padding: 7px 11px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: #bfdbfe; background: rgba(255,255,255,.06); font-size: 11px; font-weight: 800; letter-spacing: .7px; }
.login-copy h1 { margin: 20px 0 14px; font-size: clamp(34px, 5vw, 62px); line-height: 1.05; letter-spacing: -2px; }
.login-copy p { max-width: 570px; margin: 0; color: #cbd5e1; font-size: 15px; line-height: 1.8; }
.login-feature-grid { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.login-feature { padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(255,255,255,.055); backdrop-filter: blur(8px); }
.login-feature strong { display: block; margin-bottom: 4px; font-size: 12px; }
.login-feature small { color: #94a3b8; font-size: 10px; }
.login-panel { display: grid; place-items: center; padding: 40px; background: #f8fafc; }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: 0 28px 70px rgba(15,23,42,.12); }
.login-card h2 { margin: 0 0 7px; font-size: 25px; }
.login-card > p { margin: 0 0 26px; color: var(--muted); line-height: 1.6; }
.form-group { margin-bottom: 17px; }
.form-group label { display: block; margin-bottom: 7px; color: #334155; font-size: 11px; font-weight: 800; }
.form-control { width: 100%; height: 47px; padding: 0 14px; border: 1px solid #cbd5e1; border-radius: 12px; outline: none; background: #fff; }
.form-control:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(59,130,246,.11); }
.login-button { width: 100%; height: 48px; margin-top: 4px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(100deg, #1d4ed8, #2563eb); cursor: pointer; font-weight: 800; box-shadow: 0 13px 24px rgba(37,99,235,.22); }
.login-note { margin-top: 18px; color: var(--muted); font-size: 10px; line-height: 1.6; text-align: center; }

.sidebar-overlay { display: none; }

@media (max-width: 1180px) {
    .metric-grid, .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
    .main-shell { margin-left: 0; }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .app-shell.sidebar-open + .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.45); }
    .menu-toggle { display: inline-grid; place-items: center; }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
}

@media (max-width: 640px) {
    .topbar { min-height: 76px; padding: 12px 15px; }
    .topbar p, .user-copy { display: none; }
    .topbar h1 { font-size: 17px; }
    .logout-link { padding: 7px 9px; }
    .content { padding: 18px 14px 28px; }
    .footer { flex-direction: column; padding: 15px; }
    .metric-grid, .source-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 130px; }
    .section-heading, .panel-header, .table-toolbar, .pagination { align-items: stretch; flex-direction: column; }
    .search-form { align-items: stretch; flex-direction: column; }
    .search-form input { width: 100%; }
    .table-info { white-space: normal; }
    .login-panel { padding: 18px; }
    .login-card { padding: 25px 21px; }
}

