:root {
  --bg: #f4f5f7; --card: #fff; --ink: #161a1f; --muted: #667080; --line: #dfe3e8;
  --accent: #0b5cad; --accent-ink: #fff; --ok: #1a7f4b; --bad: #b3261e; --warn: #a15c00;
  --bot: #eef4fb; --me: #f3f1ea; --mech: #eaf5ee;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1f25; --ink: #e7eaee; --muted: #94a0ae; --line: #2c333c;
    --accent: #5aa7f0; --accent-ink: #08131f; --ok: #5dc48d; --bad: #f2837b; --warn: #e0a556;
    --bot: #1d2732; --me: #26241f; --mech: #1c2922;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1240px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
section > h2, main > h2 { margin-top: 22px; }
a { color: var(--accent); }
small { font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.pad { padding: 12px 14px; margin: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 17px; }
.top nav { display: flex; gap: 16px; flex: 1; }
.top nav a { text-decoration: none; }
.top .who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.card.narrow { max-width: 340px; margin: 12vh auto 0; }
.card.list { padding: 0; overflow: hidden; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.warn { color: var(--warn); border-color: var(--warn); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row .primary { margin-left: auto; }
.check { display: flex; gap: 6px; align-items: center; margin: 0; }
.check input { width: auto; margin: 0; }
.filebtn { margin: 0; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 7px; cursor: pointer; color: var(--ink); }
.filebtn input { display: none; }

.jobrow, .alertrow { display: grid; grid-template-columns: 52px 70px minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.alertrow { grid-template-columns: 96px minmax(0, 1fr) auto auto; margin: 0; }
.jobrow:last-child, .alertrow:last-child { border-bottom: 0; }
.jobrow:hover { background: var(--bg); }
.jobrow a { color: var(--ink); text-decoration: none; }
.jobrow .num { color: var(--muted); text-align: left; }
.jobrow .title { white-space: normal; }
.jobrow .unit { font-weight: 700; }
.jobrow .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.closed { opacity: .55; }
.when { font-size: 13px; white-space: nowrap; }

.station { font-size: 13px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); display: inline-block; }
.station.on { color: var(--ok); border-color: var(--ok); }
.station.off { color: var(--bad); border-color: var(--bad); }
.jobhead { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; margin-bottom: 12px; }
.jobhead h1 { margin: 0; }
.jobhead .station { margin-left: auto; }
.vin { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); }

.label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 4px; }
.step .goal { margin: 0 0 12px; }
.step .next { font-size: 19px; line-height: 1.35; font-weight: 600; margin: 0 0 12px; }
.step .next.done { color: var(--ok); }
.checks { list-style: none; margin: 0 0 4px; padding: 0; border-top: 1px solid var(--line); }
.checks li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.checks small { color: var(--muted); }
.checks .mark { width: 20px; height: 20px; flex: none; border-radius: 50%; text-align: center; line-height: 20px;
  font-size: 12px; font-weight: 700; color: #fff; margin-top: 2px; }
.checks .ok .mark { background: var(--ok); }
.checks .bad .mark { background: var(--bad); }
.checks .unknown .mark { background: var(--warn); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.quick button { flex: 1; min-width: 130px; padding: 11px; }

.confirm { border: 2px solid var(--bad); }
.confirm pre, .note { white-space: pre-wrap; font: inherit; margin: 6px 0 10px; }
.note { font-size: 17px; line-height: 1.45; }

.thread { display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.thread:empty::before { content: "Лента пуста."; color: var(--muted); }
[lang=en] .thread:empty::before { content: ""; }
.entry { padding: 8px 11px; border-radius: 9px; background: var(--me); max-width: 92%; align-self: flex-end; }
.entry.r-bot { background: var(--bot); align-self: flex-start; }
.entry.r-mechanic { background: var(--mech); }
.entry.k-system { background: none; align-self: center; color: var(--muted); font-size: 13px; padding: 2px 8px; text-align: center; }
.entry.k-tech_note, .entry.k-confirm { border: 1px solid var(--line); }
.entry.k-billing { background: none; align-self: center; color: var(--muted); font-size: 13px; padding: 2px 8px; text-align: center; }
.entry.k-billing .meta, .entry.k-billing .text { display: inline; }
.entry .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.entry.k-system .meta { display: inline; }
.entry.k-system .text { display: inline; }
.entry .tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.entry .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry img, .entry video { display: block; max-width: 100%; max-height: 320px; border-radius: 6px; margin-top: 6px; }
.busy { color: var(--muted); font-size: 13px; padding: 8px 2px 0; }
.busy::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .busy::after { animation: none; } }
.composer { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }

#screen { width: 100%; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; cursor: zoom-in; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card form { margin-top: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile .big { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.tile.on .big { color: var(--ok); }
.tile.off .big { color: var(--bad); }
.tile p { margin: 0; }
.tablewrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--accent); color: var(--accent); white-space: nowrap; }
.pill.danger { border-color: var(--bad); color: var(--bad); }
.card.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.card.inline h2 { width: 100%; margin: 0; }
.card.inline label { flex: 1; min-width: 150px; margin: 0; }

.mech { max-width: 640px; margin: 0 auto; }
.mech .jobrow { grid-template-columns: 44px 56px minmax(0, 1fr) auto; grid-template-areas: "num unit title pill" "num unit when pill"; row-gap: 2px; }
.mech .jobrow .num { grid-area: num; } .mech .jobrow .unit { grid-area: unit; }
.mech .jobrow .title { grid-area: title; } .mech .jobrow .pill { grid-area: pill; } .mech .jobrow .when { grid-area: when; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--card); color: var(--ink); width: min(480px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.worklist { margin: 0; padding-left: 18px; }
.mic.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.mech .composer { border: 0; padding: 0; margin: 0 0 12px; }
.mech button, .mech .filebtn { padding: 12px 16px; }

/* --- счёт в заказе --- */
#invoice h2 { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 15px; }
#invoice h2 .muted { font-weight: 400; }
.lines { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.lines td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines tr.total td { border-bottom: 0; padding-top: 8px; }
.lines td:last-child { width: 24px; text-align: right; }
.addline { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.addline .row label { margin: 0; }
.invoice-actions { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 12px; }
