/* HSMC Explorer — design tokens, light and dark */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --bg: #f6f7f9;
  --bg-sunken: #eef0f4;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --fg: #111827;
  --fg-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-2: #eef0f3;

  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-fg: #ffffff;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;

  --side: #ffffff;
  --side-fg: #4b5563;
  --side-hover: #f3f4f6;
  --side-active: #eef2ff;
  --side-active-fg: #4338ca;

  --ok: #047857; --ok-bg: #ecfdf5; --ok-line: #a7f3d0;
  --info: #1d4ed8; --info-bg: #eff6ff; --info-line: #bfdbfe;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-line: #fde68a;
  --bad: #b91c1c; --bad-bg: #fef2f2; --bad-line: #fecaca;
  --neutral: #4b5563; --neutral-bg: #f3f4f6; --neutral-line: #e5e7eb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
  --ring: 0 0 0 3px rgba(99, 102, 241, .25);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --bg-sunken: #07090d; --panel: #12151c; --panel-2: #161a22;
  --fg: #e5e7eb; --fg-2: #cbd5e1; --muted: #94a3b8; --faint: #64748b;
  --line: #232835; --line-2: #1b1f29;
  --accent: #818cf8; --accent-2: #a5b4fc; --accent-fg: #0b0d12; --accent-soft: rgba(129, 140, 248, .12); --accent-line: rgba(129, 140, 248, .35);
  --side: #0e1117; --side-fg: #94a3b8; --side-hover: #171b24; --side-active: rgba(129, 140, 248, .14); --side-active-fg: #c7d2fe;
  --ok: #34d399; --ok-bg: rgba(52, 211, 153, .1); --ok-line: rgba(52, 211, 153, .3);
  --info: #93c5fd; --info-bg: rgba(147, 197, 253, .1); --info-line: rgba(147, 197, 253, .3);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .1); --warn-line: rgba(251, 191, 36, .3);
  --bad: #f87171; --bad-bg: rgba(248, 113, 113, .1); --bad-line: rgba(248, 113, 113, .3);
  --neutral: #cbd5e1; --neutral-bg: #1b2030; --neutral-line: #2a3142;
  --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 16px 40px -10px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --bg-sunken: #07090d; --panel: #12151c; --panel-2: #161a22;
    --fg: #e5e7eb; --fg-2: #cbd5e1; --muted: #94a3b8; --faint: #64748b;
    --line: #232835; --line-2: #1b1f29;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-fg: #0b0d12; --accent-soft: rgba(129, 140, 248, .12); --accent-line: rgba(129, 140, 248, .35);
    --side: #0e1117; --side-fg: #94a3b8; --side-hover: #171b24; --side-active: rgba(129, 140, 248, .14); --side-active-fg: #c7d2fe;
    --ok: #34d399; --ok-bg: rgba(52, 211, 153, .1); --ok-line: rgba(52, 211, 153, .3);
    --info: #93c5fd; --info-bg: rgba(147, 197, 253, .1); --info-line: rgba(147, 197, 253, .3);
    --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .1); --warn-line: rgba(251, 191, 36, .3);
    --bad: #f87171; --bad-bg: rgba(248, 113, 113, .1); --bad-line: rgba(248, 113, 113, .3);
    --neutral: #cbd5e1; --neutral-bg: #1b2030; --neutral-line: #2a3142;
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 16px 40px -10px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
kbd { font: 500 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--panel); }
::selection { background: var(--accent-soft); }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--fg-2); }
h4 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 900px; }
small { font-size: 12px; }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details > summary:hover { color: var(--fg); }

/* ---------------------------------------------------------------- icons */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 16px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  font-weight: 700; font-size: 13px; letter-spacing: .02em; box-shadow: 0 4px 12px -2px rgba(99, 102, 241, .5);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 16px 12px 6px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; color: var(--side-fg);
  padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; transition: background .12s, color .12s;
}
.side nav a .ico { opacity: .8; }
.side nav a:hover { background: var(--side-hover); color: var(--fg); text-decoration: none; }
.side nav a.active { background: var(--side-active); color: var(--side-active-fg); font-weight: 600; }
.side nav a.active .ico { opacity: 1; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.refresh-box { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.refresh-box .btn { justify-content: center; }
.refresh-info { font-size: 11.5px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.refresh-info.bad { color: var(--bad, #b91c1c); }
.refresh-info .spinner { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; margin-right: 4px; }

.content { min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-spacer { flex: 1; }
.side-search { position: relative; display: flex; align-items: center; width: min(460px, 100%); }
.side-search .ico { position: absolute; left: 12px; color: var(--faint); width: 16px; height: 16px; pointer-events: none; }
.side-search kbd { position: absolute; right: 10px; pointer-events: none; }
.side-search input {
  width: 100%; height: 38px; padding: 0 36px 0 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); font: inherit; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s;
}
.side-search input::placeholder { color: var(--faint); }
.side-search input:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--ring); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg-2); box-shadow: var(--shadow-sm);
}
.icon-btn:hover { color: var(--fg); border-color: var(--faint); }
.menu-btn { display: none; }
#theme-btn .ico-moon { display: none; }
:root[data-theme="dark"] #theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] #theme-btn .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-btn .ico-sun { display: none; }
  :root:not([data-theme="light"]) #theme-btn .ico-moon { display: block; }
}

.main { padding: 28px 32px 72px; width: 100%; max-width: 1480px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .4; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.loading { color: var(--muted); padding: 60px 0; display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--fg); }
.crumbs span { margin: 0 6px; color: var(--faint); }

/* ---------------------------------------------------------------- buttons and form controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); font: 500 13px var(--font);
  box-shadow: var(--shadow-sm); white-space: nowrap; transition: border-color .12s, background .12s, box-shadow .12s, transform .05s;
}
.btn:hover { border-color: var(--faint); background: var(--panel-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-fg); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-ghost { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; box-shadow: none; color: var(--side-fg); padding: 0 12px; }
.btn-ghost:hover { background: var(--side-hover); color: var(--fg); border-color: transparent; }

input, select, textarea { font: inherit; color: inherit; }
.toolbar input[type=search], .toolbar input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .toolbar select,
.qrow input:not([type=checkbox]):not([type=radio]), .qrow select, #ni-lines input, #apply-rows input {
  height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--fg); box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s;
}
.toolbar input[type=search] { min-width: 300px; padding-left: 12px; }
input:focus, select:focus { outline: none; border-color: var(--accent-2) !important; box-shadow: var(--ring) !important; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
input:disabled { opacity: .55; }

.toolbar { display: flex; gap: 10px; align-items: center; margin: 14px 0 18px; flex-wrap: wrap; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.toolbar .count { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- cards and panels */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 18px 0 6px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), #8b5cf6); opacity: 0; transition: opacity .15s; }
.card:hover::before { opacity: 1; }
.card .k { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.card .k a { color: var(--muted); }
.card .k a:hover { color: var(--accent); }
.card .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card .v small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-top: 4px; }
.card .v .money { font-size: inherit; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel > h3:first-child { margin-top: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin-top: 14px; }
.kv > div { min-width: 0; }
.kv .k { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.kv .v { word-break: break-word; white-space: pre-wrap; color: var(--fg); }
.kv .v:empty::after { content: "—"; color: var(--faint); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.stat-grid .panel { margin: 0; padding: 16px 18px; min-width: 0; overflow-x: auto; }
.stat-grid h3 { margin: 0 0 10px; }

/* ---------------------------------------------------------------- tabs and sub navigation */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 24px 0 18px; }
.tabs button, .tabs a.tab-link {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 9px 12px; cursor: pointer; font: 500 13px var(--font); color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
  border-radius: 6px 6px 0 0; transition: color .12s, background .12s;
}
.tabs button:hover, .tabs a.tab-link:hover { color: var(--fg); background: var(--side-hover); }
.tabs button .n, .tabs a.tab-link .n { background: var(--neutral-bg); color: var(--neutral); border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px; margin: 0; font-variant-numeric: tabular-nums; }
.tabs button.active, .tabs a.tab-link.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button.active .n, .tabs a.tab-link.active .n { background: var(--accent-soft); color: var(--accent); }
.tabs a.tab-link { text-decoration: none; }
.tabs button.empty { opacity: .5; }

.subnav { display: inline-flex; gap: 2px; flex-wrap: wrap; padding: 3px; margin: 4px 0 18px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 10px; }
.subnav a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.subnav a:hover { color: var(--fg); text-decoration: none; }
.subnav a.active { background: var(--panel); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }
.subnav + .subnav { margin-top: -8px; }

/* ---------------------------------------------------------------- tables */
[data-rows] { overflow-x: auto; border-radius: var(--radius); }
table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.35;
}
table.grid th, table.grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
table.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line);
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
table.grid tr.row { cursor: pointer; }
table.grid tr.detail td { background: var(--panel-2) !important; padding: 12px 16px 16px; white-space: normal; }
table.grid td.num, table.grid td.money, table.grid th.money { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td .chips { gap: 4px; flex-wrap: nowrap; }
table.grid td .trunc { display: inline-block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
table.grid th a.sort { color: var(--muted); display: inline-flex; gap: 2px; }
table.grid th a.sort:hover { color: var(--fg); text-decoration: none; }
table.grid th a.sort.active { color: var(--accent); }
table.grid td input { height: 30px !important; }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
table.mini tr:last-child td { border-bottom: none; }
table.mini th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
table.mini td.money, table.mini th.money { text-align: right; font-variant-numeric: tabular-nums; }

.empty-note { color: var(--muted); padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; background: var(--panel-2); }
.pager { display: flex; gap: 14px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pager a { padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--fg); box-shadow: var(--shadow-sm); }
.pager a:hover { border-color: var(--faint); text-decoration: none; }

/* ---------------------------------------------------------------- badges and money */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; line-height: 20px;
  padding: 0 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-line); }
h1 .badge, h2 .badge { font-size: 12px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.neg { color: var(--bad); }
.money.zero { color: var(--faint); }
.link-missing { color: var(--bad); font-size: 12px; }

/* ---------------------------------------------------------------- stacks and sub cards */
.stack { display: grid; gap: 10px; }
.sub-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.sub-card .title { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; line-height: 1.35; }
.sub-card .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.sub-card .more { margin-top: 8px; }
.sub-card .more summary { font-size: 12px; }
.sub-card .nested { margin-top: 12px; padding-left: 14px; border-left: 2px solid var(--accent-line); }
.sub-card .nested h4 { margin: 10px 0 4px; }
.sub-card ul, .sub-card ol { margin: 0; padding-left: 20px; }
.sub-card > h3:first-child { margin-top: 0; }
.note-text { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; background: var(--bg-sunken); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); }
.family { margin-bottom: 14px; }
.family h3 { margin: 16px 0 6px; }
.inv-type { font-family: var(--mono); }

/* ---------------------------------------------------------------- query builder */
.qrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.qrow label { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.qrow input:not([type=checkbox]) { min-width: 200px; }
.qblock { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; background: var(--panel-2); }
.qnested { padding-left: 14px; border-left: 2px solid var(--accent-line); margin-top: 6px; }
.qcols {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; margin-top: 10px;
  max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel-2);
}
.qcols label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }

.schema {
  font-family: var(--mono); font-size: 12.5px; white-space: pre; line-height: 1.75;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; overflow-x: auto; box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 16px; }
  .main { padding: 20px 16px 56px; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .side-search kbd { display: none; }
}

/* record number shown in page titles */
h1 .mono { font-size: 15px; font-weight: 600; color: var(--muted); background: var(--bg-sunken); border: 1px solid var(--line); padding: 2px 9px; border-radius: 7px; letter-spacing: 0; }

/* AR lookup dropdown on the payment form */
.find-list { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 520px; max-height: 360px; overflow-y: auto; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.find-list a { display: block; padding: 7px 10px; color: var(--fg); border-bottom: 1px solid var(--line-2); font-size: 13px; white-space: normal; }
.find-list a:hover { background: var(--side-hover); text-decoration: none; }
.cards.cards-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cards.cards-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* signed-in user box (sidebar) and login page */
.user-box { padding: 8px 12px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.user-box .user-name { font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-box .user-links { color: var(--muted); margin-top: 2px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px 28px 24px; }
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-card .sub { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; color: var(--fg-2); margin: 12px 0 5px; }
.login-card input { width: 100%; box-sizing: border-box; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.login-card input.code { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; }
.login-card .btn { width: 100%; justify-content: center; height: 40px; margin-top: 18px; }
.login-card .err { color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-line); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 12px; font-size: 13px; }
.login-card .ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 12px; font-size: 13px; }
.login-card .qr { display: flex; justify-content: center; margin: 12px 0; }
.login-card .qr svg { width: 200px; height: 200px; border-radius: 8px; }
.login-card .secret { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--bg-sunken); padding: 8px 10px; border-radius: var(--radius-sm); }
.login-card .small { font-size: 12px; color: var(--muted); margin-top: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password] { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); min-width: 220px; }
