:root {
  color-scheme: dark;
  --bg: #080a12;
  --bg2: #111426;
  --card: rgba(22, 27, 44, .78);
  --card2: rgba(29, 36, 58, .88);
  --text: #f7f8fd;
  --muted: #aab2c5;
  --line: rgba(255,255,255,.10);
  --accent: #ff4d8d;
  --accent2: #8b5cf6;
  --good: #35d399;
  --bad: #fb7185;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,77,141,.25), transparent 35%),
    radial-gradient(circle at top right, rgba(139,92,246,.22), transparent 36%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--text);
}
a { color: #ff9bc0; text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -.04em; }
h1 { font-size: clamp(26px, 4vw, 42px); }
h2 { font-size: 24px; }
button, input, select { font: inherit; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(16, 20, 34, .86);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 28px;
  box-shadow: 0 25px 70px rgba(0,0,0,.35);
  backdrop-filter: blur(18px);
}
.brand-badge {
  width: 58px; height: 58px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-size: 27px;
  box-shadow: 0 15px 30px rgba(255,77,141,.25);
  margin-bottom: 14px;
}
.muted { color: var(--muted); line-height: 1.55; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
input, select {
  width: 100%;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 15px;
  padding: 12px 13px;
  outline: none;
}
select option { background: #171b2a; color: white; }
input:focus, select:focus {
  border-color: rgba(255,77,141,.65);
  box-shadow: 0 0 0 4px rgba(255,77,141,.12);
}
.check-row, .switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.check-row input, .switch-line input { width: auto; }

.btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 15px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}
.btn.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 800;
}
.btn.ghost { background: rgba(255,255,255,.06); }
.btn.danger { background: rgba(251,113,133,.14); border-color: rgba(251,113,133,.25); color: #ffc2cc; }
.alert {
  padding: 12px 14px;
  border-radius: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.alert.good { background: rgba(53,211,153,.12); color: #b8ffe5; border-color: rgba(53,211,153,.22); }
.alert.bad { background: rgba(251,113,133,.12); color: #ffd0d8; border-color: rgba(251,113,133,.22); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px clamp(14px, 4vw, 36px);
  position: sticky; top: 0; z-index: 10;
  background: rgba(8,10,18,.72);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  color: #ff9bc0;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 5px;
}
.page, .viewer-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 36px) 40px;
}
.glass-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(0,0,0,.20);
  backdrop-filter: blur(18px);
}
.card-title { font-size: 18px; font-weight: 900; margin-bottom: 10px; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 16px;
  margin-bottom: 16px;
}
.live-row { display:flex; align-items:center; gap:10px; font-size: 20px; margin: 12px 0; }
.dot {
  width: 12px; height: 12px; border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(251,191,36,.12);
  display: inline-block;
}
.dot.on { background: var(--good); box-shadow: 0 0 0 6px rgba(53,211,153,.13); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 6px rgba(251,113,133,.13); }

.mini-grid, .info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}
.mini-grid div, .stat-card {
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
}
.mini-grid span, .stat-card span, .address-card span {
  display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px;
}
.mini-grid b, .stat-card b {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.section-head {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.users-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.user-card summary {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; list-style: none; gap: 12px;
}
.user-card summary::-webkit-details-marker { display: none; }
.user-card summary span { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
.status-pill {
  border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 800;
}
.good-pill { background: rgba(53,211,153,.15); color: #b8ffe5; }
.bad-pill { background: rgba(251,113,133,.15); color: #ffd0d8; }
.user-edit { margin-top: 18px; }
.perm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.check-tile {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.check-tile input { width: auto; }
.time-box {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  background: rgba(255,255,255,.04);
}
.days-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}
.days-row label {
  display: flex; gap: 5px; align-items: center;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
}
.days-row input { width:auto; }
.inline-form {
  display: flex; gap: 10px; margin-top: 12px; align-items: center;
}
.inline-form input { max-width: 260px; }

.viewer-body .topbar h1 { font-size: 26px; }
.viewer-shell { padding-top: 10px; }
.map-wrap {
  height: 48vh;
  min-height: 350px;
  border-radius: 30px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.30);
}
#map { width: 100%; height: 100%; background: #111827; }
.map-overlay {
  position: absolute; top: 14px; left: 14px; z-index: 500;
  display: flex; align-items: center; gap: 10px;
  background: rgba(10,13,25,.82);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 999px;
}
.info-grid {
  grid-template-columns: repeat(4, minmax(0,1fr));
  margin-top: 14px;
}
.address-card {
  grid-column: span 2;
}
.address-card b {
  display:block; font-size: 16px; line-height: 1.45; overflow-wrap: anywhere;
}
.reactions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.emoji-row {
  display:flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
}
.emoji-row button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  border-radius: 18px;
  min-width: 50px;
  min-height: 48px;
  font-size: 24px;
  cursor: pointer;
}
.emoji-row button:active { transform: scale(.95); }
.toast {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  background: rgba(20,24,38,.92);
  color: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 15px;
  transition: .22s;
  pointer-events: none;
  z-index: 999;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .hero-grid, .form-grid, .mini-grid, .info-grid { grid-template-columns: 1fr 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .address-card { grid-column: 1 / -1; }
  .reactions { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .topbar .btn { min-width: auto; padding: 9px 12px; }
  .hero-grid, .form-grid, .mini-grid, .info-grid { grid-template-columns: 1fr; }
  .map-wrap { height: 44vh; min-height: 310px; border-radius: 22px; }
  .auth-card { padding: 22px; border-radius: 24px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input { max-width: none; }
}
