:root {
    --bg: #0c0a09;
    --panel: rgba(28, 25, 23, 0.84);
    --panel-border: rgba(251, 191, 36, 0.18);
    --panel-strong: rgba(38, 31, 27, 0.96);
    --text: #f5f5f4;
    --muted: #d6d3d1;
    --muted-soft: rgba(214, 211, 209, 0.72);
    --accent: #f59e0b;
    --accent-2: #f97316;
    --danger: #ef4444;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--text);
    line-height: 1.5;
    background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.24), transparent 34%),
        radial-gradient(circle at bottom right, rgba(251, 113, 133, 0.18), transparent 28%),
        linear-gradient(135deg, #120f0d, #0c0a09 55%, #15110d);
}

body.modal-open {
    overflow: hidden;
}

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

.admin-body {
    min-height: 100vh;
}

.page-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 28px 22px;
    border-right: 1px solid rgba(245, 158, 11, 0.15);
    background: rgba(10, 9, 8, 0.72);
    backdrop-filter: blur(12px);
}

.content {
    padding: 28px;
    display: grid;
    align-content: start;
    gap: 18px;
}

.brand h1,
.panel-head h2,
.modal-dialog h3 {
    margin: 8px 0;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    letter-spacing: -0.04em;
}

.brand h1 {
    font-size: clamp(34px, 3vw, 42px);
}

.muted,
.eyebrow,
.section-copy,
.field-hint,
.table-title small,
.status-box,
.details-box,
.helper-line,
.import-note,
.security-note p,
.action-card p {
    color: var(--muted);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 12px;
}

.panel-head {
    margin-bottom: 18px;
}

.panel-head h2 {
    font-size: clamp(24px, 2.5vw, 34px);
}

.panel-head.split,
.button-row,
.toolbar,
.session-meta,
.status-head,
.panel-actions,
.title-row,
.metric-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 28px 0;
}

.nav-link,
.primary-btn,
.secondary-btn,
.danger-btn,
.subnav-link {
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.nav-link {
    background: rgba(41, 37, 36, 0.8);
    color: var(--text);
    text-align: left;
}

.nav-link.active,
.nav-link:hover,
.subnav-link.active,
.subnav-link:hover {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(120, 53, 15, 0.35);
}

.nav-link:hover,
.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover,
.subnav-link:hover,
.help-trigger:hover,
.action-link:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.grid-form {
    display: grid;
    gap: 14px;
}

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

.grid-form label,
.grid-form .full {
    display: grid;
    gap: 8px;
}

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

.grid-form .full.button-row,
.grid-form .full.route-actions {
    display: flex;
}

.field-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.json-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.json-editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.json-action-btn {
    padding: 8px 12px;
    border-radius: 12px;
}

.json-editor-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(214, 211, 209, 0.16);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 13px;
}

.json-editor-status.is-ok {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(21, 128, 61, 0.18);
    color: #bbf7d0;
}

.json-editor-status.is-warning {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(120, 53, 15, 0.2);
    color: #fde68a;
}

.json-editor-status.is-error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(127, 29, 29, 0.24);
    color: #fecaca;
}

.auth-panel {
    max-width: 760px;
}

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

.auth-panel button {
    width: fit-content;
    min-width: 160px;
}

.checkbox-card {
    grid-template-columns: auto 1fr;
    align-items: start;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(214, 211, 209, 0.12);
    background: rgba(28, 25, 23, 0.72);
}

.checkbox-card input {
    width: auto;
    margin-top: 4px;
}

.field-copy {
    display: grid;
    gap: 4px;
}

input,
textarea,
select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(214, 211, 209, 0.2);
    background: rgba(28, 25, 23, 0.94);
    color: var(--text);
    padding: 12px 14px;
}

input::placeholder,
textarea::placeholder {
    color: rgba(214, 211, 209, 0.58);
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(245, 158, 11, 0.45);
    outline-offset: 1px;
    border-color: rgba(245, 158, 11, 0.35);
}

textarea {
    resize: vertical;
}

textarea[data-json-field] {
    font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.65;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    padding: 16px 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.01)),
        rgba(20, 17, 15, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

input[type="file"] {
    padding: 10px;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(245, 158, 11, 0.14);
    color: var(--text);
    cursor: pointer;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #120f0d;
    font-weight: 700;
}

.secondary-btn,
.subnav-link {
    background: rgba(68, 64, 60, 0.7);
    color: var(--text);
    border-color: rgba(245, 158, 11, 0.25);
}

.danger-btn {
    background: rgba(127, 29, 29, 0.6);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.flash {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 32px));
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: rgba(120, 53, 15, 0.34);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
    z-index: 80;
}

.flash.error {
    border-color: rgba(239, 68, 68, 0.34);
    background: rgba(127, 29, 29, 0.55);
}

.view-stack > * + * {
    margin-top: 24px;
}

.routes-toolbar {
    gap: 16px;
    margin-top: 20px;
    margin-bottom: 18px;
}

.routes-toolbar #reload-routes-btn {
    margin-top: 6px;
    padding-left: 20px;
    padding-right: 20px;
}

.subsection-title {
    margin: 0;
    font-size: clamp(20px, 2vw, 26px);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    letter-spacing: -0.03em;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.metric-card,
.status-box,
.details-box,
.action-card,
.security-note,
.import-note {
    border-radius: 18px;
    padding: 18px;
    background: rgba(28, 25, 23, 0.9);
    border: 1px solid rgba(214, 211, 209, 0.12);
}

.metric-head {
    align-items: flex-start;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
    color: var(--text);
}

.status-box {
    margin-top: 16px;
}

.table-wrap {
    overflow-x: auto;
}

.import-profiles-panel {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

.data-table thead {
    background: rgba(255, 255, 255, 0.02);
}

.data-table th,
.data-table td {
    border-bottom: 1px solid rgba(214, 211, 209, 0.12);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

.selection-cell {
    width: 44px;
}

.selection-cell input {
    width: auto;
    margin: 2px 0 0;
}

.table-title {
    display: grid;
    gap: 4px;
}

.table-title strong {
    color: var(--text);
}

.action-link {
    color: #fbbf24;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 10px;
    background: rgba(120, 53, 15, 0.4);
    font-size: 12px;
    margin: 2px 6px 2px 0;
}

.pill.state-runtime {
    background: rgba(21, 128, 61, 0.3);
    color: #bbf7d0;
}

.pill.state-disabled {
    background: rgba(107, 114, 128, 0.28);
    color: #e7e5e4;
}

.pill.state-draft {
    background: rgba(124, 58, 237, 0.24);
    color: #ddd6fe;
}

.helper-line,
.section-copy {
    font-size: 14px;
}

.route-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    align-items: center;
}

.route-actions > * {
    white-space: nowrap;
}

.preview-line {
    gap: 10px;
}

.hidden {
    display: none !important;
}

.details-box {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-height: 180px;
}

.subnav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.settings-panel {
    display: grid;
    gap: 18px;
}

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

.action-card {
    display: grid;
    gap: 12px;
}

.action-card strong,
.security-note strong {
    color: var(--text);
}

.import-note {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.help-trigger {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.08);
    color: #fde68a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-weight: 700;
    line-height: 1;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    overflow-y: auto;
    padding: 24px 16px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(12, 10, 9, 0.72);
    backdrop-filter: blur(6px);
}

.modal-dialog {
    position: relative;
    width: min(640px, calc(100vw - 32px));
    margin: 0 auto;
    background: var(--panel-strong);
    border: 1px solid rgba(245, 158, 11, 0.22);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.modal-dialog h3 {
    margin-top: 0;
    font-size: clamp(24px, 2.4vw, 30px);
}

.modal-dialog p + p {
    margin-top: 12px;
}

.modal-dialog code {
    color: #fde68a;
}

.modal-close {
    position: sticky;
    top: 0;
    right: 14px;
    margin-left: auto;
    display: block;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(214, 211, 209, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
}

@media (max-width: 1100px) {
    .grid-form.two-col {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(245, 158, 11, 0.15);
    }

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

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

    .route-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .content,
    .sidebar {
        padding: 18px;
    }

    .panel {
        padding: 18px;
        border-radius: 20px;
    }

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

    .modal-dialog {
        padding: 20px;
        max-height: calc(100vh - 32px);
    }

    .flash {
        top: 12px;
        width: calc(100vw - 20px);
    }
}
