:root {
  --bg: #0f0f10; --surface: #1a1a1c; --surface-2: #232327; --line: #2e2e33; --line-strong: #45454d;
  --text: #f4f4f2; --muted: #9b9ba1; --accent: #ffd200; --on-accent: #111; --green: #3ecf8e; --red: #ff5a5f; --orange: #ffb020; --blue: #6ea8fe;
  --radius: 18px; --radius-sm: 12px; --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 800; margin: 0 0 10px; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* каркас */
.app { display: flex; min-height: 100vh; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 16px); max-width: 980px; margin: 0 auto; width: 100%; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(20,20,22,.96); border-top: 1px solid var(--line); display: flex; z-index: 30; backdrop-filter: blur(10px); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav a .ico { font-size: 22px; line-height: 1; }
.nav a.active { color: var(--accent); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.topbar .back { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; width: 240px; padding: 20px 14px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; gap: 4px; }
  .side .brand { font-weight: 900; color: var(--accent); font-size: 20px; padding: 6px 12px 18px; letter-spacing: -.02em; }
  .side a { padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; display: flex; gap: 10px; align-items: center; }
  .side a.active { background: var(--surface); color: var(--text); }
  .side .foot { margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }
  .nav { display: none; }
  .main { padding: 28px 32px; }
}

/* элементы */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.pad0 { padding: 0; overflow: hidden; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer; white-space: nowrap; min-height: 42px; touch-action: manipulation; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #6b2426; }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: 13px; }
.btn.icon { width: 42px; padding: 0; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=time], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); outline: none; min-height: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); padding: 3px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle .t { font-weight: 600; }
.toggle .d { font-size: 12px; color: var(--muted); }
.sw { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--line-strong); flex: 0 0 auto; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sw.on { background: var(--accent); }
.sw.on::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); font-weight: 600; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .t { font-weight: 700; }
.item .d { font-size: 12px; color: var(--muted); }
.item .chev { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.on { background: rgba(62,207,142,.15); color: var(--green); }
.badge.off { background: rgba(255,90,95,.15); color: var(--red); }
.badge.warn { background: rgba(255,176,32,.15); color: var(--orange); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 26px; font-weight: 900; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat.ready .v { color: var(--green); } .stat.cooking .v { color: var(--orange); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; border: 2px solid transparent; cursor: pointer; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 11px; background: rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .k { position: absolute; top: 6px; left: 6px; font-size: 10px; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.thumb.on { border-color: var(--accent); }
.code { font-size: 42px; font-weight: 900; letter-spacing: .12em; text-align: center; padding: 10px; }
.pin input { font-size: 32px; text-align: center; letter-spacing: .3em; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.login .brand { color: var(--accent); font-weight: 900; font-size: 26px; letter-spacing: -.02em; margin-bottom: 4px; }
.err { background: #2a1011; border: 1px solid #6b2426; color: #ffb3b5; padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
.ok { background: #0f2a1d; border: 1px solid #1f6b46; color: #a8f0cf; padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
.info { background: #14213a; border: 1px solid #28406b; color: #b7cdf5; padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ocard { background: var(--surface-2); border-radius: 14px; padding: 12px; border-left: 4px solid var(--line-strong); }
.ocard.accepted { border-left-color: var(--muted); } .ocard.cooking { border-left-color: var(--orange); } .ocard.ready { border-left-color: var(--green); } .ocard.done { opacity: .5; }
.ocard .n { font-size: 28px; font-weight: 900; letter-spacing: -.02em; }
.ocard .s { font-size: 12px; color: var(--muted); }
.ocard .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.tabs a.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.savebar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); display: flex; gap: 10px; padding: 10px; background: rgba(26,26,28,.95); border: 1px solid var(--line); border-radius: 16px; margin-top: 14px; z-index: 5; }
@media (min-width: 900px) { .savebar { bottom: 12px; } }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 100; max-width: 90vw; font-size: 14px; }
.toast.err { background: var(--red); color: #fff; }
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); border: 1px solid var(--line); }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-card { border-radius: 22px; } }
.sheet-card .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 14px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

/* редактор макета */
.canvas-wrap { display: flex; flex-direction: column; gap: 10px; }
.canvas { position: relative; width: 100%; background: #000; border-radius: 12px; overflow: hidden; touch-action: none; border: 1px solid var(--line-strong); user-select: none; -webkit-user-select: none; }
.canvas iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; pointer-events: none; }
.canvas .blk { position: absolute; border: 2px solid rgba(255,255,255,.55); background: rgba(255,210,0,.08); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; cursor: move; overflow: hidden; }
.canvas .blk.on { border-color: var(--accent); background: rgba(255,210,0,.18); z-index: 10; }
.canvas .blk .rs { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; background: var(--accent); border-radius: 8px 0 6px 0; cursor: nwse-resize; }
.canvas .blk .rs::after { content: "⤡"; color: #111; font-size: 13px; position: absolute; right: 4px; bottom: 1px; }
.blklist .item { padding: 10px 12px; }
.blklist .item .sw-ico { font-size: 18px; width: 28px; text-align: center; }
.numrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.numrow .field { margin: 0; }
.numrow input { padding: 8px 6px; text-align: center; min-height: 38px; }
