@font-face { font-family: Inter; font-weight: 400; src: url(../fonts/Inter-400.woff) format('woff'); font-display: swap; }
@font-face { font-family: Inter; font-weight: 500; src: url(../fonts/Inter-500.woff) format('woff'); font-display: swap; }
@font-face { font-family: Inter; font-weight: 600; src: url(../fonts/Inter-600.woff) format('woff'); font-display: swap; }
@font-face { font-family: Inter; font-weight: 700; src: url(../fonts/Inter-700.woff) format('woff'); font-display: swap; }

:root {
  --bg: #0d0d10; --bg2: #141418; --card: #18181d; --card2: #1e1e24; --line: #26262d; --line2: #33333c;
  --tx: #f4f4f6; --tx2: #a3a3ad; --tx3: #6e6e78;
  --ac: #ff7a3d; --ac2: #ffb08a; --acd: rgba(255,122,61,.14);
  --ok: #30d158; --bad: #ff453a; --warn: #ffd60a; --blue: #4cc2ff;
  --r: 18px; --r2: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font: 14px/1.45 Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 15px; margin: 0; letter-spacing: -.005em; font-weight: 600; }
h3 { font-size: 13.5px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--tx2); }
.dim { color: var(--tx3); font-size: 12.5px; }
.sm { font-size: 12.5px; }
.mono { font-family: "Cascadia Code", Consolas, ui-monospace, monospace; }
a { color: var(--ac2); }
code { font: 12.5px "Cascadia Code", Consolas, monospace; background: #22222a; padding: 1px 6px; border-radius: 6px; color: #ffcfb6; word-break: break-all; }

/* ---------- shell ---------- */
#app { display: flex; height: 100%; }
.side { width: 220px; flex: none; background: linear-gradient(180deg, #121216, #0e0e11); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; font-size: 17px; letter-spacing: -.01em; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { color: var(--ac); }
.brand small { display: block; font-size: 10.5px; color: var(--tx3); letter-spacing: .08em; text-transform: uppercase; margin-top: -2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 11px; color: var(--tx2); cursor: pointer; font-weight: 500; user-select: none; text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: #1b1b21; color: var(--tx); }
.nav a.on { background: var(--acd); color: #ffd3bf; }
.nav a.on svg { stroke: var(--ac); }
.nav a .badge { margin-left: auto; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--tx3); padding: 10px 8px; line-height: 1.7; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--tx3); vertical-align: 1px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.ac { background: var(--ac); box-shadow: 0 0 8px var(--ac); }
main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.page { padding: 26px 30px 48px; max-width: 1180px; margin: 0 auto; }
.page > header { margin-bottom: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page > header p { color: var(--tx2); margin-top: 4px; }
.tabbar { display: none; }
body.demo main::before { content: 'Демо: принтер віртуальний, справжній нічого не друкує'; display: block; text-align: center; font-size: 12.5px; padding: calc(8px + var(--safe-t)) 14px 8px; color: #ffe987; background: rgba(255,214,10,.09); border-bottom: 1px solid rgba(255,214,10,.25); }

@media (max-width: 860px) {
  .side { display: none; }
  .page { padding: calc(14px + var(--safe-t)) 14px calc(96px + var(--safe-b)); }
  h1 { font-size: 22px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(18,18,22,.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--tx3); font-size: 10.5px; font-weight: 500; text-decoration: none; border-radius: 12px; user-select: none; }
  .tabbar a.on { color: var(--ac); }
  .tabbar .ico { width: 23px; height: 23px; }
}

/* ---------- cards & layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card.flat { background: var(--card2); }
.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; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cols, .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > :last-child:nth-child(odd) { grid-column: span 2; } }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.sec-h h2 { display: flex; align-items: center; gap: 8px; }
.sticky { position: sticky; top: 18px; }
.sp { height: 14px; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--ac); color: #1a0d06; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; user-select: none; transition: filter .12s, transform .06s; min-height: 40px; }
.btn:hover { filter: brightness(1.08); }
a.btn { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.off { opacity: .38; pointer-events: none; }
.btn.ghost { background: #26262e; color: var(--tx); }
.btn.line { background: transparent; border: 1px solid var(--line2); color: var(--tx); }
.btn.bad { background: rgba(255,69,58,.16); color: #ff9c95; }
.btn.ok { background: var(--ok); color: #04210d; }
.btn.blue { background: rgba(76,194,255,.16); color: #9fdcff; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 14px; min-height: 50px; }
.btn.xs { padding: 5px 10px; font-size: 12.5px; min-height: 30px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn .ico { width: 18px; height: 18px; }
.iconbtn { width: 40px; height: 40px; padding: 0; }
.in { width: 100%; background: #101014; border: 1px solid var(--line2); color: var(--tx); border-radius: 11px; padding: 10px 12px; font: inherit; outline: none; min-height: 40px; }
.in:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--acd); }
select.in { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #888 50%), linear-gradient(135deg, #888 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea.in { resize: vertical; min-height: 70px; }
label.f { display: block; font-size: 12px; color: var(--tx2); margin-bottom: 12px; }
label.f > .in, label.f > select, label.f > .range { margin-top: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: #202027; border: 1px solid var(--line2); color: var(--tx); border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer; user-select: none; font-weight: 500; }
.chip:hover { border-color: var(--ac); }
.chip.on { background: var(--acd); border-color: var(--ac); color: #ffd3bf; }
.chip .sw-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.seg { display: flex; background: #101014; border: 1px solid var(--line2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; background: transparent; border: 0; border-radius: 9px; padding: 8px 6px; color: var(--tx2); cursor: pointer; font-weight: 500; font-size: 13px; }
.seg button.on { background: #2a2a33; color: var(--tx); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.sw { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 8px 0; user-select: none; }
.sw input { display: none; }
.sw i { flex: none; width: 42px; height: 25px; border-radius: 13px; background: #3a3a44; position: relative; transition: .2s; }
.sw i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::after { left: 19px; }
.sw b { display: block; font-weight: 600; font-size: 14px; }
.sw span { display: block; color: var(--tx3); font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--ac); height: 28px; margin: 0; }
.range { display: flex; align-items: center; gap: 10px; }
.range output { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--tx); font-weight: 600; }

/* ---------- status bits ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #26262e; color: var(--tx2); }
.badge.ok { background: rgba(48,209,88,.14); color: #6fe390; }
.badge.bad { background: rgba(255,69,58,.14); color: #ff9c95; }
.badge.warn { background: rgba(255,214,10,.13); color: #ffe46b; }
.badge.ac { background: var(--acd); color: var(--ac2); }
.bar { height: 8px; background: #26262e; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ac), #ffb347); border-radius: 6px; transition: width .4s; width: 0; }
.bar.blue > i { background: linear-gradient(90deg, #2f81f7, var(--blue)); }
.bar.ok > i { background: var(--ok); }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255,214,10,.09); border: 1px solid rgba(255,214,10,.25); color: #ffe987; font-size: 13px; }
.alert.bad { background: rgba(255,69,58,.1); border-color: rgba(255,69,58,.3); color: #ffaaa4; }
.alert.info { background: rgba(76,194,255,.08); border-color: rgba(76,194,255,.25); color: #a9defa; }
.alert .ico { margin-top: 1px; }
.empty { text-align: center; color: var(--tx3); padding: 26px 10px; }
.empty .ico { width: 34px; height: 34px; margin-bottom: 8px; opacity: .6; }

/* ---------- hero (home) ---------- */
.hero { display: flex; align-items: center; gap: 22px; padding: 22px; background: radial-gradient(120% 140% at 0% 0%, rgba(255,122,61,.16), transparent 55%), var(--card); }
.ring { position: relative; width: 148px; height: 148px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring .bg { stroke: #26262e; }
.ring .fg { stroke: var(--ac); transition: stroke-dashoffset .5s, stroke .3s; }
.ring .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .mid b { font-size: 34px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring .mid span { font-size: 11.5px; color: var(--tx2); }
.hero .info { flex: 1; min-width: 0; }
.hero .info h2 { font-size: 20px; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero .stats { display: flex; gap: 20px; margin: 12px 0 14px; flex-wrap: wrap; }
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--tx3); }
@media (max-width: 560px) { .hero { flex-direction: column; text-align: center; padding: 18px; } .hero .stats, .hero .row { justify-content: center; } .hero .info h2 { white-space: normal; } }

.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; transition: border-color .15s; position: relative; overflow: hidden; }
.tile:hover { border-color: var(--line2); }
.tile .t-h { display: flex; align-items: center; justify-content: space-between; color: var(--tx2); font-size: 12.5px; font-weight: 500; }
.tile .t-v { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.tile .t-v small { font-size: 14px; color: var(--tx3); font-weight: 500; letter-spacing: 0; }
.tile.hot .t-v { color: #ffb08a; }
.tile.hot::after { content: ''; position: absolute; inset: auto 0 0 0; height: 3px; background: linear-gradient(90deg, var(--ac), #ffb347); }
.tile.absent { opacity: .45; }

.conn { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.conn:last-child { border-bottom: 0; }
.conn .ico { color: var(--tx2); }
.conn .grow b { display: block; font-weight: 600; }
.conn .grow span { font-size: 12.5px; color: var(--tx3); }

/* ---------- lists ---------- */
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list > .item:last-child { border-bottom: 0; }
.item .thumb { width: 44px; height: 44px; border-radius: 12px; background: var(--card2); display: flex; align-items: center; justify-content: center; color: var(--ac2); flex: none; overflow: hidden; }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .grow span { color: var(--tx3); font-size: 12.5px; }
.pick { cursor: pointer; border-radius: 12px; padding-left: 8px !important; padding-right: 8px !important; }
.pick:hover { background: var(--card2); }
.pick.on { background: var(--acd); }

/* ---------- viewer ---------- */
.viewer { position: relative; height: 420px; border-radius: var(--r); overflow: hidden; background: radial-gradient(100% 100% at 50% 0%, #20202a, #121216); border: 1px solid var(--line); touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.vt { position: absolute; left: 10px; top: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; gap: 8px; flex-wrap: wrap; }
.vt .badge { pointer-events: auto; background: rgba(20,20,24,.78); backdrop-filter: blur(8px); }
.vb { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.vb button { background: rgba(20,20,24,.78); backdrop-filter: blur(8px); border: 1px solid var(--line2); border-radius: 10px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.viewer .loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--tx2); }
@media (max-width: 860px) { .viewer { height: 320px; } }

.drop { border: 2px dashed var(--line2); border-radius: var(--r); padding: 22px; text-align: center; color: var(--tx2); cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--ac); background: var(--acd); color: var(--tx); }
.drop .ico { width: 30px; height: 30px; color: var(--ac); margin-bottom: 6px; }
.thumbimg { width: 100%; max-height: 180px; object-fit: cover; border-radius: 14px; }

/* ---------- pad ---------- */
.pad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 6px; }
.pad .btn { padding: 0; min-height: 0; width: 52px; height: 52px; border-radius: 14px; }
.pad .mid { background: var(--card2); color: var(--ac2); }
.zpad { display: grid; grid-template-rows: repeat(3, 52px); gap: 6px; }
.zpad .btn { padding: 0; min-height: 0; width: 52px; height: 52px; border-radius: 14px; }
.term { background: #08080a; border: 1px solid var(--line); border-radius: 12px; height: 220px; overflow-y: auto; padding: 10px; font: 12px/1.5 "Cascadia Code", Consolas, ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; }
.term .tx { color: #8de7a3; } .term .rx { color: #c9c9d2; } .term .in { color: #7cc9ff; }

/* ---------- toasts / sheet ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
@media (max-width: 860px) { #toasts { bottom: calc(86px + var(--safe-b)); } }
.toast { background: #24242b; border: 1px solid var(--line2); color: var(--tx); padding: 11px 16px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: tin .22s ease-out; font-weight: 500; pointer-events: auto; }
.toast.bad { border-color: rgba(255,69,58,.5); background: #2a1c1c; }
.toast.ok { border-color: rgba(48,209,88,.45); }
@keyframes tin { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fin .15s; }
.scrim.bottom { align-items: flex-end; padding: 0; }
.sheet { background: var(--card); border: 1px solid var(--line2); border-radius: 22px; padding: 20px; width: min(100%, 440px); max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: sin .22s ease-out; }
.scrim.bottom .sheet { width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding-bottom: calc(20px + var(--safe-b)); }
.sheet h2 { font-size: 18px; margin-bottom: 6px; }
@keyframes fin { from { opacity: 0; } }
@keyframes sin { from { transform: translateY(24px); opacity: 0; } }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--line2); border-top-color: var(--ac); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }
.pulse { animation: pls 1.6s ease-in-out infinite; }
@keyframes pls { 50% { opacity: .45; } }
.hide { display: none !important; }
.numfield { display: flex; align-items: center; gap: 8px; }
.numfield .in { text-align: center; font-size: 22px; font-weight: 700; }
.setup li { margin: 6px 0; }
.kbd { font: 600 12px Inter; background: #26262e; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 7px; padding: 1px 7px; }
details.card summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: 10px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 4px 0 10px 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--acd); color: var(--ac2); font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: center; }
