/* Жёлтый — только у пикетажной таблички (как в натуре), красный — только ось.
   Всё остальное — нейтральные оттенки и прозрачности. */
:root {
  --bg: #141518;
  --asphalt: #22242a;
  --hair: rgba(255, 255, 255, .09);
  --text: #ececec;
  --mut: rgba(255, 255, 255, .5);
  --faint: rgba(255, 255, 255, .3);
  --plate: #ffd400;
  --ink: #0e0e0e;
  --axis: #e5322d;
  --rh: 68px;       /* = RH в app.js */
  --pkw: 104px;     /* колонка пикетов */
  --fade: linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%);
}
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button, select { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.app { display: flex; flex-direction: column; height: 100dvh; padding-top: env(safe-area-inset-top); }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 8px; }
.heading { flex: 1; min-width: 0; display: grid; }
.brandline { display: flex; align-items: baseline; gap: 6px; padding: 0 8px; min-width: 0; }
.brandline strong { font-size: 15px; letter-spacing: .01em; }
.version { color: var(--faint); font-size: 11px; font-weight: 600; white-space: nowrap; }
.route { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; white-space: nowrap; color: var(--faint); font-size: 11px; }
#inTitle {
  width: 100%; min-width: 0; resize: none; padding: 4px 8px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); font: 700 16px/1.25 system-ui, sans-serif; letter-spacing: .01em;
  -webkit-user-select: text; user-select: text; transition: background .15s;
}
#inTitle::placeholder { color: var(--faint); font-weight: 500; }
#inTitle:focus { outline: 0; background: rgba(255, 255, 255, .06); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; opacity: .8; }
.icon-btn:active { background: rgba(255, 255, 255, .08); opacity: 1; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.update { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; background: rgba(255, 255, 255, .07); font-size: 14px; }
.update[hidden] { display: none; }
.update button { background: var(--text); color: var(--ink); padding: 6px 12px; border-radius: 8px; font-weight: 700; }

/* ---------- шапка таблицы ---------- */
.cols {
  display: grid; grid-template-columns: var(--pkw) 1fr 10px 1fr;
  align-items: center; height: 32px; padding-left: 6px; text-align: center;
  font-size: 13px; font-weight: 800; letter-spacing: .02em; color: #f0f0f0;
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
}

/* ---------- основная зона ---------- */
.main { position: relative; flex: 1; min-height: 0; display: flex; background: var(--asphalt); }

/* линия чтения активного пикета */
.reader {
  position: absolute; left: 0; right: 0; top: 50%; height: var(--rh); transform: translateY(-50%);
  border-top: 1px solid rgba(255, 255, 255, .10); border-bottom: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .03); pointer-events: none; z-index: 3;
}

/* ---------- дорога ---------- */
.road {
  flex: 1; min-width: 0; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain;
  -webkit-mask-image: var(--fade); mask-image: var(--fade);
}
.road::-webkit-scrollbar { display: none; }
.rows { padding: 0 6px; }
.row { display: grid; grid-template-columns: var(--pkw) 1fr 10px 1fr; height: var(--rh); align-items: center; scroll-snap-align: center; }

.pk {
  justify-self: center; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums;
  font-size: 18px; font-weight: 700; color: var(--mut); transition: color .15s;
}
.row.act .pk {
  min-width: 96px; padding: 7px 10px; border-radius: 7px;
  background: var(--plate); color: var(--ink); border: 2px solid var(--ink);
  font-size: 23px; font-weight: 900; letter-spacing: .01em;
  box-shadow: 0 0 0 1px rgba(255, 212, 0, .35), 0 6px 16px rgba(0, 0, 0, .45);
}

/* ось: красный штрих-пунктир, непрерывный между строками (период 34px = rh / 2) */
.ax {
  height: 100%; pointer-events: none; opacity: .9;
  background: repeating-linear-gradient(to bottom, var(--axis) 0 18px, transparent 18px 23px, var(--axis) 23px 27px, transparent 27px 34px)
    center / 3px 34px repeat-y;
}

.cell {
  justify-self: center; width: calc(100% - 8px); max-width: 112px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  font-size: 20px; font-weight: 500; color: rgba(255, 255, 255, .88); font-variant-numeric: tabular-nums;
  border: 1px dashed rgba(255, 255, 255, .07);
  transition: background .15s, border-color .15s;
}
.cell.has { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .10); }
.row.act .cell { border: 1.5px dashed rgba(255, 255, 255, .38); }
.row.act .cell.has { border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .12); color: #fff; }
.cell:active { background: rgba(255, 255, 255, .16); }
.cell { touch-action: pan-y; }                 /* вертикаль — дороге, горизонталь — свайпу ячейки */
.cell .num { display: inline-block; will-change: transform; }
/* «призрак» — предыдущее значение, еле видно; оживляется тапом или свайпом */
.row.act .cell.ghost { color: rgba(255, 255, 255, .26); border: 1.5px dashed rgba(255, 255, 255, .3); background: transparent; }
.row.act .cell.drag {
  background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .6); color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .06);
}
.cell .ar { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: .7; flex: none; }
.cell .ar.lf { transform: scaleX(-1); }
.cell.pop { animation: pop .35s ease-out; }
@keyframes pop {
  0% { transform: scale(.85); background: rgba(255, 255, 255, .45); }
  100% { transform: scale(1); }
}

/* ---------- подвал ---------- */
.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px calc(7px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--faint); border-top: 1px solid var(--hair); }
.foot > span:first-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save { display: inline-flex; align-items: center; gap: 6px; color: var(--mut); white-space: nowrap; }
.save::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.save.ok::before { background: #4cc46a; }
.save.warn::before { background: #e0a326; }
.save.bad { color: #ff7b72; font-weight: 800; }
.save.bad::before { background: #ff4d42; }

/* ---------- диалоги ---------- */
dialog { width: min(440px, calc(100vw - 24px)); max-height: 92dvh; overflow-y: auto; padding: 20px; border: 1px solid var(--hair); border-radius: 18px; background: #1e2024; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 16px; font-size: 20px; }
.fld { display: grid; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--mut); }
input[type=text], input[type=number], select {
  width: 100%; height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--hair); background: var(--bg); color: var(--text);
  font-size: 16px; -webkit-user-select: text; user-select: text;
}
input:focus, select:focus { outline: 0; border-color: rgba(255, 255, 255, .45); }
.hint { min-height: 1.2em; color: var(--text); font-size: 13px; }
.hint.bad { color: #ff7b72; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
dialog button { height: 46px; padding: 0 16px; border-radius: 10px; background: rgba(255, 255, 255, .08); font-weight: 600; }
dialog .chips button { min-width: 52px; height: 44px; padding: 0 12px; background: transparent; border: 1px solid var(--hair); font-weight: 700; }
dialog .chips button.on { background: var(--text); color: var(--ink); border-color: var(--text); }
.chips input { width: 76px; height: 44px; }
.dlg-actions { position: sticky; bottom: 0; z-index: 1; display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 10px 0 2px; background: #1e2024; }
.spacer { flex: 1; }
dialog .primary { background: var(--text); color: var(--ink); font-weight: 800; }
dialog .danger { background: none; color: #ff7b72; padding: 0 4px; }
.stack { display: grid; gap: 8px; }
.stack button { height: 52px; font-size: 17px; }
.status { margin: 6px 0 0; font-size: 13px; color: var(--mut); min-height: 1.2em; }
.status.ok { color: #6fd58b; }
.status.bad { color: #ff7b72; }
.info { margin: 0 0 14px; color: var(--mut); }

.toast {
  position: fixed; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: rgba(20, 20, 22, .94); border: 1px solid var(--hair);
  color: #fff; font-size: 14px; transition: .2s; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #6e1a16; }
