:root {
    --page: #f7f6f3;
    --card: #ffffff;
    --text: #0b0b0b;
    --text-2: #52514e;
    --muted: #898781;
    --line: #e7e5df;
    --grid: #efeee9;
    --axis: #c3c2b7;
    --chip: #f3f2ee;
    --brand: #eb6834;
    --brand-dark: #d4561f;
    --brand-soft: #fdeee7;
    --ok: #006300;
    --ok-soft: #e6f4e6;
    --err: #c62828;
    --err-soft: #fdecea;
    --warn: #b45309;
    --warn-soft: #fff4e0;
    /* chart series (validated: blue / orange / aqua, light surface) */
    --s-blue: #2a78d6;
    --s-orange: #eb6834;
    --s-aqua: #1baf7a;
    --s-neutral: #d9d7d0;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(11, 11, 11, .04);
    --code-bg: #111827;
    --code-text: #e5e7eb;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--page); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
.sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ---------- top navigation ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.logo .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.logo .area { font-weight: 500; color: var(--muted); font-size: 13px; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--text-2); padding: 7px 12px; border-radius: 999px; font-weight: 500; }
.topbar nav a:hover { background: var(--chip); text-decoration: none; }
.topbar nav a.active { background: var(--text); color: #fff; }
.topbar .user { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

/* ---------- layout ---------- */
.container { max-width: 1240px; margin: 24px auto 48px; padding: 0 16px; }
.narrow { max-width: 440px; margin: 56px auto; padding: 0 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.row { display: grid; gap: 16px; margin-bottom: 16px; }
.row > .card { margin-bottom: 0; }
.row.kpis { grid-template-columns: repeat(4, 1fr); }
.row.main { grid-template-columns: 2fr 1fr; }
.row.bottom { grid-template-columns: 1fr 1.6fr; }
.row.half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .row.kpis { grid-template-columns: repeat(2, 1fr); } .row.main, .row.bottom, .row.half { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .row.kpis { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpi { padding: 18px 20px; }
.kpi .top { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: 13px; }
.icon-chip { width: 32px; height: 32px; border-radius: 10px; background: var(--chip); display: grid; place-items: center; color: var(--text-2); flex: none; }
.icon-chip svg { width: 16px; height: 16px; }
.kpi .value { font-size: 28px; font-weight: 700; margin: 14px 0 6px; letter-spacing: -.01em; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }
.delta.flat { color: var(--muted); }
.delta .vs { color: var(--muted); font-weight: 400; }
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-soft); color: var(--ok); }
.pill.down { background: var(--err-soft); color: var(--err); }
.pill.flat { background: var(--chip); color: var(--muted); }
.hero { font-size: 30px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart [data-tip] { cursor: default; }
.chart .bar:hover, .chart .seg:hover { opacity: .85; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.18); display: none; }
.tooltip b { font-weight: 600; }
details.table-view { margin-top: 12px; font-size: 12px; }
details.table-view summary { color: var(--muted); cursor: pointer; }
details.table-view table { margin-top: 8px; }
.donut-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: center; }
@media (max-width: 600px) { .donut-wrap { grid-template-columns: 1fr; } }
.stat-stack > div { margin-bottom: 14px; }
.stat-stack .label { color: var(--text-2); font-size: 12px; }
.stat-stack .big { font-size: 22px; font-weight: 700; }
.stat-stack .note { color: var(--muted); font-size: 12px; }

/* ---------- lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { color: var(--muted); font-size: 12px; }
.list-item .amt { font-weight: 700; white-space: nowrap; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num, .right { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table.kv td:first-child { color: var(--text-2); width: 42%; }
table.kv td:last-child { font-weight: 600; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 5px; color: var(--text-2); }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters > * { width: auto; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--brand); color: #fff; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn.outline { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.outline:hover { background: var(--chip); }
.btn.dark { background: var(--text); }
.btn.danger { background: var(--err); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { display: flex; justify-content: center; width: 100%; padding: 12px; font-size: 15px; margin-top: 18px; }
.seg-control { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-control a { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg-control a:hover { text-decoration: none; background: var(--chip); }
.seg-control a.on { background: var(--text); color: #fff; }
form.inline { display: inline; }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--chip); color: var(--text-2); white-space: nowrap; }
.badge.SUCCESS, .badge.delivered, .badge.active, .badge.production { background: var(--ok-soft); color: var(--ok); }
.badge.FAILED, .badge.failed, .badge.disabled { background: var(--err-soft); color: var(--err); }
.badge.REVIEW, .badge.testing { background: var(--warn-soft); color: var(--warn); }
.badge.PROCESSING { background: #e8f1fc; color: #1c5cab; }
.alert { padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

pre { background: var(--code-bg); color: var(--code-text); padding: 14px; border-radius: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; background: var(--chip); padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; color: inherit; }
.pager { display: flex; gap: 8px; margin-top: 14px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; display: inline-block; vertical-align: middle; animation: spin 1s linear infinite; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: 210px 1fr; gap: 24px; }
.docs aside { position: sticky; top: 76px; align-self: start; font-size: 13px; }
.docs aside a { display: block; padding: 4px 0; color: var(--text-2); }
.docs h2 { font-size: 18px; margin: 0 0 12px; }
.method { display: inline-block; font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 6px; color: #fff; margin-right: 6px; vertical-align: middle; }
.method.post { background: #1baf7a; }
.method.get { background: #2a78d6; }
@media (max-width: 800px) { .docs { grid-template-columns: 1fr; } .docs aside { position: static; } }
