:root {
  --bg: #0f1419;
  --bg-elevated: #171d25;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(148, 163, 184, 0.18);
  --text: #e8eef6;
  --muted: #94a3b8;
  --accent: #14b8a6;
  --accent-2: #0d9488;
  --accent-soft: rgba(20, 184, 166, 0.15);
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(20, 184, 166, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(56, 189, 248, 0.1), transparent 50%),
    linear-gradient(165deg, #0b1016 0%, #121820 45%, #0f1419 100%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #0ea5e9);
  color: #042f2e;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.section-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.section-sub {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field {
  margin-bottom: 0.9rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.65);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(20, 184, 166, 0.65);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

button,
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

button:active,
.btn:active {
  transform: translateY(1px);
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #042f2e;
}

.btn-secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .stats {
    grid-template-columns: 1fr;
  }
}

.stat {
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.stat strong {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.campaign-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 420px;
  overflow: auto;
}

.campaign-card {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.4);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.campaign-card:hover,
.campaign-card.active {
  border-color: rgba(20, 184, 166, 0.55);
  background: var(--accent-soft);
}

.campaign-card h3 {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
}

.campaign-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin: 1.25rem 0 0.85rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.search {
  min-width: min(280px, 100%);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  font-size: 0.86rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #151b23;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(340px, calc(100% - 2rem));
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #13201c;
  border: 1px solid rgba(20, 184, 166, 0.35);
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
}

.toast.error {
  background: #241416;
  border-color: rgba(248, 113, 113, 0.4);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Check-in page */
.checkin-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.checkin-card {
  width: min(480px, 100%);
  padding: 1.6rem;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.checkin-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.checkin-card .lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

.consent-box {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: rgba(15, 20, 25, 0.55);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.consent-box.soft-note {
  font-size: 0.82rem;
  opacity: 0.95;
}

.status {
  min-height: 1.35rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--danger);
}

.status.warn {
  color: var(--warn);
}

.btn-checkin {
  width: 100%;
  padding: 0.95rem 1rem;
  font-size: 1rem;
}

.footer-note {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.dest-preview {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.28);
}

.dest-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dest-url {
  display: block;
  word-break: break-all;
  font-size: 0.86rem;
  line-height: 1.4;
}

.share-panel {
  margin-bottom: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.35);
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.sms-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .sms-grid {
    grid-template-columns: 1fr;
  }
}

.counter-panel {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.tool-chip {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.28);
  color: var(--warn);
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-chip:hover {
  background: rgba(251, 191, 36, 0.18);
}

.draft-container {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
}

.draft-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.draft-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(20, 184, 166, 0.3);
  cursor: pointer;
  font-size: 0.78rem;
}

.draft-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.draft-delete {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.draft-delete:hover {
  color: var(--danger);
}

.sms-log-wrap {
  max-height: 340px;
}

.badge-success,
.badge-error {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--ok);
}

.badge-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.muted-tiny {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.gps-coords {
  font-size: 0.82rem;
}

.acc-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.acc-pill.acc-high {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.12);
}

.acc-pill.acc-ok {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
}

.acc-pill.acc-low {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
}

.map-link {
  font-weight: 600;
  white-space: nowrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.live-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-pill.on {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
}

.live-pill.on::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.live-pill.off {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.live-pill.off::before {
  background: var(--danger);
}

.live-map {
  height: min(420px, 55vh);
  margin-top: 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0b1016;
  z-index: 1;
}

.leaflet-container {
  font: inherit;
  background: #0b1016;
}

.leaflet-popup-content-wrapper {
  background: #151b23;
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.leaflet-popup-tip {
  background: #151b23;
}

.leaflet-popup-content {
  margin: 0.75rem 0.9rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.25rem;
}

.device-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.device-badges .pill {
  font-size: 0.7rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 8, 14, 0.72);
  backdrop-filter: blur(6px);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  padding: 1.25rem;
  border-radius: 18px;
  background: #121820;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
