:root {
  --ink: #111417;
  --muted: #687078;
  --panel: rgba(246, 248, 250, .94);
  --panel-solid: #f6f8fa;
  --surface: rgba(255, 255, 255, .66);
  --surface-strong: #ffffff;
  --line: #caff2f;
  --turquoise: #00c2b8;
  --pink: #ff4f9a;
  --danger: #ff2f7d;
  --danger-dark: #8d123f;
  --warning: #f0b429;
  --border: rgba(17, 20, 23, .12);
  --shadow: 0 18px 48px rgba(0, 0, 0, .16);
  --tool-size: 48px;
  --safe-top: max(24px, env(safe-area-inset-top, 0px));
  --safe-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(202, 255, 47, .12), transparent 28rem),
    linear-gradient(135deg, #111417 0%, #2a2f35 48%, #0f1114 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.phone-shell {
  width: min(410px, 100vw);
  height: min(884px, 100svh);
  overflow: hidden;
  border-radius: 28px;
  background: #0d1117;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background: #d8dde2;
}

.app[data-theme="night"] {
  --ink: #f7fafc;
  --muted: #a2acb7;
  --panel: rgba(16, 22, 29, .94);
  --panel-solid: #121820;
  --surface: rgba(24, 33, 43, .7);
  --surface-strong: #18212b;
  --border: rgba(255, 255, 255, .12);
}

.app::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(17, 20, 23, .2), rgba(17, 20, 23, 0));
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.map {
  position: absolute;
  inset: 0;
  background: #d8dde2;
}

.map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, .18), transparent 28%, transparent 66%, rgba(17, 20, 23, .09)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .1) 1px, transparent 1px, transparent 88px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .1) 1px, transparent 1px, transparent 88px);
}

.app[data-theme="night"] .map {
  filter: none;
}

.app[data-theme="night"] .map::after {
  background:
    linear-gradient(180deg, rgba(5, 8, 12, .08), rgba(5, 8, 12, .03) 42%, rgba(5, 8, 12, .12)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .035) 1px, transparent 1px, transparent 88px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .03) 1px, transparent 1px, transparent 88px);
}

.topbar {
  position: absolute;
  z-index: 4;
  top: calc(var(--safe-top) + 8px);
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  pointer-events: none;
}

.tour-chip,
.live-chip,
.profile-chip,
.icon-button,
.location-banner,
.network-banner,
.bottom-sheet,
.auth-card,
.admin-card,
.profile-card,
.photo-crop-card,
.tour-detail-card,
.settings-card,
.emergency-card,
.emergency-position,
.red-alert-card,
.flyin,
.toast {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.tour-chip {
  min-width: 0;
  height: var(--tool-size);
  border-radius: 10px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  color: var(--ink);
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
}

.bottom-sheet span,
.bottom-sheet small,
.panel-header span,
.admin-form label {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.1;
}

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

.tour-chip strong {
  display: block;
  font-size: 15px;
  line-height: 1.1;
}

.live-chip {
  height: var(--tool-size);
  border-radius: 10px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: start;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.live-chip strong {
  font-size: 15px;
}

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--turquoise);
  box-shadow: 0 0 0 4px rgba(0, 194, 184, .14);
}

.app[data-network="offline"] .live-dot,
.app[data-network="reconnecting"] .live-dot {
  background: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 79, 154, .14);
}

.profile-chip {
  width: var(--tool-size);
  height: var(--tool-size);
  border-radius: 10px;
  display: grid;
  place-items: center;
  align-self: start;
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
}

.profile-chip svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.map-actions {
  position: absolute;
  z-index: 5;
  right: 14px;
  top: calc(var(--safe-top) + var(--tool-size) + 16px);
  display: grid;
  gap: 8px;
}

.icon-button[hidden] {
  display: none;
}

.auth-panel {
  position: absolute;
  z-index: 20;
  inset: 0;
  padding: calc(var(--safe-top) + 20px) 18px calc(var(--safe-bottom) + 18px);
  display: grid;
  align-items: end;
  background: linear-gradient(180deg, rgba(17, 20, 23, .28), rgba(17, 20, 23, .72));
}

.auth-panel[hidden] {
  display: none;
}

.auth-card {
  border-radius: 16px;
  padding: 16px;
  color: var(--ink);
}

.auth-card header {
  display: grid;
  gap: 3px;
}

.auth-card header span,
.auth-card header small,
.auth-form label,
.auth-form small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.auth-card header strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1.05;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0;
  padding: 4px;
  border-radius: 10px;
  background: rgba(17, 20, 23, .08);
}

.app[data-theme="night"] .auth-tabs {
  background: rgba(255, 255, 255, .07);
}

.auth-tabs button {
  height: 40px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.auth-tabs button.is-active {
  color: #111417;
  background: var(--line);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form label {
  display: grid;
  gap: 5px;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
}

.auth-form button,
.logout-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #111417;
  background: var(--line);
  font-weight: 900;
  cursor: pointer;
}

.logout-button {
  width: 100%;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.location-banner,
.network-banner {
  position: absolute;
  z-index: 7;
  top: calc(var(--safe-top) + 84px);
  left: 14px;
  right: 72px;
  min-height: 58px;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: var(--ink);
}

.network-banner {
  grid-template-columns: 28px minmax(0, 1fr);
}

.app[data-network="offline"] .location-banner,
.app[data-network="reconnecting"] .location-banner {
  top: calc(var(--safe-top) + 154px);
}

.location-banner[hidden],
.network-banner[hidden] {
  display: none;
}

.location-banner svg,
.network-banner svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.location-banner strong,
.location-banner span,
.network-banner strong,
.network-banner span {
  display: block;
}

.location-banner strong,
.network-banner strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
}

.location-banner span,
.network-banner span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.location-banner button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  color: #111417;
  background: var(--line);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.location-banner button:disabled {
  opacity: .62;
  cursor: wait;
}

.location-banner[data-mode="denied"] {
  border-color: rgba(255, 47, 125, .28);
}

.location-banner[data-mode="denied"] svg {
  color: var(--pink);
}

.location-banner[data-mode="prompt"] svg,
.location-banner[data-mode="checking"] svg {
  color: var(--turquoise);
}

.location-banner[data-mode="warning"] svg {
  color: var(--warning);
}

.network-banner svg {
  color: var(--pink);
}

.network-banner[data-mode="reconnecting"] svg {
  color: var(--warning);
}

.tool-popover {
  display: grid;
  gap: 8px;
}

.tool-popover[hidden] {
  display: none;
}

.icon-button {
  position: relative;
  width: var(--tool-size);
  height: var(--tool-size);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
}

.icon-button svg,
.tabs svg,
.stage-icon svg,
.chat-form button svg,
.admin-form button svg,
.emergency-send svg,
.emergency-help svg,
.close-button svg,
.red-alert svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon-button.orientation span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #111417;
  background: var(--line);
  font-size: 10px;
  font-weight: 950;
}

.icon-button.chat {
  color: var(--pink);
}

.icon-button.settings {
  color: var(--ink);
}

.icon-button.admin {
  color: var(--turquoise);
}

.icon-button.danger {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
}

.badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 22px;
  height: 22px;
  border: 3px solid var(--surface-strong);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff !important;
  background: var(--pink);
  font-size: 12px !important;
  font-weight: 950;
}

.bottom-sheet {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 45%;
  border-radius: 16px 16px 0 0;
  padding: 8px 14px calc(14px + var(--safe-bottom));
  overflow: auto;
  scrollbar-width: none;
  transition: transform .24s ease;
}

.bottom-sheet::-webkit-scrollbar {
  display: none;
}

.app[data-panel="collapsed"] .bottom-sheet {
  transform: translateY(calc(100% - 104px - var(--safe-bottom)));
}

.sheet-toggle {
  width: 100%;
  height: 24px;
  border: 0;
  display: grid;
  place-items: center;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.sheet-toggle span {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #b7c0c9;
}

.focus-row,
.stage-card,
.metric-grid div,
.driver-row,
.chat-list article,
.settings-section,
.admin-form {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.focus-row {
  min-height: 72px;
  padding: 10px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #111417;
  background: var(--turquoise);
  font-weight: 950;
  background-position: center;
  background-size: cover;
}

.avatar.has-photo {
  color: transparent;
  background-color: var(--surface-strong);
}

.focus-row strong,
.stage-card strong,
.metric-grid strong,
.driver-row strong,
.panel-header strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  line-height: 1.15;
}

.focus-row small,
.stage-card small,
.driver-row small {
  display: block;
  margin-top: 2px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
  padding: 4px;
  border-radius: 10px;
  background: rgba(17, 20, 23, .08);
}

.app[data-theme="night"] .tabs {
  background: rgba(255, 255, 255, .07);
}

.tabs button {
  height: 40px;
  border: 0;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.tabs svg {
  width: 18px;
  height: 18px;
}

.tabs button span {
  color: inherit;
  font-size: inherit;
}

.tabs .tab-count {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #111417;
  background: rgba(0, 194, 184, .26);
  font-size: 11px;
  line-height: 1;
  font-weight: 950;
}

.tabs button.is-active {
  color: #111417;
  background: var(--line);
}

.tabs button.is-active .tab-count {
  background: rgba(17, 20, 23, .14);
}

.panel {
  display: none;
}

.panel.is-visible {
  display: block;
}

.stage-card {
  min-height: 76px;
  padding: 11px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.stage-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #111417;
  background: var(--line);
}

.stage-selector {
  margin-top: 10px;
}

.stage-list {
  display: grid;
  gap: 8px;
}

.stage-button {
  min-height: 54px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
  cursor: pointer;
}

.stage-button strong,
.stage-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stage-button em {
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(17, 20, 23, .07);
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.stage-button.is-active {
  border-color: rgba(0, 194, 184, .35);
  background: rgba(0, 194, 184, .1);
}

.stage-button.is-active em {
  color: #111417;
  background: var(--turquoise);
}

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

.admin-form .stage-actions button {
  min-height: 32px;
  border: 1px solid var(--border);
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface);
  font-size: 11px;
}

.admin-form .stage-button.is-active [data-stage-action="select"] {
  border-color: transparent;
  color: #111417;
  background: var(--turquoise);
}

.admin-form .stage-actions [data-stage-action="delete"] {
  color: var(--pink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.metric-grid div {
  min-height: 62px;
  padding: 10px;
}

.driver-list,
.chat-list {
  display: grid;
  gap: 8px;
}

.driver-row {
  min-height: 58px;
  width: 100%;
  border: 1px solid var(--border);
  padding: 10px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.driver-row.is-followed {
  border-color: rgba(255, 79, 154, .45);
  background: color-mix(in srgb, var(--pink), var(--surface) 86%);
}

.driver-color {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--driver-color);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--driver-color), transparent 78%);
}

.driver-speed {
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
}

.follow-state {
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(17, 20, 23, .07);
  font-size: 11px;
  font-weight: 950;
}

.driver-row.is-followed .follow-state {
  color: #fff;
  background: var(--pink);
}

.chat-list article {
  padding: 10px;
  overflow: hidden;
}

.chat-list article strong,
.chat-list article span {
  display: block;
}

.chat-list article span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.chat-list article.own {
  border-color: rgba(0, 194, 184, .22);
  background: rgba(0, 194, 184, .1);
}

.chat-list article.alert {
  border-color: rgba(255, 47, 125, .34);
  background: linear-gradient(135deg, rgba(255, 47, 125, .12), rgba(141, 18, 63, .1));
}

.chat-list article.alert strong {
  color: var(--danger);
}

.chat-list article small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.chat-form,
.date-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.date-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 0;
}

.chat-form input,
.admin-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
}

.chat-form button,
.admin-form button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #111417;
  background: var(--line);
  font-weight: 900;
  cursor: pointer;
}

.chat-form button {
  width: 44px;
  padding: 0;
}

.admin-panel {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  align-items: end;
}

.emergency-panel {
  position: absolute;
  z-index: 13;
  inset: 0;
  display: grid;
  align-items: end;
}

.tour-detail-panel {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  align-items: end;
}

.profile-panel {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  align-items: end;
}

.photo-crop-panel {
  position: absolute;
  z-index: 14;
  inset: 0;
  display: grid;
  align-items: end;
}

.settings-panel {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  align-items: end;
}

.admin-panel[hidden],
.emergency-panel[hidden],
.tour-detail-panel[hidden],
.profile-panel[hidden],
.photo-crop-panel[hidden],
.settings-panel[hidden],
.red-alert[hidden] {
  display: none;
}

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .34);
}

.admin-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.emergency-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.emergency-position {
  margin-top: 12px;
  min-height: 66px;
  border-color: rgba(255, 47, 125, .18);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: #fff;
  background: linear-gradient(135deg, rgba(55, 14, 34, .98), rgba(112, 17, 61, .96));
}

.emergency-position svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.emergency-position span,
.emergency-position strong {
  display: block;
}

.emergency-position span {
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  font-weight: 800;
}

.emergency-position strong {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.15;
}

.emergency-reasons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.emergency-reasons button,
.emergency-send,
.emergency-help {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-strong);
  font-size: 15px;
  font-weight: 950;
  cursor: pointer;
}

.emergency-reasons button.is-active {
  color: #fff;
  border-color: transparent;
  background: var(--danger);
}

.emergency-send,
.emergency-help {
  width: 100%;
  margin-top: 12px;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.emergency-send {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
}

.emergency-send:disabled {
  opacity: .68;
  cursor: wait;
}

.emergency-help {
  min-height: 48px;
  color: var(--danger-dark);
  background: rgba(255, 79, 154, .14);
}

.tour-detail-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.profile-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.photo-crop-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.settings-card {
  position: relative;
  max-height: calc(100% - var(--safe-top) - 24px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  color: var(--ink);
  scrollbar-width: none;
}

.admin-card::-webkit-scrollbar {
  display: none;
}

.tour-detail-card::-webkit-scrollbar {
  display: none;
}

.profile-card::-webkit-scrollbar {
  display: none;
}

.photo-crop-card::-webkit-scrollbar {
  display: none;
}

.settings-card::-webkit-scrollbar {
  display: none;
}

.photo-crop-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #101820;
}

.photo-crop-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 33%, rgba(255, 255, 255, .28) 33%, rgba(255, 255, 255, .28) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255, 255, 255, .28) 66%, rgba(255, 255, 255, .28) calc(66% + 1px), transparent calc(66% + 1px)),
    linear-gradient(0deg, transparent 33%, rgba(255, 255, 255, .28) 33%, rgba(255, 255, 255, .28) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255, 255, 255, .28) 66%, rgba(255, 255, 255, .28) calc(66% + 1px), transparent calc(66% + 1px));
}

.app[data-theme="night"] .photo-crop-stage::after {
  background:
    linear-gradient(90deg, transparent 33%, rgba(255, 255, 255, .18) 33%, rgba(255, 255, 255, .18) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255, 255, 255, .18) 66%, rgba(255, 255, 255, .18) calc(66% + 1px), transparent calc(66% + 1px)),
    linear-gradient(0deg, transparent 33%, rgba(255, 255, 255, .18) 33%, rgba(255, 255, 255, .18) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255, 255, 255, .18) 66%, rgba(255, 255, 255, .18) calc(66% + 1px), transparent calc(66% + 1px));
}

.photo-crop-canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  touch-action: none;
  cursor: grab;
}

.photo-crop-canvas:active {
  cursor: grabbing;
}

.photo-zoom {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.photo-zoom input {
  width: 100%;
  accent-color: var(--turquoise);
}

.photo-crop-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
  margin-top: 12px;
}

.photo-crop-actions button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #111417;
  background: var(--line);
  font-weight: 900;
  cursor: pointer;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: inherit;
  background: rgba(17, 20, 23, .08);
  cursor: pointer;
}

.app[data-theme="night"] .close-button {
  background: rgba(255, 255, 255, .08);
}

.admin-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.tour-detail-hero,
.tour-detail-metrics,
.tour-detail-grid div {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.tour-detail-hero {
  min-height: 70px;
  padding: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.tour-detail-hero span,
.tour-detail-metrics span,
.tour-detail-grid span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.tour-detail-hero strong,
.tour-detail-metrics strong,
.tour-detail-grid strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.tour-detail-hero button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #111417;
  background: var(--line);
  font-weight: 900;
  cursor: pointer;
}

.tour-detail-hero button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.tour-detail-metrics {
  margin-top: 10px;
  padding: 11px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tour-detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tour-detail-grid div {
  min-height: 58px;
  padding: 10px;
}

.profile-form,
.profile-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: var(--surface);
}

.profile-form label,
.profile-section span,
.profile-form span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
}

.profile-section strong,
.profile-form strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  line-height: 1.15;
}

.profile-form label {
  display: grid;
  gap: 5px;
}

.profile-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
}

.profile-form button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #111417;
  background: var(--line);
  font-weight: 900;
  cursor: pointer;
}

.profile-photo-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: var(--surface-strong);
}

.profile-photo-preview {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #111417;
  background: var(--turquoise);
  background-position: center;
  background-size: cover;
  font-weight: 950;
}

.profile-photo-preview.has-photo {
  color: transparent;
  background-color: var(--surface);
}

.profile-photo-copy {
  min-width: 0;
}

.profile-photo-copy small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.profile-photo-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 9px;
}

.profile-photo-actions button {
  min-height: 36px;
  padding: 0 10px;
}

.profile-form .secondary,
.photo-crop-actions .secondary {
  border: 1px solid var(--border);
  color: var(--ink);
  background: var(--surface);
}

.profile-form button:disabled,
.photo-crop-actions button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.profile-account {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.profile-account .logout-button {
  width: auto;
  min-width: 108px;
}

.profile-tour-list {
  display: grid;
  gap: 8px;
}

.profile-tour-button {
  min-height: 62px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
  cursor: pointer;
}

.profile-tour-button strong,
.profile-tour-button small {
  display: block;
}

.profile-tour-button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tour-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.profile-tour-button span {
  border-radius: 999px;
  padding: 5px 8px;
  color: #111417;
  background: var(--line);
  font-size: 11px;
  font-weight: 950;
}

.profile-tour-button.is-active {
  border-color: rgba(0, 194, 184, .35);
  background: rgba(0, 194, 184, .1);
}

.profile-empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 13px;
}

.admin-tour-picker {
  gap: 10px;
}

.admin-stage-picker {
  gap: 10px;
}

.admin-tour-picker small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.admin-tour-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  overflow: auto;
  scrollbar-width: none;
}

.admin-tour-list::-webkit-scrollbar {
  display: none;
}

.admin-form .admin-tour-button {
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  background: var(--surface-strong);
  text-align: left;
}

.admin-tour-button strong,
.admin-tour-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-tour-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-tour-button em {
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(17, 20, 23, .07);
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.admin-tour-button.is-active {
  border-color: rgba(0, 194, 184, .35);
  background: rgba(0, 194, 184, .1);
}

.admin-tour-button.is-active em {
  color: #111417;
  background: var(--turquoise);
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.settings-section span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.settings-section strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  line-height: 1.15;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.color-choice {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  background: var(--surface-strong);
  font-weight: 850;
  cursor: pointer;
}

.color-choice[data-track-color="lime"] {
  --track-swatch: #caff2f;
}

.color-choice[data-track-color="red"] {
  --track-swatch: #ff3b4f;
}

.color-choice[data-track-color="blue"] {
  --track-swatch: #2f80ff;
}

.color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--track-swatch);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--track-swatch), transparent 80%);
}

.color-choice span:last-child {
  color: inherit;
  font-size: 13px;
}

.color-choice.is-active {
  border-color: color-mix(in srgb, var(--track-swatch), var(--border) 36%);
  color: var(--ink);
  background: color-mix(in srgb, var(--track-swatch), var(--surface-strong) 84%);
}

.admin-form label {
  display: grid;
  gap: 5px;
  font-weight: 800;
}

.red-alert {
  position: absolute;
  z-index: 18;
  inset: 0;
  display: grid;
  align-items: end;
}

.red-alert-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(74, 15, 42, .42);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  backdrop-filter: blur(8px) saturate(120%);
}

.red-alert-card {
  position: relative;
  margin: 0 0 calc(var(--safe-bottom) + 8px);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px 18px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  color: var(--ink);
}

.red-alert-card .close-button {
  position: absolute;
  top: 16px;
  right: 16px;
}

.red-alert-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
}

.red-alert-icon svg {
  width: 28px;
  height: 28px;
}

.red-alert-card strong,
.red-alert-card span {
  display: block;
}

.red-alert-card span {
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
}

.red-alert-card strong {
  max-width: calc(100% - 58px);
  margin-top: 2px;
  font-size: 25px;
  line-height: 1.05;
}

.red-alert-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.red-alert-card button:not(.close-button) {
  min-height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--danger-dark);
  font-weight: 950;
  cursor: pointer;
}

.flyins {
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + 78px);
  left: 14px;
  right: 72px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.flyin {
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  pointer-events: auto;
  animation: flyin-in .22s ease-out;
}

.flyin strong,
.flyin span {
  display: block;
}

.flyin strong {
  font-size: 12px;
  line-height: 1.2;
}

.flyin span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.flyin.alert {
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 47, 125, .96), rgba(141, 18, 63, .96));
}

.flyin.alert span {
  color: rgba(255, 255, 255, .82);
}

@keyframes flyin-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: calc(45% + 12px);
  min-width: 190px;
  max-width: calc(100% - 32px);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.app[data-panel="collapsed"] .toast {
  bottom: calc(104px + var(--safe-bottom));
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.vehicle-marker {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(17, 20, 23, .22);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
  cursor: pointer;
}

.vehicle-marker.is-followed {
  background: color-mix(in srgb, var(--pink), transparent 54%);
  box-shadow:
    0 0 0 7px rgba(255, 79, 154, .22),
    0 14px 30px rgba(0, 0, 0, .32);
}

.vehicle-marker span {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--driver-color, var(--turquoise));
}

.vehicle-marker.is-you span {
  background: var(--turquoise);
}

.vehicle-marker.is-followed span {
  border-color: #fff;
  background: var(--pink);
}

.waypoint-marker {
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #111417;
  background: var(--surface-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
}

.waypoint-marker.is-fuel {
  background: var(--turquoise);
}

.waypoint-marker.has-brand {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 12px;
  padding: 0;
  color: #111417;
  background: #fff;
}

.waypoint-marker.has-brand.has-high-octane {
  min-width: 42px;
}

.waypoint-brand-card,
.waypoint-brand,
.waypoint-logo,
.waypoint-plus {
  pointer-events: none;
}

.waypoint-brand-card {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.waypoint-brand {
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
}

.waypoint-plus {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 17px;
  height: 17px;
  border: 2px solid #111417;
  border-radius: 999px;
  color: #111417;
  background: transparent;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .24);
  font-size: 0;
}

.waypoint-plus::before,
.waypoint-plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.waypoint-plus::after {
  width: 2px;
  height: 8px;
}

.waypoint-logo {
  width: 29px;
  height: 29px;
  display: block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.waypoint-logo-q8 {
  width: 31px;
  height: 18px;
  background-image: url("assets/brands/q8-logo-marker.png");
}

.waypoint-logo-eni {
  background-image: url("assets/brands/eni-logo-marker.png");
}

.waypoint-marker.brand-q8 {
  color: #111417;
  background: #fff;
}

.waypoint-marker.brand-eni,
.waypoint-marker.brand-agip {
  color: #111417;
  background: #fff;
}

.waypoint-marker.brand-shell {
  color: #111417;
  background: #ffd000;
}

.waypoint-marker.brand-aral,
.waypoint-marker.brand-esso,
.waypoint-marker.brand-omv {
  color: #fff;
  background: #1f68c7;
}

.waypoint-marker.is-food,
.waypoint-marker.is-stop {
  background: var(--pink);
  color: #fff;
}

.waypoint-marker.is-hotel {
  background: #2f80ff;
  color: #fff;
}

.waypoint-marker.is-parking {
  background: #687078;
  color: #fff;
}

.driver-popup .maplibregl-popup-content {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: #111417;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .16);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font: 13px Inter, ui-sans-serif, system-ui, sans-serif;
}

.driver-popup em {
  display: inline-block;
  margin-top: 4px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  background: var(--pink);
  font-style: normal;
  font-weight: 850;
}

.maplibregl-popup-content strong,
.maplibregl-popup-content span,
.maplibregl-popup-content small {
  display: block;
}

.maplibregl-popup-content span {
  margin-top: 3px;
  color: #687078;
  font-size: 12px;
  font-weight: 800;
}

.maplibregl-popup-content small {
  max-width: 220px;
  margin-top: 5px;
  color: #687078;
  line-height: 1.25;
}

.driver-popup .maplibregl-popup-tip {
  display: none;
}

.maplibregl-ctrl-bottom-left {
  bottom: calc(45% + 10px);
  left: 10px;
}

.app[data-panel="collapsed"] .maplibregl-ctrl-bottom-left {
  bottom: calc(112px + var(--safe-bottom));
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
}

@media (max-width: 520px) {
  body {
    display: block;
    background: #111417;
  }

  .phone-shell {
    width: 100vw;
    height: 100svh;
    border-radius: 0;
  }
}
