/* BLEShark Command Center — design system.
   Dark-first "RF lab" aesthetic. One stylesheet, all panels. */

:root {
  --bg: #0a0e14;
  --bg-2: #0e141d;
  --panel: #121a25;
  --panel-2: #16202d;
  --edge: #223042;
  --edge-soft: #1a2634;
  --ink: #e6edf3;
  --ink-2: #9fb0c3;
  --ink-3: #64758a;
  --accent: #22d3ee;      /* cyan — the shark */
  --accent-2: #38bdf8;
  --accent-ink: #04121a;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --violet: #a78bfa;
  --pink: #f472b6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(34,211,238,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(167,139,250,.06), transparent 55%),
    var(--bg);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #223042; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2c3e54; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(18,26,37,.9), rgba(10,14,20,.75)); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: .2px; }
.brand svg { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(34,211,238,.5)); }
.brand .brand-name { font-size: 15px; }
.brand .brand-name b { color: var(--accent); }
.brand .brand-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: 2px; text-transform: uppercase; }
.topbar-spacer { flex: 1; }

.conn-pill {
  display: flex; align-items: center; gap: 9px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--edge); background: var(--panel); font-size: 12.5px; color: var(--ink-2);
}
.conn-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 0 0 rgba(0,0,0,0); }
.conn-pill.on .dot { background: var(--good); box-shadow: 0 0 10px var(--good); animation: pulse 2.4s infinite; }
.conn-pill.on { color: var(--ink); border-color: #1f3b39; }
.conn-pill .transport-tag { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- nav ---------- */
.nav { border-right: 1px solid var(--edge); padding: 12px 10px; background: rgba(14,20,29,.5); display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer; border: 1px solid transparent; font-weight: 500; user-select: none;
}
.nav-item .nav-ico { width: 18px; height: 18px; display: grid; place-items: center; color: var(--ink-3); }
.nav-item .nav-ico svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--panel); color: var(--ink); }
.nav-item.active { background: linear-gradient(90deg, rgba(34,211,238,.14), rgba(34,211,238,.03)); color: var(--ink); border-color: #1c3a44; }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-item.disabled { opacity: .4; pointer-events: none; }
.nav-sep { height: 1px; background: var(--edge-soft); margin: 8px 6px; }
.nav-foot { margin-top: auto; font-size: 11px; color: var(--ink-3); padding: 8px 12px; }

/* ---------- main ---------- */
.main { padding: 22px 26px 40px; overflow: auto; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-title .pt-ico { color: var(--accent); display: grid; place-items: center; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.gap-sm { gap: 6px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }

/* ---------- card ---------- */
.card { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--edge-soft); }
.card-title { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.card-title .card-ico { color: var(--accent); display: grid; place-items: center; }
.card-title .card-ico svg { width: 17px; height: 17px; }
.card-sub { color: var(--ink-3); font-weight: 400; font-size: 12px; margin-left: 4px; }
.card-actions { display: flex; gap: 7px; align-items: center; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--edge); background: var(--panel-2); color: var(--ink); font: inherit; font-weight: 550;
  cursor: pointer; transition: .13s ease; white-space: nowrap; line-height: 1;
}
.btn:hover { border-color: #33465c; background: #1a2634; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .btn-ico { display: grid; place-items: center; }
.btn .btn-ico svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; font-weight: 650; }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(34,211,238,.35); background: linear-gradient(180deg, #3ed9f0, #4ec2fa); }
.btn-danger { border-color: #4a2530; color: #fca5a5; }
.btn-danger:hover { background: #2a1720; border-color: #6b2f3c; color: #fecaca; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--panel); color: var(--ink); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid transparent; letter-spacing: .2px; }
.badge-neutral { background: #1b2735; color: var(--ink-2); border-color: var(--edge); }
.badge-good { background: rgba(52,211,153,.12); color: var(--good); border-color: rgba(52,211,153,.3); }
.badge-warn { background: rgba(251,191,36,.12); color: var(--warn); border-color: rgba(251,191,36,.3); }
.badge-bad { background: rgba(248,113,113,.12); color: var(--bad); border-color: rgba(248,113,113,.3); }
.badge-info { background: rgba(56,189,248,.12); color: var(--accent-2); border-color: rgba(56,189,248,.3); }
.badge-violet { background: rgba(167,139,250,.12); color: var(--violet); border-color: rgba(167,139,250,.3); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; color: var(--ink-2); font-weight: 550; }
.field-hint { font-size: 11px; color: var(--ink-3); }
.input {
  background: var(--bg); border: 1px solid var(--edge); color: var(--ink); border-radius: var(--radius-sm);
  padding: 8px 11px; font: inherit; width: 100%; transition: border-color .13s, box-shadow .13s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.14); }
textarea.input { min-height: 90px; font-family: var(--mono); resize: vertical; }
select.input { cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch-track { width: 38px; height: 21px; border-radius: 999px; background: var(--edge); position: relative; transition: background .16s; flex: none; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #7d8ea3; transition: .16s; }
.switch input:checked + .switch-track { background: rgba(34,211,238,.4); }
.switch input:checked + .switch-track .switch-thumb { left: 19px; background: var(--accent); }
.switch-label { font-size: 13px; color: var(--ink-2); }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 9px 12px; border-bottom: 1px solid var(--edge); position: sticky; top: 0; background: var(--bg-2); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--edge-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: rgba(34,211,238,.05); }
.tbl tr.selected td { background: rgba(34,211,238,.09); }
.tbl .al-right { text-align: right; }
.tbl .al-center { text-align: center; }
.tbl-empty { text-align: center; color: var(--ink-3); padding: 26px !important; }

/* ---------- kv / stats ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 12.5px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.stat { background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--radius); padding: 14px 16px; }
.stat-val { font-size: 24px; font-weight: 700; font-family: var(--mono); }
.stat-label { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.stat-sub { color: var(--ink-3); font-size: 11px; margin-top: 4px; }
.stat-good .stat-val { color: var(--good); }
.stat-accent .stat-val { color: var(--accent); }
.stat-warn .stat-val { color: var(--warn); }

/* ---------- rssi ---------- */
.rssi { display: inline-flex; align-items: flex-end; gap: 2px; height: 15px; }
.rssi-bar { width: 3px; background: var(--edge); border-radius: 1px; display: block; }
.rssi-bar.on { background: var(--good); }
.rssi-l2 .rssi-bar.on { background: var(--warn); }
.rssi-l1 .rssi-bar.on, .rssi-l0 .rssi-bar.on { background: var(--bad); }

/* ---------- hexdump / console ---------- */
.hexdump { font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink-2); background: var(--bg); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; margin: 0; }
.console { font-family: var(--mono); font-size: 12px; background: #060a10; border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 10px 12px; height: 200px; overflow-y: auto; color: var(--ink-2); }
.console .line { white-space: pre-wrap; word-break: break-all; }
.console .t-rx { color: var(--accent-2); } .console .t-tx { color: var(--good); } .console .t-err { color: var(--bad); } .console .t-evt { color: var(--violet); } .console .t-time { color: var(--ink-3); }

/* ---------- empty / spinner ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty-ico { font-size: 34px; opacity: .5; margin-bottom: 10px; }
.empty-ico svg { width: 44px; height: 44px; }
.empty-title { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.empty-hint { font-size: 12.5px; margin-top: 5px; max-width: 380px; margin-inline: auto; }
.spin-wrap { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--edge); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { padding: 11px 15px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--edge); box-shadow: var(--shadow); color: var(--ink); font-size: 13px; opacity: 0; transform: translateX(20px); transition: .25s; max-width: 340px; border-left: 3px solid var(--accent); }
.toast.in { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--good); }
.toast-error { border-left-color: var(--bad); }
.toast-warn { border-left-color: var(--warn); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(4,8,13,.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 90; opacity: 0; transition: opacity .2s; padding: 20px; }
.modal-back.in { opacity: 1; }
.modal { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: 88vh; display: flex; flex-direction: column; transform: translateY(10px); transition: transform .2s; }
.modal-back.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--edge-soft); font-weight: 650; }
.modal-x { background: none; border: none; color: var(--ink-3); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--edge-soft); display: flex; justify-content: flex-end; gap: 9px; }

/* ---------- connect gate ---------- */
.gate { display: grid; place-items: center; min-height: calc(100vh - 120px); padding: 30px; }
.gate-card { max-width: 560px; text-align: center; }
.gate-shark { width: 92px; height: 92px; margin: 0 auto 18px; filter: drop-shadow(0 0 26px rgba(34,211,238,.45)); }
.gate h1 { font-size: 26px; margin: 0 0 8px; }
.gate p { color: var(--ink-2); margin: 0 auto 22px; max-width: 440px; }
.gate-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; text-align: left; }
.method { border: 1px solid var(--edge); border-radius: var(--radius); padding: 16px; background: var(--panel-2); cursor: pointer; transition: .15s; }
.method:hover { border-color: var(--accent); transform: translateY(-2px); }
.method h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.method p { font-size: 12.5px; color: var(--ink-3); margin: 0; }
.method .tag { font-size: 10.5px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.warn-note { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.25); color: #e9c877; border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.5px; margin-top: 18px; text-align: left; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .nav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--edge); }
  .nav-foot, .nav-sep { display: none; }
  .gate-methods { grid-template-columns: 1fr; }
}

/* Poisoner "running" indicator — a ghost drifting around the panel. */
@keyframes poison-ghost-drift {
  0%   { left: 6%;  top: 14%; }
  20%  { left: 80%; top: 20%; }
  40%  { left: 62%; top: 72%; }
  60%  { left: 12%; top: 60%; }
  80%  { left: 46%; top: 32%; }
  100% { left: 6%;  top: 14%; }
}
@keyframes poison-ghost-bob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-9px) rotate(5deg); }
}
@keyframes poison-ghost-in { from { opacity: 0; } to { opacity: .8; } }
.poison-ghost {
  position: absolute; left: 6%; top: 14%;
  width: 30px; height: 30px; color: var(--accent);
  opacity: .8; pointer-events: none; z-index: 5;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 55%, transparent));
  animation: poison-ghost-drift 17s ease-in-out infinite, poison-ghost-bob 2.4s ease-in-out infinite, poison-ghost-in .6s ease-out;
}
.poison-ghost svg { width: 100%; height: 100%; display: block; }
@media (prefers-reduced-motion: reduce) { .poison-ghost { animation: poison-ghost-in .6s ease-out; } }
