:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1d2733;
    --muted: #617083;
    --line: #dce3ea;
    --brand: #176b87;
    --brand-dark: #0f4f65;
    --accent: #f2b84b;
    --bad: #b42318;
    --good: #067647;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--brand);
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 2;
}

.brand {
    color: var(--ink);
    font-weight: 700;
}

.env {
    background: #eef5f7;
    border-radius: 999px;
    color: var(--brand-dark);
    display: inline-block;
    font-size: 12px;
    margin-left: 10px;
    padding: 3px 8px;
}

nav {
    display: flex;
    gap: 16px;
}

.container {
    margin: 0 auto;
    max-width: 1240px;
    padding: 28px 24px 56px;
}

.hero,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.hero {
    align-items: flex-end;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 28px;
}

h1,
h2 {
    letter-spacing: 0;
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
    max-width: 780px;
}

h2 {
    font-size: 18px;
    margin-bottom: 14px;
}

.eyebrow {
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.lede {
    color: var(--muted);
    margin: 12px 0 0;
    max-width: 760px;
}

.actions,
.form-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.button,
button {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    min-height: 38px;
    padding: 8px 14px;
}

.button.primary,
button[type="submit"] {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

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

.panel {
    padding: 22px;
}

.facts {
    display: grid;
    gap: 10px;
    margin: 0 0 16px;
}

.facts div {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: 150px minmax(0, 1fr);
    padding-bottom: 9px;
}

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

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.endpoint-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

code {
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 7px;
}

.split {
    align-items: start;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
}

label {
    color: var(--ink);
    display: grid;
    font-weight: 700;
    gap: 7px;
    margin-top: 16px;
}

label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    padding: 10px;
    width: 100%;
}

textarea {
    font-family: Consolas, Monaco, monospace;
    resize: vertical;
}

pre {
    background: #111827;
    border-radius: 8px;
    color: #d1d5db;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    max-height: 420px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.pill {
    border-radius: 999px;
    color: #ffffff;
    font-weight: 700;
    padding: 5px 10px;
}

.pill.ok {
    background: var(--good);
}

.pill.bad {
    background: var(--bad);
}

.notice {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 8px;
    color: #085d3a;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.notice.warning {
    background: #fffaeb;
    border-color: #fedf89;
    color: #93370d;
}

.notice.error,
.error-box {
    background: #fef3f2;
    border-color: #fecdca;
    color: var(--bad);
}

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

.history {
    display: grid;
    gap: 14px;
}

.history-item,
.catalog-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.history-item header,
.catalog-item header {
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.history-item span {
    color: var(--muted);
}

.catalog-list {
    display: grid;
    gap: 14px;
}

.method {
    border-radius: 5px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    min-width: 54px;
    padding: 4px 7px;
    text-align: center;
}

.method.get {
    background: #176b87;
}

.method.post {
    background: #067647;
}

.method.put,
.method.patch {
    background: #9a6700;
}

.method.delete {
    background: #b42318;
}

.mini-table {
    border-collapse: collapse;
    margin-top: 12px;
    width: 100%;
}

.mini-table th,
.mini-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.mini-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.operation-meta {
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-top: 10px;
    min-height: 38px;
    padding: 9px 10px;
}

.generated-fields {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.field-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.generated-field {
    margin-top: 0;
}

.generated-field strong {
    color: var(--bad);
}

.response-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 14px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

body.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    align-items: center;
    background: rgba(17, 24, 39, 0.62);
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.32);
    max-height: calc(100vh - 48px);
    max-width: 1180px;
    overflow: hidden;
    padding: 20px;
    width: min(1180px, 100%);
}

.modal-head {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: -2px 0 14px;
    padding-bottom: 14px;
}

.modal-head h1 {
    font-size: 22px;
}

.table-view {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 12px;
    max-height: calc(100vh - 190px);
    overflow: auto;
}

.data-table {
    border-collapse: collapse;
    font-size: 13px;
    min-width: 100%;
    width: max-content;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    max-width: 360px;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
}

.data-table thead th {
    background: #f7f9fb;
    color: var(--ink);
    position: sticky;
    top: 0;
    z-index: 1;
}

.key-value-table {
    width: 100%;
}

.key-value-table th {
    width: 240px;
}

.snapshot-hero {
    align-items: flex-start;
}

.snapshot-builder {
    display: grid;
    gap: 18px;
}

.snapshot-form {
    align-items: end;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(220px, 1fr) 220px auto;
}

.snapshot-form label {
    margin-top: 0;
}

.selected-snapshot {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.lookup-row {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 1fr) auto;
    margin-bottom: 12px;
}

.lookup-results {
    margin-top: 12px;
    max-height: calc(100vh - 245px);
    overflow: auto;
}

.snapshot-insights {
    margin-top: 18px;
}

.snapshot-sales {
    margin-top: 18px;
}

.snapshot-card-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
}

.snapshot-card {
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    padding: 16px;
}

.snapshot-card span,
.snapshot-card small {
    color: var(--muted);
}

.snapshot-card strong {
    color: var(--ink);
    font-size: 26px;
    font-weight: 400;
}

.snapshot-chart {
    border-top: 1px solid var(--line);
    margin-top: 20px;
    padding-top: 18px;
}

.bar-chart {
    align-items: end;
    display: flex;
    gap: 14px;
    min-height: 230px;
    overflow-x: auto;
    padding: 12px 4px 0;
}

.bar-item {
    align-items: center;
    display: grid;
    gap: 7px;
    justify-items: center;
    min-width: 92px;
}

.bar {
    background: #ffe100;
    border: 1px solid #d0b500;
    min-height: 6px;
    width: 34px;
}

.bar-value,
.bar-label {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.sales-table-wrap {
    margin-top: 18px;
    overflow-x: auto;
}

.sales-table {
    min-width: 1080px;
}

.sales-table td {
    min-width: 150px;
}

.sales-table td:first-child {
    min-width: 230px;
}

.sales-table strong,
.sales-table span {
    display: block;
}

.sales-table strong {
    color: var(--ink);
    font-weight: 700;
}

.sales-table span {
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

@media (max-width: 860px) {
    .topbar,
    .hero,
    .actions,
    .form-head,
    .history-item header,
    .modal-head {
        align-items: stretch;
        flex-direction: column;
    }

    .grid,
    .split,
    .field-grid,
    .snapshot-card-grid,
    .snapshot-form,
    .lookup-row {
        grid-template-columns: 1fr;
    }

    nav {
        flex-wrap: wrap;
    }

    h1 {
        font-size: 24px;
    }
}
