/* Холодная нейтральная шкала + один акцент.
   Цифры выравниваются через tabular-nums, а не моноширинным шрифтом. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #0e1621;
  --ink-2: #5b6779;
  --ink-3: #8b95a5;
  --line: #e3e7ed;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --on-accent: #ffffff;
  --done: #0e9f6e;
  --warn: #e0553d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px -16px rgba(16, 24, 40, .28);
  --radius: 16px;
  --pad: 16px;
}

body.dark {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f262e;
  --ink: #e9edf3;
  --ink-2: #9aa6b6;
  --ink-3: #6e7a8a;
  --line: #242c36;
  --accent: #4c8dff;
  --accent-soft: #16273f;
  --done: #2bb884;
  --warn: #f0705a;
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 82px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* --- шапка --- */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: 12px var(--pad) 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.eyebrow { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.counter { font-size: 13px; font-weight: 500; color: var(--ink-2); }

.search {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-size: 16px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: var(--ink-3); }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 500;
  white-space: nowrap; cursor: pointer;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip b {
  font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2);
}
.chip.is-on b { background: rgba(255, 255, 255, .18); color: inherit; }

/* --- вкладки --- */
.view { display: none; padding: var(--pad); }
.view.is-open { display: block; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; cursor: pointer;
  padding: 10px 0 9px; color: var(--ink-3);
  font: inherit; font-size: 11px; font-weight: 500;
}
.tab svg {
  width: 22px; height: 22px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tab.is-active { color: var(--accent); font-weight: 600; }

/* --- карточка заявки --- */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}
.card.is-overdue { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.card.is-closed { opacity: .6; box-shadow: none; }

.card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  font-size: 13px; color: var(--ink-3);
}
.rid { font-weight: 600; color: var(--ink-2); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.obj {
  margin-left: auto; padding: 3px 9px; border-radius: 7px;
  background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500;
  max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pos { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.qty { font-weight: 700; white-space: nowrap; }
.meta { margin-top: 4px; font-size: 13px; color: var(--ink-3); }

/* Полоса маршрута: шесть отрезков — шесть стадий. Тап по отрезку переводит заявку. */
.rail { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 14px 0 10px; }
.seg {
  height: 6px; border: 0; padding: 0; cursor: pointer; border-radius: 3px;
  background: var(--surface-2); position: relative;
}
.seg::before { content: ""; position: absolute; inset: -11px -2px; }
.seg.done { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.seg.now { background: var(--accent); }
.seg.finished { background: var(--done); }

.rail-foot { display: flex; align-items: center; gap: 12px; }
.status-name { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.status-name .step { font-weight: 500; color: var(--ink-3); }
.status-name.s-received { color: var(--done); }
.status-name.s-overdue { color: var(--warn); }
.next {
  margin-left: auto; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.next:active { opacity: .75; }

/* --- форма --- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.control {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; outline: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
select.control {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-main {
  margin-top: 6px; padding: 16px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-main:disabled { opacity: .5; }

/* --- объекты --- */
.objects { display: flex; flex-direction: column; gap: 12px; }
.obj-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.obj-card.total { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }
.obj-card.total .obj-name { color: #fff; }
.obj-card.total .num b { color: #fff; }
.obj-card.total .num span { color: rgba(255, 255, 255, .82); }
.obj-card.total .num.alarm b { color: #ffd9d1; }
.obj-name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 12px; }
.obj-nums { display: flex; gap: 24px; }
.num { display: flex; flex-direction: column; gap: 3px; }
.num b { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.num span { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.num.alarm b { color: var(--warn); }

.empty { padding: 56px 24px; text-align: center; color: var(--ink-3); font-size: 15px; }
.empty b { display: block; color: var(--ink); font-size: 17px; font-weight: 600; margin-bottom: 8px; }

/* --- тост --- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 14px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px;
  font-size: 15px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 20; max-width: 88vw; text-align: center;
  box-shadow: 0 12px 32px -12px rgba(16, 24, 40, .5);
}
body.dark .toast { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--warn); color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
