/* ============================================================
 * styles.css — Mobile-first design system
 * ============================================================ */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #6b7686;
  --line: #e6e9f0;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-soft: #eef0fe;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --warn: #d97706;
  --warn-soft: #fdf1e0;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(28, 39, 76, .08);
  --shadow-sm: 0 2px 8px rgba(28, 39, 76, .06);
  --maxw: 480px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Mobile shell ---------- */
.screen {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}
.scroll { flex: 1; overflow-y: auto; padding: 16px 16px 96px; }

/* ---------- Typography ---------- */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 14px 18px;
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; width: 100%;
  transition: transform .08s ease, opacity .2s ease, background .2s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--primary-soft); color: var(--primary-d); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.sm { padding: 9px 14px; font-size: 13px; width: auto; border-radius: 10px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px;
}
.card.tight { padding: 14px; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-family: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--primary); }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pill.green  { background: var(--success-soft); color: var(--success); }
.pill.amber  { background: var(--warn-soft);   color: var(--warn); }
.pill.red    { background: var(--danger-soft);  color: var(--danger); }
.pill.indigo { background: var(--primary-soft); color: var(--primary-d); }
.pill.gray   { background: #eef1f6; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--success); } .dot.amber { background: var(--warn); }
.dot.red { background: var(--danger); } .dot.gray { background: #c2c8d4; }

/* ---------- Login ---------- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 24px; max-width: var(--maxw); margin: 0 auto; width: 100%;
}
.logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), #7c6cf0);
  display: grid; place-items: center; color: #fff; font-size: 30px;
  box-shadow: var(--shadow);
}
.demo-creds { background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--primary-d); }
.demo-creds b { font-weight: 700; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { background:#fff; border:1px solid var(--line); border-radius:999px; padding:6px 11px; font-size:12px; cursor:pointer; }
.chip:active { background: var(--primary-soft); }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.avatar {
  width: 40px; height: 40px; border-radius: 12px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; }

/* ---------- Hero / status ---------- */
.hero {
  background: linear-gradient(135deg, #4f46e5, #6d5cf5);
  color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.hero .clock { font-size: 34px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero-row { display: flex; gap: 10px; margin-top: 14px; }
.hero-box { flex: 1; background: rgba(255,255,255,.15); border-radius: 12px; padding: 10px 12px; }
.hero-box .t { font-size: 11px; opacity: .85; }
.hero-box .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- GPS panel ---------- */
.gps {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
}
.gps .ic { font-size: 22px; line-height: 1; }
.gps.ok    { border-color: #bfe6cb; background: var(--success-soft); }
.gps.warn  { border-color: #f3d9ac; background: var(--warn-soft); }
.gps.bad   { border-color: #f3c3c3; background: var(--danger-soft); }
.meter { height: 6px; border-radius: 4px; background: #e6e9f0; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--primary); transition: width .4s; }

/* ---------- List rows ---------- */
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow .nm { font-weight: 600; font-size: 14px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); background: var(--card);
  border-top: 1px solid var(--line); display: flex; padding: 8px 8px 10px;
  box-shadow: 0 -4px 16px rgba(28,39,76,.05); z-index: 20;
}
.nav button {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--muted);
  font-family: inherit; font-size: 11px; font-weight: 600; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nav button.active { color: var(--primary); }
.nav button .ic { font-size: 20px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 86px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  background: #1a2233; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow); max-width: 88%;
  animation: pop .25s ease; display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #15803d; } .toast.err { background: #b91c1c; } .toast.warn { background: #b45309; }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Spinner / loading ---------- */
.spin {
  width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite;
}
.spin.dark { border-color: rgba(79,70,229,.25); border-top-color: var(--primary); }
@keyframes rot { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg,#eef1f6 25%,#e2e6ee 50%,#eef1f6 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 8px; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { font-size: 40px; opacity: .5; }

/* ---------- Misc ---------- */
.sectiontitle { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 10px; }
.sectiontitle h2 { font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm); }
.stat .v { font-size: 24px; font-weight: 800; }
.stat .t { font-size: 12px; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #cdd3de; border-radius: 999px; transition: .2s; }
.switch .sl:before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .sl { background: var(--primary); }
.switch input:checked + .sl:before { transform: translateX(18px); }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb6{margin-bottom:6px}.mb12{margin-bottom:12px}
.fade { animation: fade .3s ease; } @keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
