/* ============================================================
   ColDon Monitor — Стили отдельных экранов
   ============================================================ */

/* ---------- Вход / регистрация ----------------------------- */
.auth {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(120% 100% at 80% 0%, color-mix(in oklch, var(--auth-bg-1) 70%, transparent), transparent 60%),
    linear-gradient(150deg, var(--auth-bg-1), var(--auth-bg-2));
  position: relative; overflow: hidden;
}
.auth::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(91deg, transparent 0 58px, oklch(1 0 0 / 0.05) 58px 60px);
  mask-image: radial-gradient(80% 90% at 70% 10%, #000, transparent 75%);
  pointer-events: none;
}
.auth__card {
  position: relative;
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth__head { padding: 26px 30px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 13px; }
.auth__mark {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
}
.auth__mark svg { width: 24px; height: 24px; }
.auth__title { font-size: 19px; font-weight: 700; line-height: 1.1; }
.auth__subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.auth__body { padding: 26px 30px 28px; }
.auth__h { font-size: 21px; margin-bottom: 18px; }
.auth__form { display: flex; flex-direction: column; gap: 16px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth__foot {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.auth__foot a { font-weight: 600; font-size: 14px; }
.lang {
  position: absolute; bottom: 18px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.lang__btn {
  font-size: 12px; font-weight: 600; color: oklch(1 0 0 / 0.55);
  background: none; border: 1px solid transparent; border-radius: 7px;
  padding: 4px 10px; cursor: pointer; letter-spacing: 0.04em;
}
.lang__btn:hover { color: oklch(1 0 0 / 0.8); }
.lang__btn.is-active,
.lang__btn.active { color: oklch(1 0 0 / 0.95); border-color: oklch(1 0 0 / 0.35); background: oklch(1 0 0 / 0.08); }

/* ---------- Поля (список участков) ------------------------- */
.field-list { display: flex; flex-direction: column; gap: 12px; }
.field-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.field-item__head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; cursor: pointer;
}
.field-item__head:hover { background: var(--surface-2); }
.field-item__icon {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-soft-ink);
  display: grid; place-items: center;
}
.field-item__icon svg { width: 20px; height: 20px; }
.field-item__name { font-size: 16px; font-weight: 600; }
.field-item__meta { font-size: 13px; color: var(--muted); margin-top: 1px; display: flex; gap: 12px; align-items: center; }
.field-item__spacer { flex: 1; }
.field-item__count { font-size: 13px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s ease; flex: none; }
.field-item.is-open .chev { transform: rotate(180deg); }
.field-item__body { padding: 4px 20px 18px; }
.tasks { display: flex; flex-direction: column; gap: 8px; padding-left: 52px; }
.task {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  width: 100%; text-align: left; cursor: pointer;
}
.task:hover { background: var(--surface-3); }
.task__bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--brand); }
.task__bar--done { background: var(--ok); }
.task__bar--pending { background: var(--amber); }
.task__main { flex: 1; min-width: 0; }
.task__name { font-weight: 600; font-size: 14.5px; }
.task__meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.task__status { font-size: 12px; font-weight: 600; }

/* Задача + кнопка параметров урожайности в одну строку. */
.task-row { display: flex; align-items: stretch; gap: 8px; }
.task-row .task { flex: 1; }
/* Кнопки действий (архив/удаление) в строке поля и задачи. */
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.task-row .row-actions { align-items: stretch; }
/* Инлайн-редактор параметров урожайности под задачей. */
.yield-edit {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  margin: 4px 0 6px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.yield-edit .field { margin: 0; }

/* ---------- Карта работ (во всю область контента) --------- */
.map-screen { position: relative; height: 100%; }
/* Полотно Leaflet заполняет всю область. */
.map-screen__canvas { position: absolute; inset: 0; }
/* Подпись имени маркера — постоянный tooltip рядом с пином, без бокса/стрелки. */
.leaflet-tooltip.marker-label {
  background: transparent; border: none; box-shadow: none; padding: 0;
  color: #1a202c; font-weight: 700; font-size: 12.5px;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
.leaflet-tooltip.marker-label::before { display: none; }
/* Кнопка обновления — оверлей в правом верхнем углу поверх карты (непрозрачный фон). */
.map-screen__refresh {
  position: absolute; top: 14px; right: 14px; z-index: 700;
  background: var(--brand); color: var(--brand-ink);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}
.map-screen__refresh:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink); }
.map-screen__refresh:disabled { background: var(--brand); }
/* Индикатор офлайна — оверлей сверху по центру, поверх карты (потеря связи с сервером). */
.map-screen__offline {
  position: absolute; top: 14px; left: 50%; z-index: 700;
  transform: translateX(-50%);
  background: var(--surface); border: 1px solid color-mix(in oklch, var(--amber) 45%, var(--border));
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--amber);
}
/* Легенда — оверлей в нижней части окна карты. */
.map-screen__legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 500;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 10px 13px; display: flex; flex-direction: column; gap: 7px;
  font-size: 12.5px;
}
.map-screen__legend-row { display: flex; align-items: center; gap: 9px; color: var(--ink-2); }
.swatch { width: 16px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
/* Swatch направляющих линий — пунктирный штрих в цвет слоя lineset (#6b46c1). */
.swatch--line { border-radius: 0; height: 0; border-top: 2px dashed #6b46c1; }

/* ---------- Панель слоёв карты (в сайдбаре на странице карты) ---------- */
/* Список слоёв длиннее сайдбара (сводки, линии, погода), а .side высоту не прокручивает —
   отдаём прокрутку самому списку: min-height:0 обязателен, иначе flex-элемент не сжимается
   и переполнение уходит за край. Футер «К полям» остаётся прижатым к низу. */
.map-layers__list {
  display: flex; flex-direction: column; gap: 8px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
}
.map-layers__row { color: var(--side-ink); }
.map-layers__lines {
  display: flex; flex-direction: column; gap: 6px;
  margin: 2px 0 0 26px;   /* отступ под мастер-тумблером линий */
}
.map-layers__empty { color: var(--side-muted); font-size: 13px; padding: 2px 0; }
/* Сводка данных слоя (площадь, тракторы со скоростью) — под чекбоксом своего слоя. */
.map-layers__sub {
  display: flex; flex-direction: column; gap: 4px;
  margin: 2px 0 0 26px;   /* тот же отступ, что у списка линий */
}
.map-layers__sub:empty { display: none; }
.map-layers__info { color: var(--side-muted); font-size: 13px; }

/* ---------- Погода участка (островок в панели слоёв) ---------- */
.weather { display: flex; flex-direction: column; gap: 6px; }
.weather__head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 8px; border: 1px solid var(--side-border); border-radius: var(--radius-sm);
  background: transparent; color: var(--side-ink); font: inherit; font-size: 13px; cursor: pointer;
}
.weather__head:hover { background: var(--side-bg-2); }
.weather__temp { font-weight: 600; }
.weather__muted { color: var(--side-muted); }
.weather__arrow { flex: none; }
.weather__body { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }

/* Развёрнутый прогноз — карточка в левом нижнем углу карты. position: fixed, а не absolute:
   панель слоёв лежит в колонке сайдбара, общего позиционированного родителя с полотном карты
   у неё нет. Отсюда и left по ширине сайдбара (264 px, в теме terminal — 232 px).
   z-index ниже кнопки обновления (700), выше легенды (500) — легенду карточка перекрывает. */
.weather-pop {
  position: fixed; left: 280px; bottom: 16px; z-index: 690;
  width: 330px; max-height: calc(100vh - 110px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  color: var(--ink);
}
/* Внутри карточки фон светлый (поверхность), а не сайдбарный — приглушённый цвет свой. */
.weather-pop .weather__muted, .weather-pop .weather__section { color: var(--muted); }
.weather-pop__head { display: flex; align-items: center; gap: 8px; }
.weather-pop__temp { font-size: 20px; font-weight: 700; }
.weather-pop__title { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; }
.weather-pop__close {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  background: transparent; border: none; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer;
}
.weather-pop__close:hover { background: var(--surface-2); color: var(--ink); }
/* Тема terminal сужает сайдбар — карточка едет следом. */
[data-theme="terminal"] .weather-pop { left: 248px; }
.weather__section { color: var(--side-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.weather__grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; }
/* Почасовая лента: прокрутка внутри панели, наружу не растягивается. */
.weather__hours { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.weather__hour {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: none; min-width: 30px;
}
/* Столбик осадков; высота задаётся инлайн, 0 мм — полоски нет. */
.weather__bar { width: 4px; border-radius: 2px; background: var(--sky); }
.weather__days { display: flex; flex-direction: column; gap: 4px; }
.weather__day { display: grid; grid-template-columns: auto auto 1fr auto; gap: 6px; align-items: center; }
.weather__day > :last-child { grid-column: 3 / -1; }

/* ---------- Аккаунт / настройки ---------------------------- */
.account { display: grid; grid-template-columns: 232px 1fr; gap: 30px; }
.acct-nav { display: flex; flex-direction: column; gap: 3px; }
.acct-nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 0 14px; height: 42px; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 500; color: var(--ink-2);
  background: none; border: none; cursor: pointer; text-align: left; width: 100%;
  text-decoration: none;
}
.acct-nav__item svg { width: 17px; height: 17px; opacity: .7; }
.acct-nav__item:hover { background: var(--surface-2); color: var(--ink); }
.acct-nav__item.is-active,
.acct-nav__item.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.acct-nav__item.is-active svg,
.acct-nav__item.active svg { opacity: 1; }

/* ---------- Витрина тарифов (/billing) --------------------- */
.plan-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
/* Карточки идут в ряд, поэтому вертикальный отступ стопки (.card + .card) здесь лишний:
   иначе вторая и третья съезжают вниз и выглядят ниже первой. */
.plan-grid > .card { flex: 1 1 220px; min-width: 220px; margin-top: 0; }
.plan-grid > .card > .card__body { display: flex; flex-direction: column; gap: 6px; }
.plan-grid ul { margin: 0; padding-left: 18px; }

/* ---------- Переключатель темы (выпадающее меню, верхний правый угол) ---------- */
/* Кнопка вертикально центрирована в верхнем баре (высота бара 64px, кнопка 36px). */
.themer {
  position: relative;
}
.themer__trigger {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 8px;
  border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  color: var(--ink-2); font-size: 13px; font-weight: 600;
  cursor: pointer; list-style: none; user-select: none;
}
.themer__trigger::-webkit-details-marker { display: none; }   /* убрать стандартный треугольник */
.themer__trigger::marker { content: ""; }
.themer__trigger:hover { background: var(--surface-2); color: var(--ink); }
.themer__trigger svg { width: 16px; height: 16px; flex: none; }
.themer__chev { transition: transform .18s ease; opacity: .7; }
.themer[open] .themer__chev { transform: rotate(180deg); }

.themer__menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 168px; z-index: 1100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.themer__btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--ink);
  padding: 9px 12px; border-radius: var(--radius-sm);
}
.themer__btn::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong);
}
.themer__btn:hover { background: var(--surface-2); }
.themer__btn.is-active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.themer__btn.is-active::before { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 2px var(--surface); }

@media (max-width: 920px) {
  .account { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; min-height: 100vh; overflow: visible; }
  [data-theme="terminal"] .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side__spacer { display: none; }
  .scroll { overflow: visible; }
  /* Узкий экран: сайдбар уезжает в строку сверху — карточка во всю ширину у нижнего края. */
  .weather-pop, [data-theme="terminal"] .weather-pop {
    left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 70vh;
  }
}

/* Модальный диалог (настройки урожайности с карты) */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in oklch, black 45%, transparent);
}
.modal {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius, 12px); box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.modal__head { font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.modal__foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal__spacer { flex: 1; }

/* Строка урожайности в панели слоёв: чекбокс + кнопка-шестерёнка справа */
.map-layers__row-yield { display: flex; align-items: center; gap: 4px; }
.map-layers__row-yield .map-layers__row { flex: 1; }
.map-layers__gear {
  display: inline-flex; padding: 4px; border: none; background: transparent;
  color: var(--side-ink); cursor: pointer; border-radius: var(--radius-sm);
}
.map-layers__gear:hover { background: var(--surface-2); color: var(--ink); }
.map-layers__gear svg { width: 16px; height: 16px; }

/* Редактор поля во весь экран: слева — основная панель приложения (.side), справа — карта.
   MainLayout для маршрута .../edit не рисует свой каркас, панель здесь единственная. */
.field-editor { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }
[data-theme="terminal"] .field-editor { grid-template-columns: 232px 1fr; }
.field-editor__side { overflow-y: auto; }
.field-editor__map { position: relative; }
.field-editor__canvas { position: absolute; inset: 0; }

/* Редактор поля: список объектов + плавающий попап (новый механизм). */
.field-editor__objects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.field-editor__object { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--side-border); border-radius: 8px; color: var(--side-ink); cursor: pointer; user-select: none; }
.field-editor__object svg { width: 18px; height: 18px; flex: 0 0 auto; }
.field-editor__object span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-editor__object:hover { border-color: var(--side-brand); }
.field-editor__object.is-active { border-color: var(--side-brand); background: color-mix(in srgb, var(--side-brand) 16%, transparent); }
.field-editor__objects:empty { display: none; }
.field-editor__create { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
/* Кнопки создания в тёмной панели: прозрачный «призрак» под цвет сайдбара. */
.field-editor__create .btn { width: 100%; justify-content: center; background: transparent; color: var(--side-ink); border-color: var(--side-border); }
.field-editor__create .btn:hover:not(:disabled) { background: oklch(1 0 0 / 0.06); border-color: var(--side-brand); color: var(--side-ink); }

.field-editor__popup { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface, #fff); border: 1px solid var(--border, #ddd); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.field-editor__popup-name { min-width: 200px; }
.field-editor__popup-area { font-size: .95rem; white-space: nowrap; }
.field-editor__popup-btns { display: flex; gap: 6px; }

/* Подпись линии на карте */
.fe-line-label { background: var(--surface, #fff); color: var(--text, #222); border: 1px solid var(--brand, #2b6cb0); border-radius: 6px; padding: 1px 6px; font-size: .8rem; font-weight: 600; box-shadow: none; }
.fe-line-label::before { display: none; }
