*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: #dfe3ea;
  min-height: 100dvh;
  overflow-x: hidden;
}

body.profile-open,
body.panel-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Shell */
.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.main--map {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  padding: 0;
}

/* Header */
.header {
  position: relative;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header__logo {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header__logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--brand-muted);
  color: var(--brand);
  outline: none;
}

/* Map */
.map-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-view {
  width: 100%;
  height: 100%;
  background: #e8edf2;
}

.map-view .leaflet-control-attribution {
  font-size: 9px;
  background: rgba(255, 255, 255, 0.75);
  max-width: 60%;
}

.map-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  margin: 0;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

.map-locate-btn {
  position: absolute;
  right: 14px;
  bottom: calc(min(72dvh, 640px) + 14px);
  z-index: 400;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--border);
  transition: transform 0.15s, background 0.2s;
}

.map-locate-btn svg {
  width: 22px;
  height: 22px;
}

.map-locate-btn:hover,
.map-locate-btn:focus-visible {
  background: var(--bg-card-hover);
  outline: none;
}

.map-locate-btn:active {
  transform: scale(0.96);
}

/* Home bottom sheet */
.home-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: min(72dvh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 0 0 calc(8px + var(--safe-bottom));
  overflow: hidden;
}

.home-sheet__handle {
  width: 40px;
  height: 4px;
  margin: 10px auto 8px;
  border-radius: var(--radius-full);
  background: #cbd5e1;
  flex-shrink: 0;
}

.home-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.home-sheet__header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  max-width: 14em;
}

.home-sheet__updated {
  margin: 2px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.home-sheet__live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--brand-muted);
}

.drivers-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
}

.drivers-loading,
.drivers-error {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.drivers-error code {
  color: var(--brand);
  font-size: 12px;
}

.home-sheet__pull {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.home-sheet__pull svg {
  width: 14px;
  height: 14px;
}

/* Driver row */
.driver-card {
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.driver-card:last-of-type {
  border-bottom: none;
}

.driver-card__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 4px;
}

.driver-card__photo-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.driver-card__photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.driver-card__status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: #94a3b8;
}

.driver-card__status-pill--on {
  background: var(--green);
}

.driver-card__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.driver-card__name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.driver-card__vehicle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-card__company {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}

.driver-card__services {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.service-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1.5px solid transparent;
}

.service-icon svg {
  width: 14px;
  height: 14px;
}

.service-icon--inva {
  color: var(--inva-blue);
  background: rgba(28, 126, 214, 0.1);
  border-color: rgba(28, 126, 214, 0.35);
}

.service-icon--paari {
  color: var(--paari-purple);
  background: rgba(121, 80, 242, 0.1);
  border-color: rgba(121, 80, 242, 0.35);
}

.service-icon--kela {
  color: var(--green);
  background: #fff;
  border-color: rgba(47, 158, 68, 0.45);
  font-size: 11px;
}

.driver-card__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  width: 88px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.15s, opacity 0.2s, background 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn--call {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px var(--green-glow);
}

.btn--call:hover {
  background: var(--brand-dark);
}

.btn-call[aria-disabled='true'] {
  opacity: 0.4;
  pointer-events: none;
}

.btn--more {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

.btn--more:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

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

.btn--gold {
  background: var(--green);
  color: #fff;
}

.btn--gold:hover {
  background: var(--brand-dark);
}

.btn--compact {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  flex-shrink: 0;
}

.btn--block {
  width: 100%;
  margin-top: 8px;
}

/* Kela strip */
.kela-strip {
  margin: 8px 12px 0;
  padding: 14px 14px 10px;
  background: var(--bg-kela);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.kela-strip__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kela-strip__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--kela-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.kela-strip__head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.kela-strip__sub {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
}

.kela-strip__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kela-strip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.kela-strip-row__pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 83, 160, 0.12);
  color: var(--kela-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kela-strip-row__pin svg {
  width: 14px;
  height: 14px;
}

.kela-strip-row__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kela-strip-row__region {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.kela-strip-row__name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kela-strip-row__phone {
  font-size: 12px;
  font-weight: 600;
  color: var(--kela-blue);
}

.kela-strip-row__call {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--kela-blue);
  letter-spacing: 0.03em;
  padding: 6px 4px;
}

.kela-strip-row__call svg {
  width: 14px;
  height: 14px;
}

.kela-strip__all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 12px;
  padding: 8px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--kela-blue);
}

.kela-strip__all svg {
  width: 16px;
  height: 16px;
}

/* KELA driver info (profile) */
.kela-info {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.35;
}

.kela-info--no {
  color: var(--text-dim);
}

.kela-info--yes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.kela-info__tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 53, 128, 0.12);
  border: 1px solid rgba(0, 83, 160, 0.35);
  color: var(--kela-blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.kela-info__car {
  font-weight: 600;
  color: var(--text);
}

.kela-info__dot {
  color: var(--text-dim);
}

.kela-info__central {
  color: var(--text-muted);
}

.kela-info--profile {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--bg-kela);
  border: 1px solid rgba(0, 83, 160, 0.2);
  border-radius: var(--radius-md);
}

.kela-info--profile .kela-info__tag {
  align-self: flex-start;
  font-size: 11px;
}

.kela-info__details {
  margin: 0;
  display: grid;
  gap: 8px;
}

.kela-info__details div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.kela-info__details dt {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.kela-info__details dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* Call centers panel */
.profile-panel__sheet--tall {
  max-height: 92dvh;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  padding-right: 40px;
}

.panel-subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.call-centers-group {
  margin-bottom: 24px;
}

.call-centers-group__title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
}

.call-centers-group__hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.call-centers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-center-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.call-center-row__logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
}

.call-center-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-center-row__name {
  font-size: 14px;
  font-weight: 600;
}

.call-center-row__meta {
  font-size: 11px;
  color: var(--text-dim);
}

.call-center-row__phone {
  font-size: 12px;
  color: var(--kela-blue);
  font-weight: 500;
}

.app-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  max-width: calc(var(--max-w) - 32px);
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.app-toast[hidden] {
  display: none;
}

/* Profile panel */
.profile-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

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

.profile-panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.profile-panel__sheet {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0.5;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.profile-panel__handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: var(--radius-full);
  background: #cbd5e1;
}

.profile-panel__close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.profile-hero {
  position: relative;
  width: fit-content;
  margin: 0 auto 20px;
}

.profile-hero__photo {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--brand);
}

.profile-hero__badge {
  position: absolute;
  bottom: -6px;
  right: -10px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: #000;
}

.profile-hero__badge .badge-img {
  width: 100%;
  height: 100%;
}

.profile-name {
  margin: 0 0 4px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
}

.profile-badge-name {
  margin: 0 0 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

.profile-vehicle {
  margin: 0 0 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.profile-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

.star {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1;
}

.star--full,
.star--half {
  color: #f59f00;
}

.profile-distance {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.profile-bio {
  margin: 0 0 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.profile-meta {
  margin: 0 0 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.badge-img {
  display: block;
  object-fit: cover;
  object-position: top center;
  background: #000;
}

.badge-img--hero {
  width: 100% !important;
  height: 100% !important;
  border-radius: 50%;
}

/* Desktop */
@media (min-width: 520px) {
  body {
    background: #cfd5de;
  }

  .app-shell {
    box-shadow: 0 0 60px rgba(15, 23, 42, 0.18);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 100dvh;
  }
}
