:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9cb3;
  --brand: #e61e25;
  --brand-dim: rgba(230, 30, 37, 0.15);
  --accent: #e61e25;
  --accent-hover: #c41920;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 220px;
  --appbar-h: 61px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 120;
}

.appbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.appbar-logo { border-radius: 50%; }
.appbar-title { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.appbar-sub { font-size: 0.85rem; color: var(--muted); font-weight: 400; }

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

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--error); }

.main-layout { display: flex; flex: 1; }

.sidebar {
  position: relative;
  z-index: 120;
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
}

.nav-item {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.95rem;
  text-decoration: none;
}
.nav-item:hover, .nav-item.active {
  color: var(--text);
  background: var(--brand-dim);
  border-left: 3px solid var(--brand);
}

.content { flex: 1; padding: 24px; overflow: auto; }

.view { display: none; }
.view.active { display: block; }

.page-title { font-size: 1.4rem; margin-bottom: 20px; }

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

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

.card-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.card-value { font-size: 1.6rem; font-weight: 600; }

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

.panel h3 { margin-bottom: 16px; font-size: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge.online, .badge.success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.offline { background: rgba(239,68,68,0.15); color: var(--error); }
.badge.pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge.error { background: rgba(239,68,68,0.15); color: var(--error); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.9rem;
  min-width: 180px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-danger {
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.45);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--error);
}
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.inline-toast {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.inline-toast.success { background: rgba(34,197,94,0.15); color: var(--success); }
.inline-toast.error { background: rgba(239,68,68,0.15); color: var(--error); }
.hidden { display: none !important; }

.cell-mono { font-family: monospace; font-size: 0.85rem; }
.cell-muted { color: var(--muted); }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }

/* Login */
.login-page {
  --login-bg: #f4f6f9;
  --login-surface: #ffffff;
  --login-border: rgba(15, 23, 42, 0.1);
  --login-text: #0f172a;
  --login-muted: #64748b;
  --login-input-bg: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(230, 30, 37, 0.05), transparent),
    radial-gradient(ellipse 60% 45% at 85% 80%, rgba(15, 23, 42, 0.04), transparent),
    linear-gradient(165deg, #f8fafc 0%, var(--login-bg) 100%);
  color: var(--login-text);
}

.login-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 20px 16px;
}

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

.login-card h1 {
  margin: 12px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--login-text);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--login-border);
}

.login-logo {
  border-radius: 50%;
  flex-shrink: 0;
}

.login-tagline {
  color: var(--login-muted);
  font-size: 0.82rem;
  margin: 6px 0 0;
}

.login-page .field-box { margin-bottom: 14px; }

.login-page .field-box label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--login-muted);
  margin-bottom: 5px;
}

.login-page .field-box input {
  width: 100%;
  background: var(--login-input-bg);
  border: 1px solid var(--login-border);
  border-radius: 8px;
  color: var(--login-text);
  padding: 10px 12px;
  font-size: 0.92rem;
}

.login-page .field-box input::placeholder { color: #94a3b8; }

.login-page .field-box input:focus {
  outline: none;
  border-color: rgba(230, 30, 37, 0.5);
  box-shadow: 0 0 0 2px rgba(230, 30, 37, 0.1);
}

.login-page .btn.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 8px;
}

.login-page .btn.login-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-alert {
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.84rem;
}

.login-page .login-alert.error {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.login-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--login-border);
  text-align: center;
}

.login-link-btn {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}

.login-link-btn:hover { color: var(--accent-hover); }

.login-meta {
  margin-top: 16px;
  text-align: center;
}

.login-copyright {
  margin: 0;
  font-size: 0.75rem;
  color: var(--login-muted);
}

.login-holdings {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--login-muted);
}

.login-holdings a {
  color: var(--login-text);
  font-weight: 600;
  text-decoration: none;
}

.login-holdings a:hover { color: var(--brand); }

@media (max-width: 480px) {
  .login-card {
    padding: 24px 18px 18px;
    border-radius: 10px;
  }

  .login-card h1 { font-size: 1.3rem; }
}

.page-network .airdrop-bubble {
  transition: none;
}

.page-network .airdrop-bubble.online .airdrop-pulse,
.page-network .airdrop-pulse-fast,
.page-network .radar-ring,
.page-network .airdrop-orbit .airdrop-bubble {
  animation: none !important;
}

.page-network .airdrop-device-icon {
  filter: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.page-network .airdrop-bubble.online .airdrop-device-icon.is-node-icon,
.page-network .airdrop-bubble.online .airdrop-device-icon.is-gateway-icon {
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 2px 8px rgba(0, 0, 0, 0.28);
}

.page-network .airdrop-bubble.offline .airdrop-device-icon {
  filter: none;
  opacity: 0.55;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.page-network .airdrop-dot.on { box-shadow: none; }

.page-network .prox-legend-item.prox-near i { box-shadow: none; }

.page-network .airdrop-legend-item.is-connected i,
.page-network .airdrop-legend-item.is-unconnected i {
  box-shadow: none;
}

/* Mesh topology layout */
.page-desc { color: var(--muted); margin: -12px 0 20px; font-size: 0.9rem; }

.gateway-add-panel { margin-bottom: 20px; }
.gateway-add-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: -4px 0 16px;
}
.gateway-add-form { max-width: 640px; }
.gateway-code-field { margin-bottom: 16px; }
.gateway-code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.35rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 16px;
  width: 100%;
  max-width: 320px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.gateway-code-input:focus {
  outline: none;
  border-color: rgba(230, 30, 37, 0.5);
  box-shadow: 0 0 0 3px rgba(230, 30, 37, 0.12);
}
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}
.gateway-meta-row .field-box { flex: 1; min-width: 200px; }
.gateway-meta-row .field-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
}
.gateway-meta-row .field-box label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.mesh-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(300px, 1fr);
  gap: 16px;
  min-height: 560px;
}

/* Network page — full canvas trong vùng content (giữ sidebar) */
/* Network page — dialog chỉ phủ vùng content, giữ sidebar + appbar */
.page-network .mesh-dialog {
  inset: var(--appbar-h) 0 0 var(--sidebar-w);
}

.page-network .app-shell { min-height: 100vh; }
.page-network .main-layout { flex: 1; min-height: 0; }
.page-network .content {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.mesh-page {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.mesh-toolbar-float {
  position: absolute;
  top: 10px;
  right: 10px;
  left: auto;
  z-index: 4;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(8px);
  max-width: min(420px, calc(100vw - 20px));
}

.mesh-canvas-full {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  border: none;
  border-radius: 0;
}

.page-network .mesh-canvas-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: calc(100vh - 56px);
  background:
    radial-gradient(ellipse 90% 70% at 50% 45%, rgba(59, 130, 246, 0.09) 0%, transparent 72%),
    radial-gradient(ellipse 120% 90% at 50% 100%, rgba(15, 23, 42, 0.92) 0%, var(--bg) 60%);
}

.page-network .mesh-canvas-full .airdrop-stage.airdrop-mesh {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  min-height: 0;
  padding: 52px 8px 16px;
  box-sizing: border-box;
}

.page-network .airdrop-coordinator {
  margin: 0 auto;
  width: 100%;
  max-width: min(96vw, 1100px);
  padding: 8px 12px 12px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.page-network .airdrop-radar-lg {
  width: min(92vmin, calc(100vw - 260px), calc(100vh - 160px));
  height: min(92vmin, calc(100vw - 260px), calc(100vh - 160px));
}

.page-network .airdrop-orbit .airdrop-bubble.orbit-placed {
  animation: none !important;
  transition: transform 0.55s ease, opacity 0.25s ease;
}

.page-network .airdrop-bubble.is-sleeping .airdrop-device-icon {
  opacity: 0.72;
  filter: saturate(0.55);
}

.page-network .airdrop-bubble.is-sleeping .airdrop-name::after {
  content: ' 💤';
}

.page-network .mesh-dialog-main,
.page-network .mesh-config-meta,
.page-network .mesh-status-lamp,
.page-network .mesh-status-lamp-dot,
.page-network .ind-panel {
  transition: none !important;
}

.page-network .radar-ring-prox-far {
  animation: none;
  opacity: 0.85;
}

.page-network .airdrop-bubble.offline {
  opacity: 0.78;
}

.page-network .airdrop-bubble.offline .airdrop-device-icon {
  opacity: 0.72;
}

.page-network .mesh-empty {
  min-height: min(400px, 50vh);
}

.mesh-loading {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.mesh-error {
  color: #fca5a5;
  text-align: center;
  padding: 24px;
  max-width: 420px;
}

.mesh-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mesh-dialog.hidden { display: none !important; }

.mesh-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, 0.82);
}

.mesh-dialog-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(1080px, 96vw);
  max-height: min(92vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #141b24;
  border: 1px solid #2d3a4f;
  border-radius: 6px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
}

.mesh-dialog-panel.is-gateway-dialog {
  max-width: min(1120px, 96vw);
  border-top: 3px solid var(--brand);
}

.mesh-dialog-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid #2d3a4f;
  background: #0f1419;
  flex-shrink: 0;
}

.mesh-dialog-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.mesh-dialog-titles {
  min-width: 0;
}

.mesh-dialog-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mesh-dialog-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mesh-device-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
}

.mesh-device-badge.is-gateway {
  color: #fff;
  background: var(--brand);
  border-color: #b8181f;
}

.mesh-device-badge.is-node {
  color: #bfdbfe;
  background: #1e3a5f;
  border-color: #2563eb;
}

.mesh-status-lamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #2d3a4f;
  background: #1a2332;
  flex-shrink: 0;
}

.mesh-status-lamp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.25);
}

.mesh-status-lamp.on .mesh-status-lamp-dot {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.65);
}

.mesh-status-lamp.off .mesh-status-lamp-dot {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.mesh-status-lamp-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mesh-status-lamp.on .mesh-status-lamp-text { color: #4ade80; }
.mesh-status-lamp.off .mesh-status-lamp-text { color: #f87171; }

.mesh-status-lamp.sleeping .mesh-status-lamp-dot {
  background: #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.65);
}

.mesh-status-lamp.sleeping .mesh-status-lamp-text { color: #93c5fd; }

.mesh-config-icon {
  flex-shrink: 0;
  border-radius: 10px;
  padding: 0;
  background: transparent;
  border: none;
  object-fit: contain;
}
.mesh-config-icon.is-gateway,
.mesh-config-icon.is-node {
  background: transparent;
  border: none;
}

.mesh-toolbar-float {
  position: relative;
  z-index: 20;
}

.mesh-pair-requests {
  display: none !important;
}

.mesh-pair-requests-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}

.mesh-pair-requests-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}

.mesh-pair-requests-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mesh-pair-req-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.8);
  color: inherit;
  padding: 8px 10px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}

.mesh-pair-req-item:hover {
  border-color: #f59e0b;
  background: rgba(51, 65, 85, 0.95);
}

.mesh-pair-req-id code {
  font-size: 12px;
}

.mesh-pair-req-meta {
  font-size: 11px;
  color: var(--muted);
}

.mesh-pair-req-badge {
  font-size: 11px;
  color: #fbbf24;
  font-weight: 600;
}

.mesh-dialog-body > .mesh-pending-panel {
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mesh-pending-form {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.mesh-pending-form .mesh-dialog-main {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mesh-pending-form .mesh-dialog-footer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.6);
}

.mesh-pending-form .mesh-tx-custom {
  margin-top: 8px;
}

.mesh-status-lamp.pending .mesh-status-lamp-dot {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.55);
}

.mesh-status-lamp.pending .mesh-status-lamp-text {
  color: #fbbf24;
}

.mesh-offline-notice {
  margin-bottom: 12px;
  text-align: center;
  padding: 16px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(15, 20, 25, 0.35);
}
.mesh-offline-icon {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.55;
}
.mesh-offline-title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text);
}
.mesh-offline-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.mesh-form-locked {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.mesh-form-sleep-partial {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.mesh-form-sleep-partial .is-editable-while-sleep {
  opacity: 1;
  pointer-events: auto;
  user-select: auto;
}

.mesh-sleep-cfg-notice {
  color: var(--accent, #3b82f6);
  margin-top: 0.35rem;
}

.field-box.field-readonly input[readonly],
.field-box.field-readonly select:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  background: var(--bg);
}

.mesh-dialog-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.mesh-dialog-close:hover {
  color: var(--text);
  background: var(--brand-dim);
}

.mesh-dialog-body {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mesh-dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.mesh-dialog-layout.is-terminal-hidden,
.mesh-dialog-layout:has(.mesh-dialog-terminal.hidden) {
  grid-template-columns: minmax(0, 1fr);
}

.mesh-dialog-main {
  grid-column: 1;
  grid-row: 1;
  padding: 14px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mesh-dialog-main > * + * {
  margin-top: 12px;
}

.mesh-dialog-footer {
  grid-column: 1;
  grid-row: 2;
  padding: 10px 14px;
  border-top: 1px solid #2d3a4f;
  background: #0f1419;
  flex-shrink: 0;
}

.mesh-dialog-terminal {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  background: #080c10;
  border-left: 1px solid #2d3a4f;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.mesh-dialog-terminal.hidden {
  display: none !important;
}

.mesh-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(45, 58, 79, 0.8);
  background: #0d1218;
}

.mesh-terminal-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: #8b9cb3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mesh-terminal-output {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}

.mesh-terminal-line {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  word-break: break-word;
}

.mesh-terminal-ts {
  flex-shrink: 0;
  color: #546e7a;
}

.mesh-terminal-text {
  color: #cfd8dc;
}

.mesh-terminal-line.is-cmd .mesh-terminal-text { color: #4fc3f7; }
.mesh-terminal-line.is-ok .mesh-terminal-text { color: #69f0ae; }
.mesh-terminal-line.is-err .mesh-terminal-text { color: #ff8a80; }
.mesh-terminal-line.is-muted .mesh-terminal-text { color: #78909c; }
.mesh-terminal-line.is-data .mesh-terminal-text { color: #eceff1; padding-left: 0; }

.mesh-panel { margin-bottom: 0; display: flex; flex-direction: column; min-height: 520px; }
.mesh-config { margin-bottom: 0; }

.mesh-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.mesh-toolbar .cell-muted { flex: 1; font-size: 0.85rem; min-width: 120px; }

.mesh-gateway-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.mesh-gateway-select {
  min-width: 200px;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.mesh-gw-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.mesh-gw-status .status-dot { flex-shrink: 0; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.mesh-canvas {
  flex: 1;
  position: relative;
  min-height: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}

/* AirDrop-style mesh */
.airdrop-stage {
  padding: 24px 16px 32px;
  min-height: 400px;
}

.airdrop-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.airdrop-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 28px 0 12px;
}

.airdrop-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.airdrop-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px 32px;
  max-width: 640px;
  margin: 0 auto;
}

.airdrop-grid-sm { gap: 20px; }

.airdrop-bubble {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.airdrop-orbit .airdrop-bubble:hover {
  transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, -130px))) scale(1.06);
}

.airdrop-bubble.is-grid:hover,
.airdrop-center-wrap .airdrop-bubble:hover {
  transform: scale(1.06);
}
.airdrop-bubble.selected .airdrop-leaf-icon,
.airdrop-bubble.selected .airdrop-avatar,
.airdrop-bubble.selected .airdrop-device-icon {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

.airdrop-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  opacity: 0;
  pointer-events: none;
}

.airdrop-bubble.online .airdrop-pulse {
  animation: airdrop-ripple 2.4s ease-out infinite;
}
.airdrop-pulse-2 { animation-delay: 1.2s !important; }

@keyframes airdrop-ripple {
  0% { transform: scale(0.85); opacity: 0.5; }
  100% { transform: scale(1.8); opacity: 0; }
}

.airdrop-avatar {
  border-radius: 50%;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}

.airdrop-device-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  padding: 0;
  background: transparent;
  border: none;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}
.airdrop-bubble.online .airdrop-device-icon.is-node-icon {
  filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.45)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}
.airdrop-bubble.online .airdrop-device-icon.is-gateway-icon {
  filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.4)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}
.airdrop-bubble.offline .airdrop-device-icon {
  opacity: 0.55;
  filter: grayscale(0.35) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}
.airdrop-bubble.is-pending .airdrop-device-icon.is-pending-icon,
.airdrop-bubble.is-active-unjoined .airdrop-device-icon.is-active-icon {
  opacity: 0.9;
}
.airdrop-bubble.is-pending .airdrop-device-icon.is-pending-icon {
  filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.55)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
  animation: mesh-pending-icon-pulse 2.4s ease-in-out infinite;
}
@keyframes mesh-pending-icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.page-network .airdrop-bubble.is-pending .airdrop-device-icon.is-pending-icon {
  animation: mesh-pending-icon-pulse 2.4s ease-in-out infinite !important;
}

.airdrop-leaf-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: linear-gradient(145deg, #2a3548, #1a2332);
  border: 2px solid var(--border);
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.airdrop-bubble.online .airdrop-leaf-icon {
  border-color: rgba(34,197,94,0.5);
}

.airdrop-name {
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airdrop-meta {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: monospace;
}

.airdrop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 2px;
}
.airdrop-dot.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.airdrop-dot.sleep { background: #60a5fa; box-shadow: 0 0 8px rgba(96, 165, 250, 0.65); }
.airdrop-dot.off { background: var(--muted); }

.airdrop-bubble.sleeping .airdrop-device-icon.is-node-icon {
  filter: saturate(0.75) brightness(0.95);
}

.airdrop-bubble.offline { opacity: 0.5; }
.airdrop-bubble.sleeping { opacity: 0.88; }

.airdrop-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 2px;
}

.airdrop-bubble.is-pending .airdrop-leaf-icon.is-pending-icon {
  border-color: rgba(251, 191, 36, 0.7);
  background: linear-gradient(145deg, #3d3520, #2a2418);
  color: #fbbf24;
  font-size: 1.1rem;
}

.airdrop-bubble.is-active-unjoined .airdrop-leaf-icon.is-active-icon {
  border-color: rgba(96, 165, 250, 0.7);
  background: linear-gradient(145deg, #1e3a5f, #172554);
  color: #60a5fa;
  font-size: 1.1rem;
}

.airdrop-bubble.is-active-unjoined .airdrop-pulse-fast {
  border-color: #60a5fa !important;
}

.airdrop-pulse-fast {
  border-color: #fbbf24 !important;
  animation: airdrop-ripple 1.2s ease-out infinite !important;
}

.mesh-pending-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Gateway detail — radar */
.airdrop-detail .airdrop-hint { margin-top: 20px; margin-bottom: 0; }

.airdrop-radar {
  position: relative;
  width: min(420px, 90vw);
  height: min(420px, 90vw);
  margin: 0 auto;
}

.radar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(230,30,37,0.2);
  animation: radar-scan 3s ease-in-out infinite;
}
.radar-ring-2 { inset: 12%; animation-delay: 1s; opacity: 0.7; }
.radar-ring-3 { inset: 24%; animation-delay: 2s; opacity: 0.4; }

@keyframes radar-scan {
  0%, 100% { transform: scale(0.95); opacity: 0.3; }
  50% { transform: scale(1); opacity: 0.8; }
}

.airdrop-center-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.airdrop-center-wrap .airdrop-bubble { width: 120px; }
.airdrop-center-wrap .airdrop-avatar,
.airdrop-center-wrap .airdrop-device-icon { width: 80px; height: 80px; padding: 0; }
.airdrop-center-wrap .airdrop-pulse { width: 88px; height: 88px; margin: -44px 0 0 -44px; }

.airdrop-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.airdrop-orbit .airdrop-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: auto;
  z-index: 1;
  opacity: 1;
  animation: orbit-in 0.45s ease both;
  animation-delay: var(--delay, 0ms);
  transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, -130px)));
}

.airdrop-bubble.is-grid {
  position: relative;
  left: auto;
  top: auto;
  z-index: auto;
  transform: none;
  animation: none;
}

@keyframes orbit-in {
  from {
    opacity: 0;
    transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, -60px))) scale(0.55);
  }
  to {
    opacity: 1;
    transform: translate(calc(-50% + var(--ox, 0px)), calc(-50% + var(--oy, -130px))) scale(1);
  }
}

/* AirDrop mesh — full topology */
.airdrop-mesh { padding-bottom: 48px; }

.mesh-quiet .airdrop-orbit .airdrop-bubble {
  animation: none;
  opacity: 1;
}
.mesh-quiet .radar-ring {
  animation: none;
}
.mesh-quiet .airdrop-pulse {
  animation: none;
}

.is-connected .airdrop-pulse,
.is-gateway .airdrop-pulse {
  display: none;
}

.airdrop-coordinator {
  margin: 36px auto 0;
  max-width: 560px;
}

.airdrop-coordinator-head {
  text-align: center;
  margin-bottom: 8px;
}

.airdrop-coordinator-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.airdrop-coordinator-meta {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.airdrop-stat-connected { color: #4ade80; }
.airdrop-stat-unconnected { color: #60a5fa; }
.airdrop-stat-sep { margin: 0 6px; opacity: 0.5; }

.airdrop-prox-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--muted);
}
.prox-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.prox-legend-item i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.prox-legend-item.prox-near i { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }
.prox-legend-item.prox-mid i { background: #60a5fa; }
.prox-legend-item.prox-far i { background: #94a3b8; }

.airdrop-bubble.prox-near .airdrop-name { color: #bbf7d0; }
.airdrop-bubble.prox-mid .airdrop-name { color: #bfdbfe; }
.airdrop-bubble.prox-far .airdrop-name,
.airdrop-bubble.prox-very-far .airdrop-name { color: var(--muted); }

.radar-ring-prox-near {
  inset: 38%;
  border-color: rgba(74, 222, 128, 0.22);
  animation: none;
}
.radar-ring-prox-mid {
  inset: 24%;
  border-color: rgba(96, 165, 250, 0.16);
  animation: none;
}
.radar-ring-prox-far {
  inset: 8%;
  border-color: rgba(148, 163, 184, 0.12);
  animation: radar-scan 4s ease-in-out infinite;
}

.airdrop-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 0.72rem;
  color: var(--muted);
}

.airdrop-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.airdrop-legend-item i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.airdrop-legend-item.is-connected i {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.airdrop-legend-item.is-unconnected i {
  background: #60a5fa;
  box-shadow: 0 0 6px rgba(96, 165, 250, 0.5);
}

.airdrop-radar-lg {
  width: min(500px, 92vw);
  height: min(500px, 92vw);
}

.radar-ring-inner {
  inset: 22%;
  border-color: rgba(74, 222, 128, 0.15);
  animation: none;
  opacity: 0.6;
}

.airdrop-bubble.is-connected .airdrop-leaf-icon {
  border-color: rgba(74, 222, 128, 0.55);
}

.airdrop-bubble.is-unconnected .airdrop-leaf-icon {
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.25);
}

.airdrop-orphans {
  margin-bottom: 8px;
}

.airdrop-empty-leaves {
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  max-width: 240px;
  pointer-events: none;
}

.mesh-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--muted);
}

.mesh-svg { width: 100%; height: 100%; min-height: 420px; display: block; }

.mesh-link { stroke-width: 2; fill: none; }
.mesh-uplink { stroke: var(--brand); stroke-opacity: 0.7; }
.mesh-lora { stroke: #3b82f6; stroke-opacity: 0.65; }
.mesh-hop { stroke: var(--muted); stroke-opacity: 0.35; stroke-width: 1.5; }

.mesh-node { transition: opacity 0.15s; }
.mesh-node.offline { opacity: 0.55; }
.mesh-node.selected .mesh-ring { stroke: var(--brand); stroke-width: 3; }

.mesh-ring {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 2;
}
.mesh-gateway .mesh-ring { fill: #1f1520; stroke: var(--brand); }
.mesh-leaf .mesh-ring { fill: var(--bg); }
.mesh-mqtt .mqtt-ring { fill: var(--brand-dim); stroke: var(--brand); }

.mesh-glow { fill: none; stroke: transparent; pointer-events: none; }
.mesh-node.online .mesh-glow { stroke: var(--success); stroke-opacity: 0.25; animation: mesh-pulse 2s ease infinite; }
.mesh-node.selected .mesh-glow { stroke: var(--brand); stroke-opacity: 0.4; }

@keyframes mesh-pulse {
  0%, 100% { stroke-opacity: 0.15; }
  50% { stroke-opacity: 0.35; }
}

.mesh-logo { border-radius: 50%; pointer-events: none; }
.mesh-icon { text-anchor: middle; font-size: 14px; fill: var(--success); pointer-events: none; }
.mesh-node.offline .mesh-icon { fill: var(--muted); }

.mesh-label {
  text-anchor: middle;
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
  pointer-events: none;
}
.mesh-sublabel {
  text-anchor: middle;
  font-size: 9px;
  fill: var(--muted);
  font-family: monospace;
  pointer-events: none;
}
.mesh-mqtt-label {
  text-anchor: middle;
  font-size: 10px;
  font-weight: 700;
  fill: var(--brand);
  pointer-events: none;
}

.mesh-legend {
  position: absolute;
  bottom: 8px;
  left: 12px;
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--muted);
}
.mesh-legend span { display: flex; align-items: center; gap: 6px; }
.mesh-legend i {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
}
.leg-uplink { background: var(--brand); }
.leg-lora { background: #3b82f6; }
.leg-mesh { background: var(--muted); opacity: 0.5; }

.mesh-config-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
}
.mesh-config-logo { border-radius: 50%; margin-bottom: 16px; opacity: 0.9; }

.mesh-config-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 0;
  font-size: 0.8rem;
}

.mesh-gw-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2d3a4f;
}

.mesh-gw-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #0f1419;
  border: 1px solid #2d3a4f;
  border-radius: 4px;
}

.mesh-gw-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.mesh-gw-stat-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.mesh-gw-stat-val.is-ok { color: #4ade80; }

.mesh-gw-stat-time {
  font-size: 0.78rem;
  font-weight: 500;
}

.ind-panel {
  border: 1px solid #2d3a4f;
  border-radius: 4px;
  background: #1a2332;
  overflow: hidden;
}

.ind-panel-head {
  padding: 8px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b9cb3;
  background: #121820;
  border-bottom: 1px solid #2d3a4f;
}

.ind-panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ind-panel-body {
  padding: 12px;
}

.ind-panel-flush {
  padding: 0;
}

.ind-status-body {
  padding: 12px;
}

.ind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ind-panel-map .mesh-location-map {
  height: 180px;
}

.mesh-params-industrial .param-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.mesh-dialog-footer .mesh-config-actions {
  margin-top: 0;
}

.mesh-dialog-footer .inline-toast {
  margin-top: 8px;
}

.mesh-node-extras {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.mesh-config-meta .badge {
  font-family: inherit;
}

.mesh-signal-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mesh-signal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 34px;
}

.mesh-signal-text {
  font-size: 0.78rem;
  color: var(--text);
  min-width: 72px;
}

.mesh-signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
  padding: 0 1px;
}

.mesh-signal-bar {
  width: 5px;
  border-radius: 1px;
  background: rgba(139, 156, 179, 0.28);
}

.mesh-signal-bar:nth-child(1) { height: 5px; }
.mesh-signal-bar:nth-child(2) { height: 8px; }
.mesh-signal-bar:nth-child(3) { height: 11px; }
.mesh-signal-bar:nth-child(4) { height: 14px; }
.mesh-signal-bar:nth-child(5) { height: 16px; }

.mesh-signal-bar.is-on {
  background: #34c759;
}

.mesh-signal-bars.is-binhthuong .mesh-signal-bar.is-on {
  background: #34c759;
}

.mesh-signal-bars.is-yeu .mesh-signal-bar.is-on {
  background: #ffcc00;
}

.mesh-signal-bars.is-kem .mesh-signal-bar.is-on {
  background: #ff9500;
}

.mesh-signal-bars.is-unknown .mesh-signal-bar.is-on {
  background: #8b9cb3;
}

.mesh-section-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.mesh-map-hint {
  margin: 0 0 8px;
}

.mesh-location-section {
  margin: 16px 0;
}

.mesh-location-map {
  height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  z-index: 0;
}

.mesh-location-map .leaflet-container {
  font: inherit;
}

.mesh-location-map.is-locked {
  opacity: 0.65;
}

.mesh-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.mesh-params-section {
  margin-top: 20px;
}

.mesh-params-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.mesh-params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.mesh-params-table th,
.mesh-params-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.mesh-params-table thead th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.mesh-params-table .param-name {
  width: 42%;
  color: var(--muted);
  background: rgba(15, 20, 25, 0.35);
}

.mesh-params-table .param-value {
  color: var(--text);
  word-break: break-word;
}

#tcParentDisplay {
  opacity: 0.85;
  cursor: not-allowed;
  background: var(--bg);
}

.mesh-node-extras {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.mesh-tx-custom {
  margin-top: 8px;
}

.mesh-log-section {
  margin-top: 20px;
}

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

.mesh-log-header .mesh-params-title {
  margin: 0;
}

.mesh-log-list {
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.mesh-log-empty {
  margin: 0;
  padding: 14px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.mesh-log-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.mesh-log-item:last-child {
  border-bottom: none;
}

.mesh-log-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mesh-log-action {
  font-weight: 600;
  color: var(--text);
}

.mesh-log-status {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.mesh-log-status.is-done,
.mesh-log-status.is-success {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.35);
}

.mesh-log-status.is-pending {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
}

.mesh-log-status.is-failed,
.mesh-log-status.is-error {
  color: var(--error);
  border-color: rgba(239, 68, 68, 0.35);
}

.mesh-log-time {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
}

.mesh-log-error {
  margin: 6px 0 0;
  color: var(--error);
  font-size: 0.78rem;
}

.mesh-log-payload {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  line-height: 1.35;
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border-radius: 6px;
  max-height: 12rem;
  overflow: auto;
}

.mesh-telemetry-payload {
  max-height: 16rem;
}

.mesh-log-meta {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted, #666);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.field-box label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.field-box input, .field-box select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.mesh-config-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.mesh-dialog-footer .mesh-delete-btn {
  pointer-events: auto;
  opacity: 1;
}

.mesh-config-actions .btn-danger {
  margin-left: auto;
}

@media (max-width: 900px) {
  .mesh-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .mesh-dialog-layout,
  .mesh-dialog-layout.is-terminal-hidden,
  .mesh-dialog-layout:has(.mesh-dialog-terminal.hidden) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
  }

  .mesh-dialog-main {
    grid-column: 1;
    grid-row: 1;
  }

  .mesh-dialog-terminal {
    grid-column: 1;
    grid-row: 2;
    border-left: none;
    border-top: 1px solid #2d3a4f;
    max-height: 220px;
  }

  .mesh-dialog-footer {
    grid-column: 1;
    grid-row: 3;
  }

  .ind-grid { grid-template-columns: 1fr; }
  .mesh-gw-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
