*,
*::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(var(--sheet-h, 58dvh) + 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, bottom 0.25s ease;
}

.main--map:has(.home-sheet[data-state='collapsed']) {
  --sheet-h: 92px;
}

.main--map:has(.home-sheet[data-state='half']) {
  --sheet-h: 58dvh;
}

.main--map:has(.home-sheet[data-state='full']) {
  --sheet-h: calc(100dvh - 76px);
}

.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 {
  --sheet-h: 58dvh;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--sheet-h);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 0;
  overflow: hidden;
  transition: height 0.25s ease;
}

.home-sheet[data-state='collapsed'] {
  --sheet-h: 92px;
}

.home-sheet[data-state='half'] {
  --sheet-h: 58dvh;
}

.home-sheet[data-state='full'] {
  --sheet-h: calc(100dvh - 76px);
}

.home-sheet[data-state='collapsed'] .drivers-list,
.home-sheet[data-state='collapsed'] .kela-footer {
  display: none;
}

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

.home-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 8px;
  flex-shrink: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.home-sheet__header:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

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

.home-sheet__updated {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  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 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
}

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

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

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

.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: 8px 4px;
  min-height: 0;
}

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

.driver-card__photo {
  width: 68px;
  height: 68px;
  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: 1px;
}

.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.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.service-icon {
  width: 24px;
  height: 24px;
  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: 12px;
  height: 12px;
}

.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: 5px;
  flex-shrink: 0;
  width: 88px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  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;
}

/* Compact Kela footer */
.kela-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  min-height: 72px;
  max-height: calc(84px + var(--safe-bottom));
  box-sizing: border-box;
  background: var(--bg-kela);
  border-top: 1px solid rgba(0, 83, 160, 0.12);
  flex-shrink: 0;
}

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

.kela-footer__text {
  min-width: 0;
  flex: 1 1 auto;
}

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

.kela-footer__sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kela-footer__open {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--kela-blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.kela-footer__open:hover,
.kela-footer__open:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.kela-footer__open:active {
  transform: scale(0.98);
}

/* Legacy strip rows (unused in compact footer; kept for safety) */
.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 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-social {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 16px;
}

.profile-social__btn {
  width: auto;
  min-width: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}

.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;
  }
}

/* Official Kela taxi ordering panel */
.kela-footer__icon svg {
  width: 18px;
  height: 18px;
}

.kela-official-notice {
  display: grid;
  gap: 3px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 83, 160, 0.2);
  border-radius: var(--radius-md);
  background: var(--bg-kela);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.kela-official-notice strong {
  color: var(--text);
}

.kela-region-picker {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
}

.kela-region-picker > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.kela-region-picker select {
  width: 100%;
  min-height: 46px;
  padding: 0 42px 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.kela-region-picker select:focus-visible {
  outline: 3px solid rgba(0, 83, 160, 0.18);
  border-color: var(--kela-blue);
}

.kela-region-empty {
  padding: 20px 16px;
  border: 1px dashed rgba(0, 83, 160, 0.28);
  border-radius: var(--radius-md);
  text-align: center;
  background: rgba(232, 238, 246, 0.55);
}

.kela-region-empty p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.kela-region-empty p + p {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

.kela-region-result h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.kela-region-result__hint {
  margin: 3px 0 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.kela-contact-list {
  display: grid;
  gap: 10px;
}

.kela-contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: 0 3px 14px rgba(15, 23, 42, 0.05);
}

.kela-contact-card__main {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 3px;
}

.kela-contact-card__name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.kela-contact-card__phone {
  width: fit-content;
  font-size: 15px;
  font-weight: 800;
  color: var(--kela-blue);
}

.kela-contact-card__phone--sv {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.kela-contact-card__call {
  min-width: 86px;
  flex-shrink: 0;
  background: var(--kela-blue);
}

.kela-contact-card__call svg {
  width: 15px;
  height: 15px;
}

.kela-source-note {
  margin: 18px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
}

.kela-source-note a {
  color: var(--kela-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.kela-region-loading {
  margin: 20px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
