/* Те же цвета, что в мобильном приложении. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-alt: #edeae3;
  --border: #e4e0d8;
  --text: #1e2725;
  --muted: #6e7773;
  --primary: #2e6f68;
  --primary-dark: #22544f;
  --primary-soft: #dcebe8;
  --sos: #e0644d;
  --sos-dark: #c24e39;
  --sos-soft: #fbe4de;
  --warn: #d99a33;
  --warn-soft: #fbf0dc;
  --ok: #3e9b6f;
  --ok-soft: #dff1e7;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(43, 42, 37, 0.07);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.error { color: var(--sos-dark); margin: 0; }

/* Вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 20px;
  padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.brand { display: flex; align-items: center; gap: 12px; color: var(--primary); margin-bottom: 6px; }
.brand.small { gap: 10px; margin: 0; }
.brand-name { font-weight: 700; font-size: 20px; color: var(--text); letter-spacing: -0.3px; }

/* Кнопки и метки */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-weight: 600;
}
.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--sos-soft); border-color: var(--sos-soft); color: var(--sos-dark); }
.btn.sos { background: var(--sos); border-color: var(--sos); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-alt); color: var(--muted); white-space: nowrap;
}
.badge.sos { background: var(--sos-soft); color: var(--sos-dark); }
.badge.warn { background: var(--warn-soft); color: #9a6a17; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.primary { background: var(--primary-soft); color: var(--primary-dark); }

/* Каркас */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn.on i { background: var(--ok); }
.conn.off i { background: var(--sos); }

.layout { flex: 1; min-height: 0; display: flex; }
.sidebar {
  width: 360px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--border);
}
.map-wrap { flex: 1; min-width: 0; position: relative; }
#map { position: absolute; inset: 0; }
.detail {
  width: 380px; flex-shrink: 0; overflow-y: auto; background: var(--surface);
  border-left: 1px solid var(--border); padding: 18px;
}

.tabs { display: flex; gap: 4px; padding: 10px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 6px;
  border-radius: 10px; font-weight: 600; font-size: 13px;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count { color: var(--muted); font-weight: 500; }
.count.alarm { color: #fff; background: var(--sos); border-radius: 999px; padding: 0 7px; }

.list { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin: 14px 4px 8px;
}
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }

.item {
  display: block; width: 100%; text-align: left; border: 2px solid transparent;
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 8px; box-shadow: var(--shadow); color: inherit;
}
.item:hover { border-color: var(--border); }
.item.selected { border-color: var(--primary); }
.item.urgent { border-left: 4px solid var(--sos); }
.item.overdue { background: var(--sos-soft); }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-title { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.late { color: var(--sos-dark); }

/* Карточка справа */
.detail h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.3px; }
.detail h3 {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin: 20px 0 8px;
}
.detail-close { float: right; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.phone { font-size: 17px; font-weight: 600; text-decoration: none; }
.eta-big { font-size: 34px; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; }

.crew-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 6px;
}
.crew-option.best { border-color: var(--primary); background: var(--primary-soft); }
.crew-option .item-sub { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .actor-client { color: var(--sos-dark); }
.timeline .actor-dispatcher { color: var(--primary-dark); }
.timeline .actor-crew { color: #9a6a17; }

.note-form { display: flex; gap: 6px; margin-top: 10px; }

/* Метки на карте */
.pin { border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.pin-call { width: 22px; height: 22px; background: var(--sos); }
.pin-call.searching { animation: pulse 1.4s infinite; }
.pin-escort { width: 18px; height: 18px; background: var(--warn); }
.pin-escort.overdue { background: var(--sos-dark); animation: pulse 1.4s infinite; }
.pin-crew {
  width: 28px; height: 28px; background: var(--primary); display: grid; place-items: center;
  color: #fff; font-size: 10px; font-weight: 700;
}
.pin-crew.busy { background: var(--primary-dark); }
.pin-crew.offline { background: #9aa19e; }
.pin.selected { outline: 3px solid var(--text); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 100, 77, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(224, 100, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 100, 77, 0); }
}

/* Режимы: дежурство и разделы управления */
.modes {
  display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px;
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.modes::-webkit-scrollbar { display: none; }
#operator { white-space: nowrap; }
@media (max-width: 1100px) {
  .clock, .conn span { display: none; }
}
.mode {
  border: 0; background: transparent; color: var(--muted); padding: 6px 14px;
  border-radius: 9px; font-weight: 600; white-space: nowrap;
}
.mode:hover { color: var(--text); }
.mode.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
button.btn.ghost#operator { color: var(--text); }

.page { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 16px 48px; }
.page > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: -0.4px; }
.page-note { margin-top: -6px; margin-bottom: 14px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input:not([type]) { flex: 1; min-width: 220px; }
.filters input, .filters select { width: auto; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px;
}

.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.4px; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.archived td { color: var(--muted); }
.more { text-align: center; margin-top: 14px; }

/* Заявки на тариф (пилот) */
.requests {
  background: var(--warn-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.requests h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.request {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-top: 8px;
}
.request-who { cursor: pointer; }
.request-actions { display: flex; align-items: center; gap: 8px; }
.request-actions label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.request-actions input { width: 90px; padding: 6px 8px; }

/* Боковая панель с карточками и формами */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(30, 39, 37, 0.25); z-index: 1500; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 1600;
  background: var(--surface); padding: 20px; overflow-y: auto; box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
}
.drawer h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.3px; }
.drawer h3 {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin: 20px 0 8px;
}
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.form label.check input { width: auto; }
.form input[readonly] { background: var(--bg); color: var(--muted); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.plain-list li:hover { background: var(--bg); }

/* Уведомления */
/* Слева внизу: справа открываются карточки и формы, уведомления их не закрывают. */
.toasts { position: fixed; bottom: 16px; left: 16px; display: grid; gap: 8px; z-index: 2000; }
.toast {
  background: var(--text); color: #fff; border-radius: 12px; padding: 12px 16px;
  box-shadow: var(--shadow); min-width: 260px; cursor: pointer;
}
.toast.sos { background: var(--sos); }

@media (max-width: 1100px) {
  .detail { position: absolute; right: 0; top: 0; bottom: 0; z-index: 1000; box-shadow: var(--shadow); }
  .layout { position: relative; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: 45%; border-right: 0; border-bottom: 1px solid var(--border); }
  .detail { width: 100%; }
  .topbar .muted, .clock { display: none; }
  .topbar { flex-wrap: wrap; }
  .modes { order: 3; width: 100%; }
}
