/* ============================================================================
   BLE Radar shared app design system (2026-09-04)
   ONE stylesheet every redesigned screen links, so the whole app is one coherent
   surface instead of ten pages that each reinvent the same tokens. Built to match
   Sergiu's 10-screen mockup set (/var/www/.private/bleradar-redesign-2026/).

   Palette is the BLE Radar instrument family: blue-black #000614, cyan #22D3EE,
   green #34D399, amber #F59E0B, plus violet for Atlas/AI. Nothing here invents a
   new brand, it sharpens the existing one.

   Naming: every class is prefixed `app-` so it can sit on a page that still has
   its own page-specific CSS without colliding, and so a screen can adopt the
   system incrementally.
   ========================================================================== */

:root {
  --app-bg:        #000614;
  --app-bg-deep:   #00030B;
  --app-card:      #081525;
  --app-card-2:    #091528;
  --app-line:      #1A3748;
  --app-line-soft: rgba(45,77,98,.48);
  --app-text:      #F2F6FA;
  --app-muted:     #9AA8BA;
  --app-dim:       #6F7E93;
  --app-cyan:      #22D3EE;
  --app-green:     #34D399;
  --app-amber:     #F59E0B;
  --app-ocean:     #38BDF8;
  --app-violet:    #A855F7;
  --app-danger:    #FB7185;
  --app-grad:      linear-gradient(100deg, #22D3EE, #34D399);
  --app-grad-violet: linear-gradient(120deg, #A855F7, #6366F1);
  --app-tabbar-h:  76px;
  --app-radius:    18px;
  --app-radius-lg: 24px;
  --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --app-display: "Space Grotesk", var(--app-font);
  --app-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--app-bg); color: var(--app-text);
  font-family: var(--app-font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* Faint hex-grid wash used across every screen behind the content, the recurring
   motif from the mockups. Fixed and pointer-transparent so it never interferes. */
body.app-shell::before {
  content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    linear-gradient(rgba(34,211,238,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34,211,238,.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, #000, transparent 74%);
}
.app-shell > * { position: relative; z-index: 1; }

/* ---------------- Layout ---------------- */
.app-wrap {
  width: min(680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 calc(var(--app-tabbar-h) + 28px);
}
.app-eyebrow {
  margin: 0 0 8px; color: var(--app-cyan);
  font: 700 11px/1.3 var(--app-mono); letter-spacing: .16em; text-transform: uppercase;
}
.app-h1 { margin: 0; font: 600 clamp(28px, 8vw, 40px)/1.02 var(--app-display); letter-spacing: -.04em; }
.app-h2 { margin: 0; font: 700 20px/1.2 var(--app-font); letter-spacing: -.01em; }
.app-sub { margin: 8px 0 0; color: var(--app-muted); font-size: 14px; line-height: 1.6; }
.app-section-title {
  margin: 26px 4px 12px; color: var(--app-muted);
  font: 700 12px/1.2 var(--app-font); letter-spacing: .1em; text-transform: uppercase;
}

/* ---------------- Top bar ---------------- */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px; gap: 10px;
}
.app-topbar .app-brand {
  font: 800 22px/1 var(--app-display); letter-spacing: -.02em; color: #fff;
  flex: 1; text-align: center;
}
.app-topbar .app-brand em { font-style: normal; color: var(--app-cyan); }
/* Surface mark (2026-09-18): each map surface carries its own hexagon from the same family, so
   Planet, Live Map and Explorer read as one product without looking identical. */
.app-topbar .app-brand .brand-mark { width: 22px; height: 22px; vertical-align: -4px; margin-right: 8px; }
.app-icon-btn {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--app-line);
  background: rgba(20,26,38,.7); color: var(--app-text); font-size: 17px;
  cursor: pointer; text-decoration: none;
}
.app-signal-bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.app-signal-bars i { width: 4px; border-radius: 2px; background: var(--app-green); }
.app-signal-bars i:nth-child(1){ height: 7px; opacity:.5 } .app-signal-bars i:nth-child(2){ height: 12px; opacity:.75 } .app-signal-bars i:nth-child(3){ height: 18px; }

/* ---------------- Status pill (SCANNING / credits) ---------------- */
.app-status {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--app-line); border-radius: var(--app-radius);
  background: linear-gradient(120deg, rgba(34,211,238,.05), rgba(52,211,153,.04)), var(--app-card);
}
.app-status .s-left { display: flex; flex-direction: column; gap: 2px; }
.app-status .s-live { display: flex; align-items: center; gap: 8px; color: var(--app-green); font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.app-status .s-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--app-green); box-shadow: 0 0 8px var(--app-green); animation: app-blink 1.6s ease-in-out infinite; }
.app-status.idle .s-live { color: var(--app-muted); } .app-status.idle .s-dot { background: var(--app-dim); box-shadow: none; animation: none; }
.app-status .s-note { color: var(--app-muted); font-size: 12px; }
.app-status .s-right { text-align: right; }
.app-status .s-credits { color: var(--app-amber); font-weight: 800; font-size: 16px; }
.app-status .s-balance { color: var(--app-muted); font-size: 12px; }
@keyframes app-blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---------------- Cards ---------------- */
.app-card {
  border: 1px solid var(--app-line); border-radius: var(--app-radius-lg);
  background: linear-gradient(160deg, rgba(9,21,40,.96), rgba(1,8,21,.96));
  padding: 18px; margin-top: 14px;
}
.app-card.glow { border-color: rgba(34,211,238,.28); box-shadow: 0 0 0 1px rgba(34,211,238,.05), 0 16px 40px rgba(0,0,0,.35); }
.app-card.violet { border-color: rgba(168,85,247,.3); background: linear-gradient(160deg, rgba(40,24,60,.7), rgba(11,14,20,.9)); }
.app-card.amber  { border-color: rgba(245,158,11,.35); background: linear-gradient(160deg, rgba(48,34,10,.55), rgba(11,14,20,.9)); }

/* Row-style tappable card (Explore menu, Action Hub) */
.app-row {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  border: 1px solid var(--app-line); border-radius: var(--app-radius);
  background: linear-gradient(160deg, rgba(9,21,40,.9), rgba(1,8,21,.96));
  padding: 16px; margin-top: 12px; transition: border-color .18s, transform .18s;
}
.app-row:hover { border-color: rgba(34,211,238,.4); }
.app-row .app-row-icon {
  flex: none; width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: 14px; border: 1px solid var(--app-line); font-size: 24px;
  background: rgba(34,211,238,.06); color: var(--app-cyan);
}
.app-row.violet .app-row-icon { color: var(--app-violet); background: rgba(168,85,247,.08); border-color: rgba(168,85,247,.3); }
.app-row.amber  .app-row-icon { color: var(--app-amber);  background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.3); }
.app-row.green  .app-row-icon { color: var(--app-green);  background: rgba(52,211,153,.08); border-color: rgba(52,211,153,.3); }
.app-row .app-row-body { flex: 1; min-width: 0; }
.app-row .app-row-body b { display: block; font-size: 17px; font-weight: 700; }
.app-row .app-row-body span { display: block; margin-top: 3px; color: var(--app-muted); font-size: 13px; }
.app-row .app-row-chev { flex: none; color: var(--app-muted); font-size: 20px; }

/* ---------------- Buttons ---------------- */
.app-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; border: 0; border-radius: 16px;
  background: var(--app-grad); color: #F7FCFF; font: 800 16px var(--app-font);
  cursor: pointer; text-decoration: none; box-shadow: 0 8px 26px rgba(34,211,238,.22);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.app-btn:hover { filter: brightness(1.08); }
.app-btn:focus-visible { outline: 2px solid #F7FCFF; outline-offset: 3px; box-shadow: 0 0 0 5px rgba(34,211,238,.22),0 8px 26px rgba(34,211,238,.25); }
.app-btn:active { transform: translateY(1px); filter: brightness(.9); }
.app-btn:disabled,.app-btn[aria-disabled="true"] { background: #102637; color: #718096; box-shadow: none; cursor: not-allowed; filter: none; transform: none; }
.app-btn.ghost { background: var(--app-card); color: var(--app-text); border: 1px solid var(--app-line); box-shadow: none; }
.app-btn.violet { background: var(--app-grad-violet); color: #fff; box-shadow: 0 8px 26px rgba(168,85,247,.24); }

/* ---------------- Toggle ---------------- */
.app-toggle { position: relative; flex: none; width: 52px; height: 30px; }
/* The visible switch is 30 px tall; the invisible input covering it is 44 px so a thumb cannot miss it. */
.app-toggle input { position: absolute; opacity: 0; top: -7px; left: -4px; width: 60px; height: 44px; margin: 0; cursor: pointer; z-index: 1; }
.app-toggle .track { position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: 999px; background: #2A3446; transition: background .2s; }
.app-toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.app-toggle input:checked ~ .track { background: var(--app-green); }
.app-toggle input:checked ~ .knob { transform: translateX(22px); }

/* ---------------- Toggle-row (settings layers) ---------------- */
.app-toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--app-line-soft); }
.app-toggle-row:first-child { border-top: 0; }
.app-toggle-row .tr-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; font-size: 18px; }
.app-toggle-row .tr-body { flex: 1; min-width: 0; font-size: 15px; }

/* ---------------- Stat chips row ---------------- */
.app-stats { display: flex; gap: 10px; margin-top: 12px; }
.app-stat { flex: 1; min-width: 0; text-align: left; }
.app-stat .v { font: 700 24px/1 var(--app-display); letter-spacing: -.03em; color: var(--app-cyan); }
.app-stat .v.green { color: var(--app-green); } .app-stat .v.amber { color: var(--app-amber); }
.app-stat .k { margin-top: 4px; font-size: 10px; color: var(--app-muted); letter-spacing: .06em; text-transform: uppercase; }

/* ---------------- Pack tiles ---------------- */
.app-packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px,1fr)); gap: 10px; margin-top: 14px; }
.app-pack {
  border: 1px solid var(--app-line); border-radius: 14px; padding: 14px 8px; text-align: center;
  background: rgba(21,29,42,.5); cursor: pointer;
}
.app-pack.selected { border-color: var(--app-green); box-shadow: 0 0 0 1px rgba(52,211,153,.25); }
.app-pack .emoji { font-size: 28px; } .app-pack .n { margin-top: 4px; font: 700 20px var(--app-display); color: var(--app-amber); }
.app-pack .label { margin-top: 4px; font-size: 12px; color: var(--app-muted); }

/* ---------------- Bottom tab bar ---------------- */
.app-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  height: var(--app-tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex; align-items: center; justify-content: space-around;
  background: linear-gradient(180deg, rgba(0,6,20,.62), rgba(0,3,11,.98) 40%);
  backdrop-filter: blur(12px); border-top: 1px solid var(--app-line);
}
.app-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--app-muted); text-decoration: none; font-size: 10px; letter-spacing: .02em;
  flex: 1; padding-top: 8px;
}
.app-tab .ico { font-size: 20px; line-height: 1; }
.app-tab.active { color: var(--app-cyan); }
.app-tab.center { flex: none; }
.app-tab.center .ico {
  width: 58px; height: 58px; margin-top: -22px; display: grid; place-items: center;
  border-radius: 50%; background: var(--app-bg-deep); border: 1px solid var(--app-cyan);
  color: var(--app-cyan); font-size: 24px; box-shadow: 0 0 18px rgba(34,211,238,.35);
}

@media (prefers-reduced-motion: reduce) {
  .app-status .s-dot { animation: none; }
}
