:root {
    --primary: #d81324;
    --primary-dark: #b10e1c;
    --secondary: #0b2154;
    --gold: #f6c50e;
    --light: #f4f6fa;
    --ink: #152033;
    --muted: #5d6b82;
    --card: #ffffff;
    --line: rgba(11, 33, 84, 0.1);
    --radius: 16px;
    color-scheme: light;
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--light);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body { background: var(--light); }

a { color: var(--primary); }

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--secondary);
}

h1 { margin: 0; font-size: clamp(1.65rem, 2vw, 2.05rem); line-height: 1.15; }

h2 { margin: 0; font-size: 1rem; }

.lede, .hint { color: var(--muted); line-height: 1.55; }

.lede { margin: 0.4rem 0 0; font-size: 0.98rem; }

.hint { margin: 0.35rem 0 0; font-size: 0.9rem; }

.section-title { margin: 0 0 0.8rem; }

.kicker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    margin: 0 0 0.55rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 17.25rem minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 0.85rem 1rem;
    background: #fff;
    border-right: 1px solid var(--line);
}

.logo-link { display: block; text-decoration: none; }

.logo {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    background: #111;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 1rem;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.62rem 0.75rem;
    border-radius: 12px;
    color: var(--secondary);
    text-decoration: none;
    font-size: 0.94rem;
    font-weight: 600;
}

.side-nav a svg {
    width: 1.15rem;
    height: 1.15rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.side-nav a:hover { background: rgba(11, 33, 84, 0.05); }

.side-nav a.active {
    color: var(--primary);
    background: rgba(216, 19, 36, 0.1);
}

.side-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
}

.side-foot form { margin: 0; }

.side-foot .button-quiet { width: 100%; text-align: center; }

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--light);
}

.workspace { flex: 1; }

.workspace-body {
    width: min(68rem, calc(100% - 2.75rem));
    margin: 1.6rem auto 2rem;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.85rem 1.25rem;
    margin-bottom: 1.35rem;
}

.page-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(11, 33, 84, 0.04);
    padding: 1.15rem 1.2rem 1.2rem;
}

.panel > h2 { margin-bottom: 0.85rem; }

.panel + .panel,
.split + .panel { margin-top: 1rem; }

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(16rem, 0.8fr);
    gap: 1rem;
    align-items: start;
}

.account-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(18rem, 32rem) minmax(0, 1fr);
}

.account-brand {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 1.15rem;
    padding: 2.4rem;
    background:
        radial-gradient(26rem 16rem at 15% 0%, rgba(216, 19, 36, 0.45), transparent 62%),
        var(--secondary);
    color: rgba(255, 255, 255, 0.82);
}

.account-brand .logo { width: min(22rem, 100%); }

.account-brand p {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.account-stage {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--light);
}

.account-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 1.15rem 1.4rem 0;
}

.account-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    margin: 0;
    padding: 1.5rem;
}

.account-card {
    align-self: center;
    width: min(26rem, 100%);
    margin: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--primary);
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(11, 33, 84, 0.08);
    padding: 1.7rem 1.5rem 1.45rem;
}

.account-card h1 { font-size: 1.65rem; }

.account-card .lede { margin-bottom: 1.1rem; }

button, a.button, a.button-quiet {
    border-radius: 11px;
    padding: 0.68rem 1rem;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

button, a.button {
    background: var(--primary);
    color: #fff;
    border: 0;
}

button:hover, a.button:hover { background: var(--primary-dark); }

.account-card button { width: 100%; }

.setup-list { list-style: none; margin: 0.8rem 0 1rem; padding: 0; }
.setup-list li { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.75rem 0; border-top: 1px solid var(--line, #e6e8ef); }
.step-mark { width: 1.2rem; font-weight: 700; }

button.button-quiet, a.button-quiet {
    background: #fff;
    color: var(--secondary);
    border: 1px solid var(--line);
}

button.button-quiet:hover, a.button-quiet:hover { background: rgba(11, 33, 84, 0.05); }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.95rem; }

.field label { font-size: 0.82rem; font-weight: 700; color: var(--secondary); }

.field input, .field select, .manual-key {
    width: 100%;
    min-height: 2.75rem;
    border: 1px solid #d5dce8;
    border-radius: 11px;
    padding: 0.7rem 0.8rem;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.field input:focus, .field select:focus {
    outline: 3px solid rgba(216, 19, 36, 0.16);
    border-color: var(--primary);
}

.manual-key {
    font-family: Consolas, "Courier New", monospace;
    letter-spacing: 0.03em;
    background: #f7f8fb;
}

.check { display: flex; gap: 0.55rem; align-items: center; margin: 0.2rem 0 1.1rem; font-size: 0.92rem; }

.alert {
    background: #fff1f2;
    color: #8d1e2a;
    border: 1px solid rgba(216, 19, 36, 0.18);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
}

.user-chip {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.5rem 0.7rem;
    border-radius: 11px;
    background: var(--light);
    color: var(--secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

.languages {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.2rem;
    padding: 0.22rem;
    border-radius: 12px;
    background: var(--light);
}

.languages a {
    color: var(--secondary);
    text-decoration: none;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 0.38rem 0.2rem;
    border-radius: 9px;
}

.languages a:hover { color: var(--primary); }

.languages a.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(11, 33, 84, 0.08);
}

.account-toolbar .languages { width: min(16rem, 100%); }

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.1rem;
    min-height: 7.1rem;
    padding: 0.95rem 1rem;
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(11, 33, 84, 0.04);
}

.stat:hover { border-color: rgba(216, 19, 36, 0.35); }

.stat-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-value {
    color: var(--secondary);
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
}

.dot {
    width: 0.48rem;
    height: 0.48rem;
    border-radius: 99px;
    background: #94a3b8;
    flex: none;
}

.empty-note { margin-top: 0.9rem; }

.empty {
    margin: 0.4rem 0 0.2rem;
    padding: 1.6rem 0.5rem;
    text-align: center;
    color: var(--muted);
}

.filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 0.85rem;
    align-items: end;
    margin-bottom: 1.1rem;
}

.filters .field { margin: 0; min-width: 0; }

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }

th:nth-child(1) { width: 4.6rem; }

th:nth-child(3) { width: 6.2rem; }

th:nth-child(4) { width: 7.2rem; }

th, td {
    text-align: left;
    padding: 0.78rem 0.7rem;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover td { background: #fbfcfe; }

.lede.host { overflow-wrap: anywhere; }

.cell-title { font-weight: 600; }

.code-link, .code-pill {
    color: var(--secondary);
    font-weight: 800;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.code-link:hover { color: var(--primary); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: #eef1f6;
    color: var(--secondary);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.dot.status-draft, .badge.status-draft { background: #fff4cc; }
.dot.status-draft { background: #e0a106; }
.badge.status-draft { color: #7a5b00; }

.dot.status-scriptgenerated { background: #0b2154; }
.badge.status-scriptgenerated { background: #e8eefc; color: #0b2154; }

.dot.status-provisioning { background: #0284c7; }
.badge.status-provisioning { background: #e7f4ff; color: #0c4a6e; }

.dot.status-active { background: #15945a; }
.badge.status-active { background: #e7f7ee; color: #146c43; }

.dot.status-suspended { background: #d81324; }
.badge.status-suspended { background: #fde8ea; color: #9f1239; }

.badge.tone-insert { background: #e7f7ee; color: #146c43; }
.badge.tone-update { background: #e8eefc; color: #0b2154; }
.badge.tone-delete { background: #fde8ea; color: #9f1239; }

.muted {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }

.codes code {
    display: block;
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    background: #f7f8fb;
    font-size: 0.92rem;
}

.site-footer { color: var(--muted); }

.site-footer p {
    width: min(68rem, calc(100% - 2.75rem));
    margin: 0 auto;
    padding: 0.85rem 0 1.1rem;
    font-size: 0.8rem;
}

.site-footer strong { color: var(--secondary); font-weight: 700; }

.wizard-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.wizard-steps li {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.7rem;
    padding: 0.45rem 0.55rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.25;
}

.wizard-steps li.current {
    color: #fff;
    background: var(--secondary);
    border-color: var(--secondary);
}

.wizard-steps li.done {
    color: var(--secondary);
    background: #fff;
}

.wizard-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.15rem; }

.review {
    display: grid;
    grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr);
    margin: 0;
}

.review dt, .review dd {
    margin: 0;
    padding: 0.68rem 0;
    border-bottom: 1px solid #eef1f6;
}

.review dt { color: var(--muted); font-size: 0.84rem; font-weight: 600; }

.review dd { font-weight: 600; overflow-wrap: anywhere; }

.script {
    width: 100%;
    min-height: 18rem;
    margin-top: 0.75rem;
    resize: vertical;
    border: 1px solid #d5dce8;
    border-radius: 12px;
    padding: 0.85rem;
    background: #f7f8fb;
    color: var(--ink);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.8rem;
    line-height: 1.45;
}

.hash {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.78rem;
    overflow-wrap: anywhere;
}

.form-grid { display: grid; gap: 0.15rem 1rem; }

.form-grid.two { grid-template-columns: 1fr; }

.pager {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    margin-top: 0.9rem;
    font-weight: 700;
}

.pager-current { color: var(--muted); font-size: 0.85rem; }

#blazor-error-ui {
    background: #fff4cc;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.validation-message { color: var(--primary); font-size: 0.85rem; }

:focus-visible { outline: 3px solid rgba(216, 19, 36, 0.35); outline-offset: 2px; }

@media (min-width: 800px) {
    .form-grid.two { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        height: auto;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "logo tools"
            "nav nav";
        align-items: center;
        column-gap: 0.75rem;
        row-gap: 0.55rem;
        padding: 0.7rem 0.75rem 0.65rem;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .logo-link { grid-area: logo; }

    .logo { width: 9.2rem; border-radius: 8px; }

    .side-nav {
        grid-area: nav;
        flex-direction: row;
        overflow-x: auto;
        margin: 0;
    }

    .side-nav a { white-space: nowrap; padding: 0.48rem 0.65rem; }

    .side-foot {
        grid-area: tools;
        margin: 0;
        padding: 0;
        border: 0;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 0.35rem;
    }

    .user-chip { display: none; }

    .languages { width: auto; padding: 0.12rem; }

    .languages a { padding: 0.28rem 0.4rem; }

    .side-foot form { width: auto; }

    .side-foot .button-quiet {
        width: auto;
        padding: 0.38rem 0.65rem;
        font-size: 0.78rem;
    }

    .account-shell { grid-template-columns: 1fr; }

    .account-brand {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.85rem 1rem;
    }

    .account-brand .logo { width: min(12rem, 58vw); }

    .account-brand p { letter-spacing: 0.04em; font-size: 0.72rem; }

    .account-main { align-items: stretch; padding-top: 0.75rem; }

    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }

    .stat { min-height: 0; gap: 0.45rem; }

    .page-actions { width: 100%; justify-content: flex-start; }

    .filters, .split { grid-template-columns: 1fr; }

    .wizard-steps { grid-template-columns: 1fr 1fr; }

    .codes { grid-template-columns: 1fr; }

    .workspace-body, .site-footer p { width: min(68rem, calc(100% - 1.4rem)); }

    .workspace-body { margin-top: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
