:root {
  color-scheme: light;
  --bg: #eef2f8;
  --canvas: #f5f7fb;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8faff;
  --input: #ffffff;
  --header: rgba(255, 255, 255, .88);
  --hover: #f1f5fb;
  --selected: #e8f1ff;
  --border: #e2e8f1;
  --border-strong: #cbd5e3;
  --text: #21324a;
  --strong: #102341;
  --ink: #102341;
  --muted: #66768d;
  --faint: #8b98aa;
  --accent: #2864ee;
  --accent-rgb: 40, 100, 238;
  --accent-hover: #1d54d7;
  --accent-soft: rgba(40, 100, 238, .11);
  --on-accent: #ffffff;
  --green: #2f9e6f;
  --green-soft: rgba(47, 158, 111, .1);
  --amber: #c88724;
  --amber-soft: rgba(200, 135, 36, .12);
  --red: #d85555;
  --red-soft: rgba(216, 85, 85, .1);
  --blue: #2864ee;
  --shadow: 0 24px 70px rgba(44, 60, 90, .16);
  --sidebar-width: 276px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="paper"] {
  color-scheme: light;
  --bg: #e9e3d9;
  --canvas: #f4efe6;
  --sidebar: #fbf7ef;
  --panel: #fffaf2;
  --panel-2: #f8f1e6;
  --input: #fffdf8;
  --header: rgba(251, 247, 239, .9);
  --hover: #efe7da;
  --selected: color-mix(in srgb, var(--accent) 11%, #fffaf2);
  --border: #dfd5c6;
  --border-strong: #cbbcab;
  --text: #443d36;
  --strong: #241f1b;
  --ink: #241f1b;
  --muted: #756b61;
  --faint: #9a8f83;
  --shadow: 0 24px 70px rgba(65, 48, 32, .14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d16;
  --canvas: #0d1420;
  --sidebar: #101927;
  --panel: #121c2b;
  --panel-2: #172335;
  --input: #0c1522;
  --header: rgba(13, 20, 32, .9);
  --hover: #1a283b;
  --selected: color-mix(in srgb, var(--accent) 18%, #172335);
  --border: #233249;
  --border-strong: #344861;
  --text: #d9e3f0;
  --strong: #f4f7fb;
  --ink: #f4f7fb;
  --muted: #93a3b8;
  --faint: #697a91;
  --green: #68c995;
  --amber: #e4ad55;
  --red: #ef7a78;
  --shadow: 0 26px 80px rgba(0, 0, 0, .48);
}

:root[data-theme="system"] { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #080d16; --canvas: #0d1420; --sidebar: #101927; --panel: #121c2b; --panel-2: #172335;
    --input: #0c1522; --header: rgba(13, 20, 32, .9); --hover: #1a283b;
    --selected: color-mix(in srgb, var(--accent) 18%, #172335); --border: #233249; --border-strong: #344861;
    --text: #d9e3f0; --strong: #f4f7fb; --ink: #f4f7fb; --muted: #93a3b8; --faint: #697a91;
    --green: #68c995; --amber: #e4ad55; --red: #ef7a78; --shadow: 0 26px 80px rgba(0, 0, 0, .48);
  }
}

:root[data-accent="ocean"] { --accent: #2864ee; --accent-rgb: 40, 100, 238; --accent-hover: #1d54d7; --accent-soft: rgba(40, 100, 238, .11); --on-accent: #fff; }
:root[data-accent="violet"] { --accent: #7c5ce7; --accent-rgb: 124, 92, 231; --accent-hover: #6848d0; --accent-soft: rgba(124, 92, 231, .12); --on-accent: #fff; }
:root[data-accent="emerald"] { --accent: #198a63; --accent-rgb: 25, 138, 99; --accent-hover: #127453; --accent-soft: rgba(25, 138, 99, .12); --on-accent: #fff; }
:root[data-accent="coral"] { --accent: #d76f4b; --accent-rgb: 215, 111, 75; --accent-hover: #bf5b3a; --accent-soft: rgba(215, 111, 75, .13); --on-accent: #fff; }
:root[data-accent="rose"] { --accent: #d8517e; --accent-rgb: 216, 81, 126; --accent-hover: #bd3e68; --accent-soft: rgba(216, 81, 126, .12); --on-accent: #fff; }

* {
  box-sizing: border-box;
  scrollbar-color: #3b3b3b transparent;
  scrollbar-width: thin;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  user-select: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(217, 119, 87, .7);
  outline-offset: 2px;
}

button:disabled,
.disabled {
  cursor: not-allowed !important;
  opacity: .48;
}

.hidden {
  display: none !important;
}

noscript {
  display: block;
  padding: 16px;
  color: #f0b2ad;
  background: #261716;
}

.button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}

.button:hover:not(:disabled):not(.disabled) {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--strong);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #180d09;
}

.button.primary:hover:not(:disabled):not(.disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #180d09;
}

.button.subtle {
  background: #181818;
}

.button.danger {
  border-color: rgba(211, 110, 104, .42);
  background: var(--red-soft);
  color: #e59b96;
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--hover);
  color: var(--strong);
}

.brand-lockup,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #101010;
  font: 750 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -.08em;
}

.brand-mark b {
  color: var(--accent);
}

.brand-mark i {
  color: #898989;
  font-style: normal;
  font-weight: 500;
}

.brand-lockup > span:last-child,
.sidebar-brand > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand-lockup strong,
.sidebar-brand strong {
  color: var(--strong);
  font-size: 13px;
}

.brand-lockup small,
.sidebar-brand small {
  color: var(--faint);
  font: 550 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--faint);
  font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.eyebrow > i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* Login is the only view available before API authorization. */

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0a0a0a;
}

.login-card {
  width: min(400px, 100%);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 26px;
  background: var(--sidebar);
  box-shadow: var(--shadow);
}

.brand-lockup {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.login-copy {
  padding: 26px 0 20px;
}

.login-copy h1 {
  margin: 10px 0 8px;
  color: var(--strong);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 670;
  letter-spacing: -.03em;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.stack-form {
  display: grid;
  gap: 13px;
}

.stack-form label,
.dialog-fields label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: #bcbcbc;
  font-size: 10.5px;
  font-weight: 620;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  padding: 0 10px;
  background: #0c0c0c;
  color: var(--text);
  font-size: 12px;
}

textarea {
  min-height: 78px;
  padding-top: 9px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(217, 119, 87, .55);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: #555;
}

.form-message {
  min-height: 17px;
  margin: 0;
  color: var(--red);
  font-size: 10.5px;
  line-height: 1.5;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.5;
}

.login-help {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 10.5px;
}

.login-help summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--faint);
  user-select: none;
}

.login-help[open] summary {
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.login-help ol {
  margin: 0;
  padding: 10px 14px 12px 26px;
  display: grid;
  gap: 6px;
  color: var(--faint);
  line-height: 1.6;
}

.login-help code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 9.5px;
}

/* Client control page */

.policy-list {
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
}

.policy-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.policy-row:hover {
  border-color: var(--accent, #e77b4f);
}

.policy-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent, #e77b4f);
}

.policy-copy {
  display: grid;
  gap: 3px;
}

.policy-copy strong {
  font-size: 11.5px;
}

.policy-copy small {
  color: var(--faint);
  font-size: 10px;
  line-height: 1.55;
}

/* App shell */

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  background: var(--canvas);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar-brand {
  min-height: 70px;
  padding: 17px 17px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 12px;
}

.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px 9px;
}

.nav-label {
  margin: 12px 8px 5px;
  color: #555;
  font: 700 8.5px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-label:first-child {
  margin-top: 3px;
}

.nav-item {
  min-height: 35px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 9px;
  background: transparent;
  color: #a9a9a9;
  cursor: pointer;
  text-align: left;
  font-size: 11.5px;
}

.nav-item i {
  color: #686868;
  font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--selected);
  color: var(--strong);
  font-weight: 620;
}

.nav-item.active i {
  color: var(--accent);
}

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.admin-chip {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  padding: 7px;
  border-radius: 6px;
  background: #171717;
}

.admin-chip > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  background: #0e0e0e;
  font-weight: 700;
}

.admin-chip > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.admin-chip strong,
.admin-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-chip strong {
  color: var(--text);
  font-size: 10.5px;
}

.admin-chip small {
  color: var(--faint);
  font-size: 8.5px;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  background: var(--canvas);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 20px;
  border-bottom: 1px solid #202020;
  background: rgba(13, 13, 13, .95);
  backdrop-filter: blur(12px);
}

.topbar > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.breadcrumb {
  color: var(--faint);
  font: 600 9.5px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.breadcrumb b {
  color: #b8b8b8;
}

.page-context {
  color: #4e4e4e;
  font: 500 8px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.connection-pill,
.badge {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  background: #151515;
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.connection-pill > i,
.status-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--faint);
}

.connection-pill.online {
  border-color: rgba(120, 165, 138, .28);
  background: var(--green-soft);
  color: #a0c0ac;
}

.connection-pill.online > i,
.status-dot.ok {
  background: var(--green);
}

.connection-pill.error,
.badge.danger {
  border-color: rgba(211, 110, 104, .3);
  background: var(--red-soft);
  color: #df918c;
}

.connection-pill.error > i,
.status-dot.error {
  background: var(--red);
}

.status-dot.warn {
  background: var(--amber);
}

.page-stage {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px clamp(18px, 3vw, 38px) 64px;
}

.page {
  display: none;
  animation: page-in .16s ease both;
}

.page.active {
  display: block;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  min-height: 66px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 7px 0 5px;
  color: var(--strong);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -.03em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metrics-grid article {
  min-height: 102px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.metrics-grid span,
.metrics-grid small {
  color: var(--muted);
  font-size: 10px;
}

.metrics-grid strong {
  color: var(--strong);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.overview-grid,
.payment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
  gap: 10px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.panel > header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #111;
}

.panel > header h2 {
  margin: 0;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
}

.panel > header p {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.45;
}

.status-list {
  display: grid;
}

.status-list > div {
  min-height: 47px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 14px;
  border-top: 1px solid #202020;
}

.status-list > div:first-child {
  border-top: 0;
}

.status-list span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b8b8b8;
  font-size: 10.5px;
}

.status-list strong {
  color: var(--muted);
  font-size: 10px;
  font-weight: 580;
  text-align: right;
}

.console-panel {
  padding-bottom: 13px;
}

.console-panel > .button {
  margin: 0 13px;
}

.console-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 18px 14px;
}

.terminal-symbol {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0d0d0d;
  color: var(--accent);
  font: 750 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.console-body > div {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.console-body strong {
  color: var(--text);
  font-size: 11px;
}

.console-body code {
  overflow: hidden;
  color: var(--faint);
  font: 8.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-panel {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: auto;
}

th {
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: #0f0f0f;
  color: #606060;
  text-align: left;
  font: 700 8px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  min-height: 55px;
  padding: 10px 12px;
  border-top: 1px solid #222;
  color: #bdbdbd;
  font-size: 10.5px;
  vertical-align: middle;
}

tbody tr:hover {
  background: #1b1b1b;
}

td strong,
td small {
  display: block;
}

td strong {
  max-width: 270px;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount-credit {
  color: var(--green);
}

.amount-debit {
  color: var(--red);
}

td small {
  max-width: 300px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--faint);
  font-size: 8.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-row td {
  height: 120px;
  color: var(--faint);
  text-align: center;
}

.badge {
  min-height: 22px;
  font-size: 8.5px;
}

.badge.ok {
  border-color: rgba(120, 165, 138, .3);
  background: var(--green-soft);
  color: #9ebca8;
}

.badge.warn {
  border-color: rgba(200, 155, 98, .3);
  background: var(--amber-soft);
  color: #d0ad7e;
}

.badge.accent {
  border-color: rgba(217, 119, 87, .35);
  background: var(--accent-soft);
  color: #dfa089;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.table-action {
  min-height: 25px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 7px;
  background: #181818;
  color: var(--muted);
  cursor: pointer;
  font-size: 8.5px;
  white-space: nowrap;
}

.table-action:hover {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--text);
}

.table-action.danger {
  color: #d98b86;
}

.split-grid {
  display: grid;
  gap: 10px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.inline-form input {
  width: 230px;
  min-height: 34px;
}

.usage-filter {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 9px;
  margin-bottom: 12px;
  padding: 12px;
}

.usage-filter label {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.usage-filter label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 620;
}

.usage-filter input,
.usage-filter select {
  min-height: 34px;
  font-size: 10px;
}

.usage-filter-actions {
  flex-wrap: nowrap;
}

.usage-metrics {
  margin-bottom: 12px;
}

.cell-note {
  max-width: 150px;
}

.payment-grid {
  align-items: start;
}

.facts {
  display: grid;
  padding: 5px 14px;
}

.facts > div {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid #222;
}

.facts > div:first-child {
  border-top: 0;
}

.facts span {
  color: var(--muted);
  font-size: 10px;
}

.facts strong {
  color: var(--text);
  font-size: 10.5px;
  text-align: right;
}

.stack-form.compact {
  padding: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.order-result {
  margin: 0 14px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px;
  background: #0e0e0e;
  color: var(--muted);
  font: 9px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.order-result.empty {
  border-style: dashed;
  color: var(--faint);
}

/* Dialogs */

.dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0;
  background: var(--sidebar);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, .74);
  backdrop-filter: blur(7px);
}

.dialog > form {
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--border);
  background: #111;
}

.dialog header h2 {
  margin: 6px 0 4px;
  color: var(--strong);
  font-size: 18px;
  font-weight: 650;
}

.dialog header p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.dialog-fields {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  padding: 18px 20px;
}

.dialog-fields label.span-2,
.dialog-fields fieldset.span-2 {
  grid-column: 1 / -1;
}

.dialog-fields fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
}

.dialog-fields legend {
  padding: 0 5px;
  color: #bcbcbc;
  font-size: 10px;
  font-weight: 620;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.check-option {
  min-width: 0;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #101010;
  cursor: pointer;
}

.check-option:hover {
  background: var(--hover);
}

.check-option input {
  width: 15px;
  min-height: 15px;
  accent-color: var(--accent);
}

.check-option span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkbox-row {
  display: flex !important;
  grid-column: 1 / -1;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px;
  background: #101010;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.dialog .form-message {
  padding: 0 20px;
}

.dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 13px 20px 17px;
  border-top: 1px solid var(--border);
  background: #111;
}

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
}

.confirm-dialog > form {
  grid-template-rows: auto auto;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 7px;
  pointer-events: none;
}

.toast {
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--green);
  border-radius: 7px;
  background: #1b1b1b;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
  font-size: 10.5px;
  line-height: 1.45;
  animation: toast-in .15s ease both;
}

.toast.error {
  border-left-color: var(--red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .usage-filter {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid,
  .payment-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand,
  .sidebar-foot {
    display: none;
  }

  .nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 7px;
  }

  .nav-label {
    display: none;
  }

  .nav-item {
    min-width: max-content;
    grid-template-columns: auto auto;
    padding: 0 9px;
  }

  .topbar {
    top: 49px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form {
    align-items: stretch;
  }

  .inline-form input {
    width: 100%;
  }

  .usage-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-fields,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .dialog-fields label.span-2,
  .dialog-fields fieldset.span-2 {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .usage-filter {
    grid-template-columns: 1fr;
  }

  .login-view {
    padding: 0;
  }

  .login-card {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    padding: 22px;
  }

  .topbar {
    padding: 8px 11px;
  }

  .page-stage {
    padding: 20px 11px 48px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar .connection-pill {
    display: none;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .dialog {
    width: 100vw;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .dialog > form {
    max-height: 100vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* --------------------------------------------------------------------------
   Hi Code Console v2 — responsive business console and multi-theme layer.
   The rules below intentionally replace the legacy terminal-like presentation
   while retaining its proven table, dialog and form primitives.
   -------------------------------------------------------------------------- */

* { scrollbar-color: var(--border-strong) transparent; }
html, body { background: var(--canvas); color: var(--text); }
body { overflow-x: hidden; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline-color: rgba(var(--accent-rgb), .65);
}
.button {
  min-height: 38px;
  border-radius: 10px;
  padding: 0 15px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 1px 1px rgba(20, 35, 60, .04);
}
.button.subtle, .table-action, .icon-button { background: var(--panel-2); }
.button.primary, .button.primary:hover:not(:disabled):not(.disabled) { color: var(--on-accent); }
.button.danger { color: var(--red); }
.icon-button {
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: 11px;
  background: var(--accent-soft);
}
.brand-mark i { color: var(--muted); }
.brand-mark.large { width: 74px; height: 74px; border-radius: 23px; font-size: 27px; box-shadow: 0 20px 42px rgba(var(--accent-rgb), .22); }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .12em; }

.login-view {
  padding: clamp(18px, 5vw, 64px);
  background:
    radial-gradient(circle at 12% 15%, rgba(var(--accent-rgb), .13), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(var(--accent-rgb), .08), transparent 28%),
    var(--canvas);
}
.login-shell {
  width: min(940px, 100%);
  min-height: 580px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .95fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-visual {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  overflow: hidden;
  padding: 56px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 12%, var(--panel)), var(--panel-2));
  text-align: center;
}
.login-visual > *:not(.login-orbit) { position: relative; z-index: 2; }
.login-visual > strong { color: var(--strong); font-size: 26px; letter-spacing: -.03em; }
.login-visual > p { max-width: 330px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.login-orbit { position: absolute; border: 1px solid rgba(var(--accent-rgb), .17); border-radius: 50%; }
.orbit-one { width: 430px; height: 430px; }
.orbit-two { width: 290px; height: 290px; border-style: dashed; animation: orbit-spin 28s linear infinite; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.login-card {
  width: auto;
  align-self: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  padding: clamp(36px, 5vw, 64px);
  background: var(--panel);
  box-shadow: none;
}
.brand-lockup { padding-bottom: 24px; }
.brand-lockup strong, .sidebar-brand strong { font-size: 15px; }
.brand-lockup small, .sidebar-brand small { color: var(--faint); font-size: 10px; }
.login-copy { padding: 34px 0 24px; }
.login-copy h1 { margin: 12px 0 9px; font-size: 34px; }
.login-copy p { font-size: 14px; }
.stack-form { gap: 16px; }
.stack-form label, .dialog-fields label, .settings-form label { color: var(--text); font-size: 12px; }
input, select, textarea {
  min-height: 43px;
  border-radius: 10px;
  padding: 0 13px;
  background: var(--input);
  color: var(--text);
  font-size: 13px;
}
textarea { padding-top: 12px; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(var(--accent-rgb), .62);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"] {
  width: 18px !important;
  min-width: 18px !important;
  height: 18px;
  min-height: 18px !important;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  box-shadow: none;
}
.login-help { background: var(--panel-2); }
.login-help code { background: var(--hover); }
.security-note { font-size: 10px; }
.login-appearance-button {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 71;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(20, 35, 60, .12);
  cursor: pointer;
  font-size: 18px;
}
body:has(.admin-app:not(.hidden)) .login-appearance-button { display: none; }

.admin-app { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); background: var(--canvas); }
.sidebar { border-color: var(--border); background: var(--sidebar); box-shadow: 6px 0 30px rgba(30, 50, 80, .035); }
.sidebar-brand {
  min-height: 82px;
  padding: 20px 20px 17px;
  background: var(--sidebar);
}
.sidebar-close { display: none; margin-left: auto; }
.nav { gap: 3px; padding: 12px 12px 24px; }
.nav-label {
  margin: 19px 11px 7px;
  color: var(--faint);
  font: 750 10px/1.2 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  letter-spacing: .1em;
}
.nav-item {
  min-height: 43px;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 8px;
  border-radius: 11px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13.5px;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}
.nav-item i {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--faint);
  font: 600 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.nav-item:hover { background: var(--hover); color: var(--strong); transform: translateX(1px); }
.nav-item.active { background: var(--selected); color: var(--accent); font-weight: 690; }
.nav-item.active i { color: var(--accent); background: rgba(var(--accent-rgb), .1); }
.sidebar-foot { padding: 13px; background: linear-gradient(180deg, transparent, var(--sidebar) 20%); }
.admin-chip { border: 1px solid var(--border); border-radius: 12px; padding: 9px; background: var(--panel-2); }
.admin-chip > span { border-radius: 9px; background: var(--accent-soft); }
.admin-chip strong { font-size: 12px; }
.admin-chip small { font-size: 10px; }
.sidebar-scrim { display: none; }

.workspace { background: var(--canvas); }
.topbar {
  min-height: 70px;
  padding: 11px clamp(18px, 2.5vw, 34px);
  border-color: var(--border);
  background: var(--header);
}
.topbar-title { min-width: 0; display: flex !important; align-items: center; gap: 12px; }
.topbar-title > div { display: grid; gap: 4px; }
.breadcrumb { font-family: inherit; font-size: 12px; }
.breadcrumb b { color: var(--strong); }
.page-context { color: var(--faint); font-family: inherit; font-size: 10px; }
.mobile-menu { display: none; }
.connection-pill, .badge { background: var(--panel-2); color: var(--muted); }
.connection-pill.online { color: var(--green); }
.connection-pill.error, .badge.danger { color: var(--red); }

.section-tabs {
  position: sticky;
  top: 70px;
  z-index: 18;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 8px clamp(18px, 3.2vw, 48px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--header) 94%, transparent);
  backdrop-filter: blur(14px);
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs:empty, .section-tabs.hidden { display: none; }

.section-tab {
  min-height: 34px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 630;
  white-space: nowrap;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}

.section-tab:hover {
  border-color: var(--border);
  background: var(--hover);
  color: var(--strong);
}

.section-tab.active {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
  background: var(--selected);
  color: var(--accent);
}

.page-stage { width: min(1540px, 100%); padding: 34px clamp(18px, 3.2vw, 48px) 76px; }
.page-head { min-height: 76px; align-items: center; margin-bottom: 24px; }
.page-head h1 { margin: 8px 0 7px; font-size: clamp(26px, 2.2vw, 34px); font-weight: 720; }
.page-head p { max-width: 830px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.hero-head { padding: 4px 0 3px; }
.updated-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
}
.metrics-grid { gap: 14px; margin-bottom: 16px; }
.metrics-grid article {
  position: relative;
  min-height: 126px;
  gap: 9px;
  overflow: hidden;
  border-radius: 16px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 4px 18px rgba(30, 50, 80, .035);
}
.metrics-grid article::after {
  content: "";
  position: absolute;
  right: -32px;
  top: -42px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--accent-soft);
}
.metrics-grid span, .metrics-grid small { font-size: 11px; }
.metrics-grid strong { color: var(--strong); font-size: 30px; }
.overview-grid, .payment-grid { gap: 15px; }
.split-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.panel {
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 4px 18px rgba(30, 50, 80, .035);
}
.panel > header { min-height: 70px; padding: 16px 19px; background: var(--panel); }
.panel > header h2 { color: var(--strong); font-size: 15px; }
.panel > header p { color: var(--muted); font-size: 11px; }
.status-list > div, .facts > div { border-color: var(--border); }
.status-list > div { min-height: 56px; padding: 0 19px; }
.status-list span { color: var(--text); font-size: 12px; }
.status-list strong { font-size: 11px; }
.console-body { padding: 22px 19px; }
.terminal-symbol { width: 46px; height: 46px; border-radius: 12px; background: var(--panel-2); }
.console-body strong { font-size: 13px; }
.console-body code { color: var(--faint); font-size: 10px; }
.console-panel > .button { margin: 0 19px; }

table { min-width: 820px; }
th {
  height: 44px;
  padding: 0 16px;
  background: var(--panel-2);
  color: var(--faint);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: .035em;
}
td { min-height: 64px; padding: 13px 16px; border-color: var(--border); color: var(--text); font-size: 12px; }
tbody tr:hover { background: var(--hover); }
td strong { color: var(--strong); font-size: 12.5px; }
td small { color: var(--faint); font-size: 10px; }
.badge { min-height: 25px; padding: 0 9px; font-size: 10px; }
.badge.ok { color: var(--green); }
.badge.warn { color: var(--amber); }
.badge.accent { color: var(--accent); }
.table-action { min-height: 29px; border-radius: 8px; padding: 0 9px; color: var(--muted); font-size: 10px; }
.table-action.danger { color: var(--red); }
.inline-form { flex-wrap: wrap; }
.inline-form input, .inline-form select { width: 220px; min-height: 38px; }
.usage-filter { grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; padding: 17px; }
.usage-filter label > span { font-size: 11px; }
.usage-filter input, .usage-filter select { min-height: 40px; font-size: 12px; }
.facts { padding: 7px 19px; }
.facts > div { min-height: 54px; }
.facts span { font-size: 12px; }
.facts strong { font-size: 12px; }
.order-result { border-radius: 10px; background: var(--panel-2); }

.policy-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px; }
.policy-row {
  align-items: center;
  gap: 13px;
  min-height: 82px;
  border-radius: 13px;
  padding: 14px;
  background: var(--panel-2);
}
.policy-row:hover { border-color: var(--accent); }
.policy-copy strong { color: var(--strong); font-size: 13px; }
.policy-copy small { color: var(--muted); font-size: 11px; }

.callout-list { display: grid; padding: 8px 19px; }
.callout-list > div { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--border); }
.callout-list > div:first-child { border-top: 0; }
.callout-list b { color: var(--strong); font-size: 12px; }
.callout-list span { color: var(--muted); font-size: 11px; text-align: right; }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 22px; }
.settings-form label { min-width: 0; display: grid; gap: 7px; }
.settings-form .span-full { grid-column: 1 / -1; }
.settings-form-section { display: grid; gap: 5px; padding: 4px 0 12px; border-bottom: 1px solid var(--border); }
.settings-form-section:not(:first-child) { margin-top: 8px; padding-top: 18px; }
.settings-form-section h2 { margin: 0; color: var(--strong); font-size: 17px; }
.settings-form-section p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.branding-layout, .settings-layout { align-items: start; }
.preview-card, .brand-preview { min-height: 360px; display: grid; align-content: center; justify-items: center; gap: 15px; padding: 35px; text-align: center; }
.preview-card h2, .brand-preview h2 { margin: 0; color: var(--strong); font-size: 27px; }
.preview-card p, .brand-preview p { max-width: 420px; margin: 0; color: var(--muted); line-height: 1.8; }
.support-preview-card { align-content: start; text-align: left; }
.support-preview-card > .eyebrow, .support-preview-card > h2, .support-preview-card > p { justify-self: stretch; }
.support-preview-block { width: 100%; display: grid; gap: 9px; margin-top: 8px; border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--panel-2); }
.support-preview-block .badge { justify-self: start; }
.support-preview-block h3 { margin: 0; color: var(--strong); font-size: 14px; }
.support-preview-block p { max-width: none; white-space: pre-wrap; }
.support-preview-block code { overflow-wrap: anywhere; color: var(--faint); font-size: 10px; }
.support-preview-card .button-row { width: 100%; }

.base-agents-panel table { min-width: 1080px; }

.catalog-receipt-note {
  max-width: 360px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.55;
  text-align: right;
}

.base-agent-version-cell strong {
  color: var(--accent);
  font: 720 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.base-agent-sync-cell { min-width: 210px; }
.base-agent-sync-cell small { max-width: none; white-space: normal; }
.base-agent-sync-cell .badge + small { margin-top: 7px; }
.support-preview-card .button { text-decoration: none; }
.support-preview-card .button.disabled { pointer-events: none; opacity: .48; }
.brand-preview-mark { width: 82px; height: 82px; display: grid; place-items: center; border-radius: 25px; background: var(--accent); color: var(--on-accent); font-size: 34px; font-weight: 800; box-shadow: 0 20px 44px rgba(var(--accent-rgb), .24); }
.brand-preview small { color: var(--faint); }
.theme-option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 18px; }
.theme-option-grid.compact { padding: 10px 0 17px; }
.theme-option {
  min-height: 66px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.theme-option[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-preview { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: linear-gradient(135deg, var(--preview-bg, #fff) 50%, var(--preview-panel, #eef2f8) 50%); }
.theme-option b { display: block; font-size: 12px; }
.theme-option small { display: block; margin-top: 3px; color: var(--faint); font-size: 9px; }
.accent-option-grid { display: flex; flex-wrap: wrap; gap: 11px; padding: 0 18px 20px; }
.appearance-popover .accent-option-grid { padding: 0; }
.accent-option {
  width: 32px;
  height: 32px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}
.accent-option[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--swatch); }
.field-label { display: block; margin: 4px 0 0; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.appearance-popover {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 70;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.appearance-popover-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.appearance-popover-head > div { display: grid; gap: 3px; }
.appearance-popover-head strong { color: var(--strong); font-size: 15px; }
.appearance-popover-head small { color: var(--faint); font-size: 10px; }

.dialog { border-radius: 18px; background: var(--panel); }
.dialog header, .dialog footer { background: var(--panel); }
.dialog::backdrop { background: rgba(17, 28, 45, .58); }
.dialog-fields label, .dialog-fields legend { color: var(--text); }
.check-option, .checkbox-row { background: var(--panel-2); }
.check-option input, .checkbox-row input { width: 16px !important; min-width: 16px !important; min-height: 16px !important; height: 16px; }
.toast { border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }

@media (max-width: 1180px) {
  :root { --sidebar-width: 248px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-filter { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .overview-grid, .payment-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .admin-app { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    z-index: 61;
    width: min(310px, calc(100vw - 48px));
    height: 100vh;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-brand, .sidebar-foot { display: flex; }
  .sidebar-foot { display: block; }
  .sidebar-close { display: grid; }
  .nav { display: grid; overflow-x: hidden; overflow-y: auto; padding: 12px 12px 24px; }
  .nav-label { display: block; }
  .nav-item { min-width: 0; grid-template-columns: 27px minmax(0, 1fr); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(16, 28, 45, .42); backdrop-filter: blur(2px); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .topbar { top: 0; }
  .section-tabs { top: 70px; padding-inline: 14px; }
  .mobile-menu { display: grid; }
  .split-grid, .branding-layout, .settings-layout { grid-template-columns: 1fr; }
  .policy-list { grid-template-columns: 1fr; }
  .appearance-button > span:last-child { display: none; }
}

@media (max-width: 680px) {
  .catalog-receipt-note { max-width: none; text-align: left; }
  .login-view { padding: 0; }
  .login-shell { min-height: 100vh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .login-visual { display: none; }
  .login-card { min-height: 100vh; display: grid; align-content: center; padding: 28px; }
  .page-stage { padding: 25px 14px 52px; }
  .topbar { padding: 10px 12px; }
  .section-tabs { top: 70px; min-height: 48px; padding-block: 7px; }
  .topbar .connection-pill { display: none; }
  .page-head { flex-direction: column; align-items: stretch; gap: 13px; }
  .page-head h1 { font-size: 27px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .usage-filter, .settings-form { grid-template-columns: 1fr; }
  .settings-form .span-full { grid-column: auto; }
  .inline-form { align-items: stretch; }
  .inline-form input, .inline-form select { width: 100%; }
  .appearance-popover { top: 64px; right: 12px; }
  .theme-option-grid { grid-template-columns: 1fr; }
}

/* Account access and billing details */
.users-panel table { min-width: 1240px; }
.user-device-cell { min-width: 112px; }
.user-device-cell small { margin-top: 6px; }
.device-count-button {
  min-width: 54px;
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.detail-dialog { width: min(1040px, calc(100vw - 32px)); }
.detail-dialog-shell {
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.device-dialog .detail-dialog-shell { grid-template-rows: auto minmax(0, 1fr) auto; }
.detail-dialog-body { min-height: 0; overflow: auto; padding: 18px 20px 20px; }
.detail-summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0 13px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
}
.detail-table-wrap { border: 1px solid var(--border); border-radius: 12px; }
.detail-table-wrap table { min-width: 820px; }
.device-dialog .detail-table-wrap th:last-child,
.device-dialog .detail-table-wrap td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 104px;
  background: var(--panel);
  box-shadow: -12px 0 18px -18px rgba(17, 28, 45, .72);
}
.device-dialog .detail-table-wrap th:last-child {
  z-index: 3;
  background: var(--panel-2);
}
.device-dialog .detail-table-wrap tbody tr:hover td:last-child { background: var(--hover); }
.detail-dialog footer { align-items: center; justify-content: space-between; }
.detail-footnote { max-width: 620px; color: var(--faint); font-size: 10px; line-height: 1.55; }
.record-tabs {
  display: inline-flex;
  justify-self: start;
  gap: 3px;
  margin: 14px 20px 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  background: var(--panel-2);
}
.record-tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
}
.record-tabs button.active { background: var(--panel); color: var(--strong); box-shadow: 0 1px 4px rgba(17, 28, 45, .1); }

@media (max-width: 680px) {
  .detail-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .detail-dialog-shell { max-height: calc(100vh - 20px); }
  .detail-dialog-body { padding: 12px; }
  .record-tabs { width: calc(100% - 24px); margin: 12px; }
  .record-tabs button { flex: 1; }
  .detail-dialog footer { align-items: stretch; flex-direction: column; }
  .detail-dialog footer .button-row { width: 100%; }
  .detail-dialog footer .button-row .button { flex: 1; }
}

/* Read-only payment integration and exact activation trace */
.wechat-config-panel { margin-top: 16px; }
.wechat-config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 0;
}
.wechat-config-layout .readonly-facts {
  padding: 12px 20px;
  border-right: 1px solid var(--border);
}
.wechat-config-layout .readonly-facts > div { min-height: 50px; }
.wechat-config-layout .readonly-facts strong {
  max-width: 68%;
  overflow-wrap: anywhere;
  font-size: 11px;
}
.integration-guide {
  align-self: stretch;
  padding: 22px;
  background: var(--panel-2);
  color: var(--muted);
}
.integration-guide > strong { color: var(--strong); font-size: 14px; }
.integration-guide p,
.integration-guide li { font-size: 11px; line-height: 1.65; }
.integration-guide p { margin: 9px 0 0; }
.integration-guide ul { margin: 14px 0 0; padding-left: 20px; }
.integration-guide li + li { margin-top: 7px; }
.integration-guide.ready {
  background: color-mix(in srgb, var(--green) 7%, var(--panel));
}
.integration-restart-note {
  border-top: 1px solid var(--border);
  padding-top: 13px;
  color: var(--strong);
  font-weight: 650;
}

.activation-lookup-panel { margin-bottom: 16px; }
.activation-lookup-panel > header { flex-wrap: wrap; }
.activation-lookup-form { margin-left: auto; }
.activation-lookup-form input { width: min(300px, 36vw); }
.activation-lookup-result { padding: 20px; }
.activation-lookup-result.empty { min-height: 110px; display: grid; place-items: center; }
.lookup-empty-state { padding: 14px; text-align: center; }
.lookup-empty-state strong { color: var(--strong); font-size: 13px; }
.lookup-empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.activation-lookup-heading,
.linked-account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.activation-lookup-heading h3 { margin: 6px 0 0; color: var(--strong); font-size: 21px; letter-spacing: .015em; }
.lookup-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: 17px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
}
.lookup-facts > div,
.linked-account-details > div {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 13px 14px;
  background: var(--panel);
}
.lookup-facts span,
.linked-account-details span { color: var(--faint); font-size: 10px; }
.lookup-facts strong,
.linked-account-details strong { overflow-wrap: anywhere; color: var(--strong); font-size: 11.5px; }
.linked-account-section { margin-top: 20px; }
.linked-account-section h4 { margin: 0; color: var(--strong); font-size: 14px; }
.credential-safety-note { margin: 7px 0 14px; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.linked-account-card,
.linked-account-empty {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px;
  background: var(--panel-2);
}
.linked-account-head > div { min-width: 0; display: grid; gap: 5px; }
.linked-account-head strong { overflow-wrap: anywhere; color: var(--strong); font-size: 13px; }
.linked-account-head span:not(.badge) { overflow-wrap: anywhere; color: var(--muted); font-size: 10.5px; }
.linked-account-details {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}
.linked-account-actions { margin-top: 14px; }
.linked-account-empty strong { color: var(--strong); font-size: 12px; }
.linked-account-empty p { margin: 6px 0 0; color: var(--muted); font-size: 10.5px; }

@media (max-width: 1100px) {
  .wechat-config-layout { grid-template-columns: 1fr; }
  .wechat-config-layout .readonly-facts { border-right: 0; border-bottom: 1px solid var(--border); }
  .lookup-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .linked-account-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .activation-lookup-form { width: 100%; margin-left: 0; }
  .activation-lookup-form input { width: 100%; }
  .activation-lookup-form .button { width: 100%; }
  .activation-lookup-result { padding: 13px; }
  .lookup-facts,
  .linked-account-details { grid-template-columns: 1fr; }
  .wechat-config-layout .readonly-facts { padding: 9px 13px; }
  .wechat-config-layout .readonly-facts > div { align-items: flex-start; flex-direction: column; padding: 10px 0; }
  .wechat-config-layout .readonly-facts strong { max-width: 100%; text-align: left; }
  .integration-guide { padding: 17px; }
}

/* Model pricing: server-synced New API snapshots or explicit per-request pricing. */
.model-pricing-cell {
  min-width: 220px;
}

.model-pricing-cell .badge {
  margin-bottom: 7px;
}

.model-pricing-cell .pricing-value {
  display: block;
  color: var(--strong);
  font-size: 11.5px;
  line-height: 1.45;
}

.model-pricing-cell .cell-note,
.model-pricing-cell .pricing-error {
  display: block;
  max-width: 250px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.model-pricing-cell .pricing-error {
  color: var(--red);
}

.model-pricing-editor {
  display: grid;
  gap: 13px;
  padding: 14px !important;
  background: color-mix(in srgb, var(--panel-2) 66%, var(--panel));
}

.pricing-mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.dialog-fields .pricing-mode-option {
  min-width: 0;
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel);
  cursor: pointer;
}

.dialog-fields .pricing-mode-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pricing-mode-option input {
  width: 17px !important;
  min-width: 17px !important;
  min-height: 17px !important;
  height: 17px;
  flex: 0 0 17px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.pricing-mode-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.pricing-mode-heading {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pricing-mode-heading b {
  color: var(--strong);
  font-size: 12px;
}

.pricing-mode-heading em {
  border-radius: 999px;
  padding: 3px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 8px;
  font-style: normal;
  font-weight: 750;
}

.pricing-mode-copy small,
.pricing-help {
  color: var(--muted);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.5;
}

.pricing-custom-panel,
.pricing-sync-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  background: var(--panel);
}

.pricing-custom-panel {
  display: grid;
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  align-items: end;
  gap: 14px;
}

.pricing-help {
  margin: 0 0 4px;
}

.pricing-sync-panel {
  display: grid;
  gap: 11px;
}

.pricing-sync-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.pricing-preview-button {
  min-height: 43px;
  background: var(--panel-2) !important;
}

.pricing-preview-summary {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-2);
}

.pricing-preview-summary.ready {
  border-style: solid;
  border-color: color-mix(in srgb, var(--green) 35%, var(--border));
}

.pricing-preview-summary.stale {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--border));
}

.pricing-summary-label {
  color: var(--faint);
  font-size: 9px;
  font-weight: 720;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pricing-preview-summary strong {
  color: var(--strong);
  font-size: 12.5px;
  line-height: 1.45;
}

.pricing-preview-summary small {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}

.pricing-preview-error {
  margin: 0;
  border-radius: 9px;
  padding: 9px 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

@media (max-width: 680px) {
  .pricing-mode-options,
  .pricing-custom-panel,
  .pricing-sync-toolbar {
    grid-template-columns: 1fr;
  }

  .pricing-preview-button {
    width: 100%;
  }
}
