:root {
  color-scheme:dark;
  --bg:#141516;
  --panel:#1c1d1f;
  --elev:#252629;
  --line:#343538;
  --muted:#afb0b3;
  --text:#f4f2ef;
  --accent:#ff9852;
  --good:#8fd6ad;
  --bad:#ff9a92;
  font:15px/1.45 Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
* {
  box-sizing:border-box;
}
body {
  margin:0;
  background:var(--bg);
  color:var(--text);
}
[hidden] {
  display:none!important;
}
button,input,textarea,select {
  font:inherit;
  color:inherit;
}
button,summary {
  cursor:pointer;
}
button,input,select,textarea {
  background:var(--elev);
  border:1px solid var(--line);
  border-radius:8px;
  padding:9px 13px;
}
button:hover,summary:hover {
  background:#333437;
}
button:focus-visible,summary:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:2px;
}
button.primary {
  background:var(--accent);
  color:#23160d;
  border:0;
  font-weight:680;
}
button:disabled {
  opacity:.5;
  cursor:wait;
}
button span {
  float:right;
}
h1,h2,h3,p {
  margin:0;
}
h1 {
  font-size:clamp(32px,4vw,48px);
  line-height:1.1;
  letter-spacing:-.05em;
  font-weight:640;
}
h2 {
  font-size:21px;
  letter-spacing:-.035em;
}
h3 {
  font-size:16px;
}
small,.muted,label {
  color:var(--muted);
}
.bar,main {
  max-width:1640px;
  margin:auto;
  padding:0 clamp(16px,3.5vw,60px);
}
header {
  border-bottom:1px solid var(--line);
  background:#18191a;
}
.bar {
  height:65px;
  display:flex;
  align-items:center;
  gap:24px;
}
.mark {
  font:bold italic 20px/32px Georgia;
  background:var(--accent);
  color:#271a12;
  border-radius:8px;
  width:32px;
  height:32px;
  text-align:center;
}
#crumb {
  font-size:13px;
  color:var(--muted);
  border-left:1px solid var(--line);
  padding-left:22px;
}
summary {
  display:flex;
  align-items:center;
  gap:12px;
  font-size:20px;
  font-weight:650;
  list-style:none;
  border-radius:8px;
  padding:4px;
}
summary::-webkit-details-marker {
  display:none;
}
#nav {
  position:relative;
}
nav {
  position:absolute;
  z-index:4;
  top:calc(100% + 8px);
  min-width:215px;
  background:var(--panel);
  padding:7px;
  border-radius:12px;
  border:1px solid var(--line);
  box-shadow:0 12px 45px #0008;
}
nav button {
  width:100%;
  border:0;
  text-align:left;
  background:none;
}
hr {
  border:0;
  border-top:1px solid var(--line);
}
.heading,.sectionhead,.dialoghead {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.heading {
  margin:32px 0 23px;
}
#actions,.tools {
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.kpis {
  display:grid;
  grid-template-columns:repeat(3,1fr);
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background:var(--panel);
  margin-bottom:24px;
}
.kpis article {
  padding:18px 22px;
  border-left:1px solid var(--line);
}
.kpis article:first-child {
  border:0;
}
.kpis label {
  display:block;
  font-size:13px;
}
.kpis strong {
  display:block;
  font-size:clamp(23px,2.5vw,40px);
  letter-spacing:-.055em;
  font-weight:600;
  font-variant-numeric:tabular-nums;
}
.kpis article:last-child strong {
  color:var(--accent);
}
.sheet {
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--panel);
  overflow:hidden;
}
.sectionhead {
  padding:16px 18px;
}
.scroll {
  overflow:auto;
}
.matrix {
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-variant-numeric:tabular-nums;
  font-size:13px;
  white-space:nowrap;
}
.matrix td,.matrix th {
  padding:8px 12px;
  text-align:right;
  border-top:1px solid #2b2d2e;
  line-height:1.25;
}
.matrix th {
  color:var(--muted);
  font-weight:500;
}
.matrix th:first-child,.matrix td:first-child {
  position:sticky;
  left:0;
  z-index:1;
  text-align:left;
  background:var(--panel);
  box-shadow:1px 0 var(--line);
}
.matrix thead th {
  background:#222325;
}
.matrix button {
  border:0;
  padding:1px 0;
  background:transparent;
  text-align:left;
  color:inherit;
  font-size:inherit;
  min-height:22px;
}
.matrix .sub {
  color:var(--muted);
  font-size:12px;
}
.matrix .sub td:first-child {
  padding-left:23px;
}
.matrix .key td {
  font-weight:650;
  border-top:1px solid #4a4541;
}
.matrix .chosen {
  background:#332b25;
  color:#ffc598;
}
.matrix tr:hover td {
  background:#28292b;
}
.matrix .gain {
  color:var(--good);
}
.matrix .loss {
  color:var(--bad);
}
.between {
  margin:28px 0 12px;
}
.products,.lanes {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,330px),1fr));
  gap:12px;
  margin-bottom:32px;
}
.pc,.lane,.setting {
  padding:15px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
}
.pc h3 {
  margin-bottom:2px;
}
.pc small {
  display:block;
  margin-bottom:12px;
}
.pcbody {
  display:grid;
  grid-template-columns:72px 1fr;
  gap:12px;
}
.thumb {
  width:100%;
  height:100%;
  min-height:76px;
  object-fit:contain;
  background:#272829;
  border-radius:7px;
  display:grid;
  place-items:center;
  color:var(--muted);
  font-size:12px;
}
.pr {
  display:grid;
  grid-template-columns:1fr auto auto;
  gap:8px;
  align-items:center;
  border-bottom:1px solid var(--line);
  font-size:13px;
  padding:5px 0;
  font-variant-numeric:tabular-nums;
}
.pr:last-child {
  border:0;
}
.pr span {
  color:var(--muted);
}
.pr b {
  min-width:64px;
  text-align:right;
}
.missing,.note {
  margin:12px 0;
  padding:13px;
  border:1px solid #61503e;
  border-radius:9px;
  color:#ffd2ab;
}
.missing {
  display:block;
}
.sources {
  margin-top:12px;
}
.sources summary {
  font-size:13px;
  color:var(--muted);
  display:inline-flex;
}
.sources li {
  overflow-wrap:anywhere;
}
.lane {
  min-height:220px;
}
.lane h2 {
  font-size:18px;
  margin-bottom:15px;
}
.task,.setting {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.task {
  display:block;
  text-align:left;
  width:100%;
  background:var(--elev);
  margin-bottom:8px;
  overflow-wrap:anywhere;
}
.task small {
  display:block;
}
.setting {
  margin:8px 0;
}
.setting.inactive {
  opacity:.65;
}
dialog {
  width:min(510px,calc(100% - 26px));
  max-height:86dvh;
  overflow:auto;
  color:inherit;
  background:var(--panel);
  border:1px solid #454648;
  border-radius:14px;
  padding:20px;
  box-shadow:0 24px 90px #0006;
}
dialog::backdrop {
  background:#0009;
}
.cross {
  border:0;
  background:none;
  font-size:22px;
}
.dialoghead {
  margin-bottom:12px;
}
dialog label {
  display:block;
  font-size:13px;
  margin-top:12px;
}
dialog input:not([type=file]),dialog textarea,dialog select {
  width:100%;
  margin:4px 0 6px;
}
input[type=file] {
  width:100%;
  min-width:0;
}
textarea {
  resize:vertical;
}
dialog .tools {
  margin-top:14px;
}
#toast {
  position:fixed;
  z-index:10;
  bottom:20px;
  left:50%;
  transform:translateX(-50%);
  background:#f3e9df;
  color:#24180f;
  padding:12px 20px;
  border-radius:9px;
  max-width:90vw;
}
.chart {
  background:#202123;
  border:1px solid var(--line);
  border-radius:12px;
  padding:15px;
  box-shadow:0 8px 40px #0007;
}
.chart svg {
  display:block;
  width:100%;
  height:auto;
}
.floating {
  position:fixed;
  width:335px;
  pointer-events:none;
  z-index:5;
}
.login {
  width:min(315px,90vw);
  margin:auto;
  text-align:center;
  display:grid;
  gap:14px;
}
.login h1 {
  margin-bottom:10px;
}
.login label {
  text-align:left;
}
.login input {
  height:48px;
}
#gate {
  min-height:100dvh;
  display:grid;
  background:radial-gradient(ellipse at 50% 34%,#30271f 0,transparent 48%);
}
.portrait {
  position:relative;
  display:grid;
  place-items:center;
  width:84px;
  height:84px;
  margin:0 auto 14px;
  background:#282422;
  border:1px solid #8b6344;
  border-radius:50%;
  font:italic bold 44px Georgia;
  color:var(--accent);
}
.portrait:after {
  content:'';
  position:absolute;
  inset:-5px;
  border:1px solid var(--accent);
  border-radius:50%;
  animation:pulse 3s ease-out infinite;
}
.portrait img {
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:50%;
  position:absolute;
}
.login .primary {
  padding:12px;
}
#loginerror,.err {
  color:var(--bad);
  font-size:13px;
}
@keyframes pulse {
  0% {
    transform:scale(.96);
    opacity:.7;
  }
  100% {
    transform:scale(1.2);
    opacity:0;
  }
}
@media(prefers-reduced-motion:reduce) {
  * {
    animation:none!important;
  }
}
@media(max-width:700px) {
  .bar {
    height:56px;
  }
  .heading {
    margin:22px 0 16px;
    align-items:flex-start;
    flex-wrap:wrap;
  }
  .heading h1 {
    font-size:36px;
  }
  .heading #actions {
    width:100%;
  }
  #actions button,#actions select {
    min-height:42px;
  }
  .kpis {
    gap:0;
  }
  .kpis article {
    padding:12px 7px;
  }
  .kpis label {
    font-size:11px;
  }
  .kpis strong {
    font-size:clamp(15px,3.7vw,24px);
    letter-spacing:-.04em;
  }
  .matrix th,.matrix td {
    padding:7px 6px;
    font-size:12px;
  }
  .matrix td:first-child {
    white-space:normal;
    width:50%;
  }
  .matrix .other {
    display:none;
  }
  .matrix .sub td:first-child {
    padding-left:13px;
  }
  .matrix button {
    min-height:30px;
  }
  .sectionhead {
    padding:12px;
  }
  .sectionhead h2,.between {
    font-size:18px;
  }
  .pr {
    font-size:12px;
  }
  .pcbody {
    grid-template-columns:65px 1fr;
    gap:8px;
  }
  .lane {
    min-height:110px;
  }
  .floating {
    display:none;
  }
  .tools button {
    min-height:42px;
  }
}
@media(max-width:420px) {
  main {
    padding-left:10px;
    padding-right:10px;
  }
  .pc {
    padding:12px;
  }
  .pcbody {
    grid-template-columns:52px minmax(0,1fr);
  }
  .pr {
    grid-template-columns:minmax(0,1fr) auto auto;
    gap:5px;
  }
  .pr b {
    min-width:0;
  }
  .pr span:first-child {
    overflow-wrap:anywhere;
  }
  .matrix button {
    white-space:normal;
  }
  .setting>div {
    min-width:0;
    overflow-wrap:anywhere;
  }
}

/* Рубли и проценты читаются по цвету строки и знаку процента. */
.matrix tr.percent td {color:#9ddbed;background:#1b282e}
.matrix tr.percent td:first-child {background:#203039}
.matrix tr.percent td.chosen {background:#263a44;color:#c3f2ff}
.matrix tr.percent:hover td {background:#293d46}
.matrix tr.percent button {font-size:inherit}
.matrix .sub {font-size:13px}
.plan-empty,.path-scroll,.truck {background:var(--panel);border:1px solid var(--line);border-radius:14px}
.plan-empty {padding:32px;color:var(--muted)}
.path-scroll {overflow:auto}
.path-table {width:100%;border-collapse:separate;border-spacing:0;font-size:14px}
.path-table th {text-align:left;color:var(--muted);background:#212325;font-size:14px;font-weight:550;padding:12px 9px}
.path-table td {padding:8px;border-top:1px solid var(--line);vertical-align:middle}
.path-table input,.path-table textarea,.path-table select,.rig-box input,.rig-box textarea,.truck-top input {
  width:100%;min-width:0;padding:8px;border:1px solid transparent;background:#222427;
}
.path-table input:hover,.path-table textarea:hover,.path-table select:hover,.truck input:hover,.truck textarea:hover {border-color:#55575b}
.path-table input:focus,.path-table textarea:focus,.path-table select:focus,.truck input:focus,.truck textarea:focus {background:#282b2e;border-color:var(--accent)}
.path-table textarea,.rig-box textarea {display:block;resize:vertical}
.path-table td {min-width:144px}
.path-table .cell-photo {min-width:74px}
.path-table .cell-spec,.path-table .cell-name {min-width:195px}
.path-table .cell-trial,.path-table .cell-ordered {min-width:96px}
.path-photo {width:58px;height:58px;display:grid;place-items:center;overflow:hidden;padding:0;color:var(--accent);font-size:22px}
.path-photo img {width:100%;height:100%;object-fit:contain}
.source-link a {color:#ffb681;display:inline-block;padding:4px 8px}
.source-link a[hidden] {display:none}
.fleet {display:grid;gap:20px}
.truck {padding:clamp(12px,2vw,28px);overflow:hidden}
.truck-top {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.truck-top input {font-weight:650;font-size:clamp(18px,2.6vw,26px);max-width:32em;background:transparent}
.truck-top button {font-size:14px;white-space:nowrap;color:var(--muted)}
.rig {position:relative;display:grid;grid-template-columns:clamp(70px,11vw,168px) minmax(0,1fr);align-items:end;padding-bottom:29px}
.rig-box {padding:clamp(14px,2vw,24px);border:2px solid #6b6060;border-left:5px solid var(--accent);background:#232426;border-radius:7px 7px 4px 4px;display:grid;grid-template-columns:minmax(150px,.8fr) minmax(200px,1.6fr) minmax(150px,1fr);gap:18px;position:relative}
.rig-box label,.cargo-heading strong {font-weight:550;font-size:14px;color:#d8d4cf}
.rig-box input,.rig-box textarea {display:block;margin-top:6px;background:#191b1d}
.rig-cab {position:relative;align-self:end;height:clamp(65px,8vw,100px);margin-right:4px;background:#e38647;clip-path:polygon(0 54%,22% 15%,30% 0,90% 0,95% 71%,100% 71%,100% 100%,0 100%);border-bottom:8px solid #63534a}
.rig-cab::before {content:'';position:absolute;inset:10% 20% 46% 9%;background:#303c41;clip-path:polygon(25% 0,100% 0,100% 100%,0 100%)}
.rig-cab i {position:absolute;right:23%;top:62%;background:#594438;width:13%;height:3px}
.rig-wheels {height:11px;bottom:19px;left:2%;right:1%;position:absolute;background:#706c68;display:flex;align-items:center;gap:6px;padding:0 3%}
.rig-wheels i {width:28px;height:28px;border:6px solid #101112;outline:2px solid #494b4d;border-radius:50%;background:#7a7e82}
.rig-wheels i:first-child {margin-right:auto}
.cargo-heading {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px}
.cargo-heading button,.cargo li button {padding:4px 8px;font-size:13px}
.cargo ul {margin:8px 0 0;padding:0;list-style:none}
.cargo li {display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:7px;padding:6px 0;border-top:1px solid var(--line);font-size:14px}
.cargo li span {overflow-wrap:anywhere}
.cargo li b {white-space:nowrap;color:#ffbe8c}
.cargo .muted {margin-top:8px;font-size:14px}
.photo-picker span {font-size:14px}
.photo-picker img {width:100%;height:120px;object-fit:contain;background:var(--bg);border-radius:6px}
@media(max-width:900px) {
  .rig-box {grid-template-columns:minmax(0,1fr);gap:12px}
}
@media(max-width:700px) {
  .path-scroll {background:none;border:0;overflow:visible}
  .path-table,.path-table tbody {display:block;width:100%}
  .path-table thead {position:absolute;clip-path:inset(50%);width:1px;height:1px;overflow:hidden}
  .path-table tr {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;background:var(--panel);border:1px solid var(--line);border-radius:12px;margin-bottom:12px;padding:12px}
  .path-table td[class] {display:block;min-width:0;border:0;padding:0}
  .path-table td:before {content:attr(data-label);font-size:13px;color:var(--muted);display:block;margin:2px 0 4px}
  .path-table .cell-photo {grid-column:1}
  .path-table .cell-link,.path-table .cell-spec,.path-table .cell-address,.path-table .cell-truck_id {grid-column:1/-1}
  .path-table input,.path-table select,.path-table textarea,.truck input,.truck textarea {font-size:16px;min-height:42px}
  .rig {grid-template-columns:39px minmax(0,1fr)}
  .rig-cab {height:48px;margin-right:2px}
  .rig-box {padding:10px;border-left-width:3px}
  .truck-top {align-items:flex-start;gap:2px}
  .truck-top button {white-space:normal;min-width:80px;max-width:105px}
  .rig-wheels i {width:22px;height:22px;border-width:5px}
  .cargo-heading button,.cargo li button {min-height:36px}
}
.edit-thumb {padding:0;overflow:hidden}
.edit-thumb img {display:block;width:100%;height:100%;object-fit:contain}
@media(max-width:700px) {
  .path-table tr {grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr)}
}
dialog:has(#photo-form),dialog:has(#product [data-saved-src]:not([data-saved-src=""])) {
  width:min(810px,calc(100% - 24px));
}
.photo-picker img[data-photo-preview] {
  display:block;width:100%;height:clamp(200px,55vh,540px);height:clamp(170px,53dvh,540px);
  object-fit:contain;border-radius:8px;
}
.photo-picker img[data-photo-preview][hidden] {display:none}
.photo-picker label {font-size:15px;color:var(--text)}
.photo-picker input {display:block;margin:6px 0}
.path-table .remove-path-item {border:0;background:transparent;color:#e6aaa4;font-size:13px;padding:5px 8px}
.path-table .remove-path-item:hover {text-decoration:underline}
button.primary.danger {background:#b13937;color:white}
