/* БТПК Производство. Бетонно-серый цех, янтарь стеклопластика, статусы линий. */
:root {
  --bg: #e8e9e4;
  --surface: #f6f6f2;
  --ink: #1c2225;
  --muted: #5b6468;
  --rule: #cbcec7;
  --brand: #a8761a;
  --brand-ink: #6f4d0f;
  --work: #2e7a4c;
  --idle: #c47a00;
  --changeover: #3b679f;
  --breakdown: #b3261e;
  --off: #8a9094;
  --radius: 6px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 1rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 2rem 0 .75rem; font-weight: 600; }
p { margin: 0 0 1rem; max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* шапка */
.top { background: var(--ink); color: #f1f1ec; }
.top-inner { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; max-width: 1400px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 700; color: #fff; text-decoration: none; display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, #e9c46a 0 30%, var(--brand) 31% 62%, #e9c46a 63%); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #c9ccc6; text-decoration: none; padding: .35rem .7rem; border-radius: var(--radius); }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(233,196,106,.18); box-shadow: inset 0 -2px 0 #e9c46a; }
.who { display: flex; align-items: center; gap: .75rem; color: #c9ccc6; font-size: .9rem; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid #4a5357; color: #e1e2dc; padding: .25rem .6rem; border-radius: var(--radius); cursor: pointer; font: inherit; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* уведомления */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; background: #dfeee3; border-left: 5px solid var(--work); }
.flash.error { background: #f6dedb; border-left-color: var(--breakdown); }

/* формы и кнопки */
label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); padding: .5rem .65rem; min-height: 2.5rem; width: 100%; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--brand); transform: scale(1.3); }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.5rem; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid transparent; background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.secondary:hover { background: #fff; filter: none; }
.btn.brand { background: var(--brand); }
.btn.danger { background: var(--breakdown); }
.btn.small { min-height: 2rem; padding: .25rem .6rem; font-size: .875rem; font-weight: 500; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 10rem; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; }
.panels { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th { font-size: .875rem; font-weight: 600; color: var(--muted); background: #eeefea; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td input, td select { min-height: 2.1rem; padding: .3rem .5rem; }
tr.inactive td { color: var(--off); }
.neg { color: var(--breakdown); font-weight: 600; }
.warn { color: var(--idle); font-weight: 600; }

/* статусы */
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--off); vertical-align: baseline; margin-right: .35rem; }
.s-work { --c: var(--work); } .s-idle { --c: var(--idle); } .s-changeover { --c: var(--changeover); } .s-breakdown { --c: var(--breakdown); } .s-off { --c: var(--off); }
.dot[class*="s-"] { background: var(--c); }

/* карта цеха */
.floor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.floor-head h1 { margin: 0; }
.summary { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.summary div { display: flex; flex-direction: column; }
.summary b { font-size: 1.6rem; line-height: 1.1; }
.summary span { color: var(--muted); font-size: .875rem; }
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.tile { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1rem 1rem 1.35rem; overflow: hidden; color: inherit; text-decoration: none; display: block; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--c); }
.tile.s-breakdown::before { background: repeating-linear-gradient(135deg, var(--breakdown) 0 8px, #1c2225 8px 14px); }
.tile.s-off { background: #efefeb; }
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.tile-name { font-weight: 700; font-size: 1.1rem; }
.tile-status { font-weight: 600; color: var(--c); }
.tile-reason { color: var(--ink); font-size: .9rem; min-height: 1.35rem; }
.tile-meters { font-size: 2.6rem; font-weight: 700; line-height: 1.05; margin: .6rem 0 .1rem; letter-spacing: -0.02em; }
.tile-meters small { display: block; font-size: .875rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: .15rem; }
.tile-meta { display: grid; grid-template-columns: auto 1fr; gap: .1rem .75rem; font-size: .875rem; margin-top: .6rem; }
.tile-meta dt { color: var(--muted); }
.tile-meta dd { margin: 0; text-align: right; }
.stale { color: var(--breakdown); font-size: .875rem; }
.alerts { margin-top: 1.5rem; }

/* пульт оператора */
.op-lines { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.op-line { display: block; padding: 1.25rem; font-size: 1.25rem; font-weight: 700; }
.op-line .tile-status { font-size: 1rem; display: block; margin-top: .25rem; }
.op-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .op-grid { grid-template-columns: 1fr; } }
.status-now { border-left: 10px solid var(--c); }
.status-now .big { font-size: 2rem; font-weight: 700; color: var(--c); line-height: 1.15; }
.status-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-top: 1rem; }
.status-buttons .btn, .reason-grid .btn { min-height: 3.75rem; font-size: 1.1rem; white-space: normal; text-align: center; }
.btn.st { background: var(--c); }
.btn.st[aria-pressed="true"] { box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px var(--c); }
.reason-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem; margin-top: .5rem; }
.reason-grid .btn { min-height: 3.25rem; font-size: 1rem; background: #fff; color: var(--ink); border-color: var(--c); border-width: 2px; }
details.reasons { margin-top: 1rem; }
details.reasons summary { cursor: pointer; font-weight: 600; padding: .5rem 0; }
.big-input input { font-size: 1.8rem; min-height: 3.75rem; font-weight: 600; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; }
.product-grid label { margin: 0; }
.product-grid input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.product-grid span { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25; min-height: 3.5rem; background: #fff; border: 2px solid var(--rule); border-radius: var(--radius); font-size: 1.1rem; font-weight: 600; color: var(--ink); cursor: pointer; text-align: center; padding: .25rem; }
.product-grid small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.product-grid input:checked + span { border-color: var(--brand); background: #f5e6c4; }
.product-grid input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.timer { font-variant-numeric: tabular-nums; }

/* вход */
.login { max-width: 26rem; margin: 8vh auto; }
.login h1 { display: flex; align-items: center; gap: .6rem; }
.login .brand-mark { width: 30px; height: 30px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
.keypad button { font: inherit; font-size: 1.5rem; font-weight: 600; min-height: 3.75rem; border: 1px solid var(--rule); background: #fff; border-radius: var(--radius); cursor: pointer; color: var(--ink); }
.keypad button:active { background: #f5e6c4; }
.pin-input { font-size: 1.8rem; letter-spacing: .4em; text-align: center; }

@media (max-width: 640px) {
  main { padding: 1rem .75rem 3rem; }
  .top-inner { gap: .5rem 1rem; padding: .5rem .75rem; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tile-meters { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem .75rem; }
.check-list label { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-size: 1rem; margin: 0; min-height: 2.25rem; }
.reason-grid .btn[aria-pressed="true"] { background: var(--c); color: #fff; }
/* справочники */
table.catalog td.c-name { min-width: 18rem; }
table.catalog td.c-label { min-width: 16rem; white-space: nowrap; }
table.catalog td.c-xs { width: 5.5rem; min-width: 5rem; }
table.catalog td.c-s { width: 7rem; min-width: 6.5rem; }
table.catalog td.c-m { width: 8.5rem; min-width: 8rem; }
details.generator summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.generator summary::-webkit-details-marker { display: none; }
details.generator summary::before { content: "+"; font-weight: 700; font-size: 1.3rem; color: var(--brand-ink); width: 1rem; }
details.generator[open] summary::before { content: "−"; }
details.generator summary h2, details.generator summary h3 { margin: 0; font-size: 1.1rem; }
details.generator + details.generator { margin-top: .75rem; }
details.generator > p { margin-top: .75rem; }
.gen-grid { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.hint { display: block; font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.inline-check { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-size: 1rem; margin-top: 1rem; }
.convert-grid { display: grid; gap: .75rem 1rem; grid-template-columns: minmax(0, 3fr) minmax(8rem, 1fr); margin-top: .5rem; }
@media (max-width: 640px) { .convert-grid { grid-template-columns: 1fr; } }
