:root {
  --bg: #eef2f6;
  --card: #fff;
  --ink: #1a2330;
  --muted: #5b6777;
  --line: #d5dde6;
  --accent: #1f497d;
  --accent-2: #16365c;
  --ok: #1b7f4e;
  --warn: #9a5b00;
  --danger: #b42318;
  --pad: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { padding-bottom: 168px; }
header.app {
  position: sticky; top: 0; z-index: 10;
  background: var(--accent); color: #fff;
  padding: 12px var(--pad) 14px;
}
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.head-actions { display: flex; gap: 8px; }
.help-btn {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff;
  font-size: 20px; font-weight: 700;
}
.lock-scroll { overflow: hidden; height: 100%; overscroll-behavior: none; }
.field-ro { background: #e8edf3 !important; color: #5b6777 !important; }
.coords-btn, .mark-add, .mode-btn {
  width: 100%; margin-top: 8px; padding: 14px 12px !important;
  font-size: 16px !important; border-width: 2px !important; min-height: 48px;
}
.mark-row.point { grid-template-columns: 48px 1fr 44px; }
.mark-row.point input[data-f="to"] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(16,24,32,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: #fff; color: var(--ink); border-radius: 16px; padding: 20px 18px 16px;
  max-width: 420px; width: 100%; position: relative;
}
.modal-card h2 { font-size: 17px; margin: 12px 0 8px; }
.modal-card p { margin: 0 0 8px; font-size: 16px; }
.modal-x {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px;
  border: 0; background: #e8edf3; border-radius: 12px; font-size: 22px;
}
.btn-off, .btn-main:disabled { background: #c5ccd4 !important; color: #6b7380 !important; pointer-events: none; }
.draft-line { display: grid; grid-template-columns: 1fr 44px; gap: 6px; align-items: center; }
header.app h1 { margin: 0; font-size: 17px; font-weight: 650; }
header.app p { margin: 4px 0 0; font-size: 12px; opacity: .85; }
.wrap { max-width: 720px; margin: 0 auto; padding: 14px var(--pad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 15px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 16px 14px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 18px; background: #fff; color: var(--ink);
  min-height: 52px;
}
textarea { min-height: 72px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: grid; gap: 8px; }
.check {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.check input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 22px; }
.check b { display: block; font-size: 14px; }
.check span { display: block; font-size: 12px; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  border: 1px solid var(--line); background: #f6f8fb; border-radius: 12px;
  padding: 16px; font-size: 18px; font-weight: 650; min-height: 52px;
}
.seg button.on-yes { background: #e8f6ee; border-color: #9ad0b3; color: var(--ok); }
.seg button.on-no { background: #fdeeee; border-color: #f0b4ae; color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.warn { color: var(--warn); font-size: 13px; margin-top: 6px; }
.preview { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; background: #f4f7fa; padding: 10px; border-radius: 10px; overflow: auto; }
.check-list { margin: 0; padding-left: 18px; }
.check-list li { margin: 8px 0; font-size: 17px; }
.admin-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 8px;
}
.bar button {
  flex: 1 1 calc(50% - 8px);
  min-width: calc(50% - 8px);
  border: 0; border-radius: 12px; padding: 14px 8px;
  font-size: 16px; font-weight: 650; min-height: 48px;
}
.btn-ghost { background: #e8edf3; color: var(--ink); }
.btn-main { background: var(--accent); color: #fff; }
.btn-main:disabled { opacity: .45; }
.steps { display: flex; gap: 4px; margin: 8px 0 0; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.28); }
.steps i.on { background: #fff; }
.drafts { display: grid; gap: 8px; }
.draft-line {
  display: grid; grid-template-columns: 1fr 52px; gap: 8px; align-items: stretch;
}
.draft-open {
  text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 10px 12px;
}
.draft-del {
  border: 1px solid var(--line); background: #f3f5f8; border-radius: 12px;
  font-size: 26px; line-height: 1; min-width: 52px; min-height: 52px;
  z-index: 2; position: relative;
}
.hidden { display: none !important; }
.defect-block { margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.defect-block:last-child { border-bottom: 0; }
.marks { margin-top: 8px; display: grid; gap: 6px; }
.mark-row { display: grid; grid-template-columns: 48px 1fr 1fr 40px; gap: 6px; align-items: center; }
.mark-no { font-size: 13px; font-weight: 650; }
.mark-del { padding: 8px 0 !important; min-width: 44px !important; min-height: 44px !important; font-size: 22px !important; }
.add-weld { width: 100%; margin-top: 8px; padding: 18px 12px !important; font-size: 17px !important; }
.weld-card { margin: 0 0 10px; background: #f8fafc; }
.weld-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.weld-head .mark-del { width: 48px; height: 48px; }
.coords-btn {
  width: 100%; margin-top: 8px; padding: 14px 12px !important;
  font-size: 16px !important; min-height: 48px;
  background: #e8f0f8; border: 2px solid #1f497d; color: #1f497d;
}
.coords-btn.on { background: #1f497d; color: #fff; border-color: #1f497d; }
.mark-add {
  width: 100%; margin-top: 6px; padding: 12px !important;
  font-size: 16px !important; min-height: 44px;
  background: #fff; border: 2px dashed #1f497d; color: #1f497d;
}
.mode-btn {
  width: 100%; margin: 4px 0 10px; padding: 8px 10px !important;
  font-size: 14px !important; min-height: 36px; font-weight: 600;
  background: #eef1f4; border: 1px solid #c5ccd4; color: #445;
}
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
