/* ---------- WiFi Session Tracker ---------- */

:root {
  --bg: #070b16;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e7ecf5;
  --muted: #8b96ad;
  --accent: #38bdf8;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
button, a, input, select, .btn { touch-action: manipulation; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient background */
.orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; animation: drift 22s ease-in-out infinite alternate; }
.orb-a { width: 480px; height: 480px; background: #0e3a5c; top: -140px; left: -120px; }
.orb-b { width: 420px; height: 420px; background: #14324f; bottom: -160px; right: -100px; animation-delay: -8s; }
.orb-c { width: 300px; height: 300px; background: #0c4a44; top: 40%; left: 55%; animation-delay: -14s; opacity: 0.35; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, -40px) scale(1.12); }
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: calc(18px + env(safe-area-inset-top)) calc(28px + env(safe-area-inset-right)) 18px calc(28px + env(safe-area-inset-left));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  background: rgba(7, 11, 22, 0.55);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.2px; }
.brand-icon { width: 24px; height: 24px; color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.device-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 999px; padding: 7px 14px;
}
.device-chip svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.device-chip input {
  background: none; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 0.85rem; width: 160px;
}
.device-chip input::placeholder { color: var(--muted); }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--muted); font-size: 0.95rem; min-width: 86px; text-align: right;
}

/* Topbar nav link + admin tag */
.nav-link {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 999px; padding: 7px 14px;
  color: var(--text); text-decoration: none;
  font-size: 0.83rem; font-weight: 600;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.09); }
.nav-link svg { width: 15px; height: 15px; color: var(--accent); }
.admin-tag {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--amber); background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.3);
  padding: 3px 9px; border-radius: 999px; margin-left: 4px;
}

/* Layout */
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px calc(48px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; font-weight: 650; letter-spacing: 0.2px; }
.muted { color: var(--muted); font-size: 0.82rem; }

/* Status hero */
.status-card { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.ring-wrap { position: relative; flex: none; }
.ring {
  width: 132px; height: 132px; border-radius: 50%;
  padding: 5px;
  background: conic-gradient(var(--green), #0ea5e9, var(--green));
  animation: spin 5s linear infinite;
  transition: background 0.4s ease;
}
.ring.offline { background: conic-gradient(var(--red), #7f1d1d, var(--red)); animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ring-core {
  width: 100%; height: 100%; border-radius: 50%;
  background: #0b1120;
  display: flex; align-items: center; justify-content: center;
  animation: spin-rev 5s linear infinite;
}
.ring.offline .ring-core { animation: none; }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
.ring-core svg { width: 46px; height: 46px; color: var(--green); transition: color 0.4s; }
.ring.offline .ring-core svg { color: var(--red); }
.live-dot {
  position: absolute; top: 6px; right: 6px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--green); border: 3px solid #0b1120;
  animation: pulse 1.6s ease-in-out infinite;
}
.live-dot.offline { background: var(--red); animation: none; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.72); opacity: 0.6; } }

.status-text { flex: 1; min-width: 220px; }
.status-text h1 { font-size: 1.9rem; font-weight: 750; letter-spacing: -0.4px; }
.status-text h1.online { color: var(--green); }
.status-text h1.offline { color: var(--red); }
.status-text p { color: var(--muted); margin-top: 4px; font-size: 0.92rem; }
.chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chip {
  font-size: 0.75rem; padding: 5px 11px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.12); color: #9ddcff;
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-variant-numeric: tabular-nums;
}

.session-timer { text-align: right; margin-left: auto; }
.elapsed { display: block; font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.elapsed-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1.4px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.stat-value { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1.2px; }

/* Timeline */
.timeline-track {
  position: relative; height: 44px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.seg {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(52,211,153,0.85), rgba(16,185,129,0.55));
  border-radius: 4px;
  min-width: 2px;
}
.seg.estimated { background: repeating-linear-gradient(45deg, rgba(251,191,36,0.7) 0 6px, rgba(251,191,36,0.35) 6px 12px); }
.now-line {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--accent); box-shadow: 0 0 8px var(--accent); z-index: 2;
}
.timeline-axis {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 0.72rem; margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.legend { display: flex; gap: 18px; margin-top: 14px; color: var(--muted); font-size: 0.78rem; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-online { background: var(--green); }
.sw-est { background: repeating-linear-gradient(45deg, var(--amber) 0 3px, transparent 3px 6px); border: 1px solid var(--amber); }
.sw-now { background: var(--accent); width: 2px; }

/* Log table */
.actions { display: flex; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(56,189,248,0.12); color: #9ddcff;
  border: 1px solid rgba(56,189,248,0.3);
  padding: 8px 15px; border-radius: 10px;
  font: inherit; font-size: 0.83rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: rgba(56,189,248,0.22); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 15px; height: 15px; }
.btn-danger { background: rgba(248,113,113,0.1); color: #fca5a5; border-color: rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th {
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
td { padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 650;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--green); background: rgba(52,211,153,0.1); }
.badge.off { color: var(--red); background: rgba(248,113,113,0.1); }
.badge.est { color: var(--amber); background: rgba(251,191,36,0.1); }
td .sub { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 34px 12px; font-size: 0.9rem; }

/* Footer */
.foot { color: var(--muted); font-size: 0.8rem; line-height: 1.6; padding: 6px 8px; }
.foot code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 6px; font-size: 0.76rem; }
.foot-meta { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.75rem; }
.dev-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 650;
  color: #9ddcff; background: rgba(56,189,248,0.1);
  border: 1px solid rgba(56,189,248,0.3);
}
.dev-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- Admin ---------- */

/* Access gate */
.gate {
  min-height: calc(100vh - 70px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-card { width: 340px; text-align: center; padding: 34px 28px; }
.gate-icon { width: 40px; height: 40px; color: var(--accent); margin: 0 auto 14px; }
.gate-card h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.gate-card .muted { font-size: 0.85rem; }
.gate-card input {
  width: 100%; margin-top: 18px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 11px 14px;
  color: var(--text); font: inherit; font-size: 1rem; text-align: center;
  letter-spacing: 3px; outline: none; transition: border-color 0.15s;
}
.gate-card input:focus { border-color: var(--accent); }
.gate-btn { width: 100%; justify-content: center; margin-top: 14px; padding: 11px; font-size: 0.9rem; }
.gate-hint { margin-top: 14px; color: var(--muted); font-size: 0.78rem; }
.gate-hint code { background: rgba(255,255,255,0.08); padding: 1px 7px; border-radius: 6px; }
.gate-err { margin-top: 10px; color: var(--red); font-size: 0.8rem; }
.gate.shake .gate-card { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}

/* Filter inputs */
.input {
  background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 8px 12px;
  color: var(--text); font: inherit; font-size: 0.83rem; outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
select.input { cursor: pointer; }
select.input option { background: #0b1120; color: var(--text); }

/* Team today strip */
.team-strip {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.member {
  display: flex; align-items: center; gap: 11px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px; padding: 11px 13px;
}
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
  background: rgba(139,150,173,0.15); color: var(--muted);
  border: 2px solid rgba(139,150,173,0.25);
}
.avatar.on { background: rgba(52,211,153,0.14); color: var(--green); border-color: rgba(52,211,153,0.45); }
.avatar.done { background: rgba(56,189,248,0.12); color: var(--accent); border-color: rgba(56,189,248,0.35); }
.member-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-name { font-size: 0.86rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-dept { font-size: 0.72rem; color: var(--muted); }
.member-state { font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.member-state.on { color: var(--green); }
.member-state.done { color: var(--accent); }
.member-state.out { color: var(--muted); }

/* Timesheet table extras */
.emp { font-weight: 650; }
.src {
  font-size: 0.72rem; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent;
}
.src-seed { color: var(--muted); background: rgba(139,150,173,0.1); border-color: rgba(139,150,173,0.25); }
.src-dev { color: var(--accent); background: rgba(56,189,248,0.1); border-color: rgba(56,189,248,0.3); }

/* hidden must win over component display rules (e.g. .wrap flex) */
[hidden] { display: none !important; }

/* Register staff modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 14, 0.66); backdrop-filter: blur(6px);
  padding: 20px;
}
.modal-card { width: min(460px, 94vw); padding: 26px; color-scheme: dark; }
.modal-card h2 { font-size: 1.1rem; font-weight: 700; }
.modal-sub { font-size: 0.82rem; margin: 6px 0 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.field.span2 { grid-column: 1 / -1; }
.field .input { width: 100%; margin-top: 6px; font-weight: 400; color: var(--text); }
.check { display: flex; align-items: center; gap: 9px; font-size: 0.84rem; color: var(--text); margin: 2px 0 16px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn-ghost { background: transparent; border-color: var(--card-border); color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  transform: translate(-50%, 18px);
  background: #0b1120; border: 1px solid var(--card-border);
  color: var(--text); font-size: 0.84rem;
  padding: 11px 18px; border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */

/* Tablets & narrow desktop windows */
@media (max-width: 900px) {
  .wrap { padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); gap: 14px; }
  .card { padding: 18px; }
  .status-card { gap: 18px; }
  .ring { width: 112px; height: 112px; }
  .status-text h1 { font-size: 1.6rem; }
  .elapsed { font-size: 1.7rem; }
  .actions { flex-wrap: wrap; }
}

/* Phones */
@media (max-width: 640px) {
  .topbar { padding-left: 16px; padding-right: 16px; gap: 10px; }
  .topbar-right { gap: 8px; }
  .brand { font-size: 0.95rem; }
  .device-chip { flex: 1; min-width: 0; }
  .device-chip input { width: 100%; min-width: 0; }
  .clock { display: none; }

  .status-card { flex-direction: column; text-align: center; padding: 20px 16px; }
  .status-text { text-align: center; min-width: 0; }
  .chips { justify-content: center; }
  .session-timer { margin-left: 0; text-align: center; }
  .ring { width: 104px; height: 104px; }
  .ring-core svg { width: 38px; height: 38px; }
  .status-text h1 { font-size: 1.5rem; }
  .elapsed { font-size: 1.55rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 1.3rem; }

  .card-head { margin-bottom: 12px; }
  .actions { width: 100%; }
  .actions .input { flex: 1 1 140px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }

  table { font-size: 0.8rem; }
  th, td { padding: 9px 8px; white-space: nowrap; }

  .team-strip { grid-template-columns: 1fr; }
  .gate-card { width: min(340px, 92vw); padding: 28px 20px; }
  .foot { font-size: 0.75rem; }
}

/* Very small phones */
@media (max-width: 380px) {
  .nav-link { padding: 7px 11px; font-size: 0.78rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .member { padding: 10px; }
}
