:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --line: #d9dee5;
  --line-strong: #bec7d2;
  --text: #17202b;
  --muted: #667383;
  --accent: #176b73;
  --accent-hover: #115860;
  --accent-soft: #e8f4f3;
  --positive: #18794e;
  --positive-soft: #e9f7ef;
  --warning: #a15c00;
  --warning-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 10px 30px rgba(23, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button, input, textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(23, 107, 115, 0.2);
  outline-offset: 1px;
}

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

.secondary-button {
  border-color: var(--line-strong);
  background: #ffffff;
  color: #354253;
}

.secondary-button:hover:not(:disabled), .quiet-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.quiet-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover:not(:disabled) {
  background: #8f1c14;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input::placeholder, textarea::placeholder {
  color: #98a3af;
}

textarea {
  min-height: 132px;
  margin-top: 12px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.action-progress {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 100;
  display: none;
  width: min(360px, calc(100% - 28px));
  grid-template-columns: minmax(110px, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  color: #445164;
  font-size: 12px;
  font-weight: 700;
}

.action-progress.active {
  display: grid;
}

.action-progress progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

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

.login-shell {
  width: min(460px, 100%);
  border-top: 4px solid #2a9d8f;
  border-radius: 6px;
  padding: 34px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-mark, .brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

.login-copy {
  margin: 24px 0 28px;
}

.product-label, .section-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-copy h1 {
  margin: 6px 0 5px;
  font-size: 28px;
  line-height: 1.2;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
}

.login-form label {
  color: #445164;
  font-size: 13px;
  font-weight: 600;
}

.login-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 10px max(24px, calc((100vw - 1360px) / 2));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand-block, .header-actions, .actions-row, .section-heading, .pagination-row, .table-toolbar {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-block h1 {
  margin: 1px 0 0;
  font-size: 18px;
  line-height: 1.15;
}

.header-actions, .actions-row {
  gap: 8px;
  flex-wrap: wrap;
}

.inline-field {
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
}

.inline-field select[multiple] {
  min-height: 76px;
  padding: 5px;
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  color: var(--positive);
  font-size: 12px;
  font-weight: 700;
}

.service-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 3px var(--positive-soft);
}

.page-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 22px 24px 48px;
}

.workspace-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 16px;
}

.workspace-tab {
  flex: 0 0 auto;
  min-height: 42px;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 18px;
}

.workspace-tab:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
}

.workspace-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.workspace {
  display: none;
}

.workspace.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.stats-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--panel);
}

.stats-grid span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.15;
}

.stat-positive {
  border-left: 3px solid var(--positive) !important;
}

.stat-positive strong {
  color: var(--positive);
}

.stat-warning {
  border-left: 3px solid var(--warning) !important;
}

.stat-warning strong {
  color: var(--warning);
}

.stats-hidden {
  display: none;
}

.panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(23, 32, 43, 0.03);
}

.panel h2 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.25;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.split-panel > div:first-child {
  margin-bottom: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.toggle-group {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 16px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.check-label input, table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

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

.monitor-status > span, .monitor-status > em {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 4px;
  color: #445164;
  font-size: 13px;
  font-style: normal;
}

.monitor-status em {
  grid-column: 1 / -1;
  color: var(--danger);
}

.monitor-status .wide {
  grid-column: 1 / -1;
}

.status-breakdown {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.status-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px;
  background: var(--panel-soft);
}

.status-card div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

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

.status-card strong {
  font-size: 18px;
}

.progress-block {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(220px, auto);
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px 14px;
  background: var(--panel-soft);
}

.progress-block progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.progress-block span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.liveness-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-strong);
  margin-top: 18px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 40px;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
}

.tab-button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.tab-button span {
  display: inline-block;
  min-width: 22px;
  margin-left: 5px;
  border-radius: 10px;
  padding: 1px 6px;
  background: #e8edf2;
  color: #4c5a6b;
  font-size: 11px;
}

.table-toolbar {
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
}

.table-toolbar > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.remote-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 8px;
}

.database-filters select[multiple] {
  min-height: 108px;
  padding: 6px;
}

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

.api-key-table-wrap {
  margin-top: 2px;
}

.api-key-table th, .api-key-table td {
  min-width: 132px;
  vertical-align: middle;
}

.api-key-table th:nth-child(3), .api-key-table td:nth-child(3) {
  min-width: 210px;
}

.api-key-table th:nth-child(4), .api-key-table td:nth-child(4) {
  min-width: 220px;
}

.api-key-table th:last-child, .api-key-table td:last-child {
  min-width: 58px;
  text-align: right;
}

.api-key-table input, .api-key-table select {
  min-width: 0;
}

.api-key-table .remove-api-row {
  min-height: 32px;
  padding: 5px 9px;
  border-color: #efc2bc;
  background: #ffffff;
  color: var(--danger);
  font-size: 12px;
}

.api-key-table .remove-api-row:hover:not(:disabled) {
  background: var(--danger-soft);
}

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

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf1f4;
  color: #536173;
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f7fafb;
}

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

.account-primary, .account-secondary {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-secondary {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.audit-input {
  max-width: 560px;
  max-height: 240px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.audit-toggle {
  white-space: nowrap;
}

.audit-summary > div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
}

.audit-summary span,
.audit-summary strong {
  display: block;
}

.audit-summary span {
  color: var(--muted);
  font-size: 12px;
}

.audit-summary strong {
  margin-top: 3px;
  font-size: 18px;
}

.audit-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.audit-term {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.audit-term button {
  min-height: 28px;
  padding: 3px 6px;
}

.audit-text-button {
  min-height: 30px;
  padding: 4px 8px;
  white-space: nowrap;
}

.audit-text-dialog {
  width: min(900px, calc(100% - 24px));
  max-width: none;
  max-height: 84vh;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(23, 32, 43, 0.28);
}

.audit-text-dialog::backdrop {
  background: rgba(23, 32, 43, 0.58);
}

.audit-text-dialog-shell {
  display: grid;
  max-height: 84vh;
  grid-template-rows: auto minmax(0, 1fr);
}

.audit-text-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
}

.audit-text-dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.audit-text-dialog-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.audit-text-dialog-header form {
  margin: 0;
}

.audit-text-dialog-close {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.audit-text-dialog-content {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding: 18px;
  background: var(--panel-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.small-button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 11px;
}

.status-ok {
  color: var(--positive);
}

.status-error {
  color: var(--danger);
}

.pagination-row {
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.job-form {
  display: grid;
  grid-template-columns: 160px 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.job {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 16px;
  border-bottom: 1px solid var(--line);
  padding: 11px 2px;
}

.job span {
  color: var(--muted);
}

.job em {
  grid-column: 1 / -1;
  color: var(--danger);
  font-style: normal;
}

.danger-zone {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  border-color: #efc2bc;
  background: var(--danger-soft);
}

.danger-zone p {
  margin: 6px 0 0;
  color: #7a4943;
  font-size: 13px;
}

.danger-zone .message {
  grid-column: 1 / -1;
}

.message {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.message:empty {
  min-height: 0;
  margin-top: 0;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
}

@media (max-width: 1050px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-breakdown {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .audit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-header {
    position: static;
    align-items: flex-start;
    padding: 12px 16px;
  }
  .service-state {
    display: none;
  }
  .page-shell {
    padding: 16px 12px 36px;
  }
  .workspace-nav {
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 10px;
  }
  .workspace-tab {
    padding: 8px 12px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .section-heading, .danger-zone {
    align-items: flex-start;
    flex-direction: column;
    display: flex;
  }
  .section-heading .actions-row, .danger-zone button {
    width: 100%;
  }
  .section-heading .actions-row button {
    flex: 1 1 auto;
  }
  .grid-form, .job-form, .monitor-status {
    grid-template-columns: 1fr;
  }
  .remote-filter-row {
    grid-template-columns: 1fr;
  }
  .status-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .progress-block {
    grid-template-columns: 1fr;
  }
  .progress-block span {
    text-align: left;
  }
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }
  .pagination-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .login {
    padding: 14px;
  }
  .login-shell {
    padding: 26px 20px;
  }
  .login-row {
    grid-template-columns: 1fr;
  }
  .app-header {
    gap: 12px;
  }
  .brand-block .product-label {
    display: none;
  }
  .brand-mark {
    width: 38px;
    height: 38px;
  }
  .header-actions {
    justify-content: flex-end;
  }
  .header-actions button {
    min-height: 34px;
    padding: 6px 9px;
  }
  .stats-grid strong {
    font-size: 21px;
  }
  .panel {
    padding: 15px;
  }
  .upload-row {
    grid-template-columns: 1fr;
  }
  .toggle-group {
    align-items: flex-start;
    flex-direction: column;
  }
}
