:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --border: #dfe5ec;
  --border-strong: #c9d2de;
  --text: #17202b;
  --text-soft: #526071;
  --text-muted: #7b8796;
  --primary: #0f6fed;
  --primary-hover: #0b58bd;
  --primary-soft: #eaf2ff;
  --success: #27845c;
  --success-soft: #e8f5ee;
  --warning: #ae7222;
  --warning-soft: #fff3dd;
  --danger: #b34444;
  --danger-soft: #fbecec;
  --violet: #6c5aa7;
  --violet-soft: #f0edfa;
  --shadow: 0 8px 28px rgba(28, 42, 51, 0.08);
  --sidebar-width: 236px;
  --radius: 7px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark {
  --bg: #10171e;
  --surface: #18212a;
  --surface-muted: #202b35;
  --border: #2d3a46;
  --border-strong: #40505e;
  --text: #edf3f7;
  --text-soft: #bec9d2;
  --text-muted: #8998a6;
  --primary: #67a7ff;
  --primary-hover: #85b8ff;
  --primary-soft: #183554;
  --success: #64c596;
  --success-soft: #17392d;
  --warning: #e3aa5a;
  --warning-soft: #3a2b17;
  --danger: #ef8989;
  --danger-soft: #402326;
  --violet: #b2a1ed;
  --violet-soft: #302947;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15, 111, 237, 0.22); outline-offset: 2px; }
[hidden] { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-shell::before { content: ""; position: fixed; inset: 0 0 auto; height: 5px; background: var(--primary); }
.login-shell::after { content: ""; position: fixed; left: 0; top: 0; width: 18%; height: 5px; background: #e95f8f; }
.login-panel { width: min(100%, 410px); display: grid; gap: 28px; padding: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.login-panel h1 { margin: 5px 0 0; font-size: 27px; line-height: 1.25; letter-spacing: 0; }
.local-note { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; }
.token-location { margin: 6px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.token-location code { color: var(--text-soft); font-family: "Cascadia Mono", Consolas, monospace; }
.brand-logo { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 6px; background: white; object-fit: cover; }
.brand-logo--large { width: 62px; height: 62px; border-color: var(--border-strong); }
.eyebrow { margin: 0; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0; }

.stack-form, .form-fields { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; color: var(--text-soft); font-size: 13px; font-weight: 650; }
.field small { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.field input, .field select, .search-field input, .select-field select { width: 100%; height: 42px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); padding: 0 12px; transition: border-color 150ms, box-shadow 150ms; }
.field textarea { width: 100%; min-height: 66px; resize: vertical; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); padding: 10px 12px; line-height: 1.5; transition: border-color 150ms, box-shadow 150ms; }
.field input:hover, .field select:hover, .search-field input:hover, .select-field select:hover { border-color: var(--text-muted); }
.field textarea:hover { border-color: var(--text-muted); }
.field input:focus, .field select:focus, .search-field input:focus, .select-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 111, 237, 0.1); outline: none; }
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 111, 237, 0.1); outline: none; }
.field input::placeholder, .field textarea::placeholder, .search-field input::placeholder, .ticket-reply-input::placeholder { color: var(--text-muted); font-weight: 400; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.input-action { position: absolute; right: 5px; top: 5px; }
.number-field { display: flex; width: min(100%, 240px); align-items: center; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); overflow: hidden; }
.number-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 111, 237, 0.1); }
.number-field input { border: 0; border-radius: 0; box-shadow: none !important; }
.number-field span { padding: 0 12px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.form-error { min-height: 17px; margin: -10px 0 0; color: var(--danger); font-size: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 11px; font-weight: 500; }
.checkbox-field input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

.button, .icon-button, .text-button, .nav-item { border: 0; cursor: pointer; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border-radius: 6px; font-size: 13px; font-weight: 700; transition: background 150ms, border-color 150ms, color 150ms, transform 100ms; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.62; }
.button--primary { background: var(--primary); color: white; }
.button--primary:hover { background: var(--primary-hover); }
.button--secondary { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-soft); }
.button--secondary:hover { border-color: var(--text-muted); background: var(--surface-muted); color: var(--text); }
.button--ghost { background: transparent; color: var(--text-soft); }
.button--ghost:hover { background: var(--surface-muted); color: var(--text); }
.button--danger { background: var(--danger); color: white; }
.button--danger:hover { background: #983737; }
.button--wide { width: 100%; }
.icon-button { display: inline-grid; width: 34px; height: 34px; padding: 0; place-items: center; border-radius: 5px; background: transparent; color: var(--text-muted); }
.icon-button:hover { background: var(--surface-muted); color: var(--text); }
.text-button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 0; background: transparent; color: var(--primary); font-size: 13px; font-weight: 700; }
.text-button svg { width: 15px; height: 15px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); min-height: 0; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); padding: 22px 14px 16px; transition: width 180ms ease, padding 180ms ease; }
.brand { display: flex; min-height: 42px; align-items: center; gap: 11px; padding: 0 8px; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0; }
.brand span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.side-nav { display: grid; min-height: 0; flex: 1; align-content: start; gap: 4px; margin: 22px -4px 10px 0; padding-right: 4px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.nav-section-label { display: block; padding: 0 11px 5px; color: var(--text-muted); font-size: 10px; font-weight: 700; line-height: 1.4; }
.nav-section-label--system { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.nav-item { display: grid; width: 100%; min-height: 42px; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; border-radius: 6px; background: transparent; color: var(--text-soft); padding: 0 11px; text-align: left; font-size: 13px; font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.nav-count { min-width: 22px; height: 20px; border-radius: 10px; background: var(--surface-muted); color: var(--text-muted); padding: 2px 6px; text-align: center; font-size: 11px; }
.nav-item.is-active .nav-count { background: var(--surface); color: var(--primary); }
.sidebar-footer { display: grid; gap: 10px; margin-top: auto; }
.service-indicator { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); color: var(--text-muted); margin: 0 8px 8px; padding: 0 2px 16px; font-size: 11px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #a6b0b6; box-shadow: 0 0 0 3px rgba(166, 176, 182, 0.15); }
.status-dot.is-ok { background: var(--success); box-shadow: 0 0 0 3px rgba(39, 132, 92, 0.13); }
.status-dot.is-error { background: var(--danger); box-shadow: 0 0 0 3px rgba(179, 68, 68, 0.13); }
.status-dot.is-warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(174, 114, 34, 0.13); }
.mobile-header, .mobile-menu { display: none; }

.main-content { position: relative; min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); background: var(--bg); padding: 32px clamp(24px, 3.5vw, 52px) 52px; transition: margin-left 180ms ease; }
.main-content::before { content: ""; position: absolute; inset: 0 0 auto; height: 116px; border-bottom: 1px solid var(--border); background: var(--surface); pointer-events: none; }
.view { position: relative; z-index: 1; width: min(100%, 1400px); min-width: 0; margin: 0 auto; }
.page-header { display: flex; min-height: 60px; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-header h1 { margin: 4px 0 0; font-size: 25px; line-height: 1.25; letter-spacing: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.health-badge { display: inline-flex; min-height: 34px; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); color: var(--text-soft); padding: 0 13px; font-size: 12px; font-weight: 650; }
.health-badge.is-ok { border-color: #c9e5d7; background: var(--success-soft); color: var(--success); }
.health-badge.is-error { border-color: #f0cccc; background: var(--danger-soft); color: var(--danger); }
.health-badge.is-warning { border-color: #ead4b2; background: #fff7e8; color: #8a5a18; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { position: relative; min-height: 146px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.metric-card strong { display: block; max-width: 100%; margin-top: 17px; overflow: hidden; font-size: 27px; font-variant-numeric: tabular-nums; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.metric-card strong span { color: var(--text-muted); font-size: 10px; font-weight: 700; }
.metric-card small { display: block; min-height: 17px; margin-top: 3px; overflow: hidden; color: var(--text-muted); font-size: 11px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.metric-icon { position: absolute; right: 17px; top: 17px; display: grid; width: 34px; height: 34px; place-items: center; border-radius: 6px; }
.metric-icon svg { width: 17px; height: 17px; }
.metric-icon--blue { background: var(--primary-soft); color: var(--primary); }
.metric-icon--green { background: var(--success-soft); color: var(--success); }
.metric-icon--amber { background: var(--warning-soft); color: var(--warning); }
.metric-icon--violet { background: var(--violet-soft); color: var(--violet); }
.metric-icon--rose { background: #fbecef; color: #bd5268; }
.metric-icon--indigo { background: #eceffd; color: #5667b8; }
.metric-heading { display: flex; min-height: 34px; align-items: flex-start; padding-right: 42px; color: var(--text-soft); font-size: 12px; font-weight: 650; }
.trend { margin-left: 4px; color: var(--success); font-size: 10px; white-space: nowrap; }

.dashboard-metrics { margin-bottom: 14px; }
.analytics-toolbar { display: flex; min-height: 58px; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 8px 12px; }
.analytics-control { display: flex; min-width: 0; align-items: center; gap: 9px; }
.analytics-control > span { color: var(--text-muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.analytics-control .select-field { width: 132px; }
.analytics-control--end { margin-left: auto; }
.analytics-grid { display: grid; grid-template-columns: minmax(310px, 0.9fr) minmax(0, 1.45fr); gap: 14px; margin-top: 14px; }
.analytics-panel { min-width: 0; min-height: 318px; overflow: hidden; }
.donut-layout { display: grid; min-width: 0; grid-template-columns: minmax(150px, 0.82fr) minmax(165px, 1fr); align-items: center; gap: 20px; margin-top: 13px; }
.donut-wrap { position: relative; width: 100%; min-width: 0; height: 228px; }
.donut-wrap canvas, .token-chart-wrap canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.model-distribution-list { display: grid; min-width: 0; align-content: center; gap: 0; }
.model-distribution-row { display: grid; min-width: 0; grid-template-columns: 8px minmax(0, 1fr) auto auto; align-items: center; gap: 7px; border-bottom: 1px solid var(--border); padding: 8px 0; color: var(--text-muted); font-size: 9px; }
.model-distribution-row:last-child { border-bottom: 0; }
.model-distribution-row strong { min-width: 0; overflow: hidden; color: var(--text-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.model-distribution-row span:nth-child(3) { white-space: nowrap; }
.model-distribution-row span:last-child { white-space: nowrap; }
.model-swatch { width: 8px; height: 8px; border-radius: 2px; }
.model-swatch--1 { background: #3b82f6; }
.model-swatch--2 { background: #10b981; }
.model-swatch--3 { background: #f59e0b; }
.model-swatch--4 { background: #ef6c7b; }
.model-swatch--5 { background: #7c6ee6; }
.model-swatch--6 { background: #18a7b8; }
.token-legend { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.token-legend > span { width: 8px; height: 8px; border-radius: 2px; }
.token-legend--input { background: #3b82f6; }
.token-legend--output { margin-left: 7px; background: #10b981; }
.token-chart-wrap { position: relative; width: 100%; min-width: 0; height: 244px; margin-top: 13px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 9px; color: var(--text-muted); font-size: 11px; }
.chart-empty svg { width: 27px; height: 27px; stroke-width: 1.4; }

.metric-card, .panel, .table-section, .endpoint-strip, .key-summary, .channel-summary, .monitor-hero, .channel-metric-grid article, .monitor-detail { box-shadow: 0 1px 2px rgba(28, 42, 51, 0.035); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 0.85fr); gap: 14px; margin-top: 14px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 20px; }
.panel-header, .section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-header h2, .section-header h2, .form-section h2 { margin: 0; font-size: 15px; letter-spacing: 0; }
.panel-header p, .section-header p, .form-section-heading p { margin: 5px 0 0; color: var(--text-muted); font-size: 11px; }
.chart-legend { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 11px; }
.chart-legend span { width: 8px; height: 8px; border-radius: 2px; background: var(--primary); }
.chart-wrap { position: relative; height: 230px; margin-top: 16px; }
.chart-wrap canvas { display: block; width: 100%; height: 100%; }
.connection-panel { display: flex; min-height: 320px; flex-direction: column; }
.connection-list { display: grid; gap: 0; margin: 12px 0 18px; }
.connection-list div { display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--border); padding: 12px 0; }
.connection-list dt { color: var(--text-muted); font-size: 11px; }
.connection-list dd { margin: 0; overflow: hidden; color: var(--text-soft); text-align: right; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; }
.connection-panel > .button { margin-top: auto; }

.table-section { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-section > .section-header { padding: 19px 20px; border-bottom: 1px solid var(--border); }
.table-wrap { position: relative; width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { height: 42px; background: var(--surface-muted); color: var(--text-muted); padding: 0 16px; text-align: left; font-size: 10px; font-weight: 700; white-space: nowrap; }
td { height: 53px; border-top: 1px solid var(--border); color: var(--text-soft); padding: 7px 16px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-muted); }
.align-right { text-align: right; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }
.primary-cell { color: var(--text); font-weight: 650; }
.secondary-line { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; font-weight: 400; }
.request-route { display: inline-flex; max-width: 260px; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-route strong { flex: 0 0 auto; color: var(--text-muted); font-size: 9px; }
.status-pill { display: inline-flex; min-width: 54px; min-height: 23px; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; padding: 2px 8px; font-size: 10px; font-weight: 700; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-pill--success { background: var(--success-soft); color: var(--success); }
.status-pill--error { background: var(--danger-soft); color: var(--danger); }
.status-pill--neutral { background: var(--surface-muted); color: var(--text-muted); }
.empty-state { display: grid; min-height: 225px; place-items: center; align-content: center; gap: 9px; color: var(--text-muted); }
.empty-state svg { width: 28px; height: 28px; stroke-width: 1.4; }
.empty-state strong { color: var(--text-soft); font-size: 13px; }

.channel-summary { display: grid; min-width: 0; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 17px 20px; }
.channel-summary h2 { margin: 0; font-size: 14px; }
.channel-summary p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.channel-summary-state { display: inline-flex; min-width: 104px; align-items: center; justify-content: center; gap: 9px; color: var(--text-soft); font-size: 12px; }
.channel-summary-state strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-table-section { margin-top: 14px; }
.channels-table { min-width: 760px; }
.channels-table th:nth-child(2) { width: 28%; }
.channels-table td code { display: block; max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channels-table .actions { display: flex; justify-content: flex-end; gap: 3px; }
.channels-table .actions .icon-button { color: var(--text-muted); }
.channels-table .actions .icon-button:hover { color: var(--primary); }

.monitor-hero { display: grid; min-width: 0; grid-template-columns: auto minmax(0, 1fr) minmax(180px, auto); align-items: center; gap: 15px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 20px; }
.monitor-signal { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 6px; background: var(--surface-muted); }
.monitor-signal .status-dot { width: 9px; height: 9px; }
.monitor-hero h2 { margin: 4px 0 0; font-size: 16px; }
.monitor-hero p:not(.eyebrow) { margin: 5px 0 0; color: var(--text-muted); font-size: 11px; }
.monitor-hero > code { min-width: 0; max-width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-muted); color: var(--text-soft); padding: 9px 11px; text-align: right; text-overflow: ellipsis; white-space: nowrap; font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }
.channel-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.channel-metric-grid article { min-width: 0; min-height: 106px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.channel-metric-grid span { display: block; color: var(--text-muted); font-size: 10px; font-weight: 650; }
.channel-metric-grid strong { display: block; margin-top: 16px; overflow: hidden; font-size: 20px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.monitor-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-top: 14px; overflow: hidden; }
.monitor-detail > div { display: grid; min-width: 0; grid-template-columns: minmax(86px, auto) minmax(0, 1fr); align-items: center; gap: 18px; min-height: 58px; padding: 12px 18px; }
.monitor-detail > div:nth-child(even) { border-left: 1px solid var(--border); }
.monitor-detail > div:nth-child(n + 3) { border-top: 1px solid var(--border); }
.monitor-detail span { color: var(--text-muted); font-size: 11px; }
.monitor-detail strong { min-width: 0; overflow: hidden; color: var(--text-soft); text-align: right; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.monitor-detail code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }

.key-toolbar { align-items: center; }
.endpoint-strip { display: grid; grid-template-columns: minmax(180px, 0.75fr) minmax(280px, 1.4fr) auto; align-items: center; gap: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 17px 20px; }
.endpoint-heading { display: flex; min-width: 0; align-items: center; gap: 12px; }
.endpoint-heading h2 { margin: 0; font-size: 14px; }
.endpoint-heading p { margin: 3px 0 0; color: var(--text-muted); font-size: 10px; }
.endpoint-value { display: flex; min-width: 0; align-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); padding: 4px 5px 4px 12px; }
.endpoint-value code { min-width: 0; flex: 1; overflow: hidden; color: var(--primary); text-overflow: ellipsis; white-space: nowrap; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; font-weight: 650; }
.deployment-note { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.model-endpoint-status { display: flex; min-width: 0; align-items: center; gap: 9px; color: var(--text-soft); font-size: 12px; }
.model-endpoint-status strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-toolbar { align-items: center; }
.models-table th:nth-child(1) { width: 48%; }
.models-table th:nth-child(2) { width: 14%; }
.models-table th:nth-child(3) { width: 20%; }
.model-id { color: var(--text); overflow-wrap: anywhere; white-space: normal; }
.model-owner { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-type { display: inline-flex; min-width: 46px; min-height: 23px; align-items: center; justify-content: center; border-radius: 5px; background: var(--primary-soft); color: var(--primary); padding: 2px 8px; font-size: 10px; font-weight: 700; }
.key-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-top: 12px; }
.key-summary > div { min-width: 0; padding: 14px 18px; }
.key-summary > div + div { border-left: 1px solid var(--border); }
.key-summary span { display: block; color: var(--text-muted); font-size: 10px; font-weight: 650; }
.key-summary strong { display: block; margin-top: 5px; overflow: hidden; font-size: 18px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.search-field { position: relative; display: block; width: min(100%, 250px); }
.search-field svg { position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; color: var(--text-muted); }
.search-field input { height: 40px; padding-left: 36px; font-size: 12px; }
.keys-table .actions { display: flex; justify-content: flex-end; gap: 3px; }
.keys-table .actions .icon-button { color: var(--text-muted); }
.keys-table .actions .icon-button:hover { color: var(--primary); }
.keys-table .actions [data-key-delete]:hover { color: var(--danger); }
.quota-cell { display: grid; min-width: 112px; gap: 5px; }
.quota-cell strong { color: var(--text); font-size: 11px; }
.quota-cell progress, .usage-budget progress { width: 100%; height: 5px; border: 0; border-radius: 3px; overflow: hidden; accent-color: var(--primary); }
.quota-cell progress::-webkit-progress-bar, .usage-budget progress::-webkit-progress-bar { background: var(--border); border-radius: 3px; }
.quota-cell progress::-webkit-progress-value, .usage-budget progress::-webkit-progress-value { background: var(--primary); border-radius: 3px; }
.quota-cell.is-warning progress, .usage-budget.is-warning progress { accent-color: var(--warning); }
.quota-cell.is-danger progress, .usage-budget.is-danger progress { accent-color: var(--danger); }
.quota-cell.is-warning progress::-webkit-progress-value, .usage-budget.is-warning progress::-webkit-progress-value { background: var(--warning); }
.quota-cell.is-danger progress::-webkit-progress-value, .usage-budget.is-danger progress::-webkit-progress-value { background: var(--danger); }
.key-status-cell { display: grid; justify-items: start; gap: 4px; }
.key-status-label { color: var(--text-muted); font-size: 10px; }
.toggle { position: relative; display: inline-flex; width: 36px; height: 20px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); transition: background 150ms; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); transition: transform 150ms; }
.toggle input:checked + span { background: var(--success); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 3px solid rgba(15, 111, 237, 0.22); outline-offset: 2px; }

.settings-form { border-top: 1px solid var(--border); }
.settings-notice { display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); background: var(--primary-soft); color: var(--primary); padding: 12px 14px; font-size: 12px; font-weight: 650; }
.settings-notice svg { width: 17px; height: 17px; }
.form-section { display: grid; grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1.3fr); gap: 50px; padding: 30px 0; border-bottom: 1px solid var(--border); }
.form-section-heading { display: flex; align-items: flex-start; gap: 13px; }
.section-icon { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.section-icon svg { width: 18px; height: 18px; }
.section-icon--security { background: var(--success-soft); color: var(--success); }
.form-fields { max-width: 620px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 22px 0; }
.save-state { color: var(--text-muted); font-size: 11px; }
.security-actions { display: grid; max-width: 620px; gap: 0; border-top: 1px solid var(--border); }
.security-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; border-bottom: 1px solid var(--border); padding: 17px 0; }
.security-action strong, .security-action span { display: block; }
.security-action strong { color: var(--text); font-size: 13px; }
.security-action span { margin-top: 5px; color: var(--text-muted); font-size: 11px; line-height: 1.5; }

/* Local operator portal */
.portal-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(28, 42, 51, 0.035);
  overflow: hidden;
}
.portal-summary > div { min-width: 0; padding: 16px 20px; }
.portal-summary > div + div { border-left: 1px solid var(--border); }
.portal-summary span { display: block; color: var(--text-muted); font-size: 10px; font-weight: 650; }
.portal-summary strong { display: block; margin-top: 5px; overflow: hidden; font-size: 20px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.portal-section {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(28, 42, 51, 0.035);
  overflow: hidden;
}
.portal-summary + .portal-section, .redeem-panel + .table-section { margin-top: 14px; }
.portal-section > .section-header { padding: 19px 20px; border-bottom: 1px solid var(--border); }
.product-grid, .account-list, .activity-list, .ticket-list {
  display: grid;
  min-width: 0;
  gap: 14px;
  padding: 16px;
}
.product-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.account-list, .activity-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); }
.ticket-list { grid-template-columns: 1fr; }
.product-grid:empty, .activity-list:empty, .ticket-list:empty { display: none; }
.product-card, .account-card, .activity-card, .ticket-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 17px;
}
.product-card, .account-card, .activity-card { display: flex; flex-direction: column; gap: 14px; }
.product-card:hover, .account-card:hover, .activity-card:hover, .ticket-card:hover { border-color: var(--border-strong); }
.product-card-head, .account-card-head, .activity-card-head, .ticket-card-head {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.product-card-head > div, .account-card-head > div, .activity-card-head > div, .ticket-card-head > div { min-width: 0; }
.product-card h3, .account-card h3, .activity-card h3, .ticket-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
.account-card-head p, .activity-card-head p, .ticket-card-head p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.5;
}
.product-card-head > div .status-pill { margin-top: 7px; }
.product-price {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}
.product-description, .activity-card > p {
  min-height: 40px;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.65;
}
.product-meta, .account-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.product-meta > span, .account-meta > span {
  min-width: 0;
  border-left: 2px solid var(--border);
  padding-left: 9px;
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1.45;
}
.product-meta strong, .account-meta strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-meta, .ticket-meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px 14px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.5;
}
.activity-meta span, .ticket-meta span { min-width: 0; overflow-wrap: anywhere; }
.portal-note {
  margin: 0;
  border-left: 2px solid var(--warning);
  background: var(--warning-soft);
  color: var(--text-soft);
  padding: 9px 10px;
  font-size: 10px;
  line-height: 1.55;
}
.product-actions, .account-actions, .activity-actions, .ticket-actions, .inline-actions, .portal-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.product-actions, .account-actions, .activity-actions { margin-top: auto; padding-top: 2px; }
.product-actions .button, .account-actions .button, .activity-actions .button { flex: 1 1 auto; }
.inline-actions, .portal-actions { margin-top: 6px; }
.inline-actions .button, .portal-actions .button { min-height: 30px; padding: 0 9px; font-size: 10px; white-space: nowrap; }
.ticket-card { display: grid; gap: 13px; }
.ticket-messages {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 0 12px;
}
.ticket-message { min-width: 0; padding: 11px 0; }
.ticket-message + .ticket-message { border-top: 1px solid var(--border); }
.ticket-message span { display: block; color: var(--text-muted); font-size: 9px; line-height: 1.5; }
.ticket-message p { margin: 4px 0 0; overflow-wrap: anywhere; color: var(--text-soft); font-size: 11px; line-height: 1.65; white-space: pre-wrap; }
.ticket-actions { padding-top: 1px; }
.ticket-reply-form, .ticket-message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 9px;
}
.ticket-reply-form .field, .ticket-message-form .field { min-width: 0; }
.ticket-reply-input, .ticket-reply-form textarea, .ticket-message-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  line-height: 1.5;
}
.ticket-reply-input:focus, .ticket-reply-form textarea:focus, .ticket-message-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 111, 237, 0.1); outline: none; }
.redeem-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.45fr) minmax(0, 1.25fr);
  align-items: end;
  gap: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(28, 42, 51, 0.035);
  padding: 20px;
}
.redeem-panel h2 { margin: 0; font-size: 15px; }
.redeem-panel > div > p { margin: 5px 0 0; color: var(--text-muted); font-size: 11px; }
.redeem-form { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.redeem-form .field { min-width: 0; }
#view-subscriptions table { min-width: 720px; }
#view-orders table { min-width: 690px; }
#view-redeem table { min-width: 600px; }
.profile-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(28, 42, 51, 0.035);
  overflow: hidden;
}
.profile-form .form-section { padding: 28px 24px; }
.profile-form .form-actions { padding: 18px 24px; }
.portal-section > .empty-state, .product-grid + .empty-state { min-height: 250px; padding: 28px 16px; text-align: center; }
.portal-section .empty-state span, .product-grid + .empty-state span { color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.account-list > .empty-state { grid-column: 1 / -1; min-height: 220px; padding: 20px; }

#productDialog { width: min(calc(100% - 32px), 560px); }
#benefitDialog, #ticketDialog { width: min(calc(100% - 32px), 520px); }
#createProductForm .modal-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#createProductForm .modal-body > .field:nth-child(-n + 2) { grid-column: 1 / -1; }
#createProductForm .number-field { width: 100%; }

.app-shell.sidebar-collapsed .sidebar, body.sidebar-collapsed .sidebar { width: 72px; padding-right: 10px; padding-left: 10px; }
.app-shell.sidebar-collapsed .main-content, body.sidebar-collapsed .main-content { margin-left: 72px; }
.app-shell.sidebar-collapsed .sidebar .brand, body.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 0; }
.app-shell.sidebar-collapsed .sidebar .brand > div, body.sidebar-collapsed .sidebar .brand > div,
.app-shell.sidebar-collapsed .sidebar .nav-item > span, body.sidebar-collapsed .sidebar .nav-item > span,
.app-shell.sidebar-collapsed .sidebar .service-indicator > span:not(.status-dot), body.sidebar-collapsed .sidebar .service-indicator > span:not(.status-dot) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.app-shell.sidebar-collapsed .sidebar .side-nav, body.sidebar-collapsed .sidebar .side-nav { margin-right: 0; padding-right: 0; scrollbar-width: none; }
.app-shell.sidebar-collapsed .sidebar .side-nav::-webkit-scrollbar, body.sidebar-collapsed .sidebar .side-nav::-webkit-scrollbar { display: none; }
.app-shell.sidebar-collapsed .sidebar .nav-item, body.sidebar-collapsed .sidebar .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
.app-shell.sidebar-collapsed .sidebar .nav-section-label, body.sidebar-collapsed .sidebar .nav-section-label {
  height: 1px;
  margin: 9px 6px;
  overflow: hidden;
  border-top: 1px solid var(--border);
  padding: 0;
  color: transparent;
}
.app-shell.sidebar-collapsed .sidebar .sidebar-footer, body.sidebar-collapsed .sidebar .sidebar-footer { gap: 6px; }
.app-shell.sidebar-collapsed .sidebar .service-indicator, body.sidebar-collapsed .sidebar .service-indicator { justify-content: center; margin: 0 5px 7px; padding: 0 0 13px; }

.log-toolbar { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--border); }
#view-logs table { min-width: 850px; }
.select-field { position: relative; display: block; width: 130px; }
.select-field--key { width: 170px; }
.select-field select { height: 40px; appearance: none; padding: 0 34px 0 12px; color: var(--text-soft); font-size: 12px; }
.select-field svg { position: absolute; right: 11px; top: 12px; width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }
.toolbar-count { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.pagination { display: flex; min-height: 62px; align-items: center; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); padding: 10px 20px; }
.pagination > span { min-width: 84px; color: var(--text-muted); text-align: center; font-size: 11px; }
.pagination .button { min-height: 36px; }

.modal { width: min(calc(100% - 32px), 480px); max-width: none; max-height: calc(100vh - 32px); border: 0; border-radius: var(--radius); background: transparent; padding: 0; color: var(--text); }
.modal::backdrop { background: rgba(20, 31, 38, 0.48); }
.modal-surface { max-height: calc(100vh - 32px); margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 18px 60px rgba(15, 26, 33, 0.24); overflow-x: hidden; overflow-y: auto; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.modal-header h2, .confirm-copy h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: 0; }
.modal-body { display: grid; gap: 20px; padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }
.secret-reveal { display: grid; justify-items: center; gap: 15px; padding: 28px 24px 30px; text-align: center; }
.secret-reveal h3 { margin: 0; font-size: 18px; }
.secret-reveal p { margin: 5px 0 0; color: var(--danger); font-size: 12px; font-weight: 650; }
.success-seal { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.success-seal svg { width: 23px; height: 23px; stroke-width: 2.3; }
.secret-box { display: flex; width: 100%; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-muted); padding: 8px 8px 8px 12px; }
.secret-box code { min-width: 0; flex: 1; overflow-wrap: anywhere; color: var(--text); text-align: left; font-size: 12px; line-height: 1.5; user-select: all; }
.modal--small { width: min(calc(100% - 32px), 400px); }
.modal--small .modal-surface { padding-top: 25px; }
.confirm-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); margin: 0 auto 15px; }
.confirm-copy { padding: 0 28px 24px; text-align: center; }
.confirm-copy p { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.modal--small .modal-actions { justify-content: center; }
.modal--small .modal-actions .button { min-width: 118px; }
.modal--wide { width: min(calc(100% - 32px), 780px); }
.modal-security-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); padding-top: 18px; }
.modal-security-row > span { color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.policy-details { border-top: 1px solid var(--border); padding-top: 4px; }
.policy-details summary { cursor: pointer; color: var(--text-soft); padding: 10px 0 4px; font-size: 12px; font-weight: 700; }
.policy-fields { display: grid; gap: 17px; padding-top: 12px; }
.policy-check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.policy-check-grid label { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--text-soft); font-size: 11px; }
.policy-check-grid input { width: 16px; height: 16px; flex: 0 0 auto; margin: 0; accent-color: var(--primary); }
.usage-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.usage-summary > div { min-width: 0; padding: 18px 20px; }
.usage-summary > div + div { border-left: 1px solid var(--border); }
.usage-summary span { display: block; color: var(--text-muted); font-size: 10px; }
.usage-summary strong { display: block; margin-top: 6px; overflow: hidden; color: var(--text); font-size: 19px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.usage-budget { display: grid; gap: 9px; border-bottom: 1px solid var(--border); padding: 16px 20px; }
.usage-budget > div { display: flex; justify-content: space-between; gap: 18px; color: var(--text-muted); font-size: 11px; }
.usage-budget strong { color: var(--text-soft); }
.usage-budget progress { height: 7px; }
.usage-log-wrap { padding-top: 4px; }
.usage-log-heading { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 10px; }
.usage-log-heading strong { font-size: 13px; }
.usage-log-heading span { color: var(--text-muted); font-size: 10px; }
.empty-state--compact { min-height: 150px; }

.toast-region { position: fixed; z-index: 100; top: 18px; right: 18px; display: grid; width: min(calc(100% - 36px), 350px); gap: 8px; pointer-events: none; }
.clipboard-fallback { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); padding: 12px 14px; color: var(--text-soft); font-size: 12px; line-height: 1.5; animation: toast-in 180ms ease-out; }
.toast.is-success { border-left-color: var(--success); }
.toast.is-error { border-left-color: var(--danger); }
.toast svg { margin-top: 1px; color: var(--primary); }
.toast.is-success svg { color: var(--success); }
.toast.is-error svg { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
.spin { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .health-badge.is-ok { border-color: #285841; }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .health-badge.is-error { border-color: #603438; }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .health-badge.is-warning { border-color: #624b2b; background: var(--warning-soft); color: var(--warning); }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .metric-icon--rose { background: #402630; color: #f29ab0; }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .metric-icon--indigo { background: #292f4b; color: #aab6ff; }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .button--danger:hover { background: #d56f6f; }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .modal::backdrop { background: rgba(2, 7, 11, 0.72); }
:is(html[data-theme="dark"], html.theme-dark, body[data-theme="dark"], body.theme-dark) .toggle span::after { background: #edf3f7; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: minmax(0, 1.5fr) minmax(240px, 0.75fr); }
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-panel { min-height: 300px; }
  .donut-layout { grid-template-columns: minmax(180px, 0.65fr) minmax(220px, 1.35fr); }
}

@media (max-width: 780px) {
  .sidebar { display: none; }
  .mobile-header { position: sticky; z-index: 30; top: 0; display: flex; height: 62px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 16px; }
  .mobile-header .brand { padding: 0; }
  .mobile-menu { position: fixed; z-index: 29; inset: 62px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(42px, auto); align-content: start; gap: 6px; border-bottom: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-menu .nav-item { min-width: 0; }
  .mobile-menu .nav-item > span { min-width: 0; overflow-wrap: anywhere; }
  .mobile-menu .nav-section-label { grid-column: 1 / -1; }
  .main-content { margin-left: 0; background: var(--bg); padding: 24px 16px 40px; }
  .main-content::before { inset: 0 0 auto; height: 97px; }
  .app-shell.sidebar-collapsed .main-content, body.sidebar-collapsed .main-content { margin-left: 0; }
  .page-header { min-height: 52px; margin-bottom: 20px; }
  .page-header h1 { font-size: 22px; }
  .overview-grid { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; gap: 24px; }
  .form-fields { max-width: none; }
  .endpoint-strip { grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1.2fr); }
  .deployment-note { display: none; }
  .model-endpoint .deployment-note { display: block; grid-column: 1 / -1; }
  .channel-summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .channel-summary-state { min-width: 0; grid-column: 2; justify-self: start; justify-content: flex-start; }
  .channel-summary > .button { grid-column: 3; grid-row: 1 / span 2; }
  .channel-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-hero { grid-template-columns: auto minmax(0, 1fr); }
  .monitor-hero > code { grid-column: 2; width: 100%; text-align: left; }
  .redeem-panel { grid-template-columns: minmax(140px, 0.4fr) minmax(0, 1fr); gap: 20px; }
}

@media (max-width: 560px) {
  .login-shell { padding: 14px; }
  .login-panel { padding: 28px 22px; }
  .page-header { align-items: center; }
  .page-header .eyebrow { display: none; }
  .page-header h1 { margin: 0; }
  .header-actions .health-badge { display: none; }
  .button { min-height: 39px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 132px; padding: 14px; }
  .metric-card strong { margin-top: 14px; font-size: 23px; }
  .metric-icon { right: 13px; top: 13px; width: 30px; height: 30px; }
  .metric-heading { padding-right: 34px; }
  .dashboard-metrics { margin-bottom: 9px; }
  .analytics-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 11px; }
  .analytics-control { display: grid; align-items: start; gap: 6px; }
  .analytics-control--end { margin-left: 0; }
  .analytics-control .select-field { width: 100%; }
  #refreshAnalytics { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .analytics-grid { gap: 9px; margin-top: 9px; }
  .analytics-panel { min-height: 0; }
  .panel { padding: 16px; }
  .chart-wrap { height: 210px; }
  .analytics-panel .panel-header { flex-wrap: wrap; }
  .donut-layout { grid-template-columns: 1fr; gap: 5px; }
  .donut-wrap { height: 190px; }
  .model-distribution-list { align-content: start; }
  .model-distribution-row { grid-template-columns: 8px minmax(0, 1fr) auto auto; gap: 7px; }
  .model-distribution-row span:nth-child(3) { display: block; white-space: nowrap; }
  .token-chart-wrap { height: 220px; }
  .connection-panel { min-height: 300px; }
  .section-header { align-items: center; }
  .section-header p { display: none; }
  .table-section > .section-header { padding: 15px 16px; }
  th, td { padding-right: 13px; padding-left: 13px; }
  .key-toolbar { flex-wrap: wrap; align-items: flex-start; }
  .key-toolbar .search-field { width: 100%; }
  .keys-table thead { display: none; }
  .keys-table, .keys-table tbody { display: block; width: 100%; }
  .keys-table tbody { padding: 0 14px 14px; }
  .keys-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px 18px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); margin-top: 14px; padding: 14px; }
  .keys-table td { min-width: 0; height: auto; border: 0; padding: 0; white-space: normal; }
  .keys-table td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 9px; font-weight: 700; }
  .keys-table td:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
  .keys-table td:first-child::before { display: none; }
  .keys-table td:last-child { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 11px; }
  .keys-table td code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .keys-table .actions { justify-content: flex-start; }
  .keys-table .quota-cell { min-width: 0; }
  .model-toolbar { flex-wrap: wrap; align-items: flex-start; }
  .model-toolbar .search-field { width: 100%; }
  .endpoint-strip { grid-template-columns: 1fr; gap: 13px; padding: 15px; }
  .endpoint-value { width: 100%; }
  .channel-summary { grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; padding: 15px; }
  .channel-summary-state { grid-column: 2; }
  .channel-summary > .button { grid-column: 1 / -1; grid-row: auto; width: 100%; }
  .channels-table { min-width: 0; }
  .channels-table thead { display: none; }
  .channels-table, .channels-table tbody { display: block; width: 100%; }
  .channels-table tbody { padding: 0 14px 14px; }
  .channels-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); margin-top: 14px; padding: 14px; }
  .channels-table td { min-width: 0; height: auto; border: 0; padding: 0; white-space: normal; }
  .channels-table td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 9px; font-weight: 700; }
  .channels-table td:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
  .channels-table td:first-child::before { display: none; }
  .channels-table td:nth-child(2), .channels-table td:last-child { grid-column: 1 / -1; }
  .channels-table td:last-child { border-top: 1px solid var(--border); padding-top: 11px; }
  .channels-table td code { max-width: 100%; }
  .channels-table .actions { justify-content: flex-start; }
  .monitor-hero { gap: 12px; padding: 15px; }
  .monitor-hero > code { grid-column: 1 / -1; }
  .channel-metric-grid { gap: 9px; margin-top: 9px; }
  .channel-metric-grid article { min-height: 96px; padding: 14px; }
  .channel-metric-grid strong { margin-top: 13px; font-size: 18px; }
  .monitor-detail { grid-template-columns: 1fr; margin-top: 9px; }
  .monitor-detail > div:nth-child(even) { border-left: 0; }
  .monitor-detail > div:nth-child(n + 2) { border-top: 1px solid var(--border); }
  .monitor-detail > div { grid-template-columns: minmax(76px, auto) minmax(0, 1fr); padding: 12px 14px; }
  .key-summary { grid-template-columns: 1fr 1fr; }
  .key-summary > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .key-summary > div:nth-child(4) { border-top: 1px solid var(--border); }
  .log-toolbar { flex-wrap: wrap; padding: 12px; }
  .log-toolbar .search-field { width: 100%; }
  .select-field, .select-field--key { width: calc(50% - 5px); }
  .toolbar-count { margin-left: auto; }
  .pagination { justify-content: center; padding: 10px 12px; }
  .pagination .button span { display: none; }
  .pagination .button { width: 38px; padding: 0; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .save-state { text-align: center; }
  .security-action { grid-template-columns: 1fr; gap: 12px; }
  .security-action .button { width: 100%; }
  .usage-summary { grid-template-columns: 1fr 1fr; }
  .usage-summary > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .usage-summary > div:nth-child(4) { border-top: 1px solid var(--border); }
  .modal-security-row { align-items: stretch; flex-direction: column; }
  .modal-security-row .button { width: 100%; }
  .policy-check-grid { grid-template-columns: 1fr; }
  .modal-header, .modal-body { padding-right: 18px; padding-left: 18px; }
  .modal-actions { padding-right: 18px; padding-left: 18px; }
  .portal-summary > div { padding: 14px 16px; }
  .portal-summary strong { font-size: 18px; }
  .portal-section > .section-header { padding: 15px 16px; }
  .product-grid, .account-list, .activity-list, .ticket-list { grid-template-columns: 1fr; gap: 11px; padding: 12px; }
  .product-card, .account-card, .activity-card, .ticket-card { padding: 14px; }
  .product-card-head, .account-card-head, .activity-card-head, .ticket-card-head { gap: 10px; }
  .product-meta, .account-meta { gap: 6px; }
  .product-meta > span, .account-meta > span { padding-left: 7px; }
  .redeem-panel { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .redeem-form, .ticket-reply-form, .ticket-message-form { grid-template-columns: 1fr; }
  .redeem-form .button, .ticket-reply-form .button, .ticket-message-form .button { width: 100%; }
  .profile-form .form-section { padding: 22px 16px; }
  .profile-form .form-actions { padding: 16px; }
  #createProductForm .modal-body { grid-template-columns: 1fr; }
  #createProductForm .modal-body > .field:nth-child(-n + 2) { grid-column: auto; }
}

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


/* DediRock v1.0.0 UI hotfix: compact short-window sidebar. */
@media (min-width: 781px) and (max-height: 950px) {
  .sidebar { padding-top: 12px; padding-bottom: 10px; }
  .side-nav { gap: 1px; margin-top: 8px; margin-bottom: 6px; }
  .side-nav .nav-item { min-height: 34px; }
  .nav-section-label--system { margin-top: 8px; padding-top: 8px; }
  .sidebar-footer { gap: 4px; }
  .service-indicator { margin-bottom: 2px; padding-bottom: 8px; }
}
