/* РЕН Лаборатория — мобильная PWA. Только системный шрифт, без hover-зависимостей. */
:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6573;
  --line: #dde3ea;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d9f0ec;
  --danger: #b91c1c;
  --danger-soft: #fde8e8;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --field: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #141d2e;
    --text: #e6edf7;
    --muted: #97a3b6;
    --line: #26324a;
    --accent: #2dd4bf;
    --accent-ink: #062a27;
    --accent-soft: #123a37;
    --danger: #f87171;
    --danger-soft: #3b1515;
    --ok: #4ade80;
    --ok-soft: #113220;
    --warn: #fbbf24;
    --warn-soft: #3a2a08;
    --field: #0f172a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden; overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  min-height: calc(56px + var(--sat));
  padding: var(--sat) var(--sar) 0 var(--sal);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.top-title { text-align: center; font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 52px; height: 56px; border: 0; background: transparent; font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--accent);
}
.icon-btn:active { opacity: .6; }
.icon-btn[hidden] { display: flex; visibility: hidden; }

/* Контент */
.main {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 16px calc(16px + var(--sar)) calc(24px + var(--sab)) calc(16px + var(--sal));
}
.screen { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 15px; }
.center { text-align: center; }
.hero { text-align: center; padding: 18px 0 4px; }
.hero .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 12px; display: block; }
.hero h1 { margin: 0; font-size: 26px; }
.hero p { margin: 6px 0 0; color: var(--muted); }

/* Поля — не меньше 16px, чтобы iOS не зумил; цели ≥ 48px */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 15px; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--field); font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); opacity: .8; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-clear { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; color: var(--muted); border-radius: 12px; }
.input-clear[hidden] { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px; background-size: 6px 6px; background-repeat: no-repeat; }

/* Сегмент пола */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 52px; border: 0; background: var(--field); font-size: 17px; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* Кнопки */
.btn {
  min-height: 52px; padding: 12px 18px; border-radius: 14px; border: 0; font-weight: 700; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; width: 100%;
  text-decoration: none;
}
.btn:active { transform: scale(.985); opacity: .9; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--accent-soft); color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-big { min-height: 60px; font-size: 18px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Списки */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  min-height: 60px; padding: 12px 14px; border-radius: 12px; background: var(--card);
  border: 1.5px solid var(--line); text-align: left; width: 100%; cursor: pointer;
}
.item:active { background: var(--accent-soft); }
.item.sel { border-color: var(--accent); background: var(--accent-soft); }
.item > span:first-child { min-width: 0; }
.item .t { display: block; font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.item .s { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.item .chev { color: var(--muted); font-size: 24px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--text); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.section-title { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 -4px; }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); }

/* Сводка выбранного */
.crumbs { display: flex; flex-direction: column; gap: 6px; }
.crumb { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line); }
.crumb .k { color: var(--muted); font-size: 14px; min-width: 64px; }
.crumb .v { font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.crumb button { min-height: 48px; min-width: 72px; border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 15px; padding: 0 6px; }

/* Зона выбора файла */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 16px; text-align: center; background: var(--card);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.drop .big { font-size: 44px; line-height: 1; }
.drop.has { border-style: solid; border-color: var(--accent); }
.file-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.file { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--bg); font-size: 15px; }
.file .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .z { color: var(--muted); flex-shrink: 0; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* Прогресс */
.progress-wrap { text-align: center; padding: 8px 0; }
.progress-pct { font-size: 64px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.progress-stage { font-size: 18px; margin-top: 4px; }
.bar { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 16px 0 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; border-radius: 999px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.step { font-size: 13px; color: var(--muted); padding: 8px 4px; border-radius: 10px; background: var(--bg); text-align: center; }
.step.on { background: var(--accent-soft); color: var(--text); font-weight: 700; }
.step.done { background: var(--ok-soft); color: var(--ok); font-weight: 700; }

/* Итог */
.done-icon { width: 96px; height: 96px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 56px; display: flex; align-items: center; justify-content: center; margin: 4px auto 10px; }
.err-icon { background: var(--danger-soft); color: var(--danger); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 16px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; overflow-wrap: anywhere; }

/* Тост */
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 16px; z-index: 50; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }

/* Подсказка установки */
.install-hint { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)); z-index: 40; }
.install-hint[hidden] { display: none; }
.install-card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.install-text { font-size: 15px; }
.install-actions { display: flex; gap: 8px; }
.install-actions .btn { min-height: 48px; }

/* Нижний лист (меню) */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 18px 18px 0 0; padding: 12px 16px calc(16px + var(--sab)); display: flex; flex-direction: column; gap: 8px; max-width: 640px; margin: 0 auto; max-height: 92dvh; overflow-y: auto; }
.sheet-body .btn { justify-content: flex-start; min-height: 50px; flex-shrink: 0; }
@media (max-height: 480px) { .sheet-body { gap: 6px; padding-top: 8px; } .sheet-body .btn { min-height: 46px; padding: 8px 14px; } .sheet-body .muted { display: none; } }

/* Планшет: две колонки */
@media (min-width: 760px) {
  .main { max-width: 1080px; padding: 20px 24px calc(28px + var(--sab)); }
  .screen.two { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
  .screen.two .col-side { position: sticky; top: calc(56px + var(--sat) + 16px); }
  .hero h1 { font-size: 30px; }
  .card { padding: 20px; }
  .login-wrap { max-width: 460px; margin: 0 auto; }
  .list.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
}
/* Ландшафт телефона: ужать шапку и герой */
@media (max-height: 480px) and (orientation: landscape) {
  .hero { padding: 6px 0 0; }
  .hero .logo { width: 48px; height: 48px; margin-bottom: 4px; }
  .hero h1 { font-size: 20px; }
  .progress-pct { font-size: 44px; }
}
