/* logger.sencha.com (admin UI) — Idera brand palette.
   Brand: teal #0E6189, navy #005F88, accent blue #00A1FF, warm grey #716558,
   green #9BBA58, orange #F5851F, light blue #4AACC5.
   Themes: light (default), dark via prefers-color-scheme, or pinned with <html data-theme="light|dark">. */

:root {
  color-scheme: light;
  --brand: #0e6189;
  --brand-strong: #005f88;
  --brand-accent: #00a1ff;
  --topbar-bg: linear-gradient(90deg, #0e6189 0%, #005f88 100%);
  --sidebar-bg: linear-gradient(180deg, #0e6189 0%, #005f88 100%);
  --topbar-text: #ffffff;

  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --surface-hover: #eef5f9;
  --text: #2a2723;
  --muted: #716558;
  --border: #e0e5e9;
  --border-strong: #c9d2d9;
  --link: #0e6189;
  --focus: #00a1ff;

  --ok: #4f6d1c;        --ok-bg: #eef4e1;
  --warn: #a8530a;      --warn-bg: #fef1e4;
  --danger: #b42318;    --danger-bg: #fdecea;
  --info: #0e6189;      --info-bg: #e5f2f8;

  --bar: #4aacc5;
  --bar-top: #0e6189;
  --code-bg: #f5f7f8;
  --shadow-sm: 0 1px 2px rgba(14, 40, 60, 0.06);
  --shadow: 0 1px 3px rgba(14, 40, 60, 0.08), 0 4px 14px rgba(14, 40, 60, 0.06);
  --shadow-lg: 0 10px 30px rgba(14, 40, 60, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
}

/* Dark: deep Idera navy. Defined twice — OS preference (unless pinned light) and pinned dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --topbar-bg: linear-gradient(90deg, #0a4a69 0%, #073a52 100%);
    --sidebar-bg: linear-gradient(180deg, #0a4a69 0%, #062f43 100%);
    --bg: #0a1820;
    --surface: #10222d;
    --surface-2: #142a37;
    --surface-hover: #183444;
    --text: #e4ecf1;
    --muted: #9db0bd;
    --border: #1f3a4a;
    --border-strong: #2b4c5f;
    --link: #4fc3ff;
    --focus: #00a1ff;
    --ok: #b5d278;        --ok-bg: rgba(155, 186, 88, 0.16);
    --warn: #ffab5e;      --warn-bg: rgba(245, 133, 31, 0.16);
    --danger: #ff8a80;    --danger-bg: rgba(255, 99, 88, 0.14);
    --info: #4fc3ff;      --info-bg: rgba(0, 161, 255, 0.14);
    --bar: #2f7f98;
    --bar-top: #4fc3ff;
    --code-bg: #0c1c25;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --topbar-bg: linear-gradient(90deg, #0a4a69 0%, #073a52 100%);
    --sidebar-bg: linear-gradient(180deg, #0a4a69 0%, #062f43 100%);
  --bg: #0a1820;
  --surface: #10222d;
  --surface-2: #142a37;
  --surface-hover: #183444;
  --text: #e4ecf1;
  --muted: #9db0bd;
  --border: #1f3a4a;
  --border-strong: #2b4c5f;
  --link: #4fc3ff;
  --focus: #00a1ff;
  --ok: #b5d278;        --ok-bg: rgba(155, 186, 88, 0.16);
  --warn: #ffab5e;      --warn-bg: rgba(245, 133, 31, 0.16);
  --danger: #ff8a80;    --danger-bg: rgba(255, 99, 88, 0.14);
  --info: #4fc3ff;      --info-bg: rgba(0, 161, 255, 0.14);
  --bar: #2f7f98;
  --bar-top: #4fc3ff;
  --code-bg: #0c1c25;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Arial, "Helvetica Neue", Helvetica, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.icon { width: 16px; height: 16px; flex: none; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip:focus { left: 8px; }

/* ---------- app shell: sidebar + main column ---------- */

.shell { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--topbar-text); flex: none; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand-divider { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.35); }
.brand-product { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; white-space: nowrap; }

.sidebar {
  width: 248px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--topbar-text); overflow-y: auto; z-index: 40;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.08);
}
.sidebar :focus-visible, .topbar :focus-visible { outline-color: #fff; }
.sb-head { display: flex; align-items: center; gap: 8px; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.sb-head .brand { flex: 1; }
.sb-close, .menu-btn {
  display: none; place-items: center; background: transparent; border: 0; min-height: 0; padding: 6px;
  color: rgba(255, 255, 255, 0.85); border-radius: 8px; cursor: pointer;
}
.sb-close:hover, .menu-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.sb-close .icon, .menu-btn .icon { width: 22px; height: 22px; }

#nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.55); padding: 4px 12px 6px; font-weight: 700; }
#nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; font-weight: 600;
  color: rgba(255, 255, 255, 0.8); transition: background 0.15s, color 0.15s;
}
#nav a .icon { width: 18px; height: 18px; opacity: 0.9; }
#nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); text-decoration: none; }
#nav a.active { color: #fff; background: rgba(255, 255, 255, 0.16); box-shadow: inset 3px 0 0 var(--brand-accent); }

.sb-foot { padding: 14px 14px 18px; border-top: 1px solid rgba(255, 255, 255, 0.12); display: flex; flex-direction: column; gap: 14px; }
.theme-switch { display: flex; background: rgba(0, 0, 0, 0.18); border-radius: 999px; padding: 3px; align-self: flex-start; }
.theme-switch button {
  background: transparent; border: 0; color: rgba(255, 255, 255, 0.75); padding: 5px 9px; min-height: 0; border-radius: 999px;
  display: grid; place-items: center; cursor: pointer;
}
.theme-switch button:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.theme-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: var(--brand); }
.theme-switch .icon { width: 15px; height: 15px; }

.who { display: flex; align-items: center; gap: 10px; color: var(--topbar-text); min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #9bba58; color: #10222d; font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.who-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.who-email { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 11px; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.06em; }
.icon-link { color: rgba(255, 255, 255, 0.85); display: grid; place-items: center; padding: 6px; border-radius: 8px; flex: none; }
.icon-link:hover { color: #fff; background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.who button.icon-link { background: transparent; border: 0; min-height: 0; }

/* Top bar: hidden on wide screens while signed in (the sidebar has everything). */
.topbar {
  display: none; align-items: center; gap: 12px; padding: 0 16px; min-height: 56px; position: sticky; top: 0; z-index: 20;
  background: var(--topbar-bg); color: var(--topbar-text); box-shadow: 0 2px 8px rgba(0, 40, 60, 0.18);
}
.topbar .brand img { height: 30px; }
#top-avatar:empty { display: none; }
body.signed-out .sidebar, body.signed-out .menu-btn { display: none; }
body.signed-out .topbar { display: flex; }
.sb-backdrop { position: fixed; inset: 0; background: rgba(6, 20, 28, 0.55); z-index: 35; }
.sb-backdrop[hidden] { display: none; }

@media (max-width: 1023px) {
  .topbar { display: flex; }
  .menu-btn { display: grid; }
  .sb-close { display: grid; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(280px, 85vw);
    transform: translateX(-100%); transition: transform 0.2s ease-out; box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
}

/* ---------- page ---------- */

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; outline: none; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { flex: 1 1 280px; min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs .icon { width: 12px; height: 12px; opacity: 0.6; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; color: var(--brand); font-weight: 700; overflow-wrap: anywhere; }
:root[data-theme="dark"] h1 { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) h1 { color: var(--text); } }
.subtitle { margin: 4px 0 0; color: var(--muted); max-width: 760px; }
h2 { font-size: 16px; margin: 32px 0 12px; font-weight: 700; }
.section-title { display: flex; align-items: center; gap: 8px; }

/* ---------- surfaces ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.cards > .card { margin-top: 0; }
.card-title { margin: 0 0 12px; font-size: 14px; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat-tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.stat-tile.accent::before { background: var(--brand-accent); }
.stat-tile.green::before { background: #9bba58; }
.stat-tile.orange::before { background: #f5851f; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.project-card { display: flex; flex-direction: column; gap: 12px; transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; }
.project-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.project-card h3 { margin: 0; font-size: 16px; }
.project-card h3 a { color: var(--text); }
.project-card .split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.project-card .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.project-card .lbl { color: var(--muted); font-size: 12px; }
.project-card .foot { display: flex; gap: 12px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; font-size: 13px; font-weight: 600; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 48px; }
.bars span { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--bar-top), var(--bar)); opacity: 0.85; transition: opacity 0.15s; }
.bars span:hover { opacity: 1; }
.bars span.zero { background: var(--border); opacity: 1; }

.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4aacc5, #0e6189); }
.meter.warn span { background: linear-gradient(90deg, #f5b46b, #f5851f); }
.meter.danger span { background: var(--danger); }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; gap: 8px; }

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

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  font-weight: 700; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-hover); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-class { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.err-msg { color: var(--muted); font-size: 13px; margin-top: 2px; }
.count-pill { display: inline-block; min-width: 36px; text-align: center; padding: 2px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-weight: 700; font-size: 12px; }
.id-link { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.table-foot { display: flex; justify-content: center; padding: 16px 0; }

/* ---------- badges ---------- */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: none; }
.badge.dot::before { display: inline-block; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.off { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.info { color: var(--info); background: var(--info-bg); border-color: transparent; }

/* ---------- forms + buttons ---------- */

button, select, input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 12px; min-height: 36px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
input, select { min-width: 0; }
input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(0, 161, 255, 0.2); }
input:disabled, select:disabled { opacity: 0.6; }
button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
button:hover { background: var(--surface-hover); }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover { background: var(--danger-bg); }
button.danger.solid { background: var(--danger); color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--link); }
button.ghost:hover { background: var(--surface-hover); }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: default; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); min-height: 36px; }
.btn-link:hover { text-decoration: none; background: var(--surface-hover); }

.form-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; min-width: 0; }
.field.narrow { flex: 0 0 130px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); min-height: 18px; }
.cap-input { width: 110px; }

/* ---------- report detail ---------- */

dl.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px 24px; margin: 0; }
dl.meta div { min-width: 0; }
dl.meta dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 2px; }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
dl.meta div.wide { grid-column: 1 / -1; }

.code-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 16px; box-shadow: var(--shadow-sm); }
.code-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.code-head h2 { margin: 0; font-size: 13px; flex: 1; }
pre { margin: 0; background: var(--code-bg); padding: 14px; overflow-x: auto; white-space: pre; font-size: 12.5px; line-height: 1.55; max-height: 70vh; }

/* ---------- notices, empty states, loading ---------- */

.notice { padding: 12px 14px; border-radius: var(--radius-sm); margin: 12px 0; border: 1px solid var(--border); background: var(--surface); display: flex; gap: 10px; align-items: flex-start; }
.notice > .icon { margin-top: 2px; }
.notice .body { flex: 1; min-width: 0; }
.notice p { margin: 4px 0 8px; }
.notice.error { border-color: transparent; background: var(--danger-bg); color: var(--danger); }
.notice.key { border-color: #f5851f; background: var(--warn-bg); }
.notice.key code { font-size: 13px; overflow-wrap: anywhere; background: var(--surface); padding: 6px 8px; border-radius: 4px; border: 1px solid var(--border); flex: 1; min-width: 0; }
.notice.info { background: var(--info-bg); border-color: transparent; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .empty-title { color: var(--text); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.empty .icon { width: 32px; height: 32px; color: var(--border-strong); margin-bottom: 8px; }
td.empty-cell { text-align: center; padding: 32px 16px; color: var(--muted); }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 48px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand-accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts + dialog ---------- */

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; min-width: 220px; max-width: 420px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid #9bba58;
  box-shadow: var(--shadow-lg); animation: toast-in 0.18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(6, 20, 28, 0.55); }
dialog .dlg-body { padding: 20px 20px 8px; }
dialog h3 { margin: 0 0 8px; font-size: 17px; }
dialog p { margin: 0; color: var(--muted); }
dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spinner { animation-duration: 1.5s !important; }
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  main { padding: 16px 16px 32px; }
  h1 { font-size: 21px; }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head > .row { width: 100%; }
  .stat-value { font-size: 24px; }
  .stats { gap: 12px; }
  .field.narrow { flex: 1 1 140px; }
  .notice .row code { flex-basis: 100%; }
}
@media (max-width: 420px) {
  .topbar .brand-divider, .topbar .brand-product { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-tile { padding: 12px 14px; }
}

/* Phones: every table becomes a stack of labelled cards (cells carry data-label), so nothing scrolls sideways. */
@media (max-width: 640px) {
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
  }
  .table-wrap tbody tr:hover { background: var(--surface); }
  .table-wrap td {
    border: 0; padding: 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    text-align: right; min-width: 0;
  }
  .table-wrap td + td { border-top: 1px dashed var(--border); }
  .table-wrap td::before {
    content: attr(data-label); flex: none; text-align: left; color: var(--muted);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  }
  .table-wrap td:not([data-label])::before { content: none; }
  .table-wrap td > * { min-width: 0; }
  .table-wrap td .row { justify-content: flex-end; }
  /* Long text cells read better as a block under their label. */
  .table-wrap td.cell-block { display: block; text-align: left; }
  .table-wrap td.cell-block::before { display: block; margin-bottom: 2px; }
  .table-wrap td.cell-block .row { justify-content: flex-start; }
  .table-wrap td.empty-cell { justify-content: center; text-align: center; }
  .clip { max-width: none; white-space: normal; }
  td.num, th.num { text-align: right; }
  .cap-input { width: 96px; }
}

/* ---------- sign-in, set password, account ---------- */

.auth-wrap { display: flex; justify-content: center; padding: 32px 0 16px; }
.auth-card { width: min(420px, 100%); padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.auth-card .field { flex: none; }
.auth-card .subtitle { margin-bottom: 4px; }
.auth-card .notice { margin: 0; }
.auth-hint { font-size: 13px; text-align: center; margin: 12px 0 0; }
button.wide { width: 100%; justify-content: center; min-height: 40px; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.account-form { max-width: 480px; display: flex; flex-direction: column; gap: 14px; }
.account-form .field { flex: none; }
