/* Дизайн по образцу sagsales.uz: тёплый светлый фон, тёмно-синий текст, синие кнопки-пилюли, крупные скруглённые карточки */
:root {
  --bg: #faf9f7;
  --surface: #fff;
  --ink: #01091c;
  --muted: #6b7280;
  --brand: #0052d2;
  --brand-hover: #0042aa;
  --brand-tint: #eef3fd;
  --border: #d5d5d5;
  --radius: 26px;
  --shadow: -2px 2px 4px -1px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(1, 9, 28, 0.05);
  /* прежние имена — чтобы остальные страницы подхватили новую палитру */
  --tile: var(--surface);
  --text: var(--ink);
  --head: var(--brand);
  --line: var(--border);
  --red: #f6cdd4;
  --red-text: #7a2a37;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Gilroy, Montserrat, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }

.container { width: 100%; max-width: 1270px; margin: 0 auto; padding: 0 32px; }

/* ---------- Шапка ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--border); }
.header-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; min-height: 76px; }
.logo { justify-self: start; line-height: 0; cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.logo img { display: block; height: 36px; width: auto; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.main-nav { display: flex; gap: 34px; }
.main-nav a { padding: 8px 0; border-bottom: 2px solid transparent; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; transition: color 0.15s, border-color 0.15s; }
.main-nav a:hover { color: var(--brand); }
.main-nav a.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 14px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.btn:hover { background: var(--brand-hover); }
.btn:focus-visible { outline: 3px solid rgba(0, 82, 210, 0.35); outline-offset: 2px; }
.btn-sm { height: 38px; padding: 0 20px; font-size: 14px; }
.btn-lg { height: 56px; padding: 0 36px; font-size: 16px; }
.btn-light { background: #fff; color: var(--brand); }
.btn-light:hover { background: #eaf1ff; transform: translateY(-1px); }

/* переключатели (в «Плане»): светлые кнопки, активная — синяя */
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--brand); color: var(--brand); }
.pill:focus-visible { outline: 3px solid rgba(0, 82, 210, 0.35); outline-offset: 2px; }
.pill.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill-sm { padding: 7px 18px; font-size: 13px; }

/* ---------- Поиск ---------- */
.search { position: relative; width: 300px; max-width: 100%; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 46px 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: #8b909c; }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 82, 210, 0.15); }
.search button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.search button:hover { background: var(--brand-hover); }
.search button:focus-visible { outline: 3px solid rgba(0, 82, 210, 0.35); outline-offset: 2px; }

/* ---------- Структура: Planning / Production, участки, станки ---------- */
.item-titles { min-width: 0; }
.crumbs { margin-bottom: 4px; font-size: 12px; color: #6d6d78; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- Статус данных ---------- */
.status {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  min-height: 18px;
  padding: 0 24px;
  font-size: 12px;
  color: #6d6d78;
}
.status-warn {
  padding: 3px 10px;
  border-radius: 4px;
  background: #fdf0c8;
  color: #6b4a00;
  font-weight: 700;
}

/* ---------- Плитки-карточки ---------- */
main.container { padding-top: 32px; padding-bottom: 72px; }

.home-title { margin: 8px 0 20px; font-size: 30px; font-weight: 700; color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}
.tile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(1, 9, 28, 0.12); }
.tile:focus-visible { outline: 3px solid rgba(0, 82, 210, 0.45); outline-offset: 3px; }
.tile-code {
  display: grid;
  place-items: center;
  min-height: 132px;
  background: linear-gradient(135deg, #eaf1ff, #d9e6ff);
  font-size: 30px;
  font-weight: 700;
  color: var(--brand);
}
.tile-name { padding: 14px 18px 16px; font-size: 15px; font-weight: 500; color: var(--ink); }

.empty { text-align: center; color: var(--muted); margin-top: 60px; }

/* ---------- Страница станка: таблица ---------- */
.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 18px;
}
.item-title { margin: 0; font-size: 30px; font-weight: 700; color: var(--ink); }
.back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 26px;
  line-height: 1;
  color: var(--brand);
  text-decoration: none;
}
.back:hover { background: var(--brand-tint); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}
.sheet {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
  text-align: center;
}
.sheet th, .sheet td { border: 1px solid var(--border); padding: 11px 14px; white-space: nowrap; }
.sheet tr > :first-child { border-left: 0; }
.sheet tr > :last-child { border-right: 0; }
.sheet thead tr:first-child th { border-top: 0; }
.sheet tbody tr:last-child td { border-bottom: 0; }
.sheet th { background: var(--head); color: #fff; font-weight: 600; }
.sheet tbody tr { transition: background 0.12s; }
.sheet tbody tr:hover { background: var(--brand-tint); }
.sheet tr.is-empty td { background: var(--red); color: var(--red-text); }
.sheet td.date { font-variant-numeric: tabular-nums; }
.sheet tr.is-today td { background: var(--brand-tint); font-weight: 700; }
.sheet tr.is-past td { color: var(--muted); } /* история: видно, что это уже прошло */

/* Раскрытие/закрытие строк истории анимирует Motion (motion.dev) настоящей пружиной —
   см. app.js. CSS тут не нужен: Motion сам ставит opacity/transform через WAAPI. */

.sheet .toggle-cell { text-align: center; background: #fff; }
.toggle-past {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--brand);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.toggle-past:hover .toggle-label { text-decoration: underline; }
.toggle-past:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.toggle-chev {
  display: inline-block;
  font-size: 15px;
  line-height: 1;
  transform: rotate(90deg);   /* «« повёрнуто на 90° — смотрит вверх, свёрнуто */
  transition: transform 0.25s ease;
}
.toggle-past.is-open .toggle-chev { transform: rotate(-90deg); } /* смотрит вниз, раскрыто */
@media (prefers-reduced-motion: reduce) {
  .toggle-chev { transition: none; }
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .header-row { grid-template-columns: 1fr auto; grid-template-areas: "logo login" "nav nav" "search search"; gap: 6px 16px; padding: 10px 0 12px; min-height: 0; }
  .logo { grid-area: logo; }
  .header-actions { display: contents; }
  .header-actions > .btn { grid-area: login; justify-self: end; }
  .header-actions .search { grid-area: search; width: 100%; }
  .main-nav { grid-area: nav; justify-content: center; gap: 26px; }
}
@media (max-width: 560px) {
  .container { padding: 0 16px; }
  main.container { padding-top: 20px; padding-bottom: 40px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .tile-code { min-height: 104px; font-size: 26px; }
  .home-title { font-size: 24px; }
  .item-title { font-size: 24px; }
}

/* ---------- Страница «% выполнения» ---------- */
:root { --alert: #d0566b; --track: #d9dbe8; }


.page { max-width: 1000px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-title { margin: 0; font-size: 30px; font-weight: 700; color: var(--ink); }
.page-sub { font-size: 13px; color: #6d6d78; }

.card {
  padding: 24px 28px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.card + .card, .card + .section-title, .grid + .note { margin-top: 28px; }
.card-title { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: #4b4b57; text-transform: uppercase; letter-spacing: 0.02em; }
.section-title { margin: 34px 0 16px; font-size: 13px; font-weight: 700; color: #4b4b57; text-transform: uppercase; letter-spacing: 0.02em; }

.hero { display: flex; align-items: center; gap: 36px; }
.hero .ring { flex: none; width: 168px; height: 168px; }
.hero-info { flex: 1; min-width: 0; }
.hero-line { margin: 0 0 6px; font-size: 15px; color: var(--text); }
.hero-line b { color: var(--brand); }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 24px; margin-top: 16px; }
.fact-label { display: block; font-size: 11px; font-weight: 700; color: #6d6d78; text-transform: uppercase; }
.fact-value { display: block; margin-top: 2px; font-size: 20px; font-weight: 700; color: var(--brand); }
.fact-value.is-low { color: var(--alert); }
.fact-note { display: block; margin-top: 1px; font-size: 12px; color: #6d6d78; }

.ring { display: block; }
.ring-track { fill: none; stroke: var(--track); }
.ring-fill { fill: none; stroke: var(--brand); stroke-linecap: round; }
.is-low .ring-fill { stroke: var(--alert); }
.ring-text { font-family: Arial, Helvetica, sans-serif; font-weight: 700; fill: var(--brand); text-anchor: middle; dominant-baseline: central; }
.is-low .ring-text { fill: var(--alert); }

.chart { display: block; width: 100%; height: auto; }
.chart text { font-family: Arial, Helvetica, sans-serif; font-size: 10px; fill: #6d6d78; }
.chart .bar { fill: var(--brand); }
.chart .bar.is-low { fill: var(--alert); }
.chart .bar:hover { opacity: 0.75; }
.chart .grid-line { stroke: #c9cbd8; stroke-width: 1; }
.chart .plan-line { stroke: var(--brand); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.7; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: 12px; color: #6d6d78; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; background: var(--brand); vertical-align: -1px; }
.legend i.low { background: var(--alert); }
.legend i.line { height: 0; border-top: 1px dashed var(--brand); border-radius: 0; background: none; vertical-align: 3px; }

.grid-exec { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 1000px; gap: 26px; }
.exec-tile { align-items: center; text-align: center; gap: 4px; padding: 22px 12px 20px; }
.exec-tile .ring { width: 96px; height: 96px; margin-bottom: 6px; }
.exec-tile .tile-code { min-height: 0; background: none; font-size: 22px; }
.exec-tile .tile-meta { font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; }
.kpis .card { margin-top: 0; padding: 16px 20px; }
.kpis + .card { margin-top: 28px; }
.warn { margin-top: 18px; padding: 12px 16px; border-radius: 12px; background: #fdf0c8; color: #6b4a00; font-size: 13px; line-height: 1.45; }
.warn p { margin: 0; }
.warn + .card { margin-top: 18px; }

.sheet td.notes { max-width: 420px; text-align: left; white-space: normal; }
.sheet td.num { font-variant-numeric: tabular-nums; }
.pct-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pct-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.pct-bar span { display: block; height: 100%; background: var(--brand); }
.pct-val { min-width: 46px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet tr.is-low .pct-bar span { background: var(--alert); }
.sheet tr.is-low .pct-val { color: var(--alert); }
.sheet th.left, .sheet td.name { text-align: left; }
.sheet td.name { font-weight: 600; }

/* ---------- «Производство» ---------- */
.prod-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.prod-tab {
  padding: 9px 22px; border: 1px solid var(--border); border-radius: 999px; background: #fff;
  color: var(--ink); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.prod-tab:hover { border-color: var(--brand); color: var(--brand); }
.prod-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.prod-page { max-width: 1100px; }
.prod-brigade-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 24px; }
.prod-brigade-tab {
  padding: 6px 16px; border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.prod-brigade-tab:hover { border-color: var(--brand); color: var(--brand); }
.prod-brigade-tab.is-active { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.prod-brigade + .prod-brigade { margin-top: 40px; }
.prod-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-top: 18px; align-items: stretch; }
@media (max-width: 1000px) { .prod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .prod-grid { grid-template-columns: 1fr; } }
.prod-grid > .prod-card { padding: 18px 16px; }
.prod-card { display: flex; flex-direction: column; height: 100%; }
.prod-grid > .card + .card { margin-top: 0; } /* общее правило «.card + .card» давало ступеньки в сетке */
.prod-card-name { margin: 0 0 14px; font-size: 17px; font-weight: 700; color: var(--ink); }

/* Карточка станка на странице «Производство»: название и общий % в шапке, под ней график
   по дням (столбик — % за день), ось % слева, числа месяца снизу, красная линия среднего. */
.prod-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.prod-card-head .prod-card-name { margin: 0; }
.prod-card-pct { font-size: 20px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.prod-card.is-low .prod-card-pct { color: var(--alert); }
.trend-svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-svg rect.bar { fill: var(--brand); }
.trend-svg rect.bar-low { fill: var(--alert); }
.trend-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.trend-svg .axis-y, .trend-svg .axis-x { font-size: 8.5px; fill: var(--muted); font-family: inherit; }
.trend-svg .avg-line-halo { fill: none; stroke: #fff; stroke-width: 3.2; }
.trend-svg .avg-line { fill: none; stroke: #e8291b; stroke-width: 1.3; }

/* Прежний индикатор-полоса — остаётся на табло (board.js). */
.prod-gauge { display: flex; align-items: center; gap: 14px; }
.prod-gauge-bar { flex: 1; height: 14px; border-radius: 999px; background: var(--track); overflow: hidden; }
.prod-gauge-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #4e8dff); transition: width 0.3s ease; }
.prod-gauge-val { flex: none; min-width: 72px; text-align: right; font-size: 26px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.prod-card.is-low .prod-gauge-bar span { background: linear-gradient(90deg, var(--alert), #e38a98); }
.prod-card.is-low .prod-gauge-val { color: var(--alert); }

.prod-stats { display: grid; grid-template-columns: 1.15fr 1.15fr 0.95fr; gap: 6px; margin-top: 16px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.prod-stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.prod-stat .fact-value { font-size: 12.5px; white-space: nowrap; }

.prod-targets { margin-top: 16px; flex: 1; display: flex; flex-direction: column; }
.prod-targets-title { font-size: 11px; font-weight: 700; color: #6d6d78; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 10px; }
.prod-target-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.target-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px; border-radius: 10px; background: var(--brand-tint); }
.target-chip-pct { font-size: 12px; font-weight: 700; color: var(--ink); }
.target-chip-val { font-size: 12.5px; font-weight: 700; color: var(--brand); }
.target-chip.is-ok { background: #e4f6ec; }
.target-chip.is-ok .target-chip-val { color: #1a9c5a; }

/* ---------- Сотрудники (вкладка «Производства») ---------- */
.prod-employees-brigade + .prod-employees-brigade { margin-top: 36px; }

/* ---------- Табло «Производство» (монитор в цеху) ---------- */
body.board { background: var(--page-bg, #f4f3ef); }
.board-bar { display: flex; align-items: center; justify-content: space-between; padding: 2vh 3vw 0; }
.board-logo { height: clamp(32px, 4.5vh, 52px); }
.board-exit { font-size: 13px; color: var(--muted); text-decoration: none; }
.board-exit:hover { color: var(--brand); text-decoration: underline; }
.board-main { padding: 2vh 3vw 4vh; max-width: 1600px; margin: 0 auto; }
.board-brigade + .board-brigade { margin-top: 5vh; }
.board-brigade-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.board-brigade-head .section-title { margin: 0; font-size: clamp(16px, 2.2vh, 24px); }
.board-brigade-pct { font-size: clamp(24px, 3.4vh, 40px); font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.board-brigade-pct.is-low { color: var(--alert); }
.board-cols { display: grid; grid-template-columns: 2.2fr 1fr; gap: 28px; margin-top: 2vh; align-items: start; }
.board-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: 0; }
.board-grid .prod-card-name { font-size: clamp(16px, 1.8vh, 20px); margin-bottom: 10px; }
.board-grid .prod-gauge-val { font-size: clamp(18px, 2.2vh, 26px); }
.board-grid .prod-stats { margin-top: 10px; padding: 10px 0; }
.board-employees { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; }
.board-emp-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.board-emp-row:last-child { border-bottom: 0; }
.board-emp-name { font-weight: 600; color: var(--ink); }
.board-emp-pct { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.board-emp-row.is-low .board-emp-pct { color: var(--alert); }
.board-emp-m { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .board-cols { grid-template-columns: 1fr; }
}

.note { margin-top: 28px; font-size: 12px; line-height: 1.5; color: #6d6d78; }
.error { text-align: center; color: var(--red-text); margin-top: 60px; }

@media (max-width: 860px) {
  .grid-exec { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
}
@media (max-width: 560px) {
  .card { padding: 16px; }
  .hero { flex-direction: column; text-align: center; gap: 16px; }
  .hero .ring { width: 140px; height: 140px; }
  .hero-facts { text-align: left; }
  .page-head { flex-direction: column; gap: 4px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpis .card { padding: 12px 14px; }
  .fact-value { font-size: 17px; }
  .page-title { font-size: 26px; }
  .grid-exec { gap: 12px; }
  .exec-tile { padding: 14px 6px; }
  .exec-tile .ring { width: 76px; height: 76px; }
}

/* ---------- Вход администратора ---------- */
.login-card { max-width: 440px; margin: 40px auto 0; }
.login-card .item-title { font-size: 26px; }
.login-card .btn { margin-top: 4px; }
.login-card .page-sub { margin: 8px 0 20px; }
.field { display: block; }
.field input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  font-size: 16px;
}
.field input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
}
.field select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field + .field { margin-top: 14px; }
.login-error { min-height: 20px; margin: 10px 0; font-size: 13px; color: var(--alert); }
.btn-block { width: 100%; }

/* ---------- Настройки (источник данных) ---------- */
.settings-card { max-width: 560px; }
.settings-card form { margin-top: 14px; }
.settings-status { margin: 0; font-size: 13px; color: var(--muted); }
.field input[type="file"] {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
}
.field-msg { min-height: 20px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.field-msg.is-ok { color: var(--brand); font-weight: 600; }
.field-msg.is-err { color: var(--alert); }
.settings-card .note { margin-top: 14px; }

/* Видимость участков/станков: дерево строк с переключателями в стиле iOS */
.visibility-card { max-width: 560px; }
.visibility-card .note { margin-top: 16px; }
.vis-section + .vis-section { margin-top: 4px; border-top: 1px solid var(--border); }
.vis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}
.vis-section-row .vis-name { font-weight: 700; color: var(--ink); }
.vis-name { font-size: 14px; color: var(--ink); }

/* Станки внутри участка — в ряд компактными чипами, переносятся по ширине, а не длинным списком */
.vis-machines {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 2px 0 14px 20px;
  transition: opacity 0.15s ease;
}
.vis-machines.is-off { opacity: 0.45; }
.vis-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}
.vis-chip .vis-name { font-size: 13px; white-space: nowrap; }

/* Список бригад «Производства»: название+статус слева, удаление справа */
.brig-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.brig-item:last-child { border-bottom: 0; }
#brig-list:not(:empty) { margin-bottom: 18px; }
.brig-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.brig-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.brig-del { flex: none; border: 0; background: none; padding: 6px 2px; color: var(--alert); font-family: inherit; font-size: 13px; cursor: pointer; }
.brig-del:hover { text-decoration: underline; }

/* Переключатель: как в iOS — овальный трек, кружок бегает туда-сюда */
.switch {
  flex: none;
  position: relative;
  width: 46px;
  height: 27px;
  border: 0;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.switch[aria-checked="true"] .switch-thumb { transform: translateX(19px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-sm { width: 34px; height: 20px; }
.switch-sm .switch-thumb { width: 16px; height: 16px; }
.switch-sm[aria-checked="true"] .switch-thumb { transform: translateX(14px); }


/* Панель «Сохранить / Отмена» в настройках: появляется снизу, когда есть несохранённые переключатели */
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 12px 0; background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(1, 9, 28, 0.08); }
.save-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 32px; }
.save-bar-text { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; color: var(--ink); }
.save-bar-msg { font-size: 12.5px; font-weight: 500; color: var(--alert); }
.save-bar-actions { display: flex; gap: 10px; flex: none; }
.save-cancel { border: 1px solid var(--border); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* Подробности дня и вкладка «Подробно» (таблица смен как в исходном документе) */
.trend-svg .bar-hit { fill: transparent; cursor: pointer; outline: none; }
.trend-svg .bar-hit:hover, .trend-svg .bar-hit:focus-visible { fill: rgba(0, 82, 210, 0.1); }
.trend-svg .avg-line, .trend-svg .avg-line-halo { pointer-events: none; }
.detail-sheet td.date { vertical-align: top; background: var(--brand-tint); font-variant-numeric: tabular-nums; }
.detail-sheet td.notes { min-width: 120px; max-width: 260px; }
.detail-sheet td.low-pct { color: var(--alert); font-weight: 700; }
.detail-sheet tr.is-low td:not(.date) { background: #fdf2f4; }
.detail-sheet tfoot td { border-top: 2px solid var(--brand); background: var(--brand-tint); font-weight: 700; }
.prod-details-brigade + .prod-details-brigade { margin-top: 40px; }
.prod-machine-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.prod-machine-tab {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: #fff;
  color: var(--ink); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.prod-machine-tab:hover { border-color: var(--brand); color: var(--brand); }
.prod-machine-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(1, 9, 28, 0.45); }
.modal-box { width: 100%; max-width: 960px; max-height: 88vh; overflow: auto; padding: 24px 28px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.modal-sub { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.modal-title { margin: 2px 0 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.modal-close { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--brand-tint); color: var(--brand); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close:hover { background: #dbe7fd; }
.modal-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-stats .fact-value { font-size: 17px; }
.detail-sheet th, .detail-sheet td { padding: 9px 10px; font-size: 13px; }

/* Таблицы подробностей вписываются в ширину окна: заголовки и текст переносятся на новую строку,
   числа и дата — нет; горизонтальная прокрутка остаётся только на совсем узких экранах. */
.detail-sheet { table-layout: auto; width: 100%; }
.detail-sheet th, .detail-sheet td { white-space: normal; padding: 8px 6px; font-size: 12.5px; line-height: 1.3; overflow-wrap: anywhere; }
.detail-sheet th { vertical-align: middle; }
.detail-sheet td.num, .detail-sheet td.date { white-space: nowrap; overflow-wrap: normal; }
.detail-sheet td.notes { min-width: 0; max-width: none; text-align: left; }
.detail-sheet td.name { white-space: nowrap; overflow-wrap: normal; }
.detail-sheet .lbl-short { display: none; }
.detail-sheet .note-line { display: none; }
@media (max-width: 700px) {
  .detail-sheet th, .detail-sheet td { padding: 6px 4px; font-size: 11.5px; overflow-wrap: normal; }
  .detail-sheet .lbl-full { display: none; }
  .detail-sheet .lbl-short { display: inline; }
  .detail-sheet .date-year, .detail-sheet .txt { display: none; } /* на узком экране — только главное */
  .detail-sheet td.name { white-space: normal; overflow-wrap: break-word; }
  .detail-sheet .note-line { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 500; color: var(--muted); line-height: 1.25; }
  .detail-sheet td.notes { overflow-wrap: break-word; }
}

/* Комментарий из документа — красным, чтобы сразу бросался в глаза */
.detail-sheet td.is-comment, .detail-sheet .note-comment { color: #d62b3d; font-weight: 600; }

/* Цели для бригады целиком (под общими % и метражом) */
.kpis .brigade-targets { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.brigade-target-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
@media (max-width: 760px) { .brigade-target-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.target-chip-sub { font-size: 10.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
