:root {
    --bg: #0b1221;
    --panel: #0f1a2f;
    --panel-strong: #0c1627;
    --border: #1f2c45;
    --muted: #94a3b8;
    --text: #e8eef9;
    --accent: #5eead4;
    --accent-strong: #38bdf8;
    --accent-2: #f59e0b;
    --danger: #f97070;
    --success: #34d399;
    --shadow: 0 14px 50px rgba(0, 0, 0, 0.35);
    --font-sans: "IBM Plex Sans", "Trebuchet MS", "Segoe UI", sans-serif;
    --font-display: "Sora", "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background:
        repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.05) 0, rgba(148, 163, 184, 0.05) 1px, transparent 1px, transparent 120px),
        repeating-linear-gradient(0deg, rgba(148, 163, 184, 0.04) 0, rgba(148, 163, 184, 0.04) 1px, transparent 1px, transparent 120px),
        radial-gradient(120% 120% at 20% 20%, rgba(94, 234, 212, 0.12), transparent 40%),
        radial-gradient(110% 110% at 80% 0%, rgba(56, 189, 248, 0.12), transparent 40%),
        linear-gradient(135deg, #0b1221 0%, #0f172a 50%, #0c1221 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
}

.background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(60% 60% at 15% 20%, rgba(56, 189, 248, 0.22), transparent 60%),
        radial-gradient(60% 60% at 85% 12%, rgba(94, 234, 212, 0.18), transparent 55%),
        radial-gradient(70% 70% at 70% 85%, rgba(245, 158, 11, 0.12), transparent 60%);
    opacity: 0.6;
    filter: blur(90px);
    z-index: 0;
}

.page {
    position: relative;
    width: min(1100px, calc(100% - 32px));
    margin: 32px auto 64px;
    z-index: 1;
}

.page.layout {
    width: min(1320px, calc(100% - 32px));
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.content {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    padding: 18px 16px;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.95), rgba(8, 14, 26, 0.95));
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.sidebar .brand {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar .brand h2 {
    margin: 4px 0 6px;
    font-size: 20px;
    font-family: var(--font-display);
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-group:not(:last-child) {
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.12);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 20px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-item::before {
    content: "";
    position: absolute;
    left: 8px;
    width: 3px;
    height: 60%;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-item:hover {
    border-color: rgba(94, 234, 212, 0.35);
    color: var(--accent);
    transform: translateX(2px);
}

.nav-item.active {
    background: rgba(94, 234, 212, 0.12);
    color: #bbf7d0;
    border-color: rgba(94, 234, 212, 0.35);
}

.nav-item.active::before,
.nav-item:hover::before {
    opacity: 1;
    transform: translateX(0);
}

.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-left: 12px;
}

.nav-subitem {
    padding: 8px 10px;
    padding-left: 24px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    position: relative;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.nav-subitem::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
    transform: translateY(-50%);
}

.nav-subitem:hover {
    border-color: rgba(94, 234, 212, 0.25);
    color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.nav-subitem.active {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
    color: var(--text);
}

.nav-subitem.active::before {
    background: var(--accent);
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(130deg, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.8));
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

h1 {
    margin: 4px 0 8px;
    font-size: 34px;
    letter-spacing: -0.02em;
    font-family: var(--font-display);
    font-weight: 600;
}

h2 {
    margin: 6px 0;
    font-size: 22px;
    font-family: var(--font-display);
    font-weight: 600;
}

h3 {
    margin: 4px 0 0;
    font-size: 26px;
    font-family: var(--font-display);
    font-weight: 600;
}

.lede {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    font-size: 12px;
    color: var(--accent);
    margin: 0 0 4px;
    font-family: var(--font-display);
}

.panel {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)) var(--panel);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 14px;
    padding: 20px 20px 18px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    backdrop-filter: blur(6px);
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120% 120% at 0% 0%, rgba(56, 189, 248, 0.12), transparent 40%);
    opacity: 0.7;
    pointer-events: none;
}

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

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.tabs {
    display: inline-flex;
    gap: 8px;
    margin: 0 0 16px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.tab {
    padding: 10px 14px;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    border: none;
    font-weight: 700;
}

.tab.active {
    background: rgba(94, 234, 212, 0.12);
    color: #bbf7d0;
    border: 1px solid rgba(94, 234, 212, 0.3);
}

.view.is-hidden {
    display: none;
}

.subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    margin-top: 6px;
}

.subtab {
    padding: 8px 12px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid transparent;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.subtab:hover {
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-strong);
}

.subtab.active {
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
    border-color: rgba(56, 189, 248, 0.45);
}

.app-pane.is-hidden {
    display: none;
}

.key-form label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-weight: 600;
}

.key-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

input[type="password"],
input[type="text"],
textarea,
select {
    width: 100%;
    padding: 12px;
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    outline: none;
    font-size: 15px;
}

input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15);
}

button {
    border: none;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}

.primary-btn {
    padding: 12px 18px;
    background: linear-gradient(90deg, #38bdf8, #0ea5e9);
    color: #0b1221;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(56, 189, 248, 0.35);
}

.primary-btn:hover {
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(0);
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
}

.ghost-btn:hover {
    border-color: rgba(56, 189, 248, 0.45);
    color: var(--accent-strong);
    background: rgba(56, 189, 248, 0.08);
}

.ghost-btn:disabled,
.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--accent);
}

.banner {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.banner-info {
    background: rgba(94, 234, 212, 0.08);
    border-color: rgba(94, 234, 212, 0.35);
    color: var(--text);
}

.banner-success {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.4);
    color: var(--text);
}

.banner-error {
    background: rgba(249, 112, 112, 0.1);
    border-color: rgba(249, 112, 112, 0.3);
    color: #fecdd3;
}

.is-hidden {
    display: none;
}

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

.stat-card {
    background: linear-gradient(160deg, rgba(56, 189, 248, 0.12), rgba(255, 255, 255, 0.02)) var(--panel-strong);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.label {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 6px;
}

.small {
    font-size: 13px;
}

.strong {
    font-weight: 700;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    font-weight: 700;
    font-size: 13px;
}

.pill-muted {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

.pill-positive {
    background: rgba(52, 211, 153, 0.12);
    color: #bbf7d0;
    border-color: rgba(52, 211, 153, 0.4);
}

.pill-negative {
    background: rgba(249, 112, 112, 0.08);
    color: #fecdd3;
    border-color: rgba(249, 112, 112, 0.35);
}

.pill-info {
    background: rgba(14, 165, 233, 0.12);
    color: #bae6fd;
    border-color: rgba(14, 165, 233, 0.4);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.16);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel-strong);
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.clickable {
    cursor: pointer;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin: 14px 0 10px;
}

.filter label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
}

.filter select,
.filter input[type="text"],
.filter input[type="datetime-local"] {
    width: 100%;
}

.muted {
    color: var(--muted);
}

.center {
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 16px;
    color: var(--muted);
}

.table-panel {
    padding-bottom: 10px;
}

.panel-head .pill {
    white-space: nowrap;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.info-row {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.info-row .label {
    margin-bottom: 4px;
}

.table-btn {
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.2);
    font-weight: 600;
}

.table-btn:hover {
    border-color: rgba(56, 189, 248, 0.5);
    color: var(--accent-strong);
    background: rgba(56, 189, 248, 0.08);
}

.table-actions {
    display: inline-flex;
    gap: 6px;
}

.row-failed {
    background: rgba(239, 68, 68, 0.08);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.4);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
}

.badge-negative {
    background: rgba(249, 112, 112, 0.12);
    border-color: rgba(249, 112, 112, 0.35);
}

.status-pill {
    border-color: transparent;
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.status-processing,
.status-running {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
}

.status-done {
    background: rgba(52, 211, 153, 0.15);
    color: #bbf7d0;
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: #fecdd3;
}

.status-cancelled {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
}

.status-info {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
}

.status-warn {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #fecdd3;
}

.status-config {
    background: rgba(59, 130, 246, 0.12);
    color: #cbd5e1;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.code-block {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.code-head {
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
}

.code-pre {
    margin: 0;
    padding: 12px;
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.code-textarea {
    width: 100%;
    resize: vertical;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0 0 12px 12px;
    border: none;
}

.has-error {
    border-color: rgba(239, 68, 68, 0.5);
}

.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.scope-list { margin-top: 8px; }
.scope-group { margin-bottom: 16px; }
.scope-group h4 { margin: 6px 0; }
.scope-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    border: 1px solid #1f2937;
    border-radius: 6px;
    background: #0c1425;
    margin-bottom: 6px;
}
.scope-item input { margin-top: 2px; }
.scope-name { font-weight: 600; }
.scope-desc { display: block; }

.scope-panel {
    margin: 12px 0 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.scope-panel .filters { margin-top: 0; }

.page.layout {
    animation: pageIn 0.6s ease both;
}

.view:not(.is-hidden) .panel {
    animation: rise 0.45s ease both;
}

.view:not(.is-hidden) .panel:nth-of-type(2) { animation-delay: 0.05s; }
.view:not(.is-hidden) .panel:nth-of-type(3) { animation-delay: 0.1s; }
.view:not(.is-hidden) .panel:nth-of-type(4) { animation-delay: 0.15s; }

.stats-grid .stat-card {
    animation: rise 0.5s ease both;
}

.stats-grid .stat-card:nth-child(2) { animation-delay: 0.04s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.08s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.12s; }

@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

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

    .sidebar {
        position: static;
    }

    .nav-sub {
        margin-left: 0;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-subitem {
        padding: 6px 10px;
    }
}

@media (max-width: 720px) {
    .key-row {
        grid-template-columns: 1fr;
    }

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

    .tabs {
        width: 100%;
        justify-content: space-between;
    }

    th:nth-child(3),
    td:nth-child(3) {
        min-width: 140px;
    }

    .pagination {
        justify-content: center;
    }
}
