:root {
    --color-app-bg: #f5f7f2;
    --color-surface: #ffffff;
    --color-surface-soft: #f5f7f2;
    --color-brand: #204286;
    --color-brand-dark: #16315f;
    --color-brand-soft: #e8eef8;
    --color-text: #20304f;
    --color-text-muted: #5f6d88;
    --color-border: #d8e0ee;
    --color-border-strong: #bcc9de;
    --color-success-bg: #eaf7ef;
    --color-success-text: #1f6a3d;
    --color-warning-bg: #fff7eb;
    --color-warning-text: #9c5b16;
    --color-danger-bg: #fceaea;
    --color-danger-text: #9d2f2f;
    --shadow-soft: 0 18px 40px rgba(32, 66, 134, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    background: var(--color-app-bg);
    color: var(--color-text);
    font-family: "Figtree", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--color-brand);
    text-decoration: none;
    transition: color 150ms ease;
}

a:hover,
a:focus {
    color: var(--color-brand-dark);
    outline: none;
}

code,
pre {
    font-family: Consolas, "Courier New", monospace;
}

code {
    display: inline-block;
    border-radius: 0.65rem;
    background: var(--color-brand-soft);
    padding: 0.2rem 0.5rem;
    color: var(--color-brand-dark);
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.875rem;
    border: 1px solid transparent;
    background: var(--color-brand);
    padding: 0.75rem 1.1rem;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

button:hover,
button:focus,
.button-link:hover,
.button-link:focus {
    background: var(--color-brand-dark);
    outline: none;
    color: #ffffff;
}

button.secondary,
.button-link.secondary {
    border-color: var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
}

button.secondary:hover,
button.secondary:focus,
.button-link.secondary:hover,
.button-link.secondary:focus {
    border-color: var(--color-brand);
    background: var(--color-brand-soft);
    color: var(--color-brand);
}

button.danger,
button.logout,
.button-link.danger {
    background: var(--color-brand-dark);
}

button.danger:hover,
button.logout:hover,
button.danger:focus,
button.logout:focus,
.button-link.danger:hover,
.button-link.danger:focus {
    background: #102344;
}

label {
    display: block;
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 0.875rem;
    background: var(--color-surface);
    padding: 0.75rem 1rem;
    color: var(--color-text);
    font: inherit;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input::placeholder,
textarea::placeholder {
    color: #8c9ab0;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--color-border-strong);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px rgba(32, 66, 134, 0.12);
}

textarea {
    min-height: 12rem;
    resize: vertical;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.25rem 2.5rem;
}

.stack-sm > * + * {
    margin-top: 0.75rem;
}

.stack-md > * + * {
    margin-top: 1rem;
}

.stack-lg > * + * {
    margin-top: 1.5rem;
}

.surface-card,
.panel,
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    box-shadow: var(--shadow-soft);
}

.panel,
.card {
    padding: 1.5rem;
}

.surface-card-padded {
    padding: 2rem;
}

.page-header,
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-kicker,
.eyebrow-text {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0 0 0.5rem;
}

.page-title,
h1 {
    margin: 0;
    color: var(--color-text);
    font-size: clamp(1.8rem, 2vw, 2.75rem);
    font-weight: 600;
    line-height: 1.15;
}

.page-subtitle,
.muted {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.section-title,
h2,
h3 {
    margin: 0;
    color: var(--color-text);
    font-weight: 600;
    line-height: 1.2;
}

h2 {
    font-size: 1.2rem;
}

h3 {
    font-size: 1rem;
}

.hero-card {
    background:
        radial-gradient(circle at top right, rgba(32, 66, 134, 0.12), transparent 32%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(232, 238, 248, 0.7));
}

.hero-copy {
    max-width: 48rem;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.content-grid-wide {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    gap: 1.5rem;
}

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

.field-grid {
    display: grid;
    gap: 1rem;
}

.field-stack {
    display: grid;
    gap: 0.5rem;
}

.inline-note {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-top: 0.2rem;
    accent-color: var(--color-brand);
}

.table-shell {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    background: var(--color-surface);
}

.table-shell table {
    margin-top: 0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

.table-link {
    color: var(--color-brand);
    font-size: 0.875rem;
    font-weight: 600;
}

.table-link:hover,
.table-link:focus {
    color: var(--color-brand-dark);
}

.metric-value-sm {
    font-size: 1rem;
    word-break: break-word;
}

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

.flash,
.error,
.warn,
.status-box {
    border-radius: 1rem;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: 0.95rem;
}

.flash {
    background: var(--color-success-bg);
    border-color: #c9e7d4;
    color: var(--color-success-text);
}

.error {
    background: var(--color-danger-bg);
    border-color: #efcaca;
    color: var(--color-danger-text);
}

.warn {
    background: var(--color-warning-bg);
    border-color: #f3d7ab;
    color: var(--color-warning-text);
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary .card strong,
.metric-title {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.summary .card div,
.metric-value {
    margin-top: 0.6rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--color-surface);
    overflow: hidden;
}

th,
td {
    border-bottom: 1px solid var(--color-border);
    padding: 0.95rem 1rem;
    text-align: left;
    vertical-align: top;
    font-size: 0.92rem;
}

th {
    background: var(--color-surface-soft);
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.badge.ok,
.ok {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge.off,
.rd {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.links code {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
}

.hint {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.inline-form {
    display: inline;
}

.link-button {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--color-brand);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
    box-shadow: none;
}

.link-button:hover,
.link-button:focus {
    background: transparent;
    color: var(--color-brand-dark);
}

.auth-shell {
    width: 100%;
    min-height: 100vh;
}

.auth-panel-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
    padding: 2.5rem;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
}

.brand-logo {
    display: block;
    width: auto;
    height: 2.75rem;
    max-width: 11rem;
    object-fit: contain;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: var(--color-brand-soft);
    color: var(--color-brand);
    font-size: 1.15rem;
    font-weight: 700;
}

.auth-copy-content {
    max-width: 44rem;
    display: grid;
    gap: 1.5rem;
}

.auth-title-accent {
    display: block;
    color: var(--color-brand);
}

.auth-copy-lead {
    max-width: 38rem;
    font-size: 1rem;
    line-height: 1.9;
}

.auth-form-intro {
    margin-bottom: 1.5rem;
    display: grid;
    gap: 0.5rem;
}

.auth-form-title {
    font-size: 1.65rem;
}

.auth-panel-login {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    background-image: linear-gradient(rgba(18, 34, 67, 0.58), rgba(18, 34, 67, 0.22)), url("./auth-background.svg");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.auth-panel-login::before {
    content: "";
    position: absolute;
    inset: 1.5rem;
    border-radius: 1.5rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.24);
}

.auth-panel-login::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 22% 18%, rgba(32, 66, 134, 0.42), transparent 28%),
        radial-gradient(circle at 76% 76%, rgba(245, 247, 242, 0.22), transparent 24%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 38%);
    pointer-events: none;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: min(100%, 26rem);
    padding: 2rem;
}

.auth-card h1 {
    font-size: 1.7rem;
}

.auth-card .field {
    margin-bottom: 1rem;
}

.app-nav {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.app-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.app-nav-main {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-left: auto;
}

.app-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.app-nav-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.nav-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0;
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 600;
}

.nav-chip:hover,
.nav-chip:focus {
    color: var(--color-brand);
}

.nav-logout-form {
    margin: 0;
}

.nav-logout-button {
    min-width: 7rem;
}

.section-stack > * + * {
    margin-top: 1.5rem;
}

.preformatted {
    white-space: pre-wrap;
    word-break: break-word;
    background: #152645;
    color: #edf2fb;
    border-radius: 1rem;
    padding: 1.25rem;
    overflow-x: auto;
    border: 1px solid #24477e;
}

.balance {
    margin-top: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

@media (min-width: 1024px) {
    .auth-shell {
        display: grid;
        grid-template-columns: minmax(0, 60%) minmax(360px, 40%);
    }

    .auth-panel-copy {
        padding: 4rem 5rem;
    }
}

@media (max-width: 900px) {
    .container {
        padding: 1.25rem 1rem 2rem;
    }

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

    .page-header,
    .topbar,
    .app-nav-inner,
    .app-nav-main {
        flex-direction: column;
        align-items: stretch;
    }

    .app-nav-actions {
        justify-content: flex-start;
    }
}

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