:root {
    color-scheme: dark;
    --bg: #07111f;
    --panel: #0d1b2d;
    --panel-soft: #12233a;
    --panel-raised: #172a43;
    --border: #243b59;
    --text: #f4f7fb;
    --muted: #9bb0c8;
    --accent: #57d0a1;
    --accent-dark: #153f36;
    --blue: #62a8ff;
    --danger: #ff7a85;
    --warning: #ffc867;
    --sidebar: 232px;
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

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

input[type="checkbox"] {
    width: auto;
}

a {
    color: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    border-right: 1px solid var(--border);
    background: #091524;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--accent), #59a9ff);
    color: #07111f;
    font-weight: 900;
    letter-spacing: -0.06em;
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    font-size: 20px;
}

.primary-nav {
    display: grid;
    gap: 6px;
    margin-top: 36px;
}

.primary-nav a {
    padding: 11px 13px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 650;
    text-decoration: none;
}

.primary-nav a:hover,
.primary-nav a.active {
    background: var(--panel-raised);
    color: var(--text);
}

.primary-nav a.active {
    box-shadow: inset 3px 0 var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 13px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--warning);
}

.main-column {
    grid-column: 2;
    min-width: 0;
}

.topbar {
    display: flex;
    min-height: 96px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: rgb(7 17 31 / 88%);
    backdrop-filter: blur(16px);
}

.topbar h1,
.content h2,
.content h3 {
    margin: 0;
}

.topbar h1 {
    margin-top: 4px;
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: -0.04em;
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    align-items: end;
    gap: 18px;
}

.workspace-switcher label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}

.workspace-switcher select {
    min-width: 190px;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: #091524;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgb(98 168 255 / 16%);
}

label {
    display: block;
    margin: 16px 0 7px;
    color: #d6e1ed;
    font-size: 14px;
    font-weight: 700;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 3px;
}

.user-menu form {
    margin: 0;
}

.text-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--blue);
    cursor: pointer;
}

.content {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 30px 32px 60px;
}

.metric-grid,
.module-grid,
.two-column {
    display: grid;
    gap: 18px;
}

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

.module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 24px;
}

.spaced-grid {
    margin-top: 18px;
}

.two-column {
    grid-template-columns: 1.4fr 1fr;
}

.metric,
.panel,
.module-card,
.empty-state {
    border: 1px solid var(--border);
    border-radius: 14px;
    background:
        linear-gradient(160deg, rgb(255 255 255 / 3%), transparent 45%),
        var(--panel);
    box-shadow: 0 16px 42px rgb(0 0 0 / 14%);
}

.metric {
    padding: 20px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 12px;
    font-size: 27px;
    letter-spacing: -0.04em;
}

.metric small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.panel,
.module-card,
.empty-state {
    padding: 24px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin: 34px 0 16px;
}

.section-heading > div {
    min-width: 0;
    flex: 1 1 520px;
}

.section-heading.compact {
    margin-top: 0;
}

.section-heading p,
.module-card p,
.empty-state p,
.muted {
    color: var(--muted);
}

.module-card {
    min-height: 190px;
}

.module-card .tag {
    display: inline-block;
    margin-bottom: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--accent-dark);
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.module-card h3 {
    margin-bottom: 8px;
}

.module-card a {
    display: inline-block;
    margin-top: 10px;
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #061a16;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary {
    border: 1px solid var(--border);
    background: var(--panel-raised);
    color: var(--text);
}

.button.danger {
    background: #57222a;
    color: #ffd7dc;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.full-width {
    width: 100%;
}

.empty-state {
    display: grid;
    min-height: 360px;
    place-items: center;
    align-content: center;
    text-align: center;
}

.empty-state h2 {
    margin-top: 12px;
    font-size: 30px;
}

.empty-state p {
    max-width: 650px;
    line-height: 1.65;
}

.alert {
    margin: 18px 0;
    padding: 12px 14px;
    border-radius: 8px;
}

.alert.error {
    border: 1px solid #76313a;
    background: #351820;
    color: #ffd1d6;
}

.alert.success {
    border: 1px solid #245d4c;
    background: #102f28;
    color: #baf7df;
}

.provider-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.provider-badge.connected {
    border-color: #286551;
    background: #102f28;
    color: #a9f2d6;
}

.provider-badge.demo {
    border-color: #67532a;
    background: #332a17;
    color: #ffe0a1;
}

.chain-filter-form {
    margin-top: 22px;
}

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

.filter-grid.primary {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.filter-grid label {
    margin-top: 0;
}

.advanced-filters {
    margin-top: 20px;
    border-top: 1px solid var(--border);
}

.advanced-filters summary {
    padding: 18px 0;
    color: var(--blue);
    font-weight: 750;
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 22px;
}

.chain-results {
    margin-top: 12px;
}

.chain-table-wrap {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
}

.chain-table {
    min-width: 1280px;
    font-variant-numeric: tabular-nums;
}

.chain-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel-raised);
}

.chain-table td {
    white-space: nowrap;
}

.chain-table td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.contract-symbol {
    color: #dcecff;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
}

.side-pill {
    display: inline-block;
    min-width: 44px;
    padding: 4px 7px;
    border-radius: 999px;
    text-align: center;
    font-size: 11px;
    font-weight: 850;
}

.side-pill.call {
    background: #113b31;
    color: #8be8c4;
}

.side-pill.put {
    background: #452129;
    color: #ffabb5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.order-draft-panel {
    margin-bottom: 22px;
}

.order-draft-panel > .section-heading {
    margin-top: 0;
}

.draft-empty {
    padding: 20px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: rgb(255 255 255 / 2%);
    color: var(--muted);
}

.draft-tabs {
    display: flex;
    gap: 9px;
    margin: 20px -4px 0;
    padding: 4px;
    overflow-x: auto;
}

.draft-tabs a {
    display: grid;
    min-width: 170px;
    gap: 4px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-soft);
    color: var(--text);
    text-decoration: none;
}

.draft-tabs a.active {
    border-color: var(--accent);
    background: var(--accent-dark);
}

.draft-tabs span {
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.draft-tabs small {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.draft-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-top: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--border);
}

.draft-summary div {
    padding: 15px;
    background: var(--panel-soft);
}

.draft-summary span,
.draft-summary strong {
    display: block;
}

.draft-summary span {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.draft-editor {
    margin-top: 18px;
}

.draft-name-field {
    width: min(480px, 100%);
    margin-bottom: 14px;
}

.draft-leg-table {
    min-width: 1160px;
    font-variant-numeric: tabular-nums;
}

.draft-leg-table select {
    min-width: 142px;
}

.draft-leg-table input[type="number"] {
    min-width: 92px;
}

.draft-leg-table td small,
.draft-leg-table .contract-symbol small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-family: inherit;
}

.archive-draft-form {
    margin-top: 14px;
}

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

.draft-create-bar {
    display: grid;
    grid-template-columns: minmax(210px, 0.8fr) minmax(240px, 1.4fr) auto;
    gap: 14px;
    align-items: end;
    margin: 18px 0 12px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-soft);
}

.draft-create-bar label {
    margin-top: 0;
}

.draft-create-bar .button {
    margin-bottom: 1px;
}

.contract-check {
    display: grid;
    width: 34px;
    height: 34px;
    margin: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
}

.contract-check:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-dark);
}

.contract-check input {
    accent-color: var(--accent);
}

.selectable-chain tbody tr:has(input:checked) {
    background: rgb(87 208 161 / 8%);
}

.data-disclaimer {
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.compact-empty {
    min-height: 220px;
}

.credential-layout {
    align-items: start;
}

.credential-empty {
    margin-top: 22px;
    padding: 28px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

.credential-list {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.credential-card {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
}

.credential-card h3 {
    margin: 12px 0 4px;
}

.credential-card code,
.credential-examples code {
    color: #cce3ff;
}

.credential-hint {
    margin: 14px 0 8px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    letter-spacing: 0.05em;
}

.credential-delete {
    width: min(240px, 100%);
}

.credential-delete label {
    margin-top: 0;
}

.credential-examples {
    display: grid;
    gap: 7px;
    margin-top: 24px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #091524;
    color: var(--muted);
    font-size: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

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

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

.login-body {
    display: grid;
    place-items: center;
    padding: 30px;
    background:
        radial-gradient(circle at 15% 20%, #18395c 0, transparent 38%),
        radial-gradient(circle at 85% 80%, #164737 0, transparent 34%),
        var(--bg);
}

.login-layout {
    display: grid;
    width: min(1100px, 100%);
    grid-template-columns: 1.2fr minmax(340px, 460px);
    gap: 80px;
    align-items: center;
}

.login-intro h1 {
    max-width: 680px;
    margin: 18px 0;
    font-size: clamp(40px, 5.5vw, 68px);
    letter-spacing: -0.055em;
    line-height: 0.98;
}

.login-intro > p:not(.eyebrow) {
    max-width: 600px;
    color: #c1cfdd;
    font-size: 18px;
    line-height: 1.65;
}

.login-points {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 32px;
}

.login-points span {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
}

.login-card {
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgb(13 27 45 / 94%);
    box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}

.login-card h2 {
    margin: 7px 0 0;
    font-size: 32px;
}

.login-footnote {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 1200px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: space-between;
    }

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

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

    .login-layout {
        gap: 34px;
    }

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

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

@media (max-width: 780px) {
    :root {
        --sidebar: 0px;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: auto;
        padding: 18px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .primary-nav {
        display: flex;
        margin-top: 18px;
        overflow-x: auto;
    }

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

    .sidebar-footer {
        display: none;
    }

    .topbar,
    .topbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        padding: 20px;
    }

    .content {
        padding: 22px 18px 50px;
    }

    .metric-grid,
    .module-grid,
    .two-column,
    .login-layout,
    .filter-grid.primary,
    .filter-grid,
    .draft-summary,
    .draft-create-bar {
        grid-template-columns: 1fr;
    }

    .login-intro {
        display: none;
    }
}

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

    .credential-card {
        align-items: stretch;
        flex-direction: column;
    }
}
