:root {
  --bg: #0d0f12;
  --card: #15181e;
  --card2: #1b1f27;
  --border: #262b34;
  --text: #e6e9ee;
  --muted: #8b93a1;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --accent: #6ea8fe;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

#layout { min-height: 100dvh; }

#view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

/* ---------- статусбар offline/pending ---------- */
#statusbar {
  position: sticky;
  top: 0;
  z-index: 50;
  text-align: center;
  font-size: 13px;
  padding: 6px 12px;
  background: #3a2d12;
  color: var(--yellow);
  border-bottom: 1px solid #4d3c17;
}

/* ---------- нижняя навигация ---------- */
#nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  background: rgba(16, 18, 23, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav[hidden] { display: none; }
#nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
}
#nav a .ico { font-size: 17px; line-height: 1; }
#nav a.active { color: var(--text); }
#nav a.nav-impulse.active, #nav a.nav-impulse { color: var(--red); }
#nav a.nav-impulse:not(.active) { opacity: .85; }

/* ---------- desktop: sidebar ---------- */
@media (min-width: 900px) {
  #layout { display: flex; }
  #nav {
    position: sticky;
    top: 0;
    bottom: auto;
    flex-direction: column;
    width: 200px;
    height: 100dvh;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 24px 8px;
    gap: 4px;
    justify-content: flex-start;
  }
  #nav a {
    flex: none;
    flex-direction: row;
    gap: 12px;
    font-size: 15px;
    padding: 12px 16px;
    border-radius: 10px;
  }
  #nav a.active { background: var(--card2); }
  #view { flex: 1; padding-bottom: 32px; }
}

/* ---------- карточки и типографика ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ---------- состояние дня ---------- */
.state-banner {
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  border: 1px solid;
}
.state-banner .state-name { font-size: 26px; font-weight: 800; letter-spacing: 1px; }
.state-banner .verdict { margin-top: 8px; font-size: 15px; line-height: 1.45; }
.state-GREEN { background: #10241c; border-color: #1d5c43; color: var(--green); }
.state-YELLOW { background: #2a2210; border-color: #6b5416; color: var(--yellow); }
.state-RED { background: #2b1414; border-color: #7f2a2a; color: var(--red); }
.state-UNKNOWN { background: var(--card); border-color: var(--border); color: var(--muted); }
.state-banner .verdict, .state-banner .note { color: var(--text); }
.state-banner .note { font-size: 13px; color: var(--muted); margin-top: 6px; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill-GREEN { background: #123a2b; color: var(--green); }
.pill-YELLOW { background: #3a2d12; color: var(--yellow); }
.pill-RED { background: #3a1616; color: var(--red); }

/* ---------- сетка метрик ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric {
  background: var(--card2);
  border-radius: 10px;
  padding: 10px 12px;
}
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 16px; font-weight: 600; margin-top: 2px; }

/* ---------- кнопки ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn-danger { background: #a03030; border-color: #b54040; color: #fff; }
.btn-primary { background: #274a86; border-color: #3560a8; color: #fff; }
.btn-green { background: #1d5c43; border-color: #27775a; color: #fff; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-big { padding: 20px; font-size: 18px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- формы ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="time"], input[type="date"], input[type="number"], input[type="password"], textarea, select {
  width: 100%;
  padding: 12px;
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* сегментированный выбор */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: inline-block;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card2);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.seg input:checked + span { background: #274a86; border-color: #3560a8; color: #fff; }

/* шкалы 1-5 / 1-10 */
.scale { display: flex; gap: 5px; }
.scale label { flex: 1; position: relative; }
.scale input { position: absolute; opacity: 0; inset: 0; }
.scale span {
  display: block;
  text-align: center;
  padding: 11px 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card2);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.scale input:checked + span { background: #274a86; border-color: #3560a8; color: #fff; font-weight: 700; }

/* чекбоксы чек-листа */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card2);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.35;
}
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--green); flex-shrink: 0; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; font-size: 15px; }
.switch input { width: 22px; height: 22px; accent-color: var(--green); }

/* ---------- таймер протокола ---------- */
.timer {
  text-align: center;
  font-size: 64px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin: 18px 0;
}
.protocol-phrase {
  font-size: 17px;
  line-height: 1.5;
  padding: 16px;
  background: var(--card2);
  border-left: 3px solid var(--red);
  border-radius: 10px;
  margin-bottom: 16px;
}

/* ---------- списки ---------- */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.list-item:last-child { border-bottom: none; }
.list-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.statrow { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.statrow:last-child { border-bottom: none; }
.statrow .sv { font-weight: 700; }

/* ---------- баннеры ---------- */
.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.45;
  border: 1px solid;
}
.banner-red { background: #2b1414; border-color: #7f2a2a; }
.banner-green { background: #10241c; border-color: #1d5c43; }
.banner-yellow { background: #2a2210; border-color: #6b5416; }

ul.plain { margin: 6px 0 0; padding-left: 18px; }
ul.plain li { margin-bottom: 4px; font-size: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #262b34;
  border: 1px solid #333a45;
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
@media (min-width: 900px) { #toast { bottom: 28px; } }

/* login */
.login-wrap { max-width: 360px; margin: 18vh auto 0; }
.login-logo { text-align: center; font-size: 40px; margin-bottom: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs .btn { margin-bottom: 0; padding: 11px; font-size: 14px; }
.tabs .btn.active { background: #274a86; border-color: #3560a8; color: #fff; }
