/* Салденс Meat — компоновка «журнал». Две темы, бордо с жёлтым: «Бордо» (светлая, по умолчанию) и «Вечер» (тёмная, винная).
   Цвета — только здесь; переключатель в меню пишет html[data-theme] и куку theme. */
:root, [data-theme="meadow"] {
  color-scheme: light;
  --bg: #f7f1e8;
  --panel: #ffffff;
  --panel-shadow: 0 1px 2px rgba(58, 18, 26, .06), 0 2px 10px rgba(58, 18, 26, .05);
  --nav: #6d1a2c;
  --line: #ecdfd2;
  --field: #ffffff;
  --field-line: #d8c5b6;
  --text: #2a1a1d;
  --muted: #664f54;
  --dim: #87706f;
  --accent: #f5c02e;
  --accent-ink: #2a1d00;
  --accent-soft: #fff3cc;
  --alarm: #d9472b;
  --ok: #23804a;
  --link: #8b1e3f;
  --link-hover: #5e1029;
  --warn: #9a5c00;
  --nav-text: #fbeef0;
  --nav-dim: #dcb0b9;
  --nav-line: #561423;
  --nav-hover: #852a3e;
  --brand: #ffd34d;
  --alarm-text: #b93a1f;
  --alarm-soft: #fbe3dc;
  --on-alarm: #fff;
  --done: #e6d9cf;
  --done-ink: #3a2a2c;
  --radius: 18px;
}
[data-theme="evening"] {
  color-scheme: dark;
  --bg: #241417;
  --panel: #331d22;
  --panel-shadow: none;
  --nav: #1b0d10;
  --line: #4a2c33;
  --field: #241417;
  --field-line: #5c3a42;
  --text: #fbf1ea;
  --muted: #e0c9c4;
  --dim: #bfa19f;
  --accent: #ffc83d;
  --accent-ink: #2a1a00;
  --accent-soft: #4a3324;
  --alarm: #ff6b4a;
  --ok: #a3e4ae;
  --link: #ffcf5a;
  --link-hover: #ffe08f;
  --warn: #ffcf5a;
  --nav-text: #fbf1ea;
  --nav-dim: #bfa19f;
  --nav-line: #3a2128;
  --nav-hover: #3a2128;
  --brand: #ffc83d;
  --alarm-text: #ffa189;
  --alarm-soft: #4d2326;
  --on-alarm: #fff;
  --done: #6a4d50;
  --done-ink: #fbf1ea;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Golos Text', system-ui, sans-serif; font-size: 17px; line-height: 1.45;
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1 { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.15; }
h2.cap {
  margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}

/* Каркас: меню слева, на узком экране — полосой сверху */
.layout { display: flex; min-height: 100vh; }
.nav {
  width: 232px; flex: none; background: var(--nav); border-right: 1px solid var(--nav-line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 1px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  font-size: 20px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand); padding: 0 12px 10px; text-decoration: none;
}
.nav a.item {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 12px;
  border-radius: 10px; color: var(--nav-text); text-decoration: none; font-size: 15px;
}
.nav a.item:hover { background: var(--nav-hover); }
.nav a.item.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.nav a.item.on .badge { background: var(--accent-ink); color: var(--accent); }
.nav .badge {
  margin-left: auto; font-size: 13px; font-weight: 700; background: var(--accent);
  color: var(--accent-ink); border-radius: 10px; padding: 1px 9px;
}
.nav .grp { display: flex; align-items: center; gap: 8px; margin: 10px 2px 3px; padding: 10px 10px 2px;
  border-top: 1px solid rgba(255, 255, 255, .16); font-size: 11.5px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--nav-dim); }
.nav .grp::before { content: ''; width: 4px; height: 12px; border-radius: 2px; background: var(--brand); }
/* сворачиваемые разделы */
.nav details.sect { display: flex; flex-direction: column; gap: 1px; }
.nav details.sect > summary { list-style: none; cursor: pointer; border-radius: 8px; }
.nav details.sect > summary::-webkit-details-marker { display: none; }
.nav details.sect > summary::after { content: '▸'; margin-left: auto; font-size: 13px; color: var(--nav-dim); }
.nav details.sect[open] > summary::after { content: '▾'; }
.nav details.sect > summary .badge { margin-left: auto; letter-spacing: 0; }
.nav details.sect[open] > summary .badge { display: none; }
.nav details.sect > summary:hover { color: var(--nav-text); }
/* скрыть меню: страница во всю ширину, ☰ — меню поверх */
.nav-pin { font: inherit; font-size: 13px; color: var(--nav-dim); background: none; border: 0; text-align: left;
  padding: 4px 12px 8px; cursor: pointer; }
.nav-open { display: none; position: fixed; top: 10px; left: 10px; z-index: 31; width: 48px; height: 48px;
  font-size: 24px; border-radius: 12px; border: 0; background: var(--nav); color: var(--nav-text); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.nav-hidden .nav { display: none; }
.nav-hidden .nav-open { display: block; }
.nav-hidden .main { padding-left: 72px; }
.nav-hidden.nav-shown .nav { display: flex; position: fixed; left: 0; top: 0; z-index: 30; box-shadow: 4px 0 24px rgba(0, 0, 0, .3);
  padding-top: 66px; }
/* сенсорный экран: пункты под палец */
@media (pointer: coarse) {
  .nav a.item { min-height: 44px; font-size: 17px; }
  .nav details.sect > summary { min-height: 44px; font-size: 13px; }
  .nav-pin { font-size: 15px; padding: 10px 12px; }
}
.nav .me { margin-top: auto; padding: 12px 14px; font-size: 14px; color: var(--nav-dim); }
.nav .me a { color: var(--brand); }
.nav .me form { display: inline; }
.nav .me button { font: inherit; color: var(--brand); background: none; border: 0; padding: 0; cursor: pointer; }

.main { flex: 1; min-width: 0; padding: 26px 30px 40px; display: flex; flex-direction: column; gap: 20px; }
.wrap { width: 100%; max-width: 1760px; display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; align-items: baseline; gap: 14px 18px; flex-wrap: wrap; }
.head .sub { font-size: 16px; color: var(--dim); }
.head .right { margin-left: auto; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .nav {
    width: auto; height: auto; position: static; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--nav-line);
  }
  .brand { padding: 0 10px 0 4px; }
  .nav a.item { flex: none; min-height: 46px; }
  .nav .grp, .nav-pin, .nav-open { display: none !important; }
  .nav details.sect { flex: none; padding: 0 4px; white-space: nowrap; }
  .nav details.sect a.item { display: inline-flex; vertical-align: middle; }  /* пункты раздела — в строку */
  .nav-hidden .nav { display: flex; }
  .nav-hidden .main { padding-left: 16px; }
  .nav .me { margin: 0 0 0 auto; flex: none; }
  .main { padding: 20px 16px 32px; }
  h1 { font-size: 25px; }
}

/* Сетки: на широком экране больше колонок */
.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.panel { background: var(--panel); border-radius: var(--radius); padding: 16px 20px; min-width: 0; box-shadow: var(--panel-shadow); }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 58px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.row:last-child { border-bottom: 0; }
.row .end { margin-left: auto; text-align: right; }
.row > span:not(.dot):not(.end) { flex: 1 1 200px; min-width: 0; }
.row .btn.end, .row .end .btn { min-height: 44px; padding: 0 14px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.empty { color: var(--dim); padding: 14px 0; }
.dot { width: 12px; height: 12px; border-radius: 6px; flex: none; background: var(--accent); }
.dot.alarm { background: var(--alarm); }
.dot.warn { background: var(--warn); }
.big { font-size: 24px; font-weight: 800; }

table.list { width: 100%; border-collapse: collapse; font-size: 16px; }
table.list th { text-align: left; font-weight: 500; font-size: 14px; color: var(--dim); padding: 8px 10px 8px 0; }
table.list td { padding: 11px 10px 11px 0; border-top: 1px solid var(--line); vertical-align: top; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* Кнопки и поля: не меньше 48 px под палец */
.btn {
  font: inherit; font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.07); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--field-line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); color: var(--text); }
.btn.alarm { background: var(--alarm); color: var(--on-alarm); }
.btn.wide { width: 100%; min-height: 62px; font-size: 20px; font-weight: 800; border-radius: 14px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1.5px solid var(--field-line); color: var(--text); text-decoration: none; font-size: 15px;
}
button.chip { font: inherit; font-size: 15px; background: none; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
/* разноцветные вкладки-кнопки (страница «Честный знак»): цвет — в --c; выбранная залита, остальные — тонированы */
.chip.tabc { border: 2px solid var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); font-weight: 600; }
.chip.tabc:hover { background: color-mix(in srgb, var(--c) 22%, transparent); }
.chip.tabc.on { background: var(--c); border-color: var(--c); color: #fff; font-weight: 700; }
[data-theme="evening"] .chip.tabc:not(.on) { color: color-mix(in srgb, var(--c) 55%, #fff); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 18px; color: var(--text); background: var(--field);
  border: 1.5px solid var(--field-line); border-radius: 12px; padding: 10px 14px; min-height: 50px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--accent-soft); }
input[type=file] { padding: 10px; }
input.num { text-align: right; font-weight: 800; font-size: 22px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--alarm-text); font-size: 14px; }

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { background: var(--panel); border-left: 0; border-radius: 12px; padding: 12px 16px; }
.messages li.success { color: var(--ok); }
.messages li.error { color: var(--alarm-text); }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }

/* Широкий экран (компьютер): три колонки на «Сегодня» */
.cols3 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); align-items: start; }

/* Камеры плиткой */
.tiles { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); align-items: start; }
.tile { display: flex; flex-direction: column; gap: 8px; }
.tile.over { box-shadow: inset 0 0 0 2px var(--alarm); }
.tile-head { display: flex; gap: 12px; align-items: flex-start; }
.tile-num { margin-left: auto; font-size: 26px; white-space: nowrap; }
.tile-num .dim { font-size: 18px; }
.fill { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.fill span { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.tile.over .fill span { background: var(--alarm); }
.tile-free { font-size: 14px; }
.alarm-text { color: var(--alarm-text); font-weight: 700; }
.tile-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 0;
  border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.tile-row:hover { background: var(--accent-soft); }
.tile-row .tr-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-row .tr-meta { font-size: 14px; color: var(--dim); text-align: right; white-space: nowrap; }
.tile-row .tr-end { grid-column: 2 / 4; font-size: 14px; color: var(--muted); }
.tile-row .tr-end:empty { display: none; }
.chip.alarm { border-color: var(--alarm); color: var(--text); text-decoration: none; gap: 8px; }
.chip.alarm:hover { background: var(--alarm-soft); }

/* Шкала созревания */
.legend { font-size: 14px; color: var(--dim); display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.lg { display: inline-block; width: 18px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.lg.done { background: var(--done); }
.lg.now { background: var(--accent); }
.lg.next { border: 1.5px solid var(--accent); }
.lg.ready { width: 10px; height: 10px; border-radius: 5px; background: var(--alarm); }
.tl { min-width: 900px; }
.tl-row { display: grid; grid-template-columns: 260px 1fr; align-items: center; min-height: 38px; color: var(--text); text-decoration: none; }
a.tl-row:hover { background: var(--accent-soft); }
.tl-label { padding-right: 12px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; height: 38px; }
.tl-axis .tl-track { height: 26px; }
.tl-tick { position: absolute; top: 4px; transform: translateX(-50%); font-size: 13px; color: var(--dim); }
.tl-today-label { position: absolute; top: 4px; transform: translateX(-50%); font-size: 13px; color: var(--warn); font-weight: 700;
  background: var(--panel); padding: 0 4px; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .8; }
.tl-group { margin-top: 12px; padding: 6px 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); }
.tl-seg { position: absolute; top: 9px; height: 20px; border-radius: 4px; overflow: hidden; font-size: 12px; line-height: 20px;
  padding: 0 6px; white-space: nowrap; box-shadow: 0 0 0 2px var(--panel); }
.tl-seg.done { background: var(--done); color: var(--done-ink); }
.tl-seg.now { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tl-seg.next { border: 1.5px solid var(--accent); color: var(--muted); line-height: 17px; }
.tl-seg.open { border-top-right-radius: 0; border-bottom-right-radius: 0; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent); }
.tl-seg-text { overflow: hidden; text-overflow: ellipsis; display: block; }
.tl-ready { position: absolute; top: 12px; width: 14px; height: 14px; margin-left: -7px; border-radius: 7px; background: var(--alarm);
  box-shadow: 0 0 0 2px var(--panel); }

/* «Сегодня»: камеры строками с полосой */
.room-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--line);
  color: var(--text); text-decoration: none; }
.room-line:first-of-type { border-top: 0; }
.room-line:hover { background: var(--accent-soft); }
.room-line .fill { grid-column: 1 / 3; height: 8px; }
.room-line.over .fill span { background: var(--alarm); }
.room-line .rl-num { font-weight: 700; }
.room-line .rl-free { grid-column: 1 / 3; font-size: 14px; }

/* Переключатель темы в меню */
.theme { display: flex; gap: 4px; padding: 4px; margin: 0 0 10px; border-radius: 12px; background: var(--nav-line); }
.theme button { flex: 1; font: inherit; font-size: 14px; min-height: 40px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--nav-dim); }
.theme button[aria-pressed="true"] { background: var(--nav-hover); color: var(--nav-text); font-weight: 700; }
@media (max-width: 900px) { .theme { margin: 0 0 0 8px; flex: none; } .theme button { padding: 0 10px; } }
/* цвет раздела: полоска у заголовка и лёгкий фон у раскрытого */
.nav details.sect { --sc: var(--brand); border-radius: 10px; }
.nav details.sect[data-sect="Производство"] { --sc: #f2b635; }
.nav details.sect[data-sect="Фасовка и ЧЗ"] { --sc: #5fb8f0; }
.nav details.sect[data-sect="Продажи"] { --sc: #f08a6c; }
.nav details.sect[data-sect="Контроль"] { --sc: #b39cf0; }
.nav details.sect > summary.grp::before { background: var(--sc); height: 14px; }
.nav details.sect[open] { background: color-mix(in srgb, var(--sc) 13%, transparent); padding-bottom: 4px; }
.nav details.sect[open] > summary.grp { color: var(--sc); }

/* сообщения после кнопок — внизу экрана, страница не прыгает наверх */
.messages.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(460px, calc(100vw - 32px)); }
.messages.toasts li { position: relative; padding-right: 40px; box-shadow: 0 6px 24px rgba(0,0,0,.18); transition: opacity .4s; }
.messages.toasts li.gone { opacity: 0; }
.toast-x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: inherit; min-height: 0; padding: 4px; }
.logbox { position: fixed; right: 16px; bottom: 16px; z-index: 61; width: min(520px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--panel); border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.logbox-head { position: relative; padding-right: 30px; margin-bottom: 8px; }
.logrow { border-top: 1px solid var(--line); padding: 8px 0; font-size: 15px; }
.logrow.success div { color: var(--ok); }
.logrow.error div { color: var(--alarm-text); }
