/* =============================================================================
   Netro — Components
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: var(--gap-md) 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 20px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.brand-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-gap {
  height: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.14s ease, color 0.14s ease;
  width: 100%;
  text-align: left;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active svg {
  color: var(--accent);
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

.nav-badge.show {
  display: flex;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--safe);
}

.sidebar-version {
  font-size: 11px;
  color: var(--text-faint);
}

/* -----------------------------------------------------------------------------
   Chấm trạng thái & pill
   -------------------------------------------------------------------------- */

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.dot.pulse {
  animation: dot-pulse 2.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 currentColor;
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 4px transparent;
    opacity: 0.65;
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.pill.safe {
  color: var(--safe);
  border-color: var(--safe-line);
  background: var(--safe-soft);
}
.pill.warn {
  color: var(--warn);
  border-color: var(--warn-line);
  background: var(--warn-soft);
}
.pill.danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.tag.safe {
  background: var(--safe-soft);
  color: var(--safe);
}
.tag.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* -----------------------------------------------------------------------------
   Nút
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0c;
}

.btn.primary:hover {
  background: #92a7fa;
  border-color: #92a7fa;
}

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

.btn.danger:hover {
  background: #f05656;
  border-color: #f05656;
}

.btn.ghost {
  background: transparent;
}

.btn.sm {
  padding: 5px 11px;
  font-size: 11.5px;
}

/* -----------------------------------------------------------------------------
   Thẻ
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  margin-bottom: 14px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
}

.card-menu {
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

.card-menu:hover {
  color: var(--text-secondary);
}

/* -----------------------------------------------------------------------------
   Lưới Overview
   -------------------------------------------------------------------------- */

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: var(--gap-md);
  align-items: start;
}

.col-left {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  min-width: 0;
}

.col-right {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  min-width: 0;
}

.full-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap-md);
}

/* -----------------------------------------------------------------------------
   Đồng hồ điểm rủi ro
   -------------------------------------------------------------------------- */

.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px var(--gap-md) 28px;
}

.gauge {
  position: relative;
  width: 208px;
  height: 208px;
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 9;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    stroke 0.4s ease;
  filter: drop-shadow(0 0 7px var(--accent-line));
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.gauge-score {
  font-size: 52px;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.gauge-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.gauge-meta {
  margin-top: 18px;
  text-align: center;
}

.gauge-net {
  font-size: 15px;
  font-weight: 600;
}

.gauge-net-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.gauge-scanned {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
}

/* -----------------------------------------------------------------------------
   Hàng thẻ trạng thái
   -------------------------------------------------------------------------- */

.status-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  position: relative;
  min-width: 0;
}

.status-card .eyebrow {
  font-size: 9.5px;
  padding-right: 18px;
}

.status-value {
  font-size: 13px;
  font-weight: 600;
  margin-top: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-check {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.status-card.checked .status-check {
  opacity: 1;
}

/* -----------------------------------------------------------------------------
   Bảng thông tin key/value
   -------------------------------------------------------------------------- */

.kv {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-sm);
  font-size: 12.5px;
}

.kv-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.kv-val {
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sparkline-wrap {
  margin-top: 14px;
  height: 46px;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  overflow: hidden;
}

.sparkline-wrap canvas {
  width: 100%;
  height: 100%;
}

/* -----------------------------------------------------------------------------
   Danh sách hoạt động
   -------------------------------------------------------------------------- */

.feed {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.feed-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  font-size: 12.5px;
}

.feed-time {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  flex-shrink: 0;
  padding-top: 1px;
  width: 40px;
}

.feed-icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}

.feed-text {
  color: var(--text-secondary);
  min-width: 0;
  line-height: 1.45;
}

.feed-empty {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 14px 0;
  text-align: center;
}

/* -----------------------------------------------------------------------------
   Sơ đồ đường hầm
   -------------------------------------------------------------------------- */

.tunnel-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 4px;
  padding: 10px 0 4px;
  position: relative;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: relative;
  min-width: 0;
}

.flow-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.flow-icon svg {
  width: 21px;
  height: 21px;
}

.flow-node.lit .flow-icon {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.flow-label {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Đường nối giữa các node */
.flow-node:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 23px;
  left: calc(50% + 30px);
  right: calc(-50% + 30px);
  height: 1px;
  background: var(--border-default);
}

.tunnel-flow.live .flow-node:not(:last-child)::after {
  background: linear-gradient(
    90deg,
    var(--accent-line) 0%,
    var(--accent) 50%,
    var(--accent-line) 100%
  );
  background-size: 200% 100%;
  animation: flow-slide 2.2s linear infinite;
}

@keyframes flow-slide {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.tunnel-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 20px;
  font-size: 12.5px;
}

.tunnel-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
}

.tunnel-caps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.tunnel-caps span:not(:last-child)::after {
  content: '|';
  margin-left: 10px;
  color: var(--border-strong);
}

.tunnel-toggle-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.tunnel-toggle-label {
  font-size: 13px;
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Công tắc
   -------------------------------------------------------------------------- */

.switch {
  width: 42px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
  padding: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.switch.on {
  background: var(--accent);
  border-color: var(--accent);
}

.switch.on::after {
  transform: translateX(18px);
  background: #fff;
}

.switch.busy {
  opacity: 0.55;
  pointer-events: none;
}

.switch.lg {
  width: 52px;
  height: 30px;
}

.switch.lg::after {
  width: 24px;
  height: 24px;
}

.switch.lg.on::after {
  transform: translateX(22px);
}

/* -----------------------------------------------------------------------------
   Radar mạng lân cận
   -------------------------------------------------------------------------- */

.radar-wrap {
  position: relative;
  width: 100%;
  height: 330px;
}

.radar-wrap canvas {
  width: 100%;
  height: 100%;
}

.radar-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--text-faint);
}

.radar-wrap.empty .radar-empty {
  display: flex;
}

/* -----------------------------------------------------------------------------
   Cảnh báo mối đe doạ
   -------------------------------------------------------------------------- */

.threat-alert {
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  padding: var(--gap-lg);
  border-radius: var(--r-lg);
  border: 1px solid var(--danger-line);
  background: linear-gradient(
    100deg,
    rgba(239, 68, 68, 0.16) 0%,
    rgba(239, 68, 68, 0.05) 55%,
    transparent 100%
  );
}

.threat-alert.is-clear {
  border-color: var(--safe-line);
  background: linear-gradient(
    100deg,
    rgba(52, 211, 153, 0.14) 0%,
    rgba(52, 211, 153, 0.04) 55%,
    transparent 100%
  );
}

.threat-gauge {
  position: relative;
  width: 104px;
  height: 104px;
  flex-shrink: 0;
}

.threat-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.threat-gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 6;
}

.threat-gauge-fill {
  fill: none;
  stroke: var(--danger);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.4s ease;
}

.threat-gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.threat-gauge-num {
  font-size: 27px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.threat-gauge-tag {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-top: 3px;
}

.threat-body {
  min-width: 0;
  flex: 1;
}

.threat-title {
  font-size: 17px;
  font-weight: 600;
}

.threat-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 5px;
  max-width: 46ch;
}

.threat-actions {
  display: flex;
  gap: var(--gap-sm);
  margin-top: 14px;
  flex-wrap: wrap;
}

.net-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--gap-md);
  margin-top: var(--gap-md);
}

.net-card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.net-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-top: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.net-card-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.net-card-bssid {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.net-card-flag {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
}

.net-card-flag svg {
  width: 14px;
  height: 14px;
}

.card.suspicious {
  border-color: var(--danger-line);
}

/* -----------------------------------------------------------------------------
   Bảng
   -------------------------------------------------------------------------- */

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

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

table.data th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 10px;
  white-space: nowrap;
}

table.data td {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.cell-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}

.signal-bar {
  width: 52px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--bg-elevated);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.signal-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
}

/* -----------------------------------------------------------------------------
   Trang cài đặt
   -------------------------------------------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: var(--gap-md);
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}

.settings-nav-item svg {
  width: 15px;
  height: 15px;
}

.settings-nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.settings-nav-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.settings-section {
  margin-bottom: var(--gap-lg);
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 12.5px;
  min-width: 0;
}

.setting-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

select.input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 10px;
  min-width: 148px;
  cursor: pointer;
}

select.input:focus {
  outline: none;
  border-color: var(--accent-line);
}

.trusted-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
}

.trusted-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.trusted-item svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.trusted-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.trusted-add {
  color: var(--accent);
  font-weight: 500;
}

.trusted-add svg {
  color: var(--accent);
}

/* -----------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 90;
  max-width: min(370px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-pop);
  font-size: 12.5px;
  animation: toast-in 0.2s ease-out;
}

.toast.safe {
  border-color: var(--safe-line);
}
.toast.warn {
  border-color: var(--warn-line);
}
.toast.danger {
  border-color: var(--danger-line);
}

.toast-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-body {
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.toast-msg {
  color: var(--text-secondary);
  line-height: 1.45;
  word-break: break-word;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -----------------------------------------------------------------------------
   Điều hướng dưới cùng (mobile) — ẩn trên desktop
   -------------------------------------------------------------------------- */

.tabbar {
  display: none;
}
