/* ============================================================
   Guard Sign-In — dark, mobile-first security theme
   ============================================================ */
:root {
  --bg: #0a0f1c;
  --bg2: #0f1729;
  --card: #121b31;
  --card2: #182342;
  --line: #223052;
  --text: #e8eefc;
  --muted: #8b98b8;
  --accent: #2dd4bf;
  --accent-2: #0ea5e9;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(14, 165, 233, .12), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(45, 212, 191, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; line-height: 1.5; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-icon { width: 38px; height: 38px; color: var(--accent); filter: drop-shadow(0 0 10px rgba(45, 212, 191, .45)); }
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: .5px; }

/* ---------- cards ---------- */
.card {
  width: 100%;
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

.card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; text-align: center; }
.card p { text-align: center; }

/* ---------- locating ---------- */
.locating-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 40px; padding-bottom: 40px; }
.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.geo-locked {
  margin-top: 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--good);
  background: rgba(34, 197, 94, .12);
  border: 1.5px solid rgba(34, 197, 94, .45);
  border-radius: 12px; padding: 10px 16px;
  animation: popIn .3s cubic-bezier(.2, 1.4, .4, 1);
}
.geo-lock-ic { font-size: 18px; }

/* ---------- denied ---------- */
.denied-card { text-align: center; }
.denied-icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- form ---------- */
.form-card h2 { text-align: left; margin-bottom: 18px; }
.geo-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--good);
  background: rgba(34, 197, 94, .10);
  border: 1px solid rgba(34, 197, 94, .35);
  border-radius: 999px; padding: 7px 12px; margin-bottom: 18px; width: fit-content;
}
.geo-badge.warn { color: var(--warn); background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .35); }
.geo-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; letter-spacing: .3px; }
.field input {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 17px;
  padding: 14px 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent-2); }
.field input.err { border-color: var(--bad); }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%;
  border: 0; border-radius: 12px;
  font-size: 16px; font-weight: 700;
  padding: 15px 16px;
  cursor: pointer;
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04121a; box-shadow: 0 8px 24px rgba(45, 212, 191, .25); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; box-shadow: 0 8px 24px rgba(239, 68, 68, .25); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--muted); margin-top: 10px; }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-big { font-size: 18px; padding: 17px; margin-top: 6px; }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn-row .btn { margin: 0; }
#form-loc { margin-top: 14px; font-size: 12px; }

/* ---------- active / result ---------- */
.active-card, .result-card { text-align: center; }
.ok-ic {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 900; color: #fff;
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 10px 30px rgba(34, 197, 94, .35);
}
.result-card.good .ok-ic { background: linear-gradient(135deg, #22c55e, #15803d); }
.result-card.warn .ok-ic { background: linear-gradient(135deg, #f59e0b, #b45309); box-shadow: 0 10px 30px rgba(245, 158, 11, .35); }
.result-card.bad .ok-ic { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 10px 30px rgba(239, 68, 68, .35); }

.kv { margin: 18px 0 4px; text-align: left; }
.kv > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.kv > div:last-child { border-bottom: 0; }
.kv span { color: var(--muted); font-size: 12.5px; }
.kv b { font-size: 15px; text-align: right; word-break: break-word; }

/* ---------- camera / capture (no preview shown) ---------- */
.camera-card { text-align: center; }
.face-icon {
  width: 110px; height: 110px; margin: 0 auto 16px;
  color: var(--accent);
  filter: drop-shadow(0 0 18px rgba(45, 212, 191, .35));
  animation: pulse 1.6s ease-in-out infinite;
}
.face-icon svg { width: 100%; height: 100%; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .85; } }
.camera-card h2 { font-size: 22px; }
.camera-card h2 b { color: var(--accent); }
.camera-card #cam-status { font-size: 15px; margin-top: 10px; min-height: 22px; }
.progress {
  width: 100%; height: 8px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line);
  margin-top: 18px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .7s ease;
}

/* ---------- success ---------- */
.success-card { text-align: center; }
.success-card .ok-ic {
  width: 72px; height: 72px; margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 900; color: #fff;
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 12px 34px rgba(34, 197, 94, .4);
  animation: popIn .4s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-card h2 { font-size: 21px; line-height: 1.35; }
.success-card .btn { margin-top: 18px; }

/* ---------- admin ---------- */
.admin-app { max-width: 860px; }
.admin-app .card { text-align: left; }
.admin-app h1 { font-size: 22px; margin-bottom: 4px; }
.admin-app h2 { text-align: left; font-size: 17px; margin: 24px 0 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-align: center;
}
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.good .n { color: var(--good); }
.stat.warn .n { color: var(--warn); }
.stat.bad .n { color: var(--bad); }
.stat.accent .n { color: var(--accent); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.toolbar input[type="date"] {
  background: var(--bg2); border: 1.5px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 14px;
}
.toolbar .btn { width: auto; padding: 11px 18px; font-size: 14px; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
td { font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.tag.active { background: rgba(34, 197, 94, .15); color: var(--good); }
.tag.done { background: rgba(139, 152, 184, .15); color: var(--muted); }
.tag.out { background: rgba(245, 158, 11, .15); color: var(--warn); }
.tag.manual { background: rgba(239, 68, 68, .15); color: var(--bad); }
.tag.okf { background: rgba(34, 197, 94, .15); color: var(--good); }
.tag.gps { background: rgba(14, 165, 233, .15); color: var(--accent-2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .field { margin-bottom: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row label { font-size: 14px; }
.switch-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line);
  transition: .2s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.login-card { max-width: 360px; margin: 0 auto; text-align: center; }
.login-card .btn { margin-top: 8px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 50;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.att-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.att-row .res { font-weight: 700; }
.att-row .res.accepted { color: var(--good); }
.att-row .res.denied { color: var(--bad); }
.att-row .res.flagged { color: var(--warn); }

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input[type="date"] { width: 100%; }
  table { font-size: 12.5px; }
  th:nth-child(5), td:nth-child(5) { display: none; } /* hide accuracy on small */
}
