:root {
  --forest: #123f32;
  --forest-deep: #0c2c23;
  --forest-soft: #1f5a48;
  --cream: #f3efe3;
  --cream-dark: #e8e2d2;
  --ink: #173b30;
  --muted: #716b5c;
  --line: rgba(23, 59, 48, 0.14);
  --red: #d64a35;
  --red-dark: #b63826;
  --amber: #d9962f;
  --green: #1b8a5a;
  --blue: #1f78ff;
  --shadow: 0 18px 40px rgba(12, 44, 35, 0.18);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button,
input,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- */
/* Shared brand bits                                                 */
/* ---------------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 4px;
  background: var(--red);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.12);
  transform: rotate(-45deg);
  flex: none;
}

.brand-mark.large {
  width: 34px;
  height: 34px;
}

/* ---------------------------------------------------------------- */
/* Tracker page                                                      */
/* ---------------------------------------------------------------- */

.tracker-page {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  background: #dfe5dc;
}

#map {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  background: #dfe5dc;
}

.topbar {
  position: absolute;
  z-index: 1200;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  color: #fff;
  background: linear-gradient(
    180deg,
    rgba(12, 44, 35, 0.94),
    rgba(12, 44, 35, 0.82)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.topbar .brand {
  font-size: 17px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.more-menu {
  position: relative;
  display: none;
}

.more-actions {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 124px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(12, 44, 35, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow);
}

.more-actions .ghost {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.ghost {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.17);
  border-color: rgba(255, 255, 255, 0.38);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.left-panels {
  position: absolute;
  z-index: 1100;
  top: calc(70px + var(--safe-top));
  left: 14px;
  width: 252px;
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  position: relative;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.panel-toggle:hover .panel-toggle-label {
  color: var(--forest-soft);
}

.panel-toggle-label {
  flex: 1;
}

.panel-chevron {
  width: 7px;
  height: 7px;
  margin-right: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: none;
}

.panel-toggle[aria-expanded="true"] .panel-chevron {
  transform: rotate(-135deg);
}

.panel-body {
  min-height: 0;
  margin-top: 10px;
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(23, 59, 48, 0.08);
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.recording {
  color: #0b6a43;
  background: rgba(27, 138, 90, 0.13);
}

.status-pill.recording::before {
  animation: pulse 1.4s ease-out infinite;
}

.status-pill.paused {
  color: #9a6513;
  background: rgba(217, 150, 47, 0.16);
}

.status-pill.stopped {
  color: var(--red-dark);
  background: rgba(214, 74, 53, 0.13);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(27, 138, 90, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(27, 138, 90, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(27, 138, 90, 0);
  }
}

.stat-states {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.save-state {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  line-height: 1.25;
}

.sync-state {
  font-size: 10px;
  font-weight: 650;
  color: var(--forest-soft);
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sync-state.offline {
  color: var(--red-dark);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 12px;
}

.stat {
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat strong {
  display: block;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gps-message {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.35;
  color: #8f2c1e;
  background: rgba(214, 74, 53, 0.1);
  border: 1px solid rgba(214, 74, 53, 0.2);
}

.controls {
  position: absolute;
  z-index: 1100;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: calc(100vw - 20px);
}

.control {
  min-width: 82px;
  min-height: 52px;
  padding: 0 17px;
  border: 0;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 750;
  color: #fff;
  background: var(--forest-soft);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}

.control:active:not(:disabled) {
  transform: translateY(1px);
}

.control:disabled {
  opacity: 0.34;
  box-shadow: none;
}

.control.primary {
  background: var(--green);
}

.control.pause {
  background: var(--amber);
  color: #3a2705;
}

.control.stop {
  background: var(--red);
}

.control.clear {
  background: #e5dfd0;
  color: #5f584a;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
}

.control:hover:not(:disabled) {
  filter: brightness(1.05);
}

.toast {
  position: absolute;
  z-index: 1500;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  color: #fff;
  background: rgba(12, 44, 35, 0.94);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

.toast.error {
  background: rgba(153, 43, 28, 0.96);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Leaflet tweaks */

.tracker-page .leaflet-top.leaflet-right {
  top: calc(64px + var(--safe-top));
}

.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  color: var(--ink) !important;
  font-size: 20px !important;
}

.leaflet-control-zoom {
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(12, 44, 35, 0.18) !important;
  border: 0 !important;
}

.map-locate-control {
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(12, 44, 35, 0.18) !important;
  border: 0 !important;
}

.map-locate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: #fffdf7;
  cursor: pointer;
}

.map-locate-button:hover {
  background: #f3efe3;
}

.map-locate-button:focus-visible {
  outline: 2px solid var(--forest-soft);
  outline-offset: -3px;
}

.map-locate-button.locating svg {
  animation: locate-pulse 0.9s ease-in-out infinite;
}

@keyframes locate-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.88);
  }
}

.leaflet-control-attribution {
  background: rgba(255, 253, 247, 0.82) !important;
  color: #5e5749 !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--forest-soft) !important;
}

.leaflet-control-scale-line {
  border-color: rgba(23, 59, 48, 0.4) !important;
  background: rgba(255, 253, 247, 0.76) !important;
  color: #4d473b !important;
}

/* ---------------------------------------------------------------- */
/* Modal                                                             */
/* ---------------------------------------------------------------- */

.modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 44, 35, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
  border-radius: 20px;
  background: #fffdf7;
  box-shadow: 0 30px 70px rgba(12, 44, 35, 0.32);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.modal-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.share-grid {
  display: grid;
  gap: 8px;
}

.share-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #faf7ee;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.share-option:hover {
  background: #f1ecdf;
  border-color: rgba(23, 59, 48, 0.28);
}

.share-title {
  display: block;
  font-weight: 750;
  font-size: 14px;
}

.share-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.secondary {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 16px;
  background: #f3efe3;
  color: var(--ink);
  font-weight: 700;
}

.secondary:hover {
  background: #e9e3d3;
}

/* ---------------------------------------------------------------- */
/* Auth pages                                                        */
/* ---------------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  background:
    radial-gradient(circle at 15% 15%, rgba(214, 74, 53, 0.16), transparent 36%),
    radial-gradient(circle at 85% 80%, rgba(27, 138, 90, 0.2), transparent 42%),
    linear-gradient(145deg, #e8e2d2, #f5f1e7 55%, #e4ddcb);
}

.auth-card {
  width: min(430px, 100%);
  padding: 30px;
  border-radius: 24px;
  background: rgba(255, 253, 247, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 30px 70px rgba(12, 44, 35, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-brand {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 26px;
}

.auth-brand h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.auth-form label {
  display: block;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.auth-form input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(23, 59, 48, 0.18);
  background: #fffdf8;
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0.16em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input:focus {
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 4px rgba(31, 90, 72, 0.12);
}

.auth-submit {
  width: 100%;
  margin-top: 14px;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--forest);
  color: #fff;
  font-size: 16px;
  font-weight: 750;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.auth-submit:hover:not(:disabled) {
  background: var(--forest-soft);
}

.auth-submit:disabled {
  opacity: 0.6;
}

.auth-error {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(214, 74, 53, 0.1);
  color: #922f21;
  font-size: 13px;
  font-weight: 600;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.auth-footer a {
  color: var(--forest-soft);
  font-weight: 700;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

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

.admin-page {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 90% 0%, rgba(27, 138, 90, 0.12), transparent 34%),
    var(--cream);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  color: #fff;
  background: var(--forest);
}

.admin-topbar .ghost {
  border-color: rgba(255, 255, 255, 0.24);
}

.admin-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.admin-banner {
  margin-bottom: 18px;
  padding: 12px 15px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.4;
}

.admin-banner.error {
  background: rgba(214, 74, 53, 0.1);
  border: 1px solid rgba(214, 74, 53, 0.22);
  color: #922f21;
}

.admin-banner.success {
  margin: 14px 0 0;
  background: rgba(27, 138, 90, 0.1);
  border: 1px solid rgba(27, 138, 90, 0.22);
  color: #12633f;
}

.admin-panel {
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fffdf7;
  box-shadow: 0 12px 30px rgba(12, 44, 35, 0.08);
}

.admin-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.admin-panel-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(150px, 0.5fr) auto;
  gap: 12px;
  align-items: end;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.field input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid rgba(23, 59, 48, 0.18);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(31, 90, 72, 0.12);
}

.user-form .auth-submit {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 0 22px;
  font-size: 14px;
}

#access-code {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
}

#handoff-code {
  text-align: center;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
}

.share-panel {
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid rgba(31, 90, 72, 0.3);
  background: #fffdf7;
  box-shadow: 0 12px 30px rgba(12, 44, 35, 0.1);
}

.share-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.share-panel h2 {
  margin: 0 0 4px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.link-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
}

.link-row label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.link-row input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f2e7;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.share-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.share-actions .small-button {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 13px;
}

.share-actions .share-submit {
  width: auto;
  min-height: 38px;
  margin: 0;
  padding: 0 18px;
  font-size: 13px;
}

.share-actions .is-armed,
.share-actions .is-armed:hover:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.link-cell {
  max-width: 380px;
}

.link-cell .user-link {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  color: var(--forest-soft);
  text-decoration: none;
}

.link-cell .user-link:hover {
  text-decoration: underline;
}

.link-cell .small-button {
  margin-left: 8px;
  vertical-align: middle;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 750;
}

.status-badge.on {
  background: rgba(27, 138, 90, 0.12);
  color: #12633f;
}

.status-badge.off {
  background: rgba(113, 107, 92, 0.12);
  color: var(--muted);
}

.tracks-heading {
  margin-top: 38px;
}

.admin-heading,
.preview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-heading h1 {
  margin: 0 0 4px;
  font-size: 29px;
  letter-spacing: -0.035em;
}

.admin-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
}

.admin-empty {
  padding: 42px 20px;
  border-radius: 16px;
  border: 1px dashed rgba(23, 59, 48, 0.24);
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fffdf7;
  box-shadow: 0 12px 30px rgba(12, 44, 35, 0.08);
}

.tracks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}

.tracks-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f6f2e7;
  border-bottom: 1px solid var(--line);
}

.tracks-table td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(23, 59, 48, 0.07);
  vertical-align: middle;
}

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

.tracks-table tbody tr:hover {
  background: #faf7ee;
}

.track-name {
  font-weight: 750;
  font-size: 14px;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-id {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.status-text {
  font-weight: 700;
  text-transform: capitalize;
}

.status-text.recording {
  color: var(--green);
}

.status-text.paused {
  color: #9a6513;
}

.status-text.stopped {
  color: var(--red-dark);
}

.status-text.idle {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f6f2e7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.small-button:hover:not(:disabled) {
  background: #ece6d7;
}

.small-button:disabled {
  opacity: 0.45;
}

.admin-preview {
  margin-top: 28px;
  padding: 18px;
  border-radius: 18px;
  background: #fffdf7;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.preview-heading h2 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.admin-map {
  height: 460px;
  border-radius: 13px;
  overflow: hidden;
  background: #dfe5dc;
}

/* ---------------------------------------------------------------- */
/* Small screens                                                     */
/* ---------------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar {
    align-items: center;
  }

  .topbar .brand {
    font-size: 15px;
  }

  .more-menu {
    display: block;
  }

  .campaign-label,
  .role-label {
    display: none;
  }

  .ghost {
    padding: 7px 10px;
    font-size: 12px;
  }

  .left-panels {
    left: 10px;
    top: calc(64px + var(--safe-top));
    width: 216px;
    max-height: calc(100vh - 82px);
    max-height: calc(100dvh - 82px);
  }

  .panel {
    padding: 10px;
  }

  .stat strong {
    font-size: 15px;
  }

  .controls {
    width: calc(100vw - 16px);
    gap: 6px;
    padding: 6px;
    bottom: calc(10px + var(--safe-bottom));
  }

  .control {
    flex: 1;
    min-width: 0;
    min-height: 50px;
    padding: 0 8px;
    font-size: 14px;
  }

  .tracker-page .leaflet-top.leaflet-right {
    top: calc(64px + var(--safe-top));
  }

  .toast {
    bottom: calc(84px + var(--safe-bottom));
  }

  .admin-heading {
    flex-direction: column;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .user-form .auth-submit {
    width: 100%;
  }

  .link-row {
    grid-template-columns: 1fr;
  }

  .link-row label {
    margin-top: 5px;
  }

  .share-panel-head {
    flex-direction: column;
  }

  .admin-map {
    height: 330px;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .top-actions {
    gap: 4px;
  }

  .ghost {
    padding: 6px 7px;
    font-size: 10.5px;
  }

  .left-panels {
    top: calc(62px + var(--safe-top));
    width: 200px;
  }

  .stat-grid {
    gap: 7px 10px;
  }

  .control {
    font-size: 13px;
    border-radius: 11px;
  }

  .auth-card {
    padding: 22px;
  }
}

/* ---------------------------------------------------------------- */
/* Campaign additions                                                */
/* ---------------------------------------------------------------- */

.campaign-label {
  font-size: 12px;
  font-weight: 650;
  color: rgba(255, 255, 255, 0.72);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-label {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.role-label.coordinator {
  background: rgba(217, 150, 47, 0.3);
}

.role-label.worker {
  background: rgba(31, 120, 255, 0.3);
}

.identity-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(23, 59, 48, 0.055);
  font-size: 12px;
  min-width: 0;
}

.identity-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identity-line strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  margin-left: auto;
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: var(--forest-soft);
  font-size: 11px;
  font-weight: 750;
}

.text-button:hover {
  text-decoration: underline;
}

.tracks-panel {
  width: 100%;
}

.tracks-panel .panel-body {
  max-height: min(42vh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tracks-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(23, 59, 48, 0.09);
  color: var(--ink);
  font-size: 11px;
}

.tracks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
}

.track-list-item {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: 9px;
  margin-bottom: 4px;
  background: rgba(23, 59, 48, 0.035);
}

.track-list-item.own {
  background: rgba(214, 74, 53, 0.09);
}

.track-list-main {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  flex: 1;
  min-width: 0;
  padding: 7px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.track-list-main:hover {
  background: rgba(23, 59, 48, 0.06);
}

.track-dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.track-list-text {
  display: block;
  min-width: 0;
}

.track-list-text strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.track-list-meta {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-list-delete {
  width: 26px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.track-list-delete:hover {
  background: rgba(214, 74, 53, 0.12);
  color: var(--red-dark);
}

.track-list-empty {
  padding: 10px 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.control.draw {
  background: #6d3f8f;
}

#map.drawing {
  cursor: crosshair;
}

.draw-vertex {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #8e44ad;
  box-shadow: 0 2px 8px rgba(40, 18, 56, 0.3);
  cursor: grab;
}

.draw-vertex:active {
  cursor: grabbing;
}

.draw-vertex span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8e44ad;
}

.draw-controls {
  position: absolute;
  z-index: 1250;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  max-width: calc(100vw - 20px);
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.96);
  border: 1px solid rgba(142, 68, 173, 0.35);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
}

#draw-hint {
  color: #6d3f8f;
}

.primary-small {
  background: var(--forest);
  border-color: var(--forest);
  color: #fff;
}

.primary-small:hover:not(:disabled) {
  background: var(--forest-soft);
}

.name-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.name-form input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(23, 59, 48, 0.18);
  border-radius: 11px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 17px;
  outline: none;
}

.name-form input:focus {
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 4px rgba(31, 90, 72, 0.12);
}

.name-form .modal-actions {
  gap: 8px;
}

.name-save {
  width: auto;
  min-height: 42px;
  margin: 0;
  padding: 0 20px;
  font-size: 14px;
}

.toast {
  bottom: calc(160px + var(--safe-bottom));
}

.role-link-block {
  margin-top: 14px;
  padding: 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #faf7ee;
}

.role-link-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.role-link-heading h3,
.browser-list-wrap h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.danger-button {
  color: var(--red-dark);
  border-color: rgba(214, 74, 53, 0.28);
  background: rgba(214, 74, 53, 0.06);
}

.danger-button:hover:not(:disabled) {
  background: rgba(214, 74, 53, 0.13);
}

.browser-list-wrap {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.browser-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.browser-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #f6f2e7;
  font-size: 12px;
}

.browser-item .admin-summary {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .campaign-label {
    display: none;
  }

  .draw-controls {
    bottom: calc(82px + var(--safe-bottom));
    gap: 5px;
    padding: 7px;
  }

  #draw-hint {
    width: 100%;
    text-align: center;
  }

  .toast {
    bottom: calc(175px + var(--safe-bottom));
  }
}

@media (max-width: 420px) {
  .role-label {
    display: none;
  }
}
