:root {
    --bg: #091119;
    --bg-accent: #0f1c29;
    --panel: rgba(14, 24, 35, 0.9);
    --panel-strong: #111d2b;
    --panel-muted: #172536;
    --ink: #e8f0f8;
    --ink-soft: #d0deea;
    --muted: #8fa4b7;
    --muted-strong: #b4c5d4;
    --line: rgba(132, 162, 191, 0.18);
    --line-strong: rgba(132, 162, 191, 0.34);
    --accent: #56b7ff;
    --accent-strong: #2b91e0;
    --accent-soft: rgba(86, 183, 255, 0.14);
    --success: #47d4a2;
    --success-soft: rgba(71, 212, 162, 0.14);
    --warning: #ffb454;
    --warning-soft: rgba(255, 180, 84, 0.14);
    --danger: #ff7f7f;
    --danger-soft: rgba(255, 127, 127, 0.14);
    --shadow-sm: 0 14px 30px rgba(1, 7, 13, 0.22);
    --shadow-md: 0 28px 60px rgba(1, 8, 15, 0.3);
    --shadow-lg: 0 44px 90px rgba(0, 0, 0, 0.38);
    --radius-xs: 12px;
    --radius-sm: 16px;
    --radius-md: 24px;
    --radius-lg: 32px;
    --sidebar-width: 292px;
    --sidebar-collapsed-width: 96px;
    --font-body: "Aptos", "Segoe UI Variable", "Segoe UI", "Trebuchet MS", sans-serif;
    --font-display: "Bahnschrift", "Aptos Display", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
    --font-mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.55;
    background:
        radial-gradient(circle at top left, rgba(86, 183, 255, 0.18), transparent 28%),
        radial-gradient(circle at 85% 10%, rgba(35, 88, 138, 0.28), transparent 24%),
        radial-gradient(circle at bottom right, rgba(32, 67, 104, 0.22), transparent 30%),
        linear-gradient(180deg, #071019 0%, var(--bg) 42%, var(--bg-accent) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

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

code {
    padding: 0.16rem 0.45rem;
    border: 1px solid rgba(132, 162, 191, 0.18);
    border-radius: 999px;
    background: rgba(18, 32, 48, 0.9);
    font-family: var(--font-mono);
    font-size: 0.92em;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #132234 0%, #101d2e 100%);
}

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

th {
    color: var(--muted-strong);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
}

tbody tr {
    transition: background-color 160ms ease, transform 160ms ease;
}

tbody tr:hover {
    background: rgba(86, 183, 255, 0.06);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    padding: 0.88rem 1rem;
    background: rgba(10, 20, 31, 0.94);
    color: var(--ink);
    font: inherit;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input::placeholder,
textarea::placeholder {
    color: #71879b;
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: rgba(86, 183, 255, 0.52);
    box-shadow: 0 0 0 4px rgba(86, 183, 255, 0.14);
    transform: translateY(-1px);
}

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

button {
    font: inherit;
}

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 200ms ease;
}

body.sidebar-collapsed .shell {
    grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    min-height: 100vh;
    padding: 1.9rem 1.25rem 1.5rem;
    background:
        linear-gradient(180deg, rgba(5, 15, 24, 0.98) 0%, rgba(11, 24, 38, 0.98) 54%, rgba(15, 30, 47, 0.98) 100%);
    color: #eaf2f8;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
    transition: padding 200ms ease, width 200ms ease;
}

.sidebar-toggle-row {
    display: flex;
    justify-content: flex-end;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: #eaf2f8;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.sidebar-toggle:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.14);
}

.sidebar-top {
    display: grid;
    gap: 0.85rem;
}

.brand {
    display: grid;
    gap: 0.35rem;
    padding: 1rem 1.05rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-kicker {
    display: block;
    color: rgba(234, 242, 248, 0.72);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.brand strong {
    font-family: var(--font-display);
    font-size: 1.45rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.sidebar-copy {
    margin: 0;
    padding: 0 0.25rem;
    color: rgba(234, 242, 248, 0.72);
    font-size: 0.93rem;
}

.nav {
    display: grid;
    gap: 0.45rem;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 48px;
    padding: 0.82rem 1rem;
    border: 1px solid transparent;
    border-radius: 14px;
    color: rgba(234, 242, 248, 0.86);
    font-weight: 600;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav a:hover {
    transform: translateX(3px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.nav a .fa {
    width: 1.15rem;
    text-align: center;
    font-size: 1rem;
    flex: 0 0 auto;
}

.nav a span {
    white-space: nowrap;
}

.nav a.is-active {
    background: linear-gradient(135deg, rgba(94, 167, 215, 0.24), rgba(64, 116, 154, 0.2));
    border-color: rgba(124, 190, 232, 0.28);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.nav a.is-active::before {
    content: "";
    position: absolute;
    left: 0.7rem;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #8ad0ff;
    box-shadow: 0 0 0 6px rgba(138, 208, 255, 0.1);
}

.nav a.is-active {
    padding-left: 1.75rem;
}

.sidebar-foot {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: auto;
    padding: 0.95rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(234, 242, 248, 0.72);
    font-size: 0.9rem;
}

.sidebar-user-card {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-user-meta {
    display: grid;
    gap: 0.2rem;
}

.sidebar-user-label {
    color: rgba(234, 242, 248, 0.66);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.sidebar-user-meta strong {
    font-size: 1rem;
    color: #ffffff;
}

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

.sidebar-logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: #f4f8fb;
    cursor: pointer;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.sidebar-logout-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
}

body.sidebar-collapsed .sidebar {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
}

body.sidebar-collapsed .sidebar-toggle-row {
    justify-content: center;
}

body.sidebar-collapsed .brand {
    justify-items: center;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

body.sidebar-collapsed .brand-kicker,
body.sidebar-collapsed .sidebar-copy,
body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .nav a span,
body.sidebar-collapsed .sidebar-foot span:last-child,
body.sidebar-collapsed .sidebar-user-label,
body.sidebar-collapsed .sidebar-user-meta strong,
body.sidebar-collapsed .sidebar-logout-button span {
    display: none;
}

body.sidebar-collapsed .nav a {
    justify-content: center;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
}

body.sidebar-collapsed .nav a.is-active {
    padding-left: 0.8rem;
}

body.sidebar-collapsed .nav a.is-active::before {
    left: 50%;
    top: auto;
    bottom: 6px;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    box-shadow: 0 0 0 4px rgba(138, 208, 255, 0.08);
}

body.sidebar-collapsed .sidebar-foot {
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

body.sidebar-collapsed .sidebar-user-card {
    justify-items: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

body.sidebar-collapsed .status-dot {
    margin: 0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #53d39b;
    box-shadow: 0 0 0 5px rgba(83, 211, 155, 0.14);
}

.content {
    padding: 2.2rem;
}

.content > * {
    animation: fade-up 320ms ease;
}

.hero,
.card,
.message {
    border: 1px solid rgba(132, 162, 191, 0.14);
    border-radius: var(--radius-md);
    background: var(--panel);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-md);
}

.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    gap: 1.75rem;
    align-items: flex-end;
    padding: 2.25rem;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(86, 183, 255, 0.15), transparent 25%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 62%);
    pointer-events: none;
}

.hero > * {
    position: relative;
    z-index: 1;
}

.eyebrow {
    margin: 0 0 0.65rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 0.76rem;
    font-weight: 700;
}

.hero h1 {
    margin: 0 0 1rem;
    max-width: 13ch;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 3vw, 3.7rem);
    line-height: 0.98;
    letter-spacing: -0.05em;
}

.lead {
    max-width: 65ch;
    margin: 0;
    color: var(--muted);
    font-size: 1.01rem;
}

.hero-actions,
.form-actions,
.actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.82rem 1.18rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: linear-gradient(180deg, #162537 0%, #111e2d 100%);
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.25);
}

.button.primary {
    border-color: rgba(86, 183, 255, 0.28);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #05121d;
}

.button.danger {
    border-color: rgba(178, 77, 66, 0.24);
    background: linear-gradient(135deg, #c35f54 0%, var(--danger) 100%);
    color: #ffffff;
}

.stats,
.grid {
    display: grid;
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.card {
    padding: 1.45rem;
}

.account-card {
    display: block;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.account-card:hover {
    transform: translateY(-5px);
    border-color: rgba(31, 95, 139, 0.24);
    box-shadow: var(--shadow-lg);
}

.stat {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(17, 29, 43, 0.98), rgba(12, 24, 36, 0.98));
}

.stat::after {
    content: "";
    position: absolute;
    inset: auto -30px -40px auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(86, 183, 255, 0.16), transparent 70%);
}

.stat span {
    position: relative;
    display: block;
    margin-bottom: 0.6rem;
    color: var(--muted);
}

.stat strong {
    position: relative;
    font-family: var(--font-display);
    font-size: 2.25rem;
    letter-spacing: -0.05em;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.section-head h1,
.section-head h2,
.card h2,
.form-card h1 {
    margin: 0;
    font-family: var(--font-display);
    letter-spacing: -0.03em;
}

.stack {
    display: grid;
    gap: 0.8rem;
}

.meta {
    display: grid;
    gap: 0.7rem;
    margin: 0;
}

.meta.stacked div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
}

.meta div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--line);
}

.meta dt {
    color: var(--muted);
    font-weight: 600;
}

.meta dd {
    margin: 0;
    text-align: right;
    color: var(--ink-soft);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.38rem 0.78rem;
    border-radius: 999px;
    border: 1px solid rgba(31, 95, 139, 0.12);
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
}

.messages {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.message {
    position: relative;
    padding: 1rem 1.1rem 1rem 1.25rem;
    border-left: 4px solid var(--accent);
    color: var(--ink-soft);
    background: linear-gradient(180deg, rgba(18, 31, 47, 0.98), rgba(13, 25, 38, 0.98));
}

.form-card {
    max-width: 1180px;
    background:
        linear-gradient(180deg, rgba(14, 24, 35, 0.96), rgba(11, 20, 30, 0.96));
}

.auth-shell {
    display: flex;
    min-height: calc(100vh - 4.4rem);
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: min(560px, 100%);
    margin: 0 auto;
    padding: 2rem;
}

.auth-card-copy {
    margin-bottom: 1.3rem;
}

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

.auth-card-note {
    margin-top: 1rem;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.1rem 1rem;
}

.form-grid.compact {
    gap: 0.8rem;
}

.field {
    display: grid;
    gap: 0.5rem;
    padding: 1rem 1rem 0.95rem;
    border: 1px solid rgba(132, 162, 191, 0.12);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(16, 28, 40, 0.92), rgba(12, 22, 32, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.field label {
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.field.is-wide,
.field.is-file {
    grid-column: 1 / -1;
}

.field small {
    color: var(--muted);
    line-height: 1.5;
}

.field.is-boolean {
    display: flex;
    align-items: center;
    min-height: 72px;
}

.toggle-field {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
}

.toggle-field input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
    accent-color: var(--accent);
}

.file-picker {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
    min-height: 74px;
    padding: 0.8rem;
    border: 1px dashed rgba(86, 183, 255, 0.24);
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(86, 183, 255, 0.08), rgba(86, 183, 255, 0.02));
}

.file-picker input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-picker-button {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.85rem 1.1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(86, 183, 255, 0.2), rgba(43, 145, 224, 0.18));
    color: #eaf6ff;
    font-weight: 700;
    border: 1px solid rgba(86, 183, 255, 0.2);
    box-shadow: var(--shadow-sm);
}

.file-picker-button .fa {
    font-size: 1rem;
}

.file-picker-meta {
    min-width: 0;
}

.file-picker-name {
    display: block;
    color: var(--muted-strong);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.error {
    color: var(--danger);
}

.error-panel {
    padding: 0.95rem 1rem;
    border: 1px solid rgba(255, 127, 127, 0.24);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    grid-column: 1 / -1;
}

.json-editor {
    min-height: 14rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.5;
    tab-size: 2;
}

.actions form {
    display: inline-flex;
    margin: 0;
}

.caption-preview {
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(18, 31, 46, 0.96), rgba(12, 22, 34, 0.96));
}

.card table {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-strong);
}

.card table th:first-child {
    border-top-left-radius: 18px;
}

.card table th:last-child {
    border-top-right-radius: 18px;
}

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

.card p:last-child {
    margin-bottom: 0;
}

.card p:first-child,
.card h2 + p {
    margin-top: 0;
}

.button + .button {
    margin-left: 0;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .content {
        padding: 1.5rem;
    }

    .hero h1 {
        max-width: 14ch;
    }
}

@media (max-width: 960px) {
    .shell {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    body.sidebar-collapsed .sidebar {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    body.sidebar-collapsed .brand-kicker,
    body.sidebar-collapsed .sidebar-copy,
    body.sidebar-collapsed .brand strong,
    body.sidebar-collapsed .nav a span,
    body.sidebar-collapsed .sidebar-foot span:last-child,
    body.sidebar-collapsed .sidebar-user-label,
    body.sidebar-collapsed .sidebar-user-meta strong,
    body.sidebar-collapsed .sidebar-logout-button span {
        display: initial;
    }

    body.sidebar-collapsed .nav a {
        justify-content: flex-start;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    body.sidebar-collapsed .nav a.is-active {
        padding-left: 1.75rem;
    }

    body.sidebar-collapsed .nav a.is-active::before {
        left: 0.7rem;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
        width: 8px;
        height: 8px;
        box-shadow: 0 0 0 6px rgba(138, 208, 255, 0.1);
    }

    body.sidebar-collapsed .sidebar-foot {
        justify-content: flex-start;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .stats,
    .grid.two {
        grid-template-columns: 1fr;
    }

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

    .hero h1 {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 1rem;
    }

    .card,
    .hero {
        padding: 1.15rem;
        border-radius: 20px;
    }

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

    .file-picker {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 0.8rem 0.7rem;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
