/* Threecom Payment Service — admin UI + merchant portal */
:root {
    --surface: #fcfcfb;
    --panel: #ffffff;
    --ink: #0b0b0b;
    --ink2: #52514e;
    --muted: #898781;
    --line: #e1e0d9;
    --line-soft: #efeee9;
    --brand: #2c3488;
    --brand-soft: #eef0fa;
    --series: #2a78d6;
    --good: #0ca30c;
    --warn: #fab219;
    --serious: #ec835a;
    --crit: #d03b3b;
    --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; }
p { margin: 0 0 10px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink2); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; color: var(--ink); }
.side .logo img { height: 34px; width: auto; }
.side .logo span { font-weight: 650; line-height: 1.15; font-size: 13.5px; }
.side .logo:hover { text-decoration: none; }
.side .group { margin: 14px 8px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px; color: var(--ink2); font-weight: 500;
}
.side nav a:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.side nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.side nav a .count {
    margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; text-align: center;
    background: var(--warn); color: var(--ink); font-size: 12px; font-weight: 650;
}
.side .who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.side .who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .who .links { display: flex; gap: 12px; margin-top: 8px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.envtag { display: inline-block; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); font-size: 11px; font-weight: 650; color: var(--ink2); letter-spacing: .04em; }

.main { padding: 26px 32px 60px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.head .sub { color: var(--ink2); margin-top: 3px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .side .logo { padding: 0 8px 0 0; }
    .side .logo span, .side .group { display: none; }
    .side nav { display: flex; flex-wrap: wrap; gap: 2px; }
    .side .who { margin: 0 0 0 auto; border: 0; padding: 0; }
    .side .who b, .side .who .role { display: none; }
    .side .who .links { margin: 0; }
    .main { padding: 18px 14px 50px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 20px 0; }
.card .cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card .cardhead h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: block; color: inherit; }
a.tile:hover { text-decoration: none; border-color: #c9c8c0; }
.tile .label { color: var(--ink2); font-size: 12.5px; font-weight: 500; }
.tile .value { font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 14px; font-weight: 500; color: var(--ink2); letter-spacing: 0; margin-right: 3px; }
.tile .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.tile.attn { border-color: var(--warn); }
.tile.attn .note { color: var(--ink2); }
.tile.attn .icon { color: #b97900; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series); }
.chart .hit { fill: transparent; }
.chart .col:hover .bar, .chart .col.on .bar { fill: #1f5fae; }
.chart .col:hover .hit, .chart .col.on .hit { fill: rgba(11, 11, 11, .04); }
.tip {
    position: absolute; pointer-events: none; z-index: 5; display: none;
    background: var(--ink); color: #fff; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; line-height: 1.35; white-space: nowrap;
    transform: translate(-50%, -100%);
}
.tip b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
details.tableview { margin-top: 10px; }
details.tableview summary { cursor: pointer; color: var(--ink2); font-size: 12.5px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 650; color: var(--ink2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data th:first-child, table.data td:first-child { padding-left: 20px; }
table.data th:last-child, table.data td:last-child { padding-right: 20px; }
table.data tbody tr:hover { background: #fafaf7; }
table.data th.right, table.data td.right { text-align: right; }
table.data td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--ink2); font-size: 12.5px; }

/* ---------- status badges: icon + label, never colour alone ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 12px; font-size: 12.5px; font-weight: 550; color: var(--ink); background: var(--line-soft); white-space: nowrap; }
.badge .icon { width: 14px; height: 14px; vertical-align: 0; }
.badge.good { background: #e6f5e6; } .badge.good .icon { color: var(--good); }
.badge.warn { background: #fef2d2; } .badge.warn .icon { color: #b97900; }
.badge.crit { background: #f9e4e4; } .badge.crit .icon { color: var(--crit); }
.badge.wait { background: #e6eff9; } .badge.wait .icon { color: var(--series); }
.badge.info { background: #f8e9e2; } .badge.info .icon { color: #c15a2f; }
.badge.mute .icon { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--good); }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #cfcec6; border-radius: 8px; background: #fff; color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9fb6e8; outline-offset: 0; border-color: var(--brand); }
input[readonly] { background: var(--line-soft); color: var(--ink2); }
.field { margin-bottom: 14px; min-width: 0; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 14px; margin-bottom: 14px; }
.check input { width: 16px; height: 16px; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters .field.grow { flex: 1 1 200px; }
.filters input, .filters select { min-width: 130px; }
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfcec6;
    background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line-soft); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #232a70; }
.btn.danger { color: #a52727; border-color: #e3b5b5; }
.btn.danger:hover { background: #fbeeee; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }
.section-note { color: var(--ink2); margin: -4px 0 14px; max-width: 78ch; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- messages ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.flash .icon { margin-top: 2px; }
.flash.ok { border-color: #a9dba9; background: #f1faf1; } .flash.ok .icon { color: var(--good); }
.flash.err { border-color: #e3b5b5; background: #fdf3f3; } .flash.err .icon { color: var(--crit); }
.flash.note { border-color: #f1d58a; background: #fffaeb; } .flash.note .icon { color: #b97900; }
.secretbox { border: 1px dashed #b97900; background: #fffaeb; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.secretbox code { display: block; margin: 4px 0 8px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 6px; word-break: break-all; font-size: 13px; }

/* ---------- detail page ---------- */
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 7px 14px; margin: 0; }
dl.kv dt { color: var(--ink2); }
dl.kv dd { margin: 0; word-break: break-word; }
.amount-hero { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.amount-hero small { font-size: 16px; font-weight: 500; color: var(--ink2); margin-right: 4px; letter-spacing: 0; }
ol.timeline { list-style: none; margin: 0; padding: 0; }
ol.timeline li { position: relative; padding: 0 0 14px 22px; }
ol.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--series); }
ol.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
ol.timeline li:last-child::after { display: none; }
ol.timeline .t { color: var(--muted); font-size: 12.5px; }
.wire { border-top: 1px solid var(--line-soft); padding: 10px 0; }
.wire:first-child { border-top: 0; padding-top: 0; }
.wire pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-all; font: 12px/1.45 Consolas, "Cascadia Mono", Menlo, monospace; color: var(--ink2); }

/* ---------- login ---------- */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .logo { text-align: center; margin-bottom: 18px; }
.login .logo img { height: 64px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login .sub { text-align: center; color: var(--ink2); margin-bottom: 18px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; }

/* ---------- test payment ---------- */
.qrbox { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.qrbox img { width: 240px; height: 240px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; }
