:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #616e7c;
  --line: #e1e6ec;
  --primary: #1d5fd1;
  --primary-dark: #174ca6;
  --ok: #138a43;
  --ok-bg: #e7f6ed;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --warn: #b45309;
  --warn-bg: #fff4e0;
  --info-bg: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: #142a4d; color: #fff;
}
.topbar .brand { font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.topbar .brand img { width: 26px; height: 26px; border-radius: 6px; }
.topbar .brand small { color: #b8c4d6; font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar a.user { color: #dce4f0; font-size: .9rem; }
.adminnav {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.adminnav a {
  white-space: nowrap; padding: 7px 12px; border-radius: 8px; color: var(--text); font-size: .95rem;
}
.adminnav a.active, .adminnav a:hover { background: var(--info-bg); color: var(--primary); text-decoration: none; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
main.wide { max-width: 1180px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 7px; color: var(--muted); font-size: .72rem; text-decoration: none;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }
.bottomnav .badge { position: absolute; margin-left: 18px; margin-top: -2px; }

/* ---------- карточки и списки ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 0 0 12px;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.list { display: flex; flex-direction: column; gap: 10px; }
a.item {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; color: var(--text); text-decoration: none;
}
a.item:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, .12); }
a.item .grow { flex: 1; min-width: 0; }
a.item .title { font-weight: 600; }
a.item .sub { color: var(--muted); font-size: .88rem; }
a.item .chev { color: #9aa5b1; font-size: 1.4rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 2.2rem; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.ok .num { color: var(--ok); }
.stat.bad .num { color: var(--bad); }
.stat.warn .num { color: var(--warn); }

/* ---------- метки ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: #eef1f5; color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--primary); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #c5ced8; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: #f59e0b; }

/* ---------- формы ---------- */
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: .95rem; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 8px 0; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
input[type=time], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: inherit;
  border: 1px solid #c9d2dc; border-radius: 10px; background: #fff;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cbcf5; border-color: var(--primary); }
input[type=checkbox] { width: 20px; height: 20px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.help { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { margin: 0; font-weight: 500; display: flex; align-items: center; gap: 4px;
  border: 1px solid #c9d2dc; border-radius: 8px; padding: 6px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; min-height: 44px;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.light { background: #fff; color: var(--text); border-color: #c9d2dc; }
.btn.light:hover { background: #f4f6f9; }
.btn.ok { background: var(--ok); } .btn.ok:hover { background: #0f6f36; }
.btn.bad { background: var(--bad); } .btn.bad:hover { background: #a61f1f; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .9rem; }
.btn.link { background: none; color: var(--primary); padding: 6px 4px; min-height: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
form.inline { display: inline; }

/* ---------- сообщения ---------- */
.flash { border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; background: var(--info-bg); }
.flash.ok { background: var(--ok-bg); color: #0b5a2c; }
.flash.bad { background: var(--bad-bg); color: #8f1d1d; }
.flash.warn { background: var(--warn-bg); color: #7a3a00; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; background: #fff;
  border: 1px dashed #9aa5b1; border-radius: 8px; padding: 6px 10px; display: inline-block; letter-spacing: .5px; }

/* ---------- таблицы ---------- */
.tablewrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f9fb; font-weight: 600; color: #3e4c59; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7faff; }

/* ---------- прохождение чек-листа ---------- */
.progress { height: 8px; background: #e4e8ee; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--primary); transition: width .3s; }
.runhead { position: sticky; top: 46px; z-index: 10; background: var(--bg); padding: 8px 0 6px; margin-bottom: 6px; }
.runhead .progress { margin: 4px 0 0; }
.step { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px;
  border-left: 5px solid #c5ced8; scroll-margin-top: 112px; }
#finish-box { scroll-margin-top: 112px; }
.step .shead { display: flex; gap: 10px; align-items: flex-start; padding: 14px 14px 10px; }
.step .num { flex: 0 0 30px; height: 30px; border-radius: 50%; background: #eef1f5; display: flex;
  align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.step .stitle { font-weight: 600; font-size: 1.02rem; }
.step .hint { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.step .sbody { padding: 0 14px 14px; }
.step.locked { opacity: .55; }
.step.locked .sbody { display: none; }
.step.done { border-left-color: var(--ok); }
.step.done.fail { border-left-color: var(--bad); }
.step.done .num { background: var(--ok); color: #fff; }
.step.done.fail .num { background: var(--bad); }
.step.active { border-left-color: var(--primary); box-shadow: 0 0 0 2px #9cbcf5, var(--shadow); }
.step.active .num { background: var(--primary); color: #fff; }
.step .summary { padding: 0 14px 12px 54px; font-size: .92rem; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.choice button { min-height: 60px; border-radius: 12px; border: 2px solid #c9d2dc; background: #fff;
  font: inherit; font-weight: 700; font-size: 1.02rem; cursor: pointer; color: var(--text); }
.choice button.ok.sel { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.choice button.bad.sel { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.mediabar { display: flex; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.mediabar label.btn { margin: 0; font-weight: 600; }
.mediabar input[type=file] { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.thumb { position: relative; width: 86px; height: 86px; border-radius: 10px; overflow: hidden; background: #e4e8ee; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; line-height: 26px; cursor: pointer; }
.thumb .vid { position: absolute; bottom: 3px; left: 3px; background: rgba(0, 0, 0, .6); color: #fff;
  border-radius: 6px; font-size: 11px; padding: 1px 5px; }
.thumb .bar { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--primary); }
.thumb.uploading::after { content: "⏳"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(255, 255, 255, .5); font-size: 22px; }
.err { color: var(--bad); font-weight: 600; margin: 6px 0; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.gallery a img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; display: block; }
.gallery video { width: 240px; max-width: 100%; border-radius: 8px; background: #000; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.login { max-width: 380px; margin: 8vh auto 0; }
.login .logo { text-align: center; margin-bottom: 12px; }
.login .logo img { width: 72px; height: 72px; border-radius: 16px; }

.banner { background: #142a4d; color: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.banner .btn { margin-top: 8px; }

@media (min-width: 900px) {
  .bottomnav { display: none; }
  main { padding-bottom: 40px; }
}
@media print {
  .topbar, .adminnav, .bottomnav, .actions, .noprint { display: none !important; }
  body { background: #fff; }
  .card, .tablewrap, .step { box-shadow: none; border: 1px solid #ddd; }
  main { max-width: none; padding: 0; }
}

/* быстрый выбор срока */
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick .btn.sel { background: var(--primary, #1f6feb); color: #fff; border-color: transparent; }
/* значение вне нормы */
.numwarn { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #fff4e5; color: #8a4b00; font-size: .92rem; }
/* таблица на компьютере, карточки на телефоне */
.only-narrow { display: none !important; }
@media (max-width: 700px) {
  .only-wide { display: none !important; }
  .only-narrow { display: flex !important; }
}
