:root {
  --color-accent: #6f4ad8;
  --color-accent-dark: #5432bb;
  --color-accent-soft: #f0ebff;
  --color-background: #f5f5f7;
  --color-surface: #ffffff;
  --color-border: #dedee5;
  --color-text: #27242f;
  --color-muted: #716d7a;
  --color-danger: #b9374c;
  --color-warning: #9a6308;
  --color-warning-soft: #fff4d8;
  --color-success: #25835b;
  --shadow-float: 0 4px 16px rgb(25 20 45 / 12%);
  --interval-0: #6f4ad8;
  --interval-1: #1976b8;
  --interval-2: #16836c;
  --interval-3: #b16813;
  --interval-4: #b34871;
  --interval-5: #5368be;
  --interval-none: #777682;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--color-text);
  background: var(--color-background);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body,
button,
input {
  font: inherit;
}

button,
input {
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.delivery-card:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(111 74 216 / 30%);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.button,
.icon-button,
.filter-toggle,
.interval-filter,
.site-button {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
  min-height: 34px;
}

.button {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

.button:hover,
.icon-button:hover,
.site-button:hover,
.filter-toggle:hover,
.interval-filter:hover {
  border-color: #bbb8c5;
  background: #faf9fc;
}

.button-primary {
  color: #fff;
  border-color: var(--color-accent);
  background: var(--color-accent);
}

.button-primary:hover {
  border-color: var(--color-accent-dark);
  background: var(--color-accent-dark);
}

.button-danger {
  color: #fff;
  border-color: var(--color-danger);
  background: var(--color-danger);
}

.button:disabled,
.icon-button:disabled,
.filter-toggle:disabled,
.interval-filter:disabled,
.site-button:disabled,
.delivery-card:disabled,
input:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button-quiet {
  border-color: transparent;
  background: transparent;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.login-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgb(111 74 216 / 5%), transparent 40%),
    var(--color-background);
}

.login-card {
  display: grid;
  width: min(100%, 360px);
  padding: 34px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  box-shadow: 0 12px 35px rgb(35 28 56 / 8%);
}

.brand-mark,
.topbar-logo {
  display: grid;
  color: #fff;
  background: var(--color-accent);
  place-items: center;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 12px;
  font-size: 21px;
}

.brand-name {
  margin: 0 0 6px;
  letter-spacing: 0.12em;
  font-size: 13px;
  font-weight: 800;
}

.login-card h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
}

.login-subtitle {
  margin: 7px 0 28px;
  color: var(--color-muted);
  font-size: 14px;
}

.login-card label {
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 650;
}

.login-card input,
.search-field input,
#delivery-date {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface);
}

.login-card input {
  height: 42px;
  margin: 0 0 18px;
  padding: 0 12px;
}

.login-card input:focus,
.search-field input:focus,
#delivery-date:focus {
  border-color: var(--color-accent);
}

.login-submit {
  height: 42px;
  margin-top: 5px;
}

.form-error {
  margin: -5px 0 10px;
  color: var(--color-danger);
  font-size: 13px;
}

.application {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.topbar {
  z-index: 1001;
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.topbar-brand {
  display: flex;
  min-width: 130px;
  align-items: center;
  gap: 9px;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 800;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.site-switcher {
  display: flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--color-background);
}

.site-button {
  min-height: 30px;
  padding: 4px 10px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.site-button[aria-pressed="true"] {
  border-color: var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgb(25 20 45 / 8%);
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

#delivery-date {
  width: 136px;
  height: 34px;
  padding: 0 7px;
  font-size: 13px;
}

.topbar-spacer {
  min-width: 4px;
  flex: 1;
}

.freshness {
  display: flex;
  max-width: 240px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-muted);
}

.freshness.is-ok .freshness-dot {
  background: var(--color-success);
}

.freshness.is-warning .freshness-dot {
  background: #db941f;
}

.freshness.is-error .freshness-dot {
  background: var(--color-danger);
}

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

.freshness strong {
  font-size: 12px;
}

.freshness span {
  margin-top: 1px;
  color: var(--color-muted);
  font-size: 11px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
}

.workspace {
  display: flex;
  min-height: 0;
  flex: 1;
}

.sidebar {
  z-index: 500;
  display: flex;
  width: 390px;
  min-width: 360px;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}

.sidebar-tools {
  display: grid;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-heading h1 {
  margin: 0;
  font-size: 18px;
}

.sidebar-heading p {
  margin: 2px 0 0;
  color: var(--color-muted);
  font-size: 12px;
}

.search-field input {
  height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.filter-toggle {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  text-align: left;
  font-size: 13px;
}

.filter-toggle[aria-pressed="true"] {
  color: #734800;
  border-color: #e8bd68;
  background: var(--color-warning-soft);
}

.filter-count {
  margin-left: auto;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.filter-label {
  margin: 0 0 7px;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.interval-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.interval-filter {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

.interval-filter[aria-pressed="true"] {
  color: var(--color-accent-dark);
  border-color: #b6a3ef;
  background: var(--color-accent-soft);
}

.interval-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--interval-color, var(--interval-none));
}

.inline-warning {
  margin: 0;
  padding: 9px 16px;
  color: #734800;
  border-bottom: 1px solid #efd28f;
  background: var(--color-warning-soft);
  font-size: 12px;
}

.coordinate-actions {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  background: #faf9fc;
}

.coordinate-actions-heading,
.coordinate-action-buttons,
.coordinate-reset-confirmation {
  display: flex;
  align-items: center;
  gap: 7px;
}

.coordinate-actions-heading {
  justify-content: space-between;
  font-size: 12px;
}

.coordinate-actions-heading span,
.coordinate-unavailable,
.coordinate-actions-message {
  color: var(--color-muted);
  font-size: 11px;
}

.coordinate-action-buttons {
  margin-top: 9px;
}

.coordinate-actions-message,
.coordinate-unavailable {
  margin: 7px 0 0;
}

.coordinate-actions-message.is-error {
  color: var(--color-danger);
}

.coordinate-reset-confirmation {
  margin-top: 9px;
  color: var(--color-danger);
  font-size: 12px;
}

.coordinate-reset-confirmation span {
  margin-right: auto;
}

.delivery-list {
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.delivery-card {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 11px 12px 10px 14px;
  border: 1px solid transparent;
  border-left: 4px solid var(--interval-color, var(--interval-none));
  border-radius: 8px;
  background: var(--color-surface);
  text-align: left;
}

.delivery-card:hover {
  background: #faf9fc;
}

.delivery-card.is-selected {
  border-color: #c7b8ef;
  border-left-color: var(--interval-color, var(--interval-none));
  background: #f7f4ff;
  box-shadow: 0 0 0 1px rgb(111 74 216 / 8%);
}

.delivery-card-heading,
.delivery-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.delivery-time {
  font-size: 13px;
  font-weight: 750;
}

.delivery-number {
  color: var(--color-accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.delivery-address {
  display: -webkit-box;
  margin: 7px 0 8px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.delivery-card-meta {
  color: var(--color-muted);
  font-size: 11px;
}

.problem-note {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 8px;
  color: var(--color-warning);
  font-size: 11px;
  font-weight: 650;
}

.source-note {
  margin-top: 6px;
  color: var(--color-muted);
  font-size: 11px;
}

.list-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  color: var(--color-muted);
  text-align: center;
  font-size: 13px;
}

.skeleton-card {
  height: 100px;
  margin: 0 0 7px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f2f1f5 25%, #faf9fb 50%, #f2f1f5 75%);
  background-size: 200% 100%;
  animation: skeleton 1.3s infinite linear;
}

@keyframes skeleton {
  to {
    background-position: -200% 0;
  }
}

.map-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  background: #e9e8ec;
}

.map {
  width: 100%;
  height: 100%;
}

.map-action {
  position: absolute;
  z-index: 800;
  top: 12px;
  right: 12px;
  box-shadow: var(--shadow-float);
}

.coordinate-edit-panel {
  position: absolute;
  z-index: 900;
  top: 12px;
  left: 12px;
  width: min(330px, calc(100% - 90px));
  padding: 13px 14px;
  border: 1px solid #b6a3ef;
  border-radius: 9px;
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}

.coordinate-edit-panel strong,
.coordinate-edit-panel > span {
  display: block;
}

.coordinate-edit-panel > span {
  margin-top: 2px;
  color: var(--color-accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.coordinate-edit-panel p {
  margin: 8px 0 10px;
  color: var(--color-muted);
  font-size: 12px;
}

.coordinate-edit-panel > div {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.coordinate-edit-panel .coordinate-edit-error {
  color: var(--color-danger);
}

.map-message {
  position: absolute;
  z-index: 900;
  top: 58px;
  right: 12px;
  max-width: 280px;
  padding: 9px 12px;
  border: 1px solid #e5c47e;
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: var(--shadow-float);
  color: #734800;
  font-size: 12px;
}

.delivery-marker-wrap {
  background: none;
  border: 0;
}

.delivery-marker {
  position: relative;
  display: grid;
  min-width: 42px;
  height: 25px;
  padding: 0 6px;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 13px;
  background: var(--interval-color, var(--interval-none));
  box-shadow: 0 2px 6px rgb(30 25 42 / 30%);
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.delivery-marker.is-problem::after {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  width: 13px;
  height: 13px;
  content: "!";
  color: #fff;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--color-warning);
  place-items: center;
  font-size: 9px;
}

.delivery-marker.is-selected {
  border-color: #1e172e;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 85%), 0 4px 10px rgb(30 25 42 / 45%);
  transform: scale(1.12);
}

.coordinate-provisional-wrap {
  background: none;
  border: 0;
}

.coordinate-provisional {
  position: relative;
  display: block;
  width: 30px;
  height: 30px;
  border: 4px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--color-accent);
  box-shadow: 0 3px 10px rgb(30 25 42 / 42%);
  transform: rotate(-45deg);
}

.coordinate-provisional::after {
  position: absolute;
  inset: 7px;
  content: "";
  border-radius: 50%;
  background: #fff;
}

.delivery-popup {
  min-width: 220px;
}

.delivery-popup-number {
  font-size: 14px;
  font-weight: 800;
}

.delivery-popup-time,
.delivery-popup-address,
.delivery-popup-status,
.delivery-popup-warning {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.35;
}

.delivery-popup-address {
  color: var(--color-text);
}

.delivery-popup-status {
  color: var(--color-muted);
}

.delivery-popup-warning {
  color: var(--color-warning);
  font-weight: 650;
}

.delivery-popup-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--color-accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.yandex-logo-link {
  position: absolute;
  z-index: 750;
  right: 8px;
  bottom: 8px;
  display: block;
}

.yandex-logo-link img {
  display: block;
  width: 88px;
  height: auto;
}

.leaflet-control-attribution {
  font-size: 9px;
}

.mobile-view-switch {
  display: none;
}

@media (max-width: 1100px) {
  .topbar {
    gap: 10px;
  }

  .topbar-brand {
    min-width: auto;
  }

  .topbar-brand > span:last-child,
  .freshness-secondary,
  .user-menu > span {
    display: none;
  }

  .sidebar {
    width: 360px;
    min-width: 340px;
  }
}

@media (max-width: 899px) {
  .topbar {
    min-height: auto;
    flex-wrap: wrap;
    padding: 8px;
  }

  .date-controls {
    order: 3;
    width: 100%;
  }

  #delivery-date {
    flex: 1;
  }

  .freshness {
    margin-left: auto;
  }

  .mobile-view-switch {
    display: flex;
    padding: 6px 8px;
    gap: 6px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
  }

  .mobile-view-switch .button {
    flex: 1;
  }

  .mobile-view-switch .is-active {
    color: var(--color-accent-dark);
    border-color: #b6a3ef;
    background: var(--color-accent-soft);
  }

  .workspace {
    position: relative;
  }

  .sidebar,
  .map-pane {
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 0;
    border: 0;
  }

  .application[data-mobile-view="list"] .map-pane,
  .application[data-mobile-view="map"] .sidebar {
    visibility: hidden;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-card {
    animation: none;
  }
}
