:root {
    --brand-navy: #0b1f3f;
    --brand-navy-2: #102b55;
    --brand-orange: #ff6a2a;
    --brand-orange-2: #ff874f;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --danger: #dc2626;
    --success: #15803d;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, Roboto, Arial, sans-serif;
}

body[data-auth-protected="true"] .app-sidebar,
body[data-auth-protected="true"] .app-main {
    visibility: hidden;
}

body[data-auth-protected="true"].auth-ready .app-sidebar,
body[data-auth-protected="true"].auth-ready .app-main {
    visibility: visible;
}

a {
    color: inherit;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    background: linear-gradient(180deg, #08172f 0%, var(--brand-navy) 100%);
    color: #fff;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
}

.brand.compact {
    margin-bottom: 24px;
}

.brand-mark {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-orange), #ff9b5f);
    color: #fff;
    font-weight: 900;
    font-size: 22px;
}

.brand small {
    display: block;
    color: #b9c5d6;
    margin-top: 2px;
}

.app-sidebar nav {
    display: grid;
    gap: 7px;
}

.app-sidebar a {
    color: #d8e0ee;
    padding: 12px 13px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
}

.app-sidebar a.active,
.app-sidebar a:hover {
    background: rgba(255, 106, 42, 0.15);
    color: #fff;
}

.app-main {
    margin-left: 270px;
    padding: 34px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.08;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--brand-orange);
    font-weight: 900;
    text-transform: uppercase;
    font-size: 12px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 20px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 14px;
    font-weight: 700;
}

.metric-card strong {
    color: var(--brand-navy);
    font-size: 36px;
}

.metric-card.warning {
    border-color: rgba(255, 106, 42, 0.42);
}

.panel {
    padding: 24px;
}

.panel h2 {
    font-size: 21px;
    color: var(--brand-navy);
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.error-page main {
    text-align: center;
}

.error-page strong {
    color: var(--brand-orange);
    font-size: 56px;
}

.muted {
    color: var(--muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    border-radius: 8px;
    font-weight: 800;
}

.btn-primary {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
}

.btn-ghost {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--brand-navy);
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(11, 31, 63, 0.06), rgba(255, 106, 42, 0.08)),
        #f7f9fc;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(360px, 500px) 1fr;
    gap: 24px;
    align-items: stretch;
}

.auth-shell.single {
    grid-template-columns: minmax(320px, 500px);
    justify-content: center;
}

.auth-panel,
.auth-copy {
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel {
    padding: 34px;
}

.auth-panel.wide {
    grid-column: 1 / -1;
    width: min(800px, 100%);
    justify-self: center;
}

.auth-logo {
    display: block;
    width: min(260px, 82%);
    max-height: 110px;
    object-fit: contain;
    object-position: left center;
    margin-bottom: 28px;
}

.auth-panel h1 {
    margin: 0 0 10px;
    color: var(--brand-navy);
    font-size: 30px;
    line-height: 1.12;
}

.auth-panel p,
.auth-copy p {
    color: var(--muted);
}

.auth-copy {
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 76% 18%, rgba(255, 106, 42, 0.22), transparent 28%),
        linear-gradient(145deg, var(--brand-navy) 0%, #07162d 100%);
    color: #fff;
    padding: 42px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.auth-copy::before,
.auth-copy::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: rotate(45deg);
}

.auth-copy::before {
    width: 180px;
    height: 180px;
    right: -56px;
    top: -42px;
}

.auth-copy::after {
    width: 120px;
    height: 120px;
    left: -38px;
    bottom: 68px;
}

.auth-copy-mark {
    position: absolute;
    right: 34px;
    top: 30px;
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 9px solid var(--brand-orange);
    color: var(--brand-orange);
    font-size: 44px;
    font-weight: 900;
}

.auth-copy span {
    color: var(--brand-orange-2);
    font-weight: 900;
    text-transform: uppercase;
    font-size: 12px;
}

.auth-copy h2 {
    position: relative;
    font-size: 38px;
    line-height: 1.08;
    margin: 12px 0;
    letter-spacing: 0;
}

.auth-copy p {
    position: relative;
    color: #cbd5e1;
}

.auth-form {
    display: grid;
    gap: 13px;
    margin-top: 22px;
}

.auth-form.grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-form .full {
    grid-column: 1 / -1;
}

.auth-form label {
    color: var(--brand-navy);
    font-weight: 800;
    font-size: 14px;
}

.auth-form input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    min-height: 46px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

.auth-form input:focus {
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 4px rgba(255, 106, 42, 0.14);
    outline: none;
}

.auth-form button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-orange), #ff8a52);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.auth-links a {
    color: var(--brand-navy);
    font-weight: 800;
    text-decoration: none;
}

.auth-links a:hover {
    color: var(--brand-orange);
}

.alert {
    border-radius: 8px;
    padding: 12px;
    margin: 14px 0;
    border: 1px solid var(--line);
}

.alert.error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #9f1239;
}

.alert.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: var(--success);
}

.alert.info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
    word-break: break-word;
}

@media (max-width: 900px) {
    .app-sidebar {
        position: static;
        width: auto;
    }

    .app-main {
        margin-left: 0;
        padding: 20px;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .page-header,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .auth-shell,
    .auth-form.grid {
        grid-template-columns: 1fr;
    }

    .auth-copy {
        display: none;
    }

    .auth-panel {
        padding: 24px;
    }

    .auth-logo {
        width: min(220px, 92%);
    }
}
