:root {
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    'SF Pro Text',
    'Segoe UI',
    sans-serif;
  color: #172033;
  background: #eef2f6;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  --bg: #eef2f6;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-soft: rgba(247, 249, 252, 0.86);
  --line: rgba(113, 128, 150, 0.2);
  --line-strong: rgba(92, 107, 129, 0.32);
  --text: #172033;
  --muted: #697386;
  --faint: #8d98a8;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #18a058;
  --green-soft: #e7f7ee;
  --amber: #b7791f;
  --amber-soft: #fff5d8;
  --red: #d64545;
  --red-soft: #ffe9e9;
  --shadow: 0 18px 55px rgba(42, 58, 82, 0.14);
  --radius: 8px;
}

:root[data-theme='dark'] {
  color: #edf3ff;
  background: #111827;
  --bg: #111827;
  --surface: rgba(24, 32, 45, 0.82);
  --surface-strong: rgba(30, 41, 59, 0.94);
  --surface-soft: rgba(18, 26, 38, 0.86);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #edf3ff;
  --muted: #9aa8bd;
  --faint: #718096;
  --blue: #69a1ff;
  --blue-soft: rgba(64, 111, 211, 0.2);
  --green: #45d483;
  --green-soft: rgba(24, 160, 88, 0.18);
  --amber: #f5b759;
  --amber-soft: rgba(245, 183, 89, 0.16);
  --red: #ff7a7a;
  --red-soft: rgba(255, 122, 122, 0.16);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-width: 0;
  width: 100%;
  min-height: 100vh;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
}

:root[data-theme='dark'] body {
  background: var(--bg);
}

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

button {
  border: 0;
}

.hidden-scrollbar {
  scrollbar-width: none;
}

.hidden-scrollbar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  color: var(--text);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: none;
}

:root[data-theme='dark'] .app-shell {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(16, 24, 36, 0.78);
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 14px 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(240, 245, 251, 0.58));
  backdrop-filter: blur(26px) saturate(1.18);
  box-shadow: inset -1px 0 0 rgba(125, 139, 158, 0.16);
}

:root[data-theme='dark'] .sidebar {
  border-right-color: rgba(148, 163, 184, 0.14);
  background: linear-gradient(180deg, rgba(28, 39, 56, 0.7), rgba(18, 27, 40, 0.66));
  box-shadow: inset -1px 0 0 rgba(148, 163, 184, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 9px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.brand:hover {
  background: rgba(255, 255, 255, 0.58);
}

:root[data-theme='dark'] .brand:hover,
:root[data-theme='dark'] .nav-item:hover,
:root[data-theme='dark'] .sidebar-status {
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme='dark'] .nav-item {
  color: #aebbd0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.sidebar-status strong {
  display: block;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.25;
}

.brand small,
.sidebar-status small {
  display: block;
  max-width: 158px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: #4f5f75;
  text-align: left;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.58);
}

.nav-item.active {
  color: #133a8b;
  background: rgba(226, 237, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

:root[data-theme='dark'] .nav-item.active {
  color: #d8e6ff;
  background: rgba(67, 111, 190, 0.24);
  box-shadow: inset 0 0 0 1px rgba(105, 161, 255, 0.18);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: inherit;
  font-size: 13px;
}

.nav-icon .bi,
.icon-button .bi {
  color: currentColor;
  font-size: 17px;
  line-height: 1;
}

.sidebar-status {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.56);
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c7ced8;
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(24, 160, 88, 0.12);
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(112, 128, 148, 0.18);
  background: #f6f9fd;
  backdrop-filter: none;
}

:root[data-theme='dark'] .topbar {
  border-bottom-color: rgba(148, 163, 184, 0.14);
  background: #162131;
}

.topbar-spacer {
  flex: 1;
  min-width: 0;
}

.topbar h1,
.page-title h1 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.2;
}

.topbar-actions,
.toolbar,
.button-row,
.segmented,
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.view-stage {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 14px 16px 16px;
  scrollbar-width: none;
}

.view-stage::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.page {
  display: grid;
  gap: 12px;
  max-width: 100%;
  margin: 0 auto;
}

.logs-page {
  min-height: min-content;
}

.requests-page {
  min-height: min-content;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.page-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.glass-panel,
.metric,
.table-panel,
.config-panel {
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.12);
}

:root[data-theme='dark'] .glass-panel,
:root[data-theme='dark'] .metric,
:root[data-theme='dark'] .table-panel,
:root[data-theme='dark'] .config-panel {
  border-color: rgba(148, 163, 184, 0.14);
  background: var(--surface);
}

.glass-panel {
  padding: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 730;
}

.panel-header p,
.muted {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.status-strip {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(150px, 1fr) minmax(106px, 0.62fr) minmax(92px, 0.52fr) minmax(216px, auto);
  gap: 0;
  align-items: center;
  min-height: 76px;
  padding: 10px 14px;
}

.strip-cell {
  min-width: 0;
  padding: 0 14px;
  border-left: 1px solid var(--line);
}

.strip-cell:first-child {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-left: 0;
  border-left: 0;
}

.strip-cell label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.strip-cell strong,
.strip-cell a {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strip-cell a {
  color: var(--blue);
}

.strip-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(24, 160, 88, 0.1);
}

.strip-dot.stopped {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(214, 69, 69, 0.1);
}

.strip-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  min-width: 216px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.strip-actions button {
  min-height: 38px;
  padding: 0 8px;
  color: #26364f;
  font-weight: 680;
  white-space: nowrap;
  border-right: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.strip-actions button:last-child {
  border-right: 0;
}

.strip-actions .active {
  color: white;
  background: linear-gradient(180deg, #2877e7, #1262d5);
}

.strip-actions button:disabled {
  color: #5d6980;
  background: rgba(248, 250, 252, 0.58);
}

.status-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-orb {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: var(--green);
  background: var(--green-soft);
}

.status-orb.stopped {
  color: var(--red);
  background: var(--red-soft);
}

.status-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.status-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.status-grid {
  margin-top: 18px;
}

.metric {
  min-width: 0;
  padding: 13px;
  box-shadow: none;
}

.metric label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

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

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

.dashboard-grid {
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr) minmax(300px, 0.95fr);
  grid-template-areas:
    'health models config'
    'requests requests usage';
  gap: 12px;
}

.area-health {
  grid-area: health;
}

.area-models {
  grid-area: models;
  min-height: 0;
}

.area-config {
  grid-area: config;
}

.compact-header {
  margin-bottom: 10px;
}

.compact-header p {
  margin-top: 4px;
}

.area-usage {
  grid-area: usage;
}

.area-requests {
  grid-area: requests;
}

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

.usage-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.usage-grid label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.usage-grid strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.usage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.config-summary-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.config-summary-item label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.config-summary-item strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-summary-item.span-2 {
  grid-column: 1 / -1;
}

.compact-link {
  margin-top: 10px;
}

.activity-chart {
  display: grid;
  grid-template-columns: repeat(36, minmax(3px, 1fr));
  align-items: end;
  height: 126px;
  gap: 4px;
  padding: 18px 12px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.8), rgba(255, 255, 255, 0.42));
}

.chart-empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  writing-mode: horizontal-tb;
  white-space: nowrap;
}

:root[data-theme='dark'] .activity-chart,
:root[data-theme='dark'] .data-table th,
:root[data-theme='dark'] .field input,
:root[data-theme='dark'] .field textarea,
:root[data-theme='dark'] .search-input,
:root[data-theme='dark'] .detail-panel pre,
:root[data-theme='dark'] .code-block {
  color: var(--text);
  border-color: var(--line);
  background: rgba(15, 23, 42, 0.74);
}

.health-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.health-stats div {
  padding: 12px 8px 2px;
  border-left: 1px solid var(--line);
}

.health-stats div:first-child {
  border-left: 0;
}

.health-stats strong {
  display: block;
  font-size: 18px;
}

.health-stats span {
  color: var(--muted);
  font-size: 11px;
}

.bar {
  min-height: 12px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #5b8def, #2563eb);
}

.model-row,
.request-row,
.log-row,
.setting-row {
  display: grid;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.model-row {
  grid-template-columns: 22px minmax(0, 1fr) auto;
}

.model-choice {
  min-height: 48px;
  padding: 9px 12px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0;
  box-shadow: inset 0 -1px 0 var(--line);
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.model-choice:hover,
.model-choice:focus-visible {
  border-color: rgba(37, 99, 235, 0.24);
  border-radius: 6px;
  background: rgba(226, 237, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

:root[data-theme='dark'] .model-choice:hover,
:root[data-theme='dark'] .model-choice:focus-visible {
  color: #f3f7ff;
  border-color: rgba(105, 161, 255, 0.38);
  background: rgba(72, 118, 214, 0.34);
}

.models-list .model-row,
.model-list-row {
  grid-template-columns: 22px minmax(220px, 1fr) minmax(260px, auto);
}

.model-specs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.spec-chip {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.spec-chip.strong {
  color: #0d6a41;
  border-color: rgba(24, 160, 88, 0.18);
  background: var(--green-soft);
}

.spec-chip.muted-chip {
  color: #8a5a08;
  border-color: rgba(217, 119, 6, 0.16);
  background: var(--warn-soft);
}

:root[data-theme='dark'] .spec-chip.strong {
  color: #7ee0aa;
}

:root[data-theme='dark'] .spec-chip.muted-chip {
  color: #ffd27a;
}

.model-brand-icon {
  display: block;
  width: 20px;
  height: 20px;
  background: var(--model-icon-color, var(--muted));
  -webkit-mask: var(--model-icon) center / contain no-repeat;
  mask: var(--model-icon) center / contain no-repeat;
}

.model-card {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  height: 295px;
}

.model-card-list,
.model-page-list,
.log-list {
  min-height: 0;
  overflow: auto;
}

.model-card-list {
  flex: 1 1 auto;
  max-height: none;
  scrollbar-width: none;
}

.model-card-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.model-page-list {
  max-height: min(560px, calc(100vh - 286px));
}

.log-list {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: min(620px, calc(100vh - 260px));
  overflow: auto;
  padding: 0 16px 8px;
  background: var(--surface-strong);
}

.models-list .model-name,
.models-list .model-meta {
  white-space: normal;
  overflow-wrap: anywhere;
}

.setting-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.setting-row .status-chip {
  width: 24px;
  min-height: 24px;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 680;
}

.radio-dot {
  width: 13px;
  height: 13px;
  border: 1px solid #b8c1ce;
  border-radius: 50%;
}

.radio-dot.active {
  border: 4px solid var(--blue);
}

.model-row:last-child,
.request-row:last-child,
.log-row:last-child,
.setting-row:last-child {
  border-bottom: 0;
}

.model-name,
.cell-main {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-meta,
.cell-sub {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-panel {
  overflow: hidden;
}

.table-panel,
.logs-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.requests-panel {
  min-height: 0;
  overflow: hidden;
}

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

.toolbar-header {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.toolbar-count {
  font-size: 12px;
  font-weight: normal;
  white-space: nowrap;
}

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

.toolbar-search-input {
  max-width: 300px;
  width: 100%;
}

.btn-sm-outline {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
}

.btn-sm-outline:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-sm-outline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm-outline i {
  margin-left: 2px;
}

:root[data-theme='dark'] .btn-sm-outline {
  color: #dce8fb;
}

:root[data-theme='dark'] .btn-sm-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.table-scroll {
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}

.requests-panel .table-scroll {
  flex: 0 0 auto;
  --request-row-height: 42px;
  --request-head-height: 43px;
  min-height: calc(var(--request-head-height) + var(--request-row-height));
  max-height: calc(var(--request-head-height) + var(--request-row-height) * 5);
  overflow: auto;
}

.requests-panel .detail-panel {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

.area-requests .table-scroll {
  min-height: 0;
  max-height: 211px;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.7);
  -webkit-user-select: text;
  user-select: text;
}

.data-table th,
.data-table td {
  min-width: 0;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table tbody td {
  padding-top: 3px;
  padding-bottom: 3px;
  line-height: 1.12;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  background: rgba(250, 252, 255, 0.94);
}

.data-table tbody tr {
  height: var(--request-row-height, 42px);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.34);
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.data-table tbody tr:hover {
  background: rgba(232, 240, 255, 0.58);
}

.data-table tbody tr.selected {
  background: rgba(219, 231, 255, 0.86);
  box-shadow: inset 3px 0 0 var(--blue);
}

:root[data-theme='dark'] .data-table {
  background: rgba(15, 23, 42, 0.8);
}

:root[data-theme='dark'] .data-table th {
  background: rgba(15, 23, 42, 0.96);
}

:root[data-theme='dark'] .data-table tbody tr {
  background: rgba(20, 31, 48, 0.7);
}

:root[data-theme='dark'] .data-table tbody tr:hover {
  background: rgba(45, 65, 96, 0.9);
}

:root[data-theme='dark'] .data-table tbody tr.selected {
  background: rgba(38, 65, 112, 0.96);
  box-shadow: inset 3px 0 0 #67a1ff;
}

.chip,
.status-chip,
.method-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.chip {
  color: #27518f;
  background: var(--blue-soft);
}

.status-chip.ok {
  color: #13754a;
  background: var(--green-soft);
}

.status-chip.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-chip.err {
  color: var(--red);
  background: var(--red-soft);
}

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

:root[data-theme='dark'] .link-row {
  color: #dce8fb;
}


.method-chip {
  color: #334155;
  background: #eef2f7;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.segmented button {
  min-height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-button {
  padding: 0 14px;
  color: white;
  font-weight: 700;
  background: linear-gradient(180deg, #3f7ff2, #2563eb);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.2);
}

.secondary-button,
.ghost-button,
.segmented button {
  padding: 0 12px;
  color: #34445d;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.danger-button {
  padding: 0 14px;
  color: #9f2626;
  font-weight: 700;
  background: var(--red-soft);
  border: 1px solid rgba(214, 69, 69, 0.18);
}

.icon-button {
  display: grid;
  width: 34px;
  place-items: center;
  color: #34445d;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.danger-icon-button {
  color: #b42318;
  background: rgba(254, 226, 226, 0.72);
  border-color: rgba(220, 38, 38, 0.24);
}

.danger-icon-button:hover {
  color: #991b1b;
  background: rgba(254, 202, 202, 0.88);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  opacity: 0.78;
  transform: none;
}

.segmented {
  flex: 0 0 auto;
  overflow-x: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.segmented button {
  min-width: 54px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}

.segmented button.active {
  color: #133a8b;
  background: white;
  box-shadow: 0 5px 12px rgba(42, 58, 82, 0.1);
}

.field {
  display: grid;
  gap: 6px;
}

.settings-fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.settings-fieldset:disabled {
  opacity: 0.56;
}

.compact-hint {
  margin-bottom: 14px;
}

.compact-form-grid {
  row-gap: 14px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.switch-field p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  width: 44px;
  height: 26px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  transition:
    background 0.16s ease,
    border-color 0.16s ease;
}

.switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  border-color: rgba(37, 99, 235, 0.72);
  background: #2563eb;
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.field input,
.field textarea,
.search-input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  outline: none;
}

.field .switch input {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

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

.field input:focus,
.field textarea:focus,
.search-input:focus {
  border-color: rgba(37, 99, 235, 0.56);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.custom-select {
  position: relative;
}

.custom-select > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  gap: 10px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
}

.custom-select.open > button,
.custom-select > button:focus {
  border-color: rgba(37, 99, 235, 0.56);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.custom-select .bi {
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.16s ease;
}

.custom-select.open .bi {
  transform: rotate(180deg);
}

.select-menu {
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  z-index: 30;
  display: grid;
  gap: 3px;
  max-height: 210px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.select-menu button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--text);
  text-align: left;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.select-menu button:hover,
.select-menu button.selected {
  color: #133a8b;
  background: var(--blue-soft);
}

:root[data-theme='dark'] .custom-select > button {
  color: var(--text);
  border-color: var(--line);
  background: rgba(15, 23, 42, 0.74);
}

:root[data-theme='dark'] .select-menu button:hover,
:root[data-theme='dark'] .select-menu button.selected {
  color: #dce9ff;
  background: rgba(72, 118, 214, 0.32);
}

.hint-box {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.55;
}

.hint-box strong {
  color: var(--text);
  font-size: 13px;
}

.hint-box code {
  color: var(--text);
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

.detect-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

:root[data-theme='dark'] .detect-card {
  background: rgba(15, 23, 42, 0.52);
}

.detect-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detect-title strong {
  color: var(--text);
  font-size: 13px;
}

.detect-title button {
  min-height: 28px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  cursor: pointer;
}

.detect-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detect-card dl > div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.detect-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.detect-card dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.muted-inline {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.warn-text {
  color: var(--danger-text) !important;
}

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

.span-2 {
  grid-column: span 2;
}

.empty-state {
  display: grid;
  min-height: 150px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.detail-panel {
  display: flex;
  min-height: 0;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.72);
  -webkit-user-select: text;
  user-select: text;
}

:root[data-theme='dark'] .detail-panel {
  background: rgba(12, 18, 30, 0.96);
}

.detail-section {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
}

.detail-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.detail-toolbar h3 {
  margin: 0;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-panel h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.detail-panel pre,
.code-block,
.json-viewer {
  max-height: min(320px, 34vh);
  margin: 0 0 14px;
  overflow: auto;
  padding: 12px;
  color: #27364d;
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-user-select: text;
  user-select: text;
  background: rgba(255, 255, 255, 0.82);
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-viewer {
  white-space: normal;
}

.json-viewer pre {
  margin: 0;
  color: inherit;
  font: inherit;
  white-space: pre-wrap;
}

.json-viewer.empty {
  color: var(--muted);
}

.json-node {
  min-width: max-content;
}

.json-line {
  display: flex;
  min-height: 22px;
  align-items: flex-start;
  gap: 2px;
  white-space: pre;
}

.json-toggle,
.json-toggle-spacer {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.json-toggle {
  display: inline-grid;
  margin: 1px 2px 0 0;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
}

.json-toggle:hover {
  color: var(--blue);
}

.json-toggle i {
  font-size: 11px;
}

.json-key {
  color: #8250df;
}

.json-string {
  color: #116329;
}

.json-number {
  color: #0550ae;
}

.json-boolean {
  color: #cf222e;
}

.json-null {
  color: #6e7781;
}

.json-punctuation {
  color: #57606a;
}

.json-summary {
  margin: 0 3px;
  padding: 0 7px;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  font: inherit;
  cursor: pointer;
}

.json-summary:hover {
  color: var(--blue);
  border-color: rgba(44, 111, 231, 0.38);
}

:root[data-theme='dark'] .json-key {
  color: #c4b5fd;
}

:root[data-theme='dark'] .json-string {
  color: #86efac;
}

:root[data-theme='dark'] .json-number {
  color: #93c5fd;
}

:root[data-theme='dark'] .json-boolean {
  color: #fca5a5;
}

:root[data-theme='dark'] .json-null,
:root[data-theme='dark'] .json-punctuation {
  color: #9aa8bd;
}

:root[data-theme='dark'] .json-summary {
  color: #b7c3d6;
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(30, 41, 59, 0.78);
}

.detail-panel pre,
.json-viewer {
  scrollbar-width: none;
}

.detail-panel pre::-webkit-scrollbar,
.json-viewer::-webkit-scrollbar {
  width: 0;
  height: 0;
}

:root[data-theme='dark'] .detail-panel pre,
:root[data-theme='dark'] .code-block,
:root[data-theme='dark'] .json-viewer {
  color: var(--text);
  border-color: var(--line);
  background: rgba(17, 24, 39, 0.94);
}

.log-row {
  grid-template-columns: 82px 58px minmax(0, 1fr);
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  -webkit-user-select: text;
  user-select: text;
}

.level-info {
  color: #2563eb;
}

.level-warn {
  color: var(--amber);
}

.level-error {
  color: var(--red);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .brand span:not(.brand-mark),
  .nav-item span:last-child,
  .sidebar-status div {
    display: none;
  }

  .sidebar-status {
    display: grid;
    width: 42px;
    min-height: 42px;
    place-items: center;
    padding: 0;
    margin-top: auto;
  }

  .sidebar {
    align-items: center;
  }

  .nav-item {
    justify-content: center;
    width: 42px;
    padding: 0;
  }

  .grid-2,
  .grid-3,
  .dashboard-grid,
  .status-grid,
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid {
    grid-template-areas:
      'health models'
      'config config'
      'usage usage'
      'requests requests';
  }

  .status-strip {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .strip-cell {
    padding: 0;
    border-left: 0;
  }

  .strip-actions {
    grid-column: span 2;
  }

  .config-summary {
    grid-template-columns: 1fr 1fr;
  }
}

:root[data-theme='dark'] .strip-actions,
:root[data-theme='dark'] .secondary-button,
:root[data-theme='dark'] .ghost-button,
:root[data-theme='dark'] .icon-button,
:root[data-theme='dark'] .segmented,
:root[data-theme='dark'] .segmented button {
  color: var(--text);
  border-color: var(--line);
  background: rgba(30, 41, 59, 0.66);
}

:root[data-theme='dark'] .danger-icon-button {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.32);
  background: rgba(127, 29, 29, 0.42);
}

:root[data-theme='dark'] .danger-icon-button:hover {
  color: #fff1f2;
  background: rgba(153, 27, 27, 0.62);
}

:root[data-theme='dark'] .strip-actions {
  background: rgba(15, 23, 42, 0.78);
}

:root[data-theme='dark'] .strip-actions button {
  color: #e6eefc;
}

:root[data-theme='dark'] .strip-actions button:disabled {
  color: #a9b7cc;
  background: rgba(15, 23, 42, 0.52);
  opacity: 0.86;
}

:root[data-theme='dark'] .segmented button.active {
  color: #f8fbff;
  background: rgba(72, 118, 214, 0.42);
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: 100vh;
    min-height: 0;
    width: 100vw;
    border-radius: 0;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .sidebar-status {
    display: none;
  }

  .brand span:not(.brand-mark),
  .nav-item span:last-child {
    display: block;
  }

  .brand {
    flex: 0 0 auto;
  }

  .nav-list {
    display: flex;
    flex: 0 0 auto;
  }

  .nav-item {
    width: auto;
    padding: 0 10px;
  }

  .topbar,
  .page-title,
  .hero-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 16px;
  }

  .view-stage {
    padding: 16px;
    overflow: auto;
  }

  .grid-2,
  .grid-3,
  .dashboard-grid,
  .status-grid,
  .metrics-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-areas:
      'health'
      'models'
      'config'
      'usage'
      'requests';
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .strip-actions {
    grid-column: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .config-summary {
    grid-template-columns: 1fr;
  }

  .config-summary-item.span-2 {
    grid-column: auto;
  }

  .span-2 {
    grid-column: auto;
  }

  .topbar-actions,
  .button-row,
  .toolbar {
    flex-wrap: wrap;
  }
}
