:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --sidebar-top: #0b1220;
  --sidebar-bottom: #131e32;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --border: #e5eaf2;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #10b981;
  --success-hover: #059669;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-hover: #d97706;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: #fef2f2;
  --radius-lg: 12px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 24px 60px rgba(15, 23, 42, 0.25);
}

* { box-sizing: border-box; }

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

/* Custom sleek scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.layout {
  display: flex;
  min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
  width: 224px;
  background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 30;
}

.brand {
  height: 60px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.38);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
}
.brand-sub {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 2px;
}

.nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 8px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 9px;
  cursor: pointer;
  color: #cbd5e1;
  transition: all 0.16s ease;
  user-select: none;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-icon {
  width: 17px;
  height: 17px;
  opacity: 0.78;
  flex-shrink: 0;
  transition: opacity 0.16s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.11);
  color: #e2e8f0;
}
.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.14);
}
.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #e2e8f0;
  font-weight: 500;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==================== Main & Topbar ==================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.global-switch-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  font-weight: 600;
  font-size: 12.5px;
  transition: all 0.2s ease;
}
.global-switch-box.paused {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.content {
  padding: 14px 22px 24px;
  flex: 1;
}

/* ==================== KPI Overview Strip ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

/* ==================== Cards & Toolbars ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.node-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.node-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.node-chip:hover { border-color: #93c5fd; background: #f0f7ff; }
.node-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #1e40af;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.online { background: var(--success); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
.dot.offline { background: #94a3b8; }

/* ==================== Inputs & Buttons ==================== */
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  border: 1px solid #d5dde8;
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }
input:hover, select:hover, textarea:hover { border-color: #b4c2d4; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: var(--radius);
  border: 1px solid #d8e0ec;
  background: #fff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #b8c4d6; color: #0f172a; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-refreshing svg { animation: spin 0.7s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.24);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.btn-success:hover { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }

.btn-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.btn-warning:hover { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

.btn-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: var(--radius-sm); }

.btn-link {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 2px 4px;
  cursor: pointer;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

/* ==================== Tables ==================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #edf1f7;
  border-radius: 10px;
}

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

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafd;
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid #e6ecf5;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover td { background: #f8fbff; }
tr.dragging td { background: #eff6ff !important; opacity: 0.72; }

.drag-handle {
  cursor: grab;
  color: #94a3b8;
  margin-right: 6px;
  font-weight: 700;
  padding: 2px 3px;
  border-radius: 4px;
}
.drag-handle:hover { background: #e2e8f0; color: #475569; }

.actions-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

/* ==================== Tags & Price Pills ==================== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.tag-green { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.tag-red { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.tag-gray { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tag-blue { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.tag-orange { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.tag-purple { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }

#strategyTable th {
  padding: 7px 10px;
}
#strategyTable td {
  padding: 4px 10px;
}

.top3-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: "Segoe UI", "Inter", "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  line-height: 1.25;
}
.top3-row {
  padding: 1px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  width: fit-content;
  white-space: nowrap;
  font-weight: 500;
}
.top3-price {
  font-weight: 700;
  letter-spacing: 0.1px;
}
.top3-cur {
  font-size: 11.5px;
  opacity: 0.72;
  font-weight: 600;
}
.top3-seller {
  font-weight: 500;
}
.top3-row.qualified {
  color: #0f172a;
  background: #f1f5f9;
}
.top3-row.qualified:first-child {
  color: #065f46;
  background: #ecfdf5;
}
.top3-row.filtered {
  color: #b91c1c;
  background: #fef2f2;
}

.last-priced-cell {
  font-family: "Segoe UI", "Inter", "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}

.inline-min-price {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}
.inline-min-price:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.inline-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.inline-edit-input {
  width: 108px !important;
  padding: 4px 7px !important;
  font-size: 12.5px !important;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.inline-edit-btn {
  padding: 4px 7px !important;
  min-width: 26px;
}

.copy-id {
  cursor: pointer;
  color: #475569;
  transition: color 0.12s ease;
}
.copy-id:hover { color: var(--primary); text-decoration: underline; }

/* ==================== Toggle Switch ==================== */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  transition: 0.2s ease;
  border-radius: 99px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 15px;
  width: 15px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
input:checked + .slider { background: #10b981; }
input:checked + .slider:before { transform: translateX(17px); }

/* ==================== Modals ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: modalPop 0.16s ease-out;
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
  border-radius: 0 0 14px 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-section {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin: 16px 0 10px;
  padding: 4px 10px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
}
.form-row { margin-bottom: 12px; }
.form-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #334155;
  font-size: 12.5px;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="password"],
.form-row select,
.form-row textarea { width: 100%; }

.form-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.quick-pct { display: flex; gap: 6px; margin-top: 6px; }

.check-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: #fcfdff;
}
.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.check-item:hover { background: #eff6ff; }

.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 8px;
  font-family: Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

/* ==================== Toasts ==================== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

.empty-state {
  text-align: center;
  padding: 44px 16px;
  color: var(--muted);
  font-size: 13px;
}
.mono {
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}
.truncate {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== Auth Screen & Topbar User ==================== */
body.auth-checking .layout,
body.auth-locked .layout {
  display: none;
}

.auth-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: radial-gradient(circle at top right, #1e293b 0%, #0b1220 60%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.auth-locked .auth-screen {
  display: flex;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.auth-brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.auth-brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.auth-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 4px 0 16px;
  cursor: pointer;
  user-select: none;
}

.auth-submit-btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.user-chip:empty {
  display: none;
}

/* ==================== Server Monitor ==================== */
.monitor-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.monitor-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.monitor-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12.5px;
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.monitor-pill strong {
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.monitor-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px;
}

.health-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.health-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.health-label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.health-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.health-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}
.srv-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.srv-card:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}
.srv-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 8px 22px rgba(37, 99, 235, 0.08);
}
.srv-card.offline {
  background: #fafafa;
  border-color: #e2e8f0;
}
.srv-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.srv-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.srv-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.srv-cpu-big {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.srv-cpu-big span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.srv-metric-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.srv-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}
.srv-metric-sub {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.srv-progress {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: #eef2f7;
  overflow: hidden;
}
.srv-progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  transition: width 0.35s ease;
}
.srv-progress-bar.warn {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}
.srv-progress-bar.danger {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.srv-net-box {
  background: #f8fafc;
  border: 1px solid #e7edf5;
  border-radius: 10px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 11.5px;
}
.srv-net-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.srv-net-label {
  color: var(--muted);
  font-size: 11px;
}
.srv-net-val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.srv-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  font-size: 11.5px;
  color: var(--muted);
}

.monitor-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.monitor-alert-item {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.monitor-alert-item.warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.monitor-alert-item.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chart-tab-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.chart-tab-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}
.chart-tab-btn.active {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: var(--primary);
}
.chart-range-pills {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
}
.chart-range-btn {
  padding: 5px 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.chart-range-btn.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.chart-summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.chart-summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.chart-summary-stats strong {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-line {
  width: 14px;
  height: 2px;
  display: inline-block;
}
.legend-line.solid { background: #2563eb; }
.legend-line.dashed { border-top: 2px dashed #60a5fa; height: 0; }
.legend-line.emerald { background: #10b981; }

.chart-svg-wrap {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.chart-svg-wrap svg {
  width: 100%;
  height: 240px;
  display: block;
}
.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.55;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  z-index: 30;
  white-space: nowrap;
}
