:root {
    --bg: #f5f7fb;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --surface-muted: #f8fafc;
    --text: #0f172a;
    --text-soft: #475569;
    --text-faint: #64748b;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.14);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.1);
    --success: #15803d;
    --success-soft: rgba(21, 128, 61, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --warning: #b45309;
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 20px 55px rgba(15, 23, 42, 0.08);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --content-width: 1240px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.09), transparent 26%),
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 48%, #eff3f8 100%);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.container {
    width: min(100% - 2rem, var(--content-width));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(20px);
    background: rgba(248, 251, 255, 0.72);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 76px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none;
    color: var(--text);
}

.site-brand__mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.site-brand__text {
    display: flex;
    flex-direction: column;
}

.site-brand__title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.1;
}

.site-brand__subtitle {
    color: var(--text-faint);
    font-size: 0.78rem;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
    content: "";
}

.nav-toggle__icon {
    position: relative;
}

.nav-toggle__icon::before {
    position: absolute;
    top: -6px;
    left: 0;
}

.nav-toggle__icon::after {
    position: absolute;
    top: 6px;
    left: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon::before {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon::after {
    transform: translateY(-6px) rotate(-45deg);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-soft);
    font-size: 0.95rem;
    font-weight: 600;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.site-nav__link:hover,
.site-nav__link:focus-visible,
.site-nav__link.is-active {
    color: var(--text);
    background: rgba(15, 23, 42, 0.06);
}

.site-nav__link:focus-visible,
.button:focus-visible,
.input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-toggle:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    outline-offset: 2px;
}

.main-content {
    padding: var(--space-8) 0 var(--space-12);
}

.stack {
    display: grid;
    gap: var(--space-6);
}

.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

.page-hero__content {
    max-width: 760px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    padding: 0.48rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(15, 23, 42, 0.06);
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    letter-spacing: -0.03em;
    line-height: 1.08;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.5rem);
}

h2 {
    font-size: clamp(1.3rem, 2vw, 1.9rem);
}

h3 {
    font-size: 1.1rem;
}

.lead,
.section-intro {
    margin: 1rem 0 0;
    color: var(--text-soft);
    font-size: clamp(1rem, 1.5vw, 1.1rem);
    max-width: 62ch;
}

.hero-actions,
.actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.card,
.metric,
.data-panel,
.auth-shell,
.empty-state {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
}

.card,
.data-panel,
.auth-shell,
.empty-state {
    padding: clamp(1.2rem, 2vw, 1.75rem);
}

.card::before,
.metric::before,
.data-panel::before,
.auth-shell::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), transparent 50%, rgba(255, 255, 255, 0.24));
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.section-header__text {
    display: grid;
    gap: 0.45rem;
}

.section-kicker {
    color: var(--text-faint);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.section-description,
.supporting-text,
.muted {
    color: var(--text-faint);
}

.metric-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
    padding: 1.25rem;
    min-height: 138px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    justify-content: space-between;
}

.metric__label {
    color: var(--text-faint);
    font-size: 0.92rem;
    font-weight: 600;
}

.metric__value {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.metric__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-soft);
    font-size: 0.88rem;
}

.button,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 48px;
    padding: 0.8rem 1.15rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.01em;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(37, 99, 235, 0.22);
}

.button.secondary,
button.secondary {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.button.secondary:hover,
button.secondary:hover {
    background: #ffffff;
    border-color: var(--border-strong);
}

.button.danger,
button.danger {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.12);
    box-shadow: none;
}

.button.danger:hover,
button.danger:hover {
    background: rgba(220, 38, 38, 0.12);
}

.inline-form {
    display: inline-flex;
}

label,
.form-label {
    display: block;
    margin-bottom: 0.55rem;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 700;
}

.form-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row {
    min-width: 0;
}

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

input,
select,
textarea,
.input {
    width: 100%;
    min-height: 52px;
    padding: 0.9rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(100, 116, 139, 0.28);
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.46);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    background: #ffffff;
    outline: none;
}

.form-hint {
    margin-top: 0.5rem;
    color: var(--text-faint);
    font-size: 0.88rem;
}

.alert-stack {
    display: grid;
    gap: 0.9rem;
    margin-bottom: var(--space-5);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1rem 1rem 1.05rem;
    border-radius: 18px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.alert::before {
    content: "";
    display: block;
    width: 11px;
    min-width: 11px;
    min-height: 11px;
    border-radius: 999px;
    margin-top: 0.4rem;
}

.alert.success {
    background: #f0fdf4;
    border-color: rgba(21, 128, 61, 0.12);
    color: #166534;
}

.alert.success::before {
    background: var(--success);
}

.alert.error {
    background: #fef2f2;
    border-color: rgba(220, 38, 38, 0.14);
    color: #991b1b;
}

.alert.error::before {
    background: var(--danger);
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.table-wrap {
    overflow: auto;
    border-radius: 20px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: rgba(255, 255, 255, 0.8);
}

.table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
}

.table th,
.table td {
    padding: 1rem 1.05rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(248, 250, 252, 0.96);
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.table tbody tr {
    transition: background-color 0.18s ease;
}

.table tbody tr:hover {
    background: rgba(37, 99, 235, 0.035);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table-entity {
    display: grid;
    gap: 0.25rem;
}

.table-entity__title {
    font-weight: 700;
    color: var(--text);
}

.table-entity__meta {
    color: var(--text-faint);
    font-size: 0.9rem;
    word-break: break-word;
}

.tag,
.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 32px;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tag,
.badge {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-soft);
}

.status-pill--success {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.trend {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 800;
}

.trend--up {
    color: #b91c1c;
}

.trend--down {
    color: #166534;
}

.kpi-note,
.stat-note {
    color: var(--text-faint);
    font-size: 0.88rem;
}

.auth-layout {
    min-height: calc(100vh - 76px - 3rem);
    display: grid;
    place-items: center;
}

.auth-shell {
    width: min(100%, 520px);
    padding: clamp(1.5rem, 3vw, 2rem);
}

.auth-shell__header {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 1.35rem;
}

.auth-shell__meta {
    color: var(--text-faint);
}

.code-input {
    text-align: center;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.28em;
}

.empty-state {
    display: grid;
    gap: 0.55rem;
    justify-items: start;
}

.empty-state__title {
    font-size: 1.1rem;
    font-weight: 800;
}

.empty-state__text {
    color: var(--text-faint);
    max-width: 55ch;
}

.site-footer {
    padding: 0 0 var(--space-8);
}

.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.2rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-faint);
    font-size: 0.92rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

@media (max-width: 860px) {
    .site-header__inner {
        min-height: 70px;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .site-nav {
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 1rem;
        right: 1rem;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 0.8rem;
        border: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: var(--shadow-md);
    }

    .site-nav.is-open {
        display: flex;
    }

    .site-nav__link {
        justify-content: flex-start;
        border-radius: 14px;
    }

    .page-hero,
    .section-header,
    .panel-toolbar,
    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-content {
        padding-top: var(--space-6);
    }
}

@media (max-width: 720px) {
    .container {
        width: min(100% - 1rem, var(--content-width));
    }

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

    .card,
    .data-panel,
    .auth-shell,
    .empty-state,
    .metric {
        border-radius: 20px;
    }

    .table {
        min-width: 640px;
    }

    .button,
    button,
    input[type="submit"] {
        width: 100%;
    }

    .inline-form {
        width: 100%;
    }

    .inline-form button,
    .inline-form .button {
        width: 100%;
    }
}