/* BGS App Scanner: blue band header with orange glow, white cards overlapping it.
   Chart series colours were run through the dataviz palette validator for both modes. */
:root {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --border: #e2e9f1;
  --text: #0f2133;
  --muted: #5f6f82;

  --blue: #0284c7;
  --blue-strong: #0369a1;
  --blue-deep: #0c4a6e;
  --blue-soft: #e6f4fd;
  --orange: #ea580c;
  --orange-bright: #f97316;
  --orange-text: #c2410c;
  --orange-soft: #fff1e7;

  --ok: #16a34a;     --ok-text: #15803d;   --ok-soft: #e7f7ed;
  --warn: #d4a106;   --warn-text: #a16207; --warn-soft: #fdf5d8;
  --bad: #dc2626;    --bad-text: #b91c1c;  --bad-soft: #fdeceb;

  --s1: #0284c7; --s2: #ea580c; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s-other: #a3b1c2;

  --band-from: #0a355c;
  --band-to: #0284c7;
  --band-glow: rgba(249, 115, 22, .55);
  --on-band: #ffffff;
  --on-band-muted: rgba(255, 255, 255, .78);

  --radius: 16px;
  --shadow: 0 1px 2px rgba(12, 45, 80, .05), 0 8px 24px -12px rgba(12, 45, 80, .18);
  --shadow-lift: 0 2px 4px rgba(12, 45, 80, .06), 0 16px 32px -12px rgba(12, 45, 80, .28);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1117;
    --surface: #131b24;
    --surface-2: #18222e;
    --border: #243241;
    --text: #e6edf5;
    --muted: #97a6b8;

    --blue: #38a8e8;
    --blue-strong: #5bb8ee;
    --blue-deep: #9fd4f5;
    --blue-soft: #10283a;
    --orange: #f07b3a;
    --orange-bright: #f58a4b;
    --orange-text: #f6a06c;
    --orange-soft: #34200f;

    --ok: #3fb96a;   --ok-text: #6fd093;   --ok-soft: #10291a;
    --warn: #e0b23a; --warn-text: #ecc766; --warn-soft: #2e2509;
    --bad: #f0645a;  --bad-text: #f68b83;  --bad-soft: #36191a;

    --s1: #0284c7; --s2: #ea580c; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s-other: #5d6b7c;

    --band-from: #051b2e;
    --band-to: #0a4a70;
    --band-glow: rgba(234, 88, 12, .35);

    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 8px 24px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.6 "Sarabun", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(520px 260px at 92% 0, var(--band-glow), transparent 70%) top / 100% 320px no-repeat,
    linear-gradient(120deg, var(--band-from) 0%, var(--band-to) 100%) top / 100% 320px no-repeat,
    var(--bg);
}

a { color: var(--blue-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; }
.panel > h2, .panel-head h2 { margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; }
h2::before {
  content: "";
  align-self: center;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--orange);
}

code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 14px; }

/* ---------------------------------------------------------------- top bar */

.topbar { color: var(--on-band); border-top: 4px solid var(--orange-bright); }

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px 6px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--on-band);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  margin-right: auto;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.brand svg { width: 28px; height: 28px; }
.brand svg .screen { fill: var(--band-to); }
.brand svg .stand { fill: var(--orange-bright); }
.brand svg path { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand small { display: block; font-size: 13px; font-weight: 400; color: var(--on-band-muted); }

nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .12);
}
nav a {
  padding: 7px 16px;
  border-radius: 9px;
  color: var(--on-band-muted);
  font-weight: 600;
  white-space: nowrap;
}
nav a:hover { color: #fff; background: rgba(255, 255, 255, .12); text-decoration: none; }
nav a.active { background: #fff; color: #0c4a6e; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }

#logout { display: flex; align-items: center; gap: 8px; }
#logout a {
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--on-band-muted);
  white-space: nowrap;
}
#logout a:hover, #logout a.active { color: #fff; background: rgba(255, 255, 255, .14); text-decoration: none; }
#logout .icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .35);
}
#logout .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s; }
#logout .icon-btn:hover svg { transform: rotate(60deg); }
#logout .icon-btn.active { border-color: var(--orange-bright); }
#logout button {
  font: inherit;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: transparent;
  color: var(--on-band-muted);
  cursor: pointer;
  white-space: nowrap;
}
#logout button:hover { color: #fff; border-color: var(--orange-bright); background: rgba(249, 115, 22, .2); }
#logout[hidden] { display: none; }

/* ---------------------------------------------------------------- layout */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-head { color: var(--on-band); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--on-band-muted); }
.page-head .back { color: var(--on-band-muted); font-weight: 600; display: inline-block; margin-bottom: 4px; }
.page-head .back:hover { color: #fff; }
.head-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.head-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.panel.flush { padding: 0; overflow: hidden; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

.hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading, .empty { color: var(--muted); margin: 0; }
.page-loading { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; color: var(--on-band-muted); }
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .3);
  border-top-color: var(--orange-bright);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.error { color: var(--bad-text); }
.panel.error { background: var(--bad-soft); border-color: transparent; }

/* ---------------------------------------------------------------- KPI tiles */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }

.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 18px 20px;
  color: var(--text);
  overflow: hidden;
  transition: transform .15s ease;
}
a.kpi:hover { transform: translateY(-2px); text-decoration: none; }
.kpi-top { display: flex; align-items: center; gap: 14px; }
.kpi-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #38bdf8, #0369a1);
  box-shadow: 0 6px 14px -6px rgba(3, 105, 161, .7);
}
.kpi-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi.orange .kpi-icon { background: linear-gradient(135deg, #fdba74, #ea580c); box-shadow: 0 6px 14px -6px rgba(234, 88, 12, .7); }
.kpi.ok .kpi-icon { background: linear-gradient(135deg, #4ade80, #15803d); box-shadow: 0 6px 14px -6px rgba(21, 128, 61, .7); }
.kpi.bad .kpi-icon { background: linear-gradient(135deg, #f87171, #b91c1c); box-shadow: 0 6px 14px -6px rgba(185, 28, 28, .7); }
.kpi-value { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: 14px; }
.kpi.bad .kpi-value { color: var(--bad-text); }
.kpi-foot { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.kpi-foot .meter { flex: 1; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; background: var(--blue); }
.kpi.ok .meter span { background: var(--ok); }
.kpi.bad .meter span { background: var(--bad); }

/* ---------------------------------------------------------------- donut + legend */

.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 156px; height: 156px; flex: none; }
.donut circle { fill: none; stroke-width: 20; }
.donut .track { stroke: var(--surface-2); }
.donut .seg { transition: opacity .15s; }
.donut-wrap:hover .seg { opacity: .55; }
.donut-wrap .seg:hover, .donut-wrap .seg.hot { opacity: 1; }
.donut .total { font-size: 30px; font-weight: 700; fill: var(--text); }
.donut .unit { font-size: 13px; fill: var(--muted); }

.legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.legend li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  margin: 0 -8px;
  border-radius: 8px;
}
.legend li:hover { background: var(--surface-2); }
.swatch { width: 12px; height: 12px; border-radius: 4px; }
.legend .lbl { line-height: 1.35; }
.legend .val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.legend .pct { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; width: 40px; text-align: right; }

/* ---------------------------------------------------------------- bar list (single series) */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.bar-row:hover { text-decoration: none; }
.bar-top { display: flex; justify-content: space-between; gap: 12px; }
.bar-top .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 0 4px 4px 0; }
.bar-fill { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 4px; }

/* ---------------------------------------------------------------- ranked list */

/* columns (not grid) so ranks read top-to-bottom: 1-8 left, 9-15 right */
.rank-list { list-style: none; margin: 0; padding: 0; columns: 2 340px; column-gap: 40px; }
.rank-list li { break-inside: avoid; padding: 2px 0; }
.rank-list a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 10px;
  color: var(--text);
}
.rank-list a:hover { background: var(--surface-2); text-decoration: none; }
.rank {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--blue-soft);
  color: var(--blue-strong);
}
.rank.top { background: linear-gradient(135deg, #fdba74, #ea580c); color: #fff; }
.rank-name { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rank-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-count { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-count b { font-size: 17px; }

/* ---------------------------------------------------------------- toolbar, inputs, segmented filter */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

input[type="search"] {
  flex: 1 1 320px;
  max-width: 560px;
  padding: 11px 16px 11px 44px;
  font: inherit;
  color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230284c7' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 15px center / 19px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  outline: none;
}
input[type="search"]:focus { border-color: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.panel-head input[type="search"] { flex: 0 1 300px; padding-top: 8px; padding-bottom: 8px; box-shadow: none; }
.page-head input[type="search"] { border-color: transparent; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); flex-wrap: wrap; }
.segmented button {
  font: inherit;
  font-weight: 600;
  border: 0;
  padding: 6px 14px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.segmented button:hover { color: var(--text); background: var(--surface-2); }
.segmented button.active { background: var(--blue-soft); color: var(--blue-strong); }
.segmented .n { font-variant-numeric: tabular-nums; font-size: 13px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); }
.segmented button.active .n { background: var(--blue); color: #fff; }

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.chip.blue { background: var(--blue-soft); color: var(--blue-strong); }
.chip.orange { background: var(--orange-soft); color: var(--orange-text); }
.chip.ok { background: var(--ok-soft); color: var(--ok-text); }
.chip.warn { background: var(--warn-soft); color: var(--warn-text); }
.chip.bad { background: var(--bad-soft); color: var(--bad-text); }
.chip .dot { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
  user-select: none;
}
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table td.empty { text-align: center; padding: 32px; }

.table.sortable th { cursor: pointer; }
.table.sortable th:hover, .table th.sorted { color: var(--orange-text); }
.table th.sorted::after { content: " ▲"; font-size: 10px; }
.table th.sorted.desc::after { content: " ▼"; }

.table tbody tr[data-id], .table tbody tr.expandable { cursor: pointer; transition: background .1s; }
.table tbody tr[data-id]:hover, .table tbody tr.expandable:hover { background: var(--surface-2); }

.cell-main { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  background: var(--blue-soft);
  color: var(--blue-strong);
}
.avatar.orange { background: var(--orange-soft); color: var(--orange-text); }
.two-line { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.table .two-line { white-space: nowrap; }
.two-line b, .two-line a { font-weight: 700; }
.two-line span { color: var(--muted); font-size: 13px; }
.spec { white-space: nowrap; }

.table tr.expandable.open { background: var(--orange-soft); }
.table tr.expandable .caret { display: inline-block; color: var(--orange); font-weight: 700; transition: transform .15s; }
.table tr.expandable.open .caret { transform: rotate(90deg); }
.table tr.detail > td { background: var(--surface-2); padding: 4px 16px 16px 66px; }
.table.inner { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table.inner th { background: var(--surface); }
.table.inner td, .table.inner th { padding: 9px 14px; }

.usage { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.usage .meter { width: 70px; }

/* ---------------------------------------------------------------- machine detail */

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }

.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h2 { margin: 0; }
.card-title h2::before { display: none; }
.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
}
.card-icon.orange { background: var(--orange-soft); color: var(--orange); }
.card-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- change password */

.form-panel { max-width: 520px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form .field {
  font: inherit;
  font-weight: 400;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
.form .field:focus { border-color: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.form .help { font-weight: 400; font-size: 13px; color: var(--muted); }
.btn-primary {
  align-self: flex-start;
  font: inherit;
  font-weight: 700;
  padding: 10px 22px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #f97316, #ea580c);
  box-shadow: 0 10px 20px -10px rgba(234, 88, 12, .8);
}
.btn-primary:disabled { opacity: .6; cursor: wait; }
.notice { padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.notice.ok { background: var(--ok-soft); color: var(--ok-text); }
.notice.bad { background: var(--bad-soft); color: var(--bad-text); }

.welcome { text-align: center; padding: 48px 20px; }
.welcome h2 { justify-content: center; margin-bottom: 8px; }
.welcome p { margin: 0 auto; max-width: 560px; color: var(--muted); }

@media (max-width: 720px) {
  .topbar-inner { padding: 12px 16px 4px; }
  main { padding: 14px 16px 48px; }
  nav { width: 100%; }
  nav a { flex: 1; text-align: center; padding: 7px 6px; }
  h1 { font-size: 24px; }

  /* KPI tiles: 2 per row, icon above the number */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px; gap: 8px; }
  .kpi-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-icon { width: 38px; height: 38px; border-radius: 11px; }
  .kpi-icon svg { width: 20px; height: 20px; }
  .kpi-value { font-size: 26px; }
  .kpi-label { font-size: 13px; line-height: 1.35; }
  .kpi-foot { font-size: 12px; }

  /* filter pills scroll sideways instead of wrapping */
  .segmented { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .segmented button { flex: none; white-space: nowrap; }
  .desktop-only { display: none; }

  /* table rows become cards: first cell is the title, the rest are label/value lines */
  .table.stack > thead { display: none; }
  .table.stack, .table.stack > tbody, .table.stack > tbody > tr, .table.stack > tbody > tr > td { display: block; width: 100%; }
  .table.stack > tbody > tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table.stack > tbody > tr:last-child { border-bottom: none; }
  .table.stack > tbody > tr > td {
    border: 0;
    padding: 3px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
  }
  .table.stack > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 13px;
    text-align: left;
  }
  .table.stack > tbody > tr > td:first-child { padding-bottom: 8px; justify-content: flex-start; text-align: left; }
  .table.stack > tbody > tr > td[data-label] .two-line { align-items: flex-end; }
  .table.stack > tbody > tr > td.empty { justify-content: center; }
  .table.stack > tbody > tr.detail { padding: 0 12px 12px; }
  .table.stack > tbody > tr.detail > td { display: block; padding: 0; }
  .table.stack .cell-main { min-width: 0; }
  .rank-list { columns: 1; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 10px; }
  .table tr.detail > td { padding-left: 16px; }
}
