:root {
  color-scheme: light dark;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-hover: #fafcfc;
  --ink: #202726;
  --muted: #65706e;
  --line: #dce2e0;
  --line-strong: #c8d0ce;
  --table-line: #e8eceb;
  --chart-grid: #e5eae8;
  --green: #16794a;
  --green-soft: #e7f4ec;
  --red: #b42318;
  --red-soft: #fcebea;
  --cyan: #087c89;
  --cyan-soft: #e4f4f5;
  --yellow: #8a6100;
  --yellow-soft: #fff5d6;
  --charcoal: #18201f;
  --topbar: rgba(255, 255, 255, 0.97);
  --overlay: rgba(19, 26, 25, 0.58);
  --sidebar-width: 224px;
  --topbar-height: 72px;
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.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;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: #f4f7f6;
  background: var(--charcoal);
  border-right: 1px solid #2d3735;
}

.brand-block {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid #303a38;
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  color: #ffffff;
  background: var(--green);
  border-radius: 6px;
  font-size: 16px;
  font-weight: 700;
}

.brand-block strong,
.brand-block span {
  display: block;
}

.brand-block strong {
  font-size: 15px;
}

.brand-block div > span {
  color: #9fa9a7;
  font-size: 12px;
}

.primary-nav {
  display: grid;
  gap: 3px;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-section-label {
  padding: 12px 12px 4px;
  color: #75807d;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-section-label:first-child {
  padding-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 39px;
  padding: 0 12px;
  color: #b9c2c0;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  text-decoration: none;
}

.nav-item:hover {
  color: #ffffff;
  background: #222c2a;
}

.nav-item.is-active {
  color: #ffffff;
  background: #26332f;
  border-color: #35443f;
  box-shadow: inset 3px 0 0 var(--green);
}

.sidebar-footer {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 0 12px 0 16px;
  color: #9fa9a7;
  border-top: 1px solid #303a38;
  font-size: 12px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  background: #77817f;
  border-radius: 50%;
}

.connection-dot.is-online {
  background: #38a169;
}

.connection-dot.is-error {
  background: #e0564a;
}

.sidebar-logout {
  margin-left: auto;
  color: #b9c2c0 !important;
  border-color: transparent !important;
  background: transparent !important;
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 20px;
  padding: 9px 24px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}

.page-heading {
  min-width: 150px;
}

.page-heading h1 {
  margin: 1px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.compact-field select,
.search-field,
.search-field input {
  height: 36px;
}

.compact-field select,
.search-field {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.compact-field select {
  min-width: 122px;
  padding: 0 28px 0 10px;
}

.search-field {
  display: flex;
  width: min(260px, 25vw);
  align-items: center;
  gap: 6px;
  padding: 0 9px;
}

.search-field span {
  color: var(--muted);
  font-size: 17px;
}

.search-field input {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-size: 18px;
}

.icon-button:hover {
  background: var(--surface-muted);
}

.icon-button.is-spinning {
  animation: spin 0.7s linear infinite;
}

.mobile-menu {
  display: none;
}

.main-content {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.section-heading,
.surface-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  min-height: 44px;
  margin-bottom: 16px;
}

.section-heading h2,
.surface-heading h3 {
  margin: 0;
  color: var(--ink);
}

.section-heading h2 {
  font-size: 17px;
}

.surface-heading h3 {
  font-size: 14px;
}

.section-heading p,
.surface-heading span {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-chip,
.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-chip.neutral,
.status-badge.neutral {
  color: #56605e;
  background: #edf0ef;
}

.status-chip.success,
.status-badge.success {
  color: var(--green);
  background: var(--green-soft);
}

.status-chip.danger,
.status-badge.danger {
  color: var(--red);
  background: var(--red-soft);
}

.status-chip.warning,
.status-badge.warning {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.status-chip.info,
.status-badge.info {
  color: var(--cyan);
  background: var(--cyan-soft);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-card,
.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-card {
  min-height: 110px;
  padding: 15px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 25px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  min-height: 18px;
  font-size: 11px;
}

.resource-count {
  color: var(--ink) !important;
  font-weight: 600;
}

.resource-metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.resource-metric-card {
  min-width: 0;
  min-height: 92px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: 6px;
}

.resource-metric-card.success { border-top-color: var(--green); }
.resource-metric-card.warning { border-top-color: #d49b16; }
.resource-metric-card.danger { border-top-color: var(--red); }
.resource-metric-card.info { border-top-color: var(--cyan); }

.settings-table-wrap {
  min-height: 220px;
}

.settings-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.settings-dirty-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.settings-save-all {
  min-width: 132px;
  min-height: 40px;
  font-weight: 700;
}

.settings-table tr.is-dirty td:first-child {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.settings-table td {
  vertical-align: middle;
}

.setting-key,
.setting-meta {
  display: block;
}

.setting-key {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}

.setting-meta {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
}

.setting-value-cell {
  min-width: 260px;
}

.setting-input {
  width: min(100%, 440px);
  min-height: 32px;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: inherit;
}

.setting-input:focus {
  outline: 2px solid var(--cyan-soft);
  border-color: var(--cyan);
}

.setting-secret-wrap {
  display: flex;
  width: min(100%, 440px);
  align-items: center;
  gap: 5px;
}

.setting-secret-wrap .setting-input {
  min-width: 0;
  flex: 1;
}

.setting-reveal {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
}

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

.provider-card {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--line-strong);
  border-radius: 6px;
}

.provider-card.is-healthy { border-top-color: var(--green); }
.provider-card.is-failed { border-top-color: var(--red); }

.provider-card-head,
.provider-card-head > div,
.provider-availability > div,
.provider-card-footer {
  display: flex;
  align-items: center;
}

.provider-card-head,
.provider-card-footer,
.provider-availability > div {
  justify-content: space-between;
}

.provider-card-head > div {
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-card-head strong {
  color: var(--ink);
  font-size: 15px;
}

.provider-card-head > div > span,
.provider-purpose,
.provider-card-footer,
.provider-availability small {
  color: var(--muted);
  font-size: 11px;
}

.provider-status {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.provider-status.success { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.provider-status.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.provider-status.neutral { color: var(--muted); }

.provider-purpose {
  margin: 7px 0 9px;
}

.provider-endpoint {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.provider-metrics > div {
  min-width: 0;
  padding: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.provider-metrics span,
.provider-metrics strong {
  display: block;
}

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

.provider-metrics strong {
  margin-top: 5px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0;
}

.provider-availability {
  padding: 10px 0 8px;
  border-top: 1px solid var(--line);
}

.provider-availability span { color: var(--muted); font-size: 11px; }
.provider-availability strong { color: var(--green); font-size: 18px; }

.provider-history {
  display: grid;
  grid-template-columns: repeat(30, minmax(3px, 1fr));
  align-items: end;
  min-height: 42px;
  gap: 3px;
  margin: 8px 0 12px;
}

.provider-history i {
  display: block;
  min-height: 24px;
  border-radius: 2px;
  background: var(--line-strong);
}

.provider-history i.success { background: var(--green); }
.provider-history i.danger { background: var(--red); }
.provider-history span { grid-column: 1 / -1; align-self: center; color: var(--muted); font-size: 11px; }

.provider-test-one {
  min-height: 30px;
  padding: 5px 12px;
}

.setting-actions {
  flex-wrap: wrap;
}

.setting-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.setting-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.setting-toggle span {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background .15s ease;
}

.setting-toggle span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  content: "";
  transition: transform .15s ease;
}

.setting-toggle input:checked + span {
  background: var(--green);
}

.setting-toggle input:checked + span::after {
  transform: translateX(16px);
}

.resource-metric-card > span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.resource-metric-card strong {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.value-meter {
  display: inline-grid;
  min-width: 128px;
  grid-template-columns: minmax(64px, 1fr) 42px;
  align-items: center;
  gap: 7px;
}

.value-meter > i {
  display: block;
  height: 6px;
  overflow: hidden;
  background: var(--chart-grid);
  border-radius: 999px;
}

.value-meter > i > b {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.value-meter > i > b[data-level="medium"] { background: #d49b16; }
.value-meter > i > b[data-level="high"] { background: var(--red); }

.value-meter > span {
  color: var(--muted);
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.summary-meter {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.surface {
  padding: 16px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend i {
  width: 13px;
  height: 3px;
  background: var(--cyan);
}

.chart-legend i:nth-of-type(2) {
  margin-left: 7px;
  background: var(--green);
}

.chart-frame {
  position: relative;
  height: 220px;
  margin-top: 13px;
}

#trend-chart {
  display: block;
  width: 100%;
  height: 220px;
}

.text-button {
  min-height: 30px;
  padding: 0 8px;
  color: var(--cyan);
  background: transparent;
  border: 0;
}

.queue-list {
  display: grid;
  gap: 12px;
  margin-top: 15px;
}

.queue-row {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) 2fr auto;
  align-items: center;
  gap: 10px;
}

.queue-label {
  min-width: 0;
}

.queue-label strong,
.queue-label span {
  display: block;
}

.queue-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

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

.queue-bar {
  height: 7px;
  overflow: hidden;
  background: #edf0ef;
  border-radius: 4px;
}

.queue-bar i {
  display: block;
  height: 100%;
  background: var(--cyan);
  border-radius: inherit;
}

.queue-row[data-tone="success"] .queue-bar i { background: var(--green); }
.queue-row[data-tone="warning"] .queue-bar i { background: #d49b16; }
.queue-row[data-tone="danger"] .queue-bar i { background: var(--red); }

.queue-count {
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.table-wrap {
  position: relative;
  min-height: 132px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  height: 43px;
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--table-line);
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: var(--surface-muted);
  white-space: nowrap;
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-hover);
}

td {
  max-width: 340px;
  color: var(--ink);
}

.cell-clip {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-number {
  font-variant-numeric: tabular-nums;
}

.table-state {
  display: grid;
  min-height: 88px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

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

.loading-line {
  width: min(240px, 70%);
  height: 8px;
  background: #e7ebea;
  border-radius: 4px;
  animation: pulse 1.1s ease-in-out infinite;
}

.inline-filters {
  display: flex;
  gap: 8px;
}

.resource-table-wrap {
  max-height: calc(100vh - 318px);
  min-height: 300px;
}

.pagination {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.pagination > div {
  display: flex;
  gap: 8px;
}

.pagination-button {
  min-width: 76px;
}

.row-action {
  min-width: 48px;
  height: 29px;
  padding: 0 9px;
  color: var(--cyan);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: max-content;
}

.row-action.is-danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 36%, var(--line));
}

.row-action.is-warning {
  color: var(--yellow);
  border-color: color-mix(in srgb, var(--yellow) 40%, var(--line));
}

.row-action.is-success {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 36%, var(--line));
}

.cell-muted {
  color: var(--muted);
}

.admin-audit-surface {
  margin-top: 18px;
}

.system-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 14px;
}

.system-status dl {
  margin: 13px 0 0;
}

.system-status dl div,
.maintenance-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--table-line);
}

.system-status dt {
  color: var(--muted);
}

.system-status dd {
  margin: 0;
  font-weight: 600;
}

.maintenance-row {
  margin-top: 13px;
  padding-top: 14px;
}

.maintenance-row strong,
.maintenance-row span {
  display: block;
}

.maintenance-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 5px;
  font-weight: 600;
}

.primary-button {
  color: #ffffff;
  background: var(--green);
  border: 1px solid var(--green);
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.danger-button {
  color: #ffffff;
  background: var(--red);
  border: 1px solid var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(19, 26, 25, 0.78);
}

.login-panel {
  width: min(390px, 100%);
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 18px 48px rgba(10, 18, 16, 0.22);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-panel h2 {
  margin: 22px 0 16px;
  font-size: 20px;
}

.login-panel label span {
  display: block;
  margin-bottom: 6px;
  color: #4f5a58;
  font-size: 12px;
  font-weight: 600;
}

.login-panel input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.login-panel .remember-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  cursor: pointer;
}

.login-panel .remember-field input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.login-panel .remember-field span {
  margin: 0;
  color: #4f5a58;
  font-weight: 500;
}

.login-panel .primary-button {
  width: 100%;
  margin-top: 4px;
}

.form-error {
  min-height: 20px;
  margin: 7px 0 0;
  color: var(--red);
  font-size: 12px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(21, 28, 27, 0.34);
}

.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 70;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: -14px 0 40px rgba(15, 25, 22, 0.16);
}

.detail-drawer > header {
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.detail-drawer header span {
  color: var(--muted);
  font-size: 11px;
}

.detail-drawer header h2 {
  margin: 1px 0 0;
  font-size: 17px;
}

.drawer-content {
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
}

.message-row {
  margin-bottom: 10px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: 5px;
}

.message-row.assistant {
  border-left-color: var(--green);
}

.message-row.sensitive-content {
  border-left-color: var(--red);
}

.message-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.message-row p {
  margin: 7px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.confirm-dialog {
  width: min(410px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 18px 48px rgba(10, 18, 16, 0.24);
}

.confirm-dialog::backdrop {
  background: rgba(19, 26, 25, 0.58);
}

.confirm-dialog form {
  padding: 22px;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 17px;
}

.confirm-dialog p {
  margin: 8px 0 20px;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 10px 13px;
  color: #ffffff;
  background: var(--charcoal);
  border-radius: 5px;
  box-shadow: 0 10px 28px rgba(10, 18, 16, 0.18);
}

.nav-backdrop {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

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

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(19, 26, 25, 0.45);
    border: 0;
  }

  body.sidebar-open .nav-backdrop {
    display: block;
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar {
    padding-inline: 14px;
  }

  .eyebrow,
  .range-field {
    display: none;
  }

  .search-field {
    width: min(220px, 35vw);
  }

  .main-content {
    padding: 18px 14px 32px;
  }

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

@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding-block: 9px;
  }

  .page-heading {
    min-width: 0;
    flex: 1;
  }

  .page-heading h1 {
    font-size: 17px;
  }

  .topbar-actions {
    width: 100%;
  }

  .search-field {
    width: auto;
    flex: 1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .metric-card {
    min-height: 98px;
  }

  .section-heading.resource-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-filters {
    width: 100%;
  }

  .inline-filters label,
  .inline-filters select {
    width: 100%;
  }

  .settings-heading-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .settings-heading-actions label,
  .settings-heading-actions select,
  .settings-heading-actions button {
    width: 100%;
  }

  .provider-board {
    grid-template-columns: 1fr;
  }

  .queue-row {
    grid-template-columns: minmax(86px, 1fr) 1.2fr auto;
  }

  .maintenance-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-table-wrap {
    overflow: visible;
  }

  .settings-table,
  .settings-table tbody,
  .settings-table tr,
  .settings-table td {
    display: block;
    width: 100%;
  }

  .settings-table thead {
    display: none;
  }

  .settings-table tr {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
  }

  .settings-table tr:last-child {
    border-bottom: 0;
  }

  .settings-table td {
    min-width: 0;
    padding: 5px 0;
    border: 0;
  }

  .settings-table td:nth-child(3),
  .settings-table td:nth-child(4),
  .settings-table td:nth-child(5) {
    display: inline-flex;
    width: auto;
    align-items: center;
    margin-right: 12px;
  }

  .settings-table td:nth-child(4)::before {
    margin-right: 5px;
    color: var(--muted);
    content: "版本";
    font-size: 11px;
  }

  .setting-value-cell,
  .setting-secret-wrap,
  .setting-input {
    width: 100%;
    max-width: none;
  }

  .setting-actions {
    margin-top: 4px;
  }
}

/* 用户详情抽屉与系统页扩展模块 */
.system-block {
  margin-top: 14px;
}

.drawer-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.drawer-section {
  margin-bottom: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.drawer-section h3 {
  margin: 0 0 9px;
  font-size: 13px;
}

.drawer-section dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  margin: 0;
}

.drawer-section dl div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.drawer-section dt {
  color: var(--muted);
}

.drawer-section dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  text-align: right;
}

.drawer-section p {
  margin: 0;
}

.drawer-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--table-line);
  border-radius: 5px;
}

.drawer-table-wrap table {
  min-width: 430px;
}

@media (max-width: 1080px) {
  :root {
    --sidebar-width: 188px;
  }

  .metric-grid,
  .resource-metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body.sidebar-open {
    overflow: visible;
  }

  .nav-backdrop {
    display: none !important;
  }

  .mobile-menu {
    display: none;
  }

  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid #2d3735;
    transform: none;
  }

  .brand-block {
    min-height: 0;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 0;
  }

  .brand-block div > span {
    display: none;
  }

  .primary-nav {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .nav-section-label {
    display: none;
  }

  .nav-item {
    min-height: 40px;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    min-height: 0;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 0 10px;
    border-top: 0;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .page-heading {
    min-width: 0;
    flex: 1;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-field {
    width: 100%;
    flex: 1 1 100%;
  }

  #refresh-button {
    margin-left: auto;
  }

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

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 640px;
  }

  .table-wrap th:first-child,
  .table-wrap td:first-child {
    position: sticky;
    left: 0;
  }

  .table-wrap th:first-child {
    z-index: 3;
    background: var(--surface-muted);
  }

  .table-wrap td:first-child {
    z-index: 1;
    background: var(--surface);
  }

  .table-wrap tbody tr:hover td:first-child {
    background: var(--surface-hover);
  }

  .detail-drawer {
    width: 100vw;
    border-left: 0;
  }

  .row-actions {
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .row-action,
  .pagination-button,
  .primary-button,
  .secondary-button,
  .danger-button,
  .text-button {
    min-height: 40px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .compact-field select,
  .search-field,
  .search-field input {
    height: 40px;
  }

  .login-panel {
    width: min(92vw, 420px);
  }
}

@media (max-width: 380px) {
  .metric-grid,
  .resource-metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .settings-table-wrap {
    overflow: visible;
  }

  .settings-table-wrap .settings-table {
    min-width: 0;
  }

  .settings-table-wrap .settings-table th:first-child,
  .settings-table-wrap .settings-table td:first-child {
    position: static;
  }

  .setting-secret-wrap .setting-input {
    width: 0;
    min-width: 0;
    flex: 1 1 auto;
  }

  .setting-actions {
    flex-direction: row;
    align-items: center;
  }
}
