:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #eef2f7;
    --border: #d9e0e8;
    --text: #16202f;
    --muted: #667085;
    --primary: #1769aa;
    --primary-dark: #124d7d;
    --success: #16845b;
    --success-bg: #e8f7ef;
    --danger: #c43d3d;
    --danger-bg: #fdecec;
    --accent: #9a6b1f;
    --accent-bg: #fff4df;
    --shadow: 0 18px 45px rgba(18, 32, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

button,
input,
select {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px clamp(16px, 3vw, 34px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

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

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

.topnav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topnav a {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
}

.topnav a:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: clamp(18px, 3vw, 34px);
}

.intro,
.detail-header {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.intro {
    padding: clamp(24px, 4vw, 38px);
    background: #172033;
    color: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.intro h1,
.detail-header h1,
.empty-state h1 {
    margin: 8px 0 12px;
    max-width: 780px;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1;
    letter-spacing: 0;
}

.intro p,
.detail-header p,
.empty-state p {
    margin: 0;
    max-width: 760px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1.02rem;
    line-height: 1.65;
}

.detail-header p,
.empty-state p {
    color: var(--muted);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    color: #617188;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.intro .eyebrow {
    color: #9dc2e2;
}

.intro-panel {
    align-self: stretch;
    display: grid;
    min-width: 220px;
    gap: 8px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.intro-panel span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    color: #e7edf5;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card,
.panel,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    min-height: 134px;
    padding: 18px;
    border-top: 4px solid var(--primary);
}

.metric-card.success {
    border-top-color: var(--success);
}

.metric-card.danger {
    border-top-color: var(--danger);
}

.metric-card.accent {
    border-top-color: var(--accent);
}

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin: 12px 0 4px;
    font-size: clamp(1.7rem, 3vw, 2.5rem);
    line-height: 1;
}

.metric-card .metric-date {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 1.2;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    margin-bottom: 18px;
}

.bottom-grid,
.detail-grid {
    grid-template-columns: minmax(0, 1fr) 440px;
}

.panel {
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 4px 0 0;
    font-size: 1.1rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

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

.data-table strong,
.muted {
    display: block;
}

.muted {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.84rem;
}

.endpoint {
    max-width: 320px;
    overflow-wrap: anywhere;
    color: #445064;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
}

.flow-arrow {
    display: inline-block;
    margin: 0 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-success,
.badge-active {
    color: var(--success);
    background: var(--success-bg);
}

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

.badge-muted {
    color: #586274;
    background: #edf1f5;
}

.table-actions {
    white-space: nowrap;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.icon-button:hover:not(:disabled) {
    transform: translateY(-1px);
}

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

.icon-button.primary {
    background: var(--primary);
    color: #fff;
}

.icon-button.primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.icon-button.secondary {
    background: #fff;
    color: var(--primary);
    border-color: var(--border);
}

.wide {
    width: 100%;
}

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

.stacked-form label,
.filter-control {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(23, 105, 170, 0.14);
}

.filter-control {
    grid-template-columns: auto 160px;
    align-items: center;
}

.json-panel pre {
    min-height: 420px;
    max-height: 620px;
    margin: 0;
    padding: 18px;
    overflow: auto;
    background: #111827;
    color: #e5edf7;
    border-radius: 0 0 8px 8px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.86rem;
    line-height: 1.62;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.detail-header {
    align-items: center;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.detail-header h1 {
    font-size: clamp(1.8rem, 3vw, 3rem);
}

.back-link {
    display: inline-flex;
    margin-bottom: 16px;
    color: var(--primary);
    font-weight: 800;
}

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

.definition-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0 18px 18px;
}

.definition-list div {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.definition-list div:last-child {
    border-bottom: 0;
}

.definition-list dt {
    color: var(--muted);
    font-weight: 800;
}

.definition-list dd {
    margin: 0;
    min-width: 0;
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: clamp(28px, 5vw, 60px);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 40;
    display: none;
    max-width: min(420px, calc(100vw - 40px));
    padding: 14px 16px;
    border-radius: 8px;
    background: #172033;
    color: #fff;
    box-shadow: var(--shadow);
    font-weight: 700;
}

.toast.is-visible {
    display: block;
}

.toast.is-error {
    background: var(--danger);
}

@media (max-width: 1180px) {
    .metrics-grid,
    .detail-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-column,
    .bottom-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .topbar,
    .intro,
    .detail-header,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .topnav {
        width: 100%;
        overflow-x: auto;
    }

    .metrics-grid,
    .detail-metrics,
    .form-row {
        grid-template-columns: 1fr;
    }

    .intro-panel {
        width: 100%;
    }

    .filter-control {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .definition-list div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .shell {
        padding-inline: 12px;
    }
}
