:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --success: #15803d;
  --warning: #b45309;
  --danger: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

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

.text-xs {
  font-size: 12px;
}

.mt-16 {
  margin-top: 16px;
}

code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  max-width: 380px;
}

.toast.success {
  background: #166534;
}

.toast.error {
  background: #991b1b;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.login-card h1 {
  margin: 10px 0 6px;
  font-size: 20px;
}

.brand-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: #eff6ff;
  padding: 4px 10px;
  border-radius: 999px;
}

.login-hint {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  font-weight: 600;
  font-size: 12px;
  color: #334155;
}

.field input,
.field select,
.field textarea,
.input-sm {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: var(--text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  padding: 9px 14px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  border-color: #cbd5e1;
  background: #fff;
}

.btn-ghost:hover {
  background: #f8fafc;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}

.btn-danger-ghost {
  border-color: #fecaca;
  color: var(--danger);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
}

.topbar-sub {
  font-size: 12px;
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.banner {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.banner-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.tabs-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.main-content {
  padding: 16px 20px 32px;
  max-width: 1480px;
  margin: 0 auto;
}

.alerts-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.alert-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid;
}

.alert-item.critical {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-item.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

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

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}

.table-scroll {
  overflow-x: auto;
}

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

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

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.badge-err {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-muted {
  background: #f1f5f9;
  color: #475569;
}

.chart-wrap {
  width: 100%;
  min-height: 180px;
  overflow-x: auto;
}

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

.sub-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.sub-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
}

.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 18px;
  background: #f8fafc;
  text-align: center;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.drawer-backdrop {
  justify-content: flex-end;
  padding: 0;
}

.modal-box {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.drawer-box {
  background: var(--surface);
  width: 100%;
  max-width: 580px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.2);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.secret-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

.kv-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  margin-bottom: 16px;
}

.kv-label {
  color: var(--muted);
  font-weight: 600;
}
