:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #dfe4ea;
  --text: #17212b;
  --muted: #5d6b79;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0f7;
  --ok: #1e7f4f;
  --ok-soft: #e3f4ea;
  --warn: #9a6200;
  --warn-soft: #fdf1d8;
  --fail: #b42318;
  --fail-soft: #fde7e5;
  --na: #6b7785;
  --na-soft: #eef1f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: .85em; word-break: break-all; }
.hidden { display: none !important; }

/* ---------- Каркас ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000;
}
.brand { font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand svg { flex: none; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: var(--accent-soft); color: var(--accent); }
main.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.side { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* ---------- Кнопки и формы ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--fail); border-color: var(--fail); }
.btn.small { padding: 5px 10px; font-size: .86rem; }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: block; }
label.field > span { display: block; font-size: .86rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.form-grid .c2 { grid-column: span 2; } .form-grid .c3 { grid-column: span 3; } .form-grid .c6 { grid-column: span 6; }
.error { color: var(--fail); background: var(--fail-soft); padding: 10px 12px; border-radius: 8px; }

/* ---------- Статусы ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }
.badge.na { background: var(--na-soft); color: var(--na); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: currentColor; }

/* ---------- Список заказов ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.list td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface-2); }
.progress { height: 6px; background: var(--na-soft); border-radius: 3px; overflow: hidden; width: 120px; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- Проверки ---------- */
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.checks .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; margin-top: 1px; }
.checks .ok .ic { background: var(--ok); } .checks .warn .ic { background: #c98a00; } .checks .fail .ic { background: var(--fail); } .checks .na .ic { background: var(--na); }
.checks b { display: block; }
.verdict { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 8px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); } .verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.fail { background: var(--fail-soft); color: var(--fail); } .verdict.na { background: var(--na-soft); color: var(--na); }
.verdict strong { font-size: 1.05rem; display: block; }

/* ---------- Карта и профиль высоты ---------- */
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }
.map.pick { height: 100%; min-height: 460px; }
.shot-marker { background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: 12px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.shot-marker.plate { background: #b42318; }
.obj-marker { width: 18px; height: 18px; background: #fff; border: 4px solid var(--text); border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.profile svg { width: 100%; height: auto; display: block; }
.profile .axis { stroke: var(--border); }
.profile .floor-line { stroke: var(--border); stroke-dasharray: 3 4; }
.profile .lbl { fill: var(--muted); font-size: 11px; }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.profile .area { fill: var(--accent-soft); }
.profile .target { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 6 4; }
.profile .shot circle { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.profile .shot text { font-size: 10px; fill: var(--accent); font-weight: 700; }

/* ---------- Галерея ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.shot-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; }
.shot-card:hover { border-color: var(--accent); }
.shot-card .img { aspect-ratio: 1 / 1; background: var(--na-soft) center / cover no-repeat; position: relative; }
.shot-card .num { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-weight: 700; }
.shot-card .body { padding: 10px 12px; font-size: .84rem; }
.shot-card .body b { font-size: .92rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: .86rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.lightbox { position: fixed; inset: 0; background: rgba(10, 15, 20, .86); z-index: 2000; display: grid; grid-template-columns: 1fr 360px; }
.lightbox img { max-width: 100%; max-height: 100vh; margin: auto; display: block; object-fit: contain; }
.lightbox .meta { background: var(--surface); padding: 20px; overflow: auto; }
.lightbox .close { position: absolute; top: 12px; left: 12px; }

.qr-box { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.qr-box img { width: 180px; height: 180px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.copy-area { width: 100%; min-height: 120px; font-size: .86rem; }

.steps-editor { width: 100%; border-collapse: collapse; font-size: .88rem; }
.steps-editor td, .steps-editor th { padding: 6px; border-bottom: 1px solid var(--border); text-align: left; }
.steps-editor th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.steps-editor input[type=text] { padding: 6px 8px; }
.steps-editor input[type=checkbox] { width: auto; }
.events { list-style: none; margin: 0; padding: 0; font-size: .86rem; max-height: 320px; overflow: auto; }
.events li { padding: 6px 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 130px 1fr; gap: 8px; }

.login { max-width: 380px; margin: 12vh auto; }

@media (max-width: 980px) {
  .grid.two, .grid.side { grid-template-columns: minmax(0, 1fr) !important; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid > * { grid-column: span 2 !important; }
  .topbar { gap: 12px; padding: 0 12px; } .topbar .brand span { display: none; }
  main.container { padding: 16px; }
  .qr-box { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { height: auto; min-height: 52px; flex-wrap: nowrap; }
  .topbar nav { overflow-x: auto; scrollbar-width: none; }
  .topbar nav a { white-space: nowrap; padding: 6px 8px; font-size: .9rem; }
  .topbar nav a[target] { display: none; }
  .topbar #logout { padding: 4px 8px; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  table.list td { border: 0; padding: 4px 12px; }
  .lightbox { grid-template-rows: 45vh auto; overflow: auto; }
}

/* ---------- Подсказки адреса ---------- */
.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 1500; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); margin-top: 4px; overflow: hidden; }
.suggest .opt { padding: 9px 12px; cursor: pointer; font-size: .92rem; }
.suggest .opt:hover, .suggest .opt.active { background: var(--accent-soft); color: var(--accent); }
.suggest .opt.loading { color: var(--muted); cursor: default; }
.suggest .opt.loading:hover { background: none; color: var(--muted); }
.suggest .opt.warn { background: var(--warn-soft); color: var(--warn); cursor: default; line-height: 1.4; }
.suggest .opt.warn:hover { background: var(--warn-soft); color: var(--warn); }
