/* ============================================================
   PatrolSEC — Rust edition styles
   Dual theme (black default / white) via html[data-theme]
   ============================================================ */

:root[data-theme="black"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #9ca3af;
  --card: #0d0d0f;
  --card2: #141418;
  --line: #26262c;
  --accent: #ffffff;
  --accent-ink: #000000;
  --danger: #ef4444;
  --ok: #22c55e;
  --input-bg: #0a0a0c;
}

:root[data-theme="white"] {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #56565e;
  --card: #f5f5f7;
  --card2: #ececf0;
  --line: #d9d9e0;
  --accent: #000000;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --input-bg: #ffffff;
}

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

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

#root { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ---------- screens ---------- */
.screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* splash */
.splash {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
}
.splash-logo {
  width: 88px; height: 88px;
  animation: splashPulse 1.6s ease-in-out infinite;
}
.splash-title { font-size: 1.7rem; font-weight: 800; letter-spacing: .12em; }
.splash-sub {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .3em;
  color: var(--muted); font-family: ui-monospace, monospace;
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: .75; }
}

/* ---------- generic ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.upper { text-transform: uppercase; letter-spacing: .14em; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent; color: var(--fg);
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; transition: transform .12s, border-color .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .16em; color: var(--muted);
}
.field input, .field select, .field textarea {
  background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; color: var(--fg); font: inherit; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 90px; }

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

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.warn { color: var(--danger); border-color: var(--danger); }

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.app-header .title { font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
  cursor: pointer; flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.94); }

/* ---------- content ---------- */
.content {
  flex: 1; overflow-y: auto;
  padding: 18px 18px 96px;
}

/* dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card { padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.stat-card .num { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat-card .lbl {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); margin-top: 2px;
}

.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.menu-item {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 18px 8px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
  cursor: pointer; transition: transform .12s, border-color .15s;
  text-align: center;
}
.menu-item:active { transform: scale(.95); }
.menu-item svg { width: 24px; height: 24px; }
.menu-item .lbl { font-size: .68rem; font-weight: 600; color: var(--muted); }

.section-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--muted); margin: 22px 0 12px; font-weight: 700;
}

/* list rows */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
}
.list-row .main { flex: 1; min-width: 0; }
.list-row .name { font-weight: 700; font-size: .95rem; }
.list-row .sub { font-size: .8rem; color: var(--muted); }
.list-row .icon-box {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--card2); border: 1px solid var(--line);
}
.list-row .icon-box svg { width: 20px; height: 20px; }

.empty {
  text-align: center; color: var(--muted);
  padding: 40px 20px; font-size: .9rem;
}

/* forms */
.form-panel { max-width: 560px; margin: 0 auto; }
.form-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px; padding: 10px 14px; font-size: .85rem; margin-bottom: 14px;
}
.form-success {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid var(--ok); color: var(--ok);
  border-radius: 10px; padding: 10px 14px; font-size: .85rem; margin: 12px 0;
}

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); cursor: pointer; padding: 4px 12px;
  border: none; background: transparent; font: inherit;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item .lbl { font-size: .62rem; font-weight: 600; }
.nav-item.active { color: var(--fg); }

/* ---------- login ---------- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 28px;
  overflow-y: auto;
}
/* spacer pseudo-elements: centers content when short, scrolls cleanly when tall */
.login-wrap::before, .login-wrap::after { content: ""; flex: 1; min-height: 8px; }
.login-wrap > * { flex-shrink: 0; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { width: 52px; height: 52px; }

/* login hero (system description) */
.login-hero {
  text-align: center;
  max-width: 400px;
  margin-bottom: 24px;
}
.hero-title {
  font-size: 1.75rem; font-weight: 800;
  letter-spacing: .1em; margin: 8px 0 2px;
}
.hero-desc {
  font-size: .85rem; color: var(--muted);
  margin: 14px 0 16px;
}
.hero-desc b { color: var(--fg); }
.hero-feats {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-bottom: 20px;
}
.hero-feats .chip svg { width: 13px; height: 13px; }
.hero-company {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  margin-bottom: 4px;
}
.hero-company .by {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .3em;
  color: var(--muted);
}
.hero-company .name {
  font-weight: 800; font-size: 1.05rem; letter-spacing: .08em;
}

/* download section (mobile / desktop) */
.dl-section {
  width: 100%; max-width: 400px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line);
}
.dl-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dl-col.span2 { grid-column: 1 / -1; }
.dl-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
}
.dl-head svg { width: 15px; height: 15px; flex: none; }
.dl-head .os { color: var(--muted); font-weight: 600; letter-spacing: .04em; font-size: .62rem; }
.dl-btn { padding: 11px 12px; font-size: .84rem; }
.dl-btn:disabled { opacity: .45; }
.dl-note { font-size: .66rem; text-align: center; margin: 0; }
.dl-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.dl-grid .dl-btn.mini {
  padding: 8px 10px; font-size: .74rem;
  justify-content: center;
}
.dl-grid .dl-btn.mini.ok {
  border-color: var(--ok); color: var(--ok);
}
@media (max-width: 360px) {
  .dl-section { grid-template-columns: 1fr; }
  .dl-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- camera ---------- */
.camera-box {
  position: relative; border-radius: 18px; overflow: hidden;
  background: var(--card2); border: 1px solid var(--line);
  aspect-ratio: 3/4; max-height: 55vh; margin: 0 auto; width: 100%; max-width: 480px;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; }
.camera-box .off-msg {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: .9rem; padding: 20px; text-align: center;
}
.capture-preview { max-width: 480px; margin: 14px auto 0; }
.capture-preview img { width: 100%; border-radius: 14px; border: 1px solid var(--line); }

/* speedtest */
.speed-big { font-size: 2.6rem; font-weight: 800; text-align: center; }
.speed-unit { font-size: .9rem; color: var(--muted); }
.speed-bar { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; margin: 18px 0; }
.speed-bar > div { height: 100%; background: var(--accent); width: 0%; transition: width .3s; }

/* map */
#map-view .map { height: 46vh; border-radius: 16px; border: 1px solid var(--line); }

/* toggle switch */
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); cursor: pointer;
  transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--fg); transition: transform .2s;
}
.switch input:checked + .track::after { transform: translateX(22px); }

/* toast */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--fg); color: var(--bg);
  padding: 10px 20px; border-radius: 12px; font-size: .88rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .content { padding: 24px; }
}
/* android apk banner (login screen) */
.apk-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ok);
  color: #fff;
  font-weight: 700; font-size: .82rem;
  text-decoration: none;
}
.apk-banner svg { width: 16px; height: 16px; }
