/* ==========================================================================
   Умная AI-Теплица — тема оформления
   ========================================================================== */

:root {
  --bg: #eef3ea;
  --bg-2: #f7faf5;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --border: rgba(60, 90, 55, 0.14);
  --text: #1f2b1c;
  --text-dim: #5d6b57;
  --accent: #4f9a48;
  --accent-2: #78c257;
  /* Тот же акцент в виде rgb(r, g, b): нужен там, где полупрозрачность
     задаётся в CSS (свечение кнопок, пульсация индикатора связи). */
  --accent-rgb: 79, 154, 72;
  --accent-soft: rgba(79, 154, 72, 0.12);
  --water: #3a9bd9;
  --sun: #e5a72c;
  --danger: #d9564f;
  --warn: #d9913c;
  --warn-rgb: 217, 145, 60;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(35, 60, 30, 0.10);
  --shadow-lg: 0 18px 45px rgba(35, 60, 30, 0.16);
  --grid: rgba(60, 90, 55, 0.12);
}

[data-theme="dark"] {
  --bg: #0e1511;
  --bg-2: #131d17;
  --surface: rgba(28, 40, 32, 0.72);
  --surface-solid: #1a241d;
  --border: rgba(150, 210, 150, 0.14);
  --text: #e8f2e4;
  --text-dim: #9db096;
  --accent: #6fc25f;
  --accent-2: #9ade7a;
  --accent-rgb: 111, 194, 95;
  --accent-soft: rgba(111, 194, 95, 0.16);
  --water: #57b6ef;
  --sun: #f0bb4b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.55);
  --grid: rgba(150, 210, 150, 0.12);
}

/* ===== Красная палитра раздела игр =====
   Включается атрибутом data-palette="red" у <html> (только /games).
   Панель теплицы и служебная консоль остаются в зелёной теме. */
:root[data-palette="red"] {
  --bg: #f2ebea;
  --bg-2: #faf5f4;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --border: rgba(95, 50, 45, 0.14);
  --text: #2a1c1a;
  --text-dim: #6b5854;
  --accent: #c5342b;
  --accent-2: #e8735c;
  --accent-rgb: 197, 52, 43;
  --accent-soft: rgba(197, 52, 43, 0.12);
  --water: #b8404a;
  --sun: #e5903c;
  --shadow: 0 10px 30px rgba(70, 32, 28, 0.10);
  --shadow-lg: 0 18px 45px rgba(70, 32, 28, 0.16);
  --grid: rgba(95, 50, 45, 0.12);
}

:root[data-palette="red"][data-theme="dark"] {
  --bg: #150f0e;
  --bg-2: #1d1413;
  --surface: rgba(46, 29, 27, 0.72);
  --surface-solid: #271a18;
  --border: rgba(235, 160, 150, 0.14);
  --text: #f7eae7;
  --text-dim: #b49a95;
  --accent: #e2554a;
  --accent-2: #ff9075;
  --accent-rgb: 226, 85, 74;
  --accent-soft: rgba(226, 85, 74, 0.16);
  --water: #e0707f;
  --sun: #f0b060;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.55);
  --grid: rgba(235, 160, 150, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 15% -10%, var(--bg-2), var(--bg) 60%);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ===== Декоративный фон ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  animation: float 18s ease-in-out infinite;
}

.orb-1 { width: 420px; height: 420px; background: var(--accent-2); top: -140px; left: -120px; }
.orb-2 { width: 360px; height: 360px; background: var(--water); bottom: -140px; right: -100px; animation-delay: -6s; }
.orb-3 { width: 300px; height: 300px; background: var(--sun); top: 45%; left: 55%; opacity: 0.22; animation-delay: -11s; }

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(20px, -30px, 0) scale(1.08); }
}

/* ===== Каркас ===== */
.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Шапка ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 28px;
  border-radius: 18px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}

.brand-text h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.15;
}

.brand-text p {
  color: var(--text-dim);
  font-size: 13.5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

.status-pill .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(var(--warn-rgb), 0.18);
}

.status-pill.online .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 2s ease-out infinite;
}

.status-pill.err .dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(217, 86, 79, 0.18);
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
  100% { box-shadow: 0 0 0 14px rgba(var(--accent-rgb), 0); }
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: var(--accent);
  color: #fff;
}

/* ===== Навигация ===== */
.tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}

.tab:hover { color: var(--text); background: var(--accent-soft); }

.tab.active {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.32);
}

/* ===== Представления ===== */
.views { display: flex; flex-direction: column; }

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: appear 0.35s ease both;
}

.view[hidden] { display: none; }

@keyframes appear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ===== Показатели ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}

.kpi {
  position: relative;
  padding: 18px 18px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.kpi-temp::before  { background: var(--warn); }
.kpi-moist::before { background: var(--water); }
.kpi-light::before { background: var(--sun); }
.kpi-tank::before  { background: var(--accent-2); }

.kpi-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.kpi-icon { font-size: 15px; }

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 2px;
}

.kpi-value b {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.kpi-value i {
  font-style: normal;
  color: var(--text-dim);
  font-size: 14px;
}

.spark { display: block; width: 100%; height: 46px; }

/* ===== Сетка карточек ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 20px;
}

.card {
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-center { align-items: center; text-align: center; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
}

.badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

.chart { display: block; width: 100%; height: 220px; }

.legend {
  display: flex;
  gap: 18px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.legend span { display: inline-flex; align-items: center; gap: 7px; }

.sw { width: 22px; height: 3px; border-radius: 3px; background: var(--accent); }
.sw-dash {
  background: repeating-linear-gradient(90deg, var(--text-dim) 0 5px, transparent 5px 9px);
}

/* ===== Устройства ===== */
.device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.device.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.device-info { display: flex; align-items: center; gap: 12px; flex: 1 1 150px; min-width: 0; }

.device-icon { font-size: 22px; }

.device-info b { display: block; font-size: 14.5px; font-weight: 600; }
.device-info small { color: var(--text-dim); font-size: 12.5px; }

.device-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.device-actions .btn { white-space: nowrap; }

/* Переключатель */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: rgba(120, 140, 120, 0.28);
  cursor: pointer;
  transition: background 0.25s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: transform 0.25s ease;
}

.switch.on { background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.switch.on::after { transform: translateX(22px); }

/* ===== Кнопки ===== */
.btn {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 22px rgba(var(--accent-rgb), 0.30);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-sm { padding: 7px 13px; font-size: 12.5px; }

.btn-wide { width: 100%; margin-top: auto; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-tight { gap: 6px; }

/* ===== Формы ===== */
.field { display: flex; flex-direction: column; gap: 9px; }
.field[hidden] { display: none; }
.field > span { font-size: 13.5px; color: var(--text-dim); }
.field > span b { color: var(--text); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border: 3px solid var(--surface-solid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface-solid);
  cursor: pointer;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Браузер подсвечивает автозаполнение своим цветом и ломает вид поля:
   возвращаем оформление панели. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-solid) inset;
  box-shadow: 0 0 0 1000px var(--surface-solid) inset;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.check {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== Датчик влажности ===== */
.gauge-wrap { position: relative; width: 180px; height: 180px; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }

.gauge circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.gauge-track { stroke: var(--accent-soft); }

.gauge-value {
  stroke: var(--water);
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s ease;
}

.gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
}

.gauge-text b { font-size: 34px; font-weight: 700; }
.gauge-text i { font-style: normal; color: var(--text-dim); }
.gauge-text small {
  flex-basis: 100%;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
}

.big-number {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.big-number b { font-size: 46px; font-weight: 700; }
.big-number i { font-style: normal; color: var(--text-dim); }

.meter { display: flex; flex-direction: column; gap: 8px; }
.meter-head {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-dim);
}

.meter-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.meter-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--water), var(--accent-2));
  transition: width 0.6s ease;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
  color: var(--text-dim);
}

.stat-row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ===== Режимы ===== */
.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.mode {
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.mode b { display: block; font-size: 16px; margin-bottom: 3px; }
.mode small { color: var(--text-dim); font-size: 12.5px; }
.mode:hover { transform: translateY(-3px); border-color: var(--accent); }

.mode.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== Журнал ===== */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.log-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  background: var(--surface-solid);
  font-size: 13.5px;
}

.log-item.warn { border-left-color: var(--warn); }
.log-item.err  { border-left-color: var(--danger); }

.log-time {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.log-msg { color: var(--text); }

.log-list-full .log-item { border-left-width: 4px; }

.empty {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
}

/* ===== Подвал ===== */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

/* ===== Всплывающие уведомления ===== */
.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
}

.toast {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toast-in 0.3s ease both;
}

.toast.warn { border-left-color: var(--warn); }
.toast.err  { border-left-color: var(--danger); }
.toast.out  { animation: toast-out 0.3s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateX(30px); }
}

.muted { color: var(--text-dim); font-size: 13px; }

/* ===== Участки теплицы (12 секций) ===== */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.zone-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.zone-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.zone-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.zone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.zone-title {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 14.5px; text-align: left;
}

.zone-title b { font-weight: 600; }

.zone-status {
  font-size: 11.5px; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; background: var(--accent-soft); color: var(--text-dim);
}

.zone-status.ok   { color: #2f7d32; }
.zone-status.dry  { background: rgba(58, 155, 217, 0.16); color: #2b7cb0; }
.zone-status.hot  { background: rgba(229, 167, 44, 0.18); color: #b07b12; }
.zone-status.dark { background: rgba(120, 120, 140, 0.18); color: #5a5a72; }

.zone-metrics { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 13px; color: var(--text-dim); }
.zone-metrics b { color: var(--text); font-variant-numeric: tabular-nums; }

.zone-bar { height: 7px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.zone-bar span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--water), var(--accent));
  transition: width 0.4s ease;
}

.zone-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.zone-actions .btn { flex: 1 1 auto; }

.switch-sm { width: 40px; height: 22px; flex: 0 0 auto; }
.switch-sm::after { width: 16px; height: 16px; }
.switch-sm.on::after { transform: translateX(18px); }

#pwa-install[hidden] { display: none; }
body.pwa-standalone .app { padding-top: max(18px, env(safe-area-inset-top)); }

/* ===== Вход в аккаунт и профиль ===== */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: radial-gradient(900px 500px at 20% -10%, var(--bg-2), var(--bg) 65%);
  backdrop-filter: blur(6px);
}

.login-gate[hidden] { display: none; }

body.auth-locked .app { filter: blur(3px); pointer-events: none; user-select: none; }

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  color: var(--accent);
}

.login-card h2 { font-size: 21px; }
.login-card .muted { font-size: 13px; }
.login-hint { font-size: 12.5px; }

.login-error {
  font-size: 13px;
  color: var(--danger);
  background: rgba(217, 86, 79, 0.12);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.login-error[hidden] { display: none; }
.login-card .btn[disabled] { opacity: 0.6; cursor: default; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  font-size: 13px;
  font-weight: 500;
}

.user-pill[hidden] { display: none; }
.user-pill.admin { border-color: var(--accent); color: var(--accent); }
.user-pill #user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link-btn {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}

/* ===== Гостевой режим ===== */
.limit-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(217, 145, 60, 0.35);
  background: rgba(217, 145, 60, 0.12);
  font-size: 14px;
}

.limit-banner[hidden] { display: none; }
.limit-banner > span:nth-child(2) { flex: 1 1 220px; }

.limit-banner.flash { animation: limit-flash 0.9s ease 2; }

@keyframes limit-flash {
  0%, 100% { background: rgba(217, 145, 60, 0.12); }
  50%      { background: rgba(217, 145, 60, 0.32); }
}

/* Заблокированные в гостевом режиме элементы остаются видимыми,
   чтобы было понятно, что откроется после входа в аккаунт. */
body.limited .modes .mode,
body.limited .switch,
body.limited .btn.blocked {
  opacity: 0.5;
}

body.limited .modes .mode,
body.limited .btn.blocked { cursor: not-allowed; }

body.limited .modes .mode.active {
  outline: 1px dashed var(--border);
}

/* ===== Адаптивность ===== */
@media (max-width: 760px) {
  .app { padding: 18px 14px 32px; }
  .kpi-value b { font-size: 28px; }
  .brand-text h1 { font-size: 24px; }
  .topbar { gap: 12px; }
  .toasts { left: 14px; right: 14px; max-width: none; }
  .zone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .zone-card { padding: 11px; }
  .zone-metrics { font-size: 12px; gap: 6px 10px; }
  .zone-actions .btn { padding: 7px 9px; font-size: 12px; }
}

@media (max-width: 380px) {
  .zone-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}