:root {
  --bg: #f4f5f7; --card: #fff; --text: #1b1f24; --muted: #6a7380; --line: #e2e5ea;
  --accent: #1f6feb; --ok: #1a7f37; --bad: #cf222e; --off: #8c959f; --tag: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --text: #e6e9ee; --muted: #8b949e; --line: #2a3038;
          --accent: #4493f8; --ok: #3fb950; --bad: #f85149; --off: #6e7681; --tag: #222831; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 6px 12px; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px; }
button.ghost:hover:not(:disabled) { border-color: var(--accent); }
button.small { padding: 4px 10px; font-size: 13px; }
input, select { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); min-height: 1em; margin: 6px 0; }
.spacer { flex: 1; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
main { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 18px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.groups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grp { display: inline-flex; gap: 4px; }
.lot { display: grid; grid-template-columns: auto 1fr 150px 110px; gap: 12px; align-items: center;
       padding: 10px 0; border-top: 1px solid var(--line); }
.lot.off .name b, .lot.off .name .tag { color: var(--off); }
.lot.busy { opacity: .6; }
.name { min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { background: var(--tag); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.field { display: grid; gap: 2px; }
.field .row { display: flex; gap: 4px; }
.field input { width: 100%; }
.switch { width: 46px; height: 26px; border-radius: 13px; padding: 0; position: relative;
          background: var(--off); border: none; transition: background .15s; }
.switch.on { background: var(--ok); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
                background: #fff; transition: left .15s; }
.switch.on .knob { left: 23px; }
.audit { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.audit li.bad { color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100% - 32px);
         background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 5; }
.toast.bad { background: var(--bad); color: #fff; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px; color: var(--text); }
@media (max-width: 640px) {
  .lot { grid-template-columns: auto 1fr 1fr; grid-template-areas: "sw name name" "sw stock dl"; }
  .lot > .switch { grid-area: sw; align-self: start; }
  .lot > .name { grid-area: name; }
  .lot > .field:nth-of-type(1) { grid-area: stock; }
  .lot > .field:nth-of-type(2) { grid-area: dl; }
}
