:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #d8dee7;
    --text: #18202a;
    --muted: #667085;
    --brand: #f4c430;
    --brand-strong: #c99200;
    --blue: #2563eb;
    --green: #14855f;
    --red: #c2413b;
    --teal: #0f766e;
    --sidebar: #22272f;
    --sidebar-soft: #2d3440;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    color: #1746a2;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: #fff;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    padding: 8px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--brand);
    color: #1d1d1d;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.1;
}

.brand small {
    color: #cbd5e1;
    margin-top: 3px;
    font-size: .78rem;
}

.side-nav {
    display: grid;
    gap: 5px;
}

.side-link,
.mobile-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 6px;
    color: #dbe3ef;
    font-weight: 600;
}

.side-link:hover,
.mobile-link:hover,
.side-link.active,
.mobile-link.active {
    background: var(--sidebar-soft);
    color: #fff;
}

.side-link.active {
    box-shadow: inset 3px 0 0 var(--brand);
}

.side-link i,
.mobile-link i {
    width: 18px;
    text-align: center;
}

.sidebar-foot {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding: 14px 8px 4px;
}

.mini-label,
.section-kicker,
.top-eyebrow {
    display: block;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-foot .mini-label {
    color: #b8c2cf;
    margin-bottom: 8px;
}

.db-pill {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 7px 9px;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 700;
}

.db-pill.prod {
    background: #dbeafe;
    color: #1d4ed8;
}

.db-pill.test {
    background: #fee2e2;
    color: #b91c1c;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 72px;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: space-between;
    padding: 14px 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.top-title {
    font-size: 1.15rem;
    margin: 0;
    font-weight: 800;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.database-select {
    min-width: 180px;
}

.mobile-menu {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 6px;
    width: 40px;
    height: 40px;
}

.mobile-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 8px;
}

.mobile-link {
    color: var(--text);
}

.mobile-link.active {
    background: #fff4c2;
    color: #6b4a00;
}

.content-area {
    padding: 22px;
}

.page-head,
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.page-head {
    margin-bottom: 16px;
}

.page-head h2,
.panel-head h3 {
    margin: 0;
    font-weight: 800;
}

.page-head h2 {
    font-size: 1.45rem;
}

.panel-head h3 {
    font-size: 1rem;
}

.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.kpi-card,
.metric,
.dash-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(24, 32, 42, .06);
}

.kpi-card {
    min-height: 138px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--brand);
}

.kpi-card span,
.metric span {
    display: block;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.kpi-card strong {
    display: block;
    font-size: 1.45rem;
    line-height: 1.15;
    margin-bottom: 10px;
}

.kpi-card small {
    color: var(--muted);
    font-weight: 600;
}

.accent-yellow::before { background: var(--brand); }
.accent-green::before { background: var(--green); }
.accent-blue::before { background: var(--blue); }
.accent-teal::before { background: var(--teal); }
.accent-red::before { background: var(--red); }

.good { color: var(--green); }
.bad { color: var(--red); }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
}

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }

.dash-panel,
.panel {
    padding: 15px;
}

.narrow {
    max-width: 560px;
}

.metric {
    display: block;
    padding: 14px;
    min-height: 82px;
    color: inherit;
}

.metric strong {
    font-size: 1.08rem;
}

.metric-link:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.rank-list,
.finance-stack,
.stock-list,
.state-chart,
.sync-grid {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.company-finance {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.company-block {
    border: 1px solid #e7ebf1;
    border-radius: 6px;
    background: var(--surface-soft);
    padding: 10px;
}

.company-title,
.finance-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.company-title {
    padding-bottom: 8px;
    border-bottom: 1px solid #e7ebf1;
}

.company-title strong {
    font-size: .95rem;
}

.company-title span,
.finance-total span,
.finance-total small {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
}

.finance-stack.compact {
    gap: 0;
    margin-top: 6px;
}

.finance-stack.compact div {
    padding: 7px 0;
}

.finance-total {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    background: #eef4ff;
}

.total-block {
    margin-top: 12px;
    background: #eef4ff;
    border-color: #c7d7fe;
}

.comparison-stack > div {
    align-items: flex-start;
}

.finance-stack .finance-values {
    display: grid;
    justify-items: end;
    gap: 3px;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    text-align: right;
}

.finance-values small {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 700;
}

.finance-values em {
    display: inline-block;
    margin-left: 4px;
    font-style: normal;
    font-weight: 800;
}

.neutral {
    color: var(--muted);
}

.rank-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    align-items: center;
    padding: 10px;
    background: var(--surface-soft);
    border: 1px solid #e7ebf1;
    border-radius: 6px;
}

.rank-meta {
    min-width: 0;
}

.rank-meta strong {
    display: inline-block;
    margin-right: 8px;
}

.rank-meta span {
    color: var(--muted);
}

.rank-values {
    text-align: right;
    white-space: nowrap;
}

.rank-values span,
.rank-values b {
    display: block;
}

.rank-values span {
    color: var(--muted);
    font-size: .82rem;
}

.rank-bar {
    grid-column: 1 / -1;
    height: 7px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.rank-bar i {
    display: block;
    height: 100%;
    background: var(--teal);
    border-radius: 6px;
}

.state-chart {
    margin-top: 14px;
}

.state-row {
    padding: 10px;
    border: 1px solid #e7ebf1;
    border-radius: 6px;
    background: var(--surface-soft);
}

.state-head {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.state-head strong {
    color: var(--text);
    font-size: .98rem;
}

.state-head span {
    color: var(--muted);
    font-weight: 700;
}

.state-head b {
    text-align: right;
    white-space: nowrap;
}

.state-bar {
    height: 10px;
    border-radius: 6px;
    background: #e5e7eb;
    overflow: hidden;
}

.state-bar i {
    display: block;
    height: 100%;
    border-radius: 6px;
    background: var(--blue);
}

.finance-stack div,
.stock-row,
.sync-grid > div,
.sync-grid > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f4;
}

.finance-stack span,
.stock-row span,
.sync-grid span {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.stock-row {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) auto;
}

.stock-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .9rem;
}

.stock-row b {
    padding: 4px 7px;
    border-radius: 6px;
    background: #fff7d1;
    color: #765300;
}

.soft-alert {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    background: #fff7d1;
    color: #765300;
    font-weight: 700;
}

.sync-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.sync-grid > div,
.sync-grid > a {
    border: 1px solid #e7ebf1;
    border-radius: 6px;
    padding: 12px;
    background: var(--surface-soft);
    color: inherit;
}

.sync-grid i {
    color: var(--blue);
    font-size: 1.1rem;
}

.sync-grid strong {
    text-align: right;
}

.dashboard-table {
    margin-bottom: 0;
}

.dashboard-table thead th,
.table thead th {
    color: var(--muted);
    font-size: .78rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}

.table td,
.table th {
    white-space: nowrap;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #f8fafc;
}

.form-control,
.form-select,
.btn {
    border-radius: 6px;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
}

.btn-outline-primary {
    color: var(--blue);
    border-color: #b6c7f8;
}

.empty-state {
    padding: 18px;
    color: var(--muted);
    background: var(--surface-soft);
    border-radius: 6px;
    text-align: center;
}

.toast-layer {
    z-index: 1080;
}

@media (max-width: 1100px) {
    .kpi-grid,
    .sync-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-4,
    .span-5,
    .span-7,
    .span-8 {
        grid-column: span 12;
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        display: none;
    }

    .mobile-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        align-items: flex-start;
        padding: 12px;
    }

    .top-actions {
        margin-left: auto;
    }

    .database-select {
        min-width: 140px;
        max-width: 160px;
    }

    .content-area {
        padding: 14px;
    }

    .page-head,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .kpi-grid,
    .sync-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    .app-sidebar,
    .topbar,
    .mobile-nav,
    .btn,
    form,
    .toast-layer {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    body {
        background: #fff;
    }

    .content-area {
        padding: 0;
    }
}
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top, #fff7d1 0, #eef1f5 42%, #e7ecf3 100%);
}

.auth-card {
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(24, 32, 42, .12);
    padding: 24px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.auth-brand strong,
.auth-brand small {
    display: block;
    line-height: 1.15;
}

.auth-brand small,
.auth-subtitle {
    color: var(--muted);
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 0 6px;
}

.auth-subtitle {
    margin: 0 0 18px;
    font-size: .94rem;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}
