/* GreatBridgeHome Panel — 自包含样式，无外部 CDN */
:root {
  --bg: #0c0d10;
  --surface: #14161c;
  --surface2: #1a1d26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --muted: #8b92a5;
  --accent: #818cf8;
  --accent2: #6366f1;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 10% -10%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(900px 600px at 100% 0%, rgba(52, 211, 153, 0.06), transparent), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 22, 28, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 0.8rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  background: rgba(12, 13, 16, 0.5);
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1.25rem;
  margin: 0.1rem 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn.active {
  color: var(--text);
  border-left-color: var(--accent2);
  background: rgba(99, 102, 241, 0.1);
}

main {
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1400px;
}

.panel {
  display: none;
}
.panel.active {
  display: block;
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.card h3 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}
.badge.warn {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warn);
}
.badge.err {
  background: rgba(248, 113, 113, 0.15);
  color: var(--err);
}

pre.log {
  margin: 0;
  padding: 1rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
}

textarea.code {
  width: 100%;
  min-height: 220px;
  padding: 0.85rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: vertical;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

button.btn {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

button.btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.45);
}

button.btn.primary {
  background: linear-gradient(135deg, var(--accent2), #4f46e5);
  border-color: transparent;
  color: #fff;
}

button.btn.danger {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--err);
}

button.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input.inp {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  min-width: 200px;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.login-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.login-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  z-index: 100;
  animation: fade 0.2s ease;
  max-width: 420px;
}

.toast.err {
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--err);
}

.json-view {
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow: auto;
  max-height: 360px;
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.mini {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.mini th,
table.mini td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.mini th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}

.hint.tiny {
  font-size: 0.78rem;
  margin: 0 0 0.5rem;
  opacity: 0.85;
}

/* —— 总览仪表盘（与 AIOPC 布局对齐）—— */
.dashboard-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
  padding: 1.25rem 1.35rem;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(30, 32, 42, 0.9));
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.95;
}

.dashboard-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dashboard-sub {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  background: rgba(22, 26, 36, 0.65);
  border: 1px solid var(--border);
}

.health-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.health-item .health-label {
  color: var(--muted);
  font-size: 0.76rem;
}

.health-item .health-val {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.health-item.ok .health-dot {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.45);
}

.health-item.bad .health-dot {
  background: var(--err);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.4);
}

.health-item.neutral .health-dot {
  background: var(--muted);
  box-shadow: none;
}

.stat-card-pro {
  position: relative;
  overflow: hidden;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card-pro:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.stat-card-pro .stat-ico {
  position: absolute;
  top: 0.85rem;
  right: 0.95rem;
  font-size: 1.05rem;
  opacity: 0.22;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.stat-card-pro .label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card-pro .big {
  font-size: 1.28rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-card-pro .sub {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.progress-track {
  margin-top: 0.65rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), #22d3ee);
  transition: width 0.4s ease;
}

.progress-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.progress-fill.err {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.dash-section {
  margin-bottom: 1.5rem;
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.section-icon {
  color: var(--accent);
  font-size: 0.85rem;
  opacity: 0.9;
}

.dash-card-inner {
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  min-height: 2rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.15rem;
  padding: 0 0.15rem;
}

table.node-table.striped tbody tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.02);
}

.node-tag {
  font-size: 0.76rem;
  color: var(--muted);
}

.latency-cell {
  vertical-align: middle;
  min-width: 7.5rem;
}

.latency-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.latency-num.latency-good {
  color: var(--ok);
}

.latency-num.latency-mid {
  color: var(--warn);
}

.latency-num.latency-high {
  color: #fb923c;
}

.latency-bar {
  display: block;
  margin-top: 0.28rem;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.latency-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent2), rgba(34, 211, 238, 0.85));
  max-width: 100%;
}

.hostapd-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
}

.hostapd-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.wifi-band-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}

.wifi-mini-card {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(99, 102, 241, 0.06), var(--surface2));
}

.wifi-mini-card.ok {
  border-color: rgba(52, 211, 153, 0.22);
}

.wifi-mini-card.bad {
  border-color: rgba(248, 113, 113, 0.28);
}

.wifi-mini-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.wifi-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.wifi-mini-ssid {
  font-weight: 650;
  font-size: 0.95rem;
  word-break: break-word;
}

.wifi-mini-meta {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
}

.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

table.node-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table.node-table th,
table.node-table td {
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.node-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
}

table.node-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--mono);
}

.pill.ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}

.pill.bad {
  background: rgba(248, 113, 113, 0.12);
  color: var(--err);
}

.pill.warn {
  background: rgba(251, 191, 36, 0.14);
  color: var(--warn);
}

.wifi-band-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.wifi-band-row:last-child {
  border-bottom: none;
}

.dash-sweep-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.sweep-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.sweep-chip.ok {
  border-color: rgba(52, 211, 153, 0.35);
}

.sweep-chip.bad {
  border-color: rgba(248, 113, 113, 0.35);
}

.best-node-banner {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.15), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 0.9rem;
}

.best-node-banner code {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

@media (max-width: 900px) {
  .dashboard-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
  }
  .nav-btn {
    width: auto;
    border-left: none;
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
  }
  .nav-btn.active {
    border-left: none;
    background: rgba(99, 102, 241, 0.2);
  }
}
