:root {
    --bg: #070d1a;
    --bg2: #0b1426;
    --card: #0f1a2e;
    --card2: #13203a;
    --line: #1d2b47;
    --line2: #26385c;
    --tx: #e6edf7;
    --tx2: #a7b4c9;
    --tx3: #6c7d98;
    --acc: #38bdf8;
    --acc2: #0ea5e9;
    --ok: #22c55e;
    --bad: #ef4444;
    --warn: #f59e0b;
    --prep: #eab308;
    --inst: #c084fc;
    --off: #64748b;
    --info: #38bdf8;
    --r: 16px;
    --r2: 10px;
    --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}
* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    height: 100%;
}
body {
    background:
        radial-gradient(1200px 600px at 10% -10%, #0f2547 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 10%, #1a1440 0%, transparent 55%), var(--bg);
    background-attachment: fixed;
    color: var(--tx);
    font:
        14px/1.45 Inter,
        "Segoe UI",
        system-ui,
        -apple-system,
        Roboto,
        Arial,
        sans-serif;
    font-variant-numeric: tabular-nums;
    min-height: 100vh;
}
a {
    color: inherit;
    text-decoration: none;
}
button {
    font: inherit;
    color: inherit;
}
.muted {
    color: var(--tx3);
}
.dim {
    color: var(--tx2);
}
.mono {
    font-family: var(--mono);
}
.boot {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    justify-content: center;
    color: var(--tx2);
}
.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--line2);
    border-top-color: var(--acc);
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--ok)) 70%, transparent);
    }
    70% {
        box-shadow: 0 0 0 8px transparent;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}
@keyframes blink {
    50% {
        opacity: 0.35;
    }
}

/* ---------- login ---------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login {
    width: min(420px, 100%);
    background: linear-gradient(180deg, #12213d, #0d172b);
    border: 1px solid var(--line2);
    border-radius: 22px;
    padding: 34px 32px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.login .brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
}
.login h1 {
    font-size: 20px;
    margin: 0;
}
.login .srv {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 18px;
    color: var(--tx2);
    font-size: 13px;
}
.login label {
    display: block;
    font-size: 12px;
    color: var(--tx2);
    margin: 12px 0 6px;
}
.login input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line2);
    background: #0a1324;
    color: var(--tx);
    font-size: 15px;
    outline: none;
    transition: border 0.15s;
}
.login input:focus {
    border-color: var(--acc);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line2);
    background: var(--card2);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: 0.15s;
    white-space: nowrap;
}
.btn:hover {
    border-color: var(--acc);
    color: #fff;
}
.btn.primary {
    width: 100%;
    margin-top: 22px;
    padding: 13px;
    background: linear-gradient(90deg, #0ea5e9, #6366f1);
    border: 0;
    font-weight: 600;
    font-size: 15px;
    color: #fff;
}
.btn.primary:disabled {
    opacity: 0.6;
    cursor: wait;
}
.btn.icon {
    padding: 7px 9px;
}
.err {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fecaca;
    font-size: 13px;
}
.logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: conic-gradient(from 200deg, #0ea5e9, #6366f1, #22c55e, #0ea5e9);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
}
.logo > div {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #0b1426;
    display: grid;
    place-items: center;
}
.logo > div > div {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #38bdf8;
}

/* ---------- top bar ---------- */
.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 22px;
    background: rgba(7, 13, 26, 0.82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.top .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.top .logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}
.top .logo > div {
    width: 22px;
    height: 22px;
}
.top .logo > div > div {
    width: 8px;
    height: 8px;
}
.top .title {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
}
.top .title small {
    display: block;
    font-weight: 400;
    font-size: 11.5px;
    color: var(--tx3);
}
.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tx2);
    min-width: 0;
    overflow: hidden;
}
.crumbs a:hover {
    color: #fff;
}
.crumbs b {
    color: var(--tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top .sp {
    flex: 1;
}
.live {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--tx2);
    white-space: nowrap;
}
.live .dot {
    --c: var(--ok);
}
.clock {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tx2);
    font-size: 13px;
    white-space: nowrap;
}
.seg {
    display: inline-flex;
    background: #0a1324;
    border: 1px solid var(--line2);
    border-radius: 10px;
    padding: 3px;
}
.seg button {
    border: 0;
    background: transparent;
    padding: 5px 12px;
    border-radius: 7px;
    cursor: pointer;
    color: var(--tx2);
    font-size: 13px;
}
.seg button.on {
    background: var(--card2);
    color: #fff;
    box-shadow: inset 0 0 0 1px var(--line2);
}
.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--c, var(--ok));
    flex: none;
}
.dot.pulse {
    animation: pulse 2s infinite;
}
.dot.err {
    --c: var(--bad);
}

/* ---------- layout ---------- */
.page {
    padding: 20px 22px 40px;
    max-width: 1880px;
    margin: 0 auto;
}
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    align-items: start;
}
.side {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow: auto;
    background: rgba(15, 26, 46, 0.6);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 10px;
}
.side h4 {
    margin: 12px 8px 6px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tx3);
    font-weight: 600;
}
.side a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border-radius: 9px;
    color: var(--tx2);
    font-size: 13px;
}
.side a:hover {
    background: var(--card2);
    color: #fff;
}
.side a.on {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.18), rgba(56, 189, 248, 0.03));
    color: #fff;
    box-shadow: inset 2px 0 0 var(--acc);
}
.side a span.n {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .side {
        display: none;
    }
}

.card {
    background: linear-gradient(180deg, rgba(19, 32, 58, 0.92), rgba(14, 24, 43, 0.92));
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px 18px;
    min-width: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.card-h {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -2px 0 12px;
    font-weight: 600;
    font-size: 14.5px;
}
.card-h .sub {
    font-weight: 400;
    color: var(--tx3);
    font-size: 12.5px;
}
.card-h .sp {
    flex: 1;
}
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}
.s12 {
    grid-column: span 12;
}
.s8 {
    grid-column: span 8;
}
.s7 {
    grid-column: span 7;
}
.s6 {
    grid-column: span 6;
}
.s5 {
    grid-column: span 5;
}
.s4 {
    grid-column: span 4;
}
.s3 {
    grid-column: span 3;
}
@media (max-width: 1400px) {
    .s3 {
        grid-column: span 6;
    }
    .s4,
    .s5 {
        grid-column: span 12;
    }
    .s8,
    .s7 {
        grid-column: span 12;
    }
}
@media (max-width: 800px) {
    .s6,
    .s3 {
        grid-column: span 12;
    }
}
.chart {
    width: 100%;
    height: 260px;
}
.chart.tall {
    height: 320px;
}
.chart.short {
    height: 200px;
}
.empty {
    color: var(--tx3);
    font-size: 13px;
    padding: 18px 4px;
    text-align: center;
}

/* ---------- KPIs ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(19, 32, 58, 0.95), rgba(14, 24, 43, 0.95));
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
}
.kpi:before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--c, var(--acc));
}
.kpi .l {
    font-size: 12px;
    color: var(--tx2);
    display: flex;
    gap: 6px;
    align-items: center;
}
.kpi .v {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
    margin-top: 4px;
    letter-spacing: -0.5px;
}
.kpi .v small {
    font-size: 15px;
    font-weight: 500;
    color: var(--tx3);
    margin-left: 4px;
    letter-spacing: 0;
}
.kpi .h {
    font-size: 12px;
    color: var(--tx3);
    margin-top: 2px;
}

/* ---------- overview ---------- */
.orders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.order {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.13), rgba(99, 102, 241, 0.08));
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: var(--r);
    padding: 14px 18px;
}
.order .t {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: space-between;
}
.order .p {
    font-weight: 600;
    font-size: 15px;
}
.order .c {
    font-size: 12px;
    color: var(--tx2);
}
.bar {
    height: 10px;
    border-radius: 6px;
    background: #0a1324;
    overflow: hidden;
    display: flex;
    margin: 10px 0 8px;
    border: 1px solid var(--line);
}
.bar i {
    display: block;
    height: 100%;
}
.order .m {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 12.5px;
    color: var(--tx2);
}
.order .m b {
    color: var(--tx);
}
.group {
    margin-bottom: 26px;
}
.group-h {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 2px 12px;
    flex-wrap: wrap;
}
.group-h h2 {
    font-size: 17px;
    margin: 0;
    font-weight: 650;
}
.group-h .stat {
    font-size: 12.5px;
    color: var(--tx2);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.group-h .stat b {
    color: var(--tx);
}
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
    gap: 14px;
}
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, rgba(19, 32, 58, 0.95), rgba(13, 22, 40, 0.95));
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 14px 12px;
    transition:
        transform 0.15s,
        border-color 0.15s,
        box-shadow 0.15s;
    overflow: hidden;
}
.tile:before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--st);
}
.tile:after {
    content: "";
    position: absolute;
    inset: -40% -30% auto auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--st) 22%, transparent), transparent);
    pointer-events: none;
}
.tile:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--st) 55%, var(--line));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
.tile-top {
    display: flex;
    gap: 12px;
    align-items: center;
}
.thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.thumb.ic {
    background: linear-gradient(135deg, #1b2d50, #14223d);
    border: 1px solid var(--line2);
    color: var(--acc);
}
.thumb.ic svg {
    width: 28px;
    height: 28px;
}
.tile-name {
    font-weight: 650;
    font-size: 14.5px;
    line-height: 1.25;
}
.tile-sub {
    font-size: 12px;
    color: var(--tx3);
    margin-top: 2px;
}
.tile-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.tile-status b {
    font-weight: 650;
}
.tile-status .dur {
    margin-left: auto;
    color: var(--tx2);
    font-size: 12.5px;
}
.tile-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 12px;
    color: var(--tx3);
    min-height: 38px;
}
.tile-metrics b {
    display: block;
    color: var(--tx);
    font-size: 15px;
    font-weight: 600;
}
.tile-metrics .w {
    grid-column: span 2;
}
.tile-foot {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--tx3);
}
.tile-foot b {
    color: var(--tx);
}
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: -2px;
    align-items: center;
}
.badge {
    font-size: 11px;
    line-height: 16px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 20px;
    background: var(--bc, #334155);
    color: #fff;
    white-space: nowrap;
}
.badge.err {
    --bc: rgba(239, 68, 68, 0.9);
}
.badge.warn {
    --bc: rgba(245, 158, 11, 0.92);
    color: #1a1205;
}
.badge.info {
    --bc: rgba(99, 102, 241, 0.9);
}
.minibar {
    height: 6px;
    background: #0a1324;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}
.minibar i {
    display: block;
    height: 100%;
    border-radius: 4px;
}

/* ---------- timeline ---------- */
.tl {
    position: relative;
    height: 30px;
    border-radius: 8px;
    background: #0a1324;
    overflow: hidden;
    border: 1px solid var(--line);
}
.tl.mini {
    height: 9px;
    border-radius: 5px;
    border: 0;
}
.tl i {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--c);
}
.tl i:hover {
    filter: brightness(1.25);
}
.tl-axis {
    position: relative;
    height: 18px;
    font-size: 11px;
    color: var(--tx3);
    margin-top: 4px;
}
.tl-axis span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--tx2);
}
.legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.legend .sq {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: var(--c);
}
.legend b {
    color: var(--tx);
}

/* ---------- detail ---------- */
.det-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 22px;
    align-items: center;
    padding: 18px 22px;
}
.det-photo {
    width: 120px;
    height: 120px;
    border-radius: 18px;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}
.det-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.det-photo.ic {
    background: linear-gradient(135deg, #1b2d50, #14223d);
    border: 1px solid var(--line2);
    color: var(--acc);
}
.det-photo.ic svg {
    width: 60px;
    height: 60px;
}
.det-title h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: -0.3px;
    line-height: 1.15;
}
.det-title .sub {
    color: var(--tx2);
    margin-top: 4px;
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 20px;
    background: #0a1324;
    border: 1px solid var(--line2);
    color: var(--tx2);
}
.chip b {
    color: var(--tx);
    font-weight: 600;
}
.det-state {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.bigpill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 20px;
    font-weight: 700;
    background: color-mix(in srgb, var(--c) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
    color: #fff;
}
.bigpill .dot {
    width: 12px;
    height: 12px;
}
.det-state .since {
    color: var(--tx2);
    font-size: 13px;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    background: color-mix(in srgb, var(--c, #64748b) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, #64748b) 50%, transparent);
    color: #fff;
    white-space: nowrap;
}
.pill:before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c, #64748b);
}
.pill.np:before {
    display: none;
}
.alerts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 14px 0;
}
.alerts:empty {
    display: none;
}
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 500;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.alert.warn {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
}
.alert.info {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.35);
}
.alert .ic {
    font-size: 16px;
}
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat {
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
}
.stat .l {
    font-size: 11.5px;
    color: var(--tx3);
}
.stat .v {
    font-size: 21px;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: -0.3px;
}
.stat .v small {
    font-size: 12px;
    color: var(--tx3);
    font-weight: 500;
    margin-left: 3px;
}
.stat .h {
    font-size: 11.5px;
    color: var(--tx3);
}
.stat.wide {
    grid-column: span 2;
}
.kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    font-size: 13px;
}
.kv span {
    color: var(--tx3);
}
.kv b {
    font-weight: 600;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.spindles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}
.spindle {
    min-width: 0;
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
}
.spindle .h {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.spindle .h b {
    font-size: 15px;
}
.spindle .body {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    align-items: center;
}
.ovr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 5px 10px;
    align-items: center;
    font-size: 12px;
    color: var(--tx3);
    margin-top: 10px;
}
.ovr .bar {
    margin: 0;
    height: 7px;
}
.prog {
    margin-top: 10px;
    font-size: 12px;
    color: var(--tx3);
}
.prog b {
    display: block;
    color: var(--tx);
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}
.code {
    display: block;
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: #a5f3fc;
    background: #06101f;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 9px;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
}
.machine-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.mbox {
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 12px;
    min-width: 0;
}
.mbox .l {
    font-size: 11.5px;
    color: var(--tx3);
}
.mbox .v {
    font-weight: 600;
    margin-top: 2px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.35);
}
.check.bad {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
}
.leds {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
    gap: 6px 12px;
}
.led {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--tx2);
    padding: 4px 0;
}
.led i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1e293b;
    border: 1px solid #334155;
    flex: none;
}
.led.on i {
    background: var(--c, var(--ok));
    border-color: transparent;
    box-shadow: 0 0 10px var(--c, var(--ok));
}
.led.on {
    color: var(--tx);
}
.led.on.blink i {
    animation: blink 1s infinite;
}
.sect {
    font-size: 11.5px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--tx3);
    margin: 16px 0 8px;
    font-weight: 600;
}
.sect:first-child {
    margin-top: 0;
}
.axes {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.axes div {
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 8px;
    text-align: center;
}
.axes span {
    font-size: 11px;
    color: var(--tx3);
}
.axes b {
    display: block;
    font-size: 15px;
}
table.t {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.t th {
    text-align: left;
    font-weight: 500;
    color: var(--tx3);
    font-size: 12px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line2);
}
table.t td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    overflow-wrap: anywhere;
}
table.t tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}
table.t td.r,
table.t th.r {
    text-align: right;
}
table.t .code-c {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--tx3);
}
.search {
    background: #0a1324;
    border: 1px solid var(--line2);
    border-radius: 9px;
    padding: 6px 10px;
    color: var(--tx);
    outline: none;
    width: 220px;
}
details summary {
    cursor: pointer;
    list-style: none;
}
details summary::-webkit-details-marker {
    display: none;
}
details summary .card-h {
    margin: 0;
}
details[open] summary .card-h {
    margin-bottom: 12px;
}
.chev {
    transition: transform 0.2s;
    display: inline-block;
}
details[open] .chev {
    transform: rotate(90deg);
}
.tower {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.tower i {
    width: 30px;
    height: 22px;
    border-radius: 6px;
    background: #1e293b;
    border: 1px solid #334155;
}
.tower i.r.on {
    background: #ef4444;
    box-shadow: 0 0 18px #ef4444;
}
.tower i.y.on {
    background: #facc15;
    box-shadow: 0 0 18px #facc15;
}
.tower i.g.on {
    background: #22c55e;
    box-shadow: 0 0 18px #22c55e;
}
.tower .pole {
    width: 6px;
    height: 26px;
    background: #334155;
    border-radius: 2px;
}
.flow {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: stretch;
}
.flow .st {
    flex: 1 1 92px;
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    font-size: 11.5px;
    color: var(--tx3);
    position: relative;
}
.flow .st b {
    display: block;
    color: var(--tx2);
    font-size: 13px;
    margin-top: 3px;
}
.flow .st.on {
    border-color: rgba(56, 189, 248, 0.6);
    background: rgba(56, 189, 248, 0.1);
    color: var(--tx2);
}
.flow .st.on b {
    color: #fff;
}
.tank {
    width: 84px;
    height: 120px;
    border: 2px solid #3b4d70;
    border-top: 0;
    border-radius: 0 0 14px 14px;
    position: relative;
    overflow: hidden;
    background: #0a1324;
}
.tank .w {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #38bdf8, #0369a1);
    transition: height 0.6s;
}
.tank .lbl {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 700;
    text-shadow: 0 1px 3px #000;
}
.subsys {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}
.ss {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12.5px;
}
.ss b {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
}
.ss.bad {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
}
.ss.wait {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.45);
}
.ss .n {
    color: var(--tx3);
    font-size: 11.5px;
}
.list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 330px;
    overflow: auto;
}
.li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 7px 10px;
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 12.5px;
}
.li .t {
    color: var(--tx3);
    font-size: 11.5px;
    white-space: nowrap;
    margin-left: auto;
}
.li .lv {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex: none;
    background: var(--c, var(--bad));
}
.members {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.member {
    display: block;
    background: #0a1324;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--st);
}
.member:hover {
    border-color: var(--line2);
}
.member .n {
    font-weight: 600;
    font-size: 13px;
}
.member .s {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--tx2);
    margin: 4px 0 6px;
}
.tip {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    background: #0b1528;
    border: 1px solid var(--line2);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 12.5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 360px;
    white-space: pre-line;
}
.note {
    font-size: 12px;
    color: var(--tx3);
    margin-top: 8px;
}
.toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #3b1220;
    border: 1px solid #7f1d1d;
    color: #fecaca;
    padding: 10px 16px;
    border-radius: 12px;
    z-index: 200;
    font-size: 13px;
}
.kiosk .top .hide-k {
    display: none;
}

/* ======================= responsive ======================= */
.m-only {
    display: none;
}
.eq-switch {
    display: none;
}
.det-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.stats.c4 {
    grid-template-columns: repeat(4, 1fr);
    margin-top: 10px;
}
.split2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.leds.two {
    grid-template-columns: 1fr 1fr;
}
.wash-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 22px;
    align-items: center;
}
.wash-top .machine-row {
    margin: 0;
}
.tank-w {
    text-align: center;
}
.tank-w .muted {
    font-size: 11.5px;
    margin-top: 4px;
}
.gauges {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
}
.hbars {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.hb {
    display: grid;
    grid-template-columns: minmax(0, 42%) 1fr 64px;
    gap: 10px;
    align-items: center;
    font-size: 12.5px;
}
.hb-l {
    color: #c3cee0;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hb-b {
    height: 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 5px;
    overflow: hidden;
}
.hb-b i {
    display: block;
    height: 100%;
    border-radius: 0 5px 5px 0;
}
.hb-v {
    font-weight: 600;
}
.lv-err {
    color: #fca5a5;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
select#eqSel {
    flex: 1;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    background: #0a1324
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a7b4c9' stroke-width='1.6' fill='none'/%3E%3C/svg%3E")
        no-repeat right 12px center;
    border: 1px solid var(--line2);
    border-radius: 10px;
    color: var(--tx);
    padding: 9px 34px 9px 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
}
select#eqSel optgroup {
    background: #0b1426;
    color: var(--tx2);
}
select#eqSel option {
    background: #0b1426;
    color: var(--tx);
}

/* tablet: the sidebar is hidden, show the equipment switcher instead */
@media (max-width: 1100px) {
    .eq-switch {
        display: flex;
        gap: 8px;
        align-items: center;
        margin-bottom: 12px;
    }
    .eq-switch .btn {
        width: 42px;
        height: 40px;
        font-size: 20px;
        line-height: 1;
        flex: none;
    }
    .top {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .top .title small {
        display: none;
    }
    .uname {
        display: none;
    }
    .det-head {
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 10px 18px;
    }
    .det-photo {
        width: 96px;
        height: 96px;
        border-radius: 14px;
    }
    .det-state {
        grid-column: 1/-1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        gap: 8px 12px;
        padding-top: 10px;
        border-top: 1px solid var(--line);
    }
    .det-pills {
        justify-content: flex-start;
    }
    .spindle .h b {
        white-space: nowrap;
    }
    .spindle .body {
        grid-template-columns: 130px minmax(0, 1fr);
    }
    .spindle .body svg {
        width: 130px;
        height: auto;
    }
}
@media (max-width: 1250px) {
    #kioskBtn {
        display: none;
    }
}

/* phone */
@media (max-width: 760px) {
    body {
        font-size: 13.5px;
        background-attachment: scroll;
    }
    /* two-row header: [logo, connection, logout] / [back to overview, period] */
    .top {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 10px;
        padding: 8px 12px;
        align-items: center;
    }
    .top::after {
        content: "";
        order: 4;
        flex-basis: 100%;
        height: 0;
    }
    .top .brand {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        gap: 9px;
    }
    .top .title {
        font-size: 15px;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .top .logo {
        width: 30px;
        height: 30px;
        flex: none;
    }
    .live {
        order: 2;
        font-size: 12px;
        gap: 6px;
        min-width: 0;
    }
    .lv-srv,
    .uname,
    .clock,
    .top .sp,
    #kioskBtn {
        display: none !important;
    }
    .lv-err {
        max-width: 150px;
    }
    .user {
        order: 3;
    }
    .crumbs {
        order: 5;
        flex: 1 1 auto;
        min-width: 0;
    }
    .crumbs .cr-mid {
        display: none;
    }
    .crumbs b {
        font-size: 14px;
    }
    .cr-home {
        color: var(--acc);
        font-weight: 600;
        white-space: nowrap;
    }
    .m-only {
        display: inline;
    }
    .m-hide {
        display: none !important;
    }
    #periodSw {
        order: 6;
        margin-left: auto;
    }
    .seg button {
        padding: 5px 9px;
        font-size: 12.5px;
    }

    .page {
        padding: 12px 10px 32px;
    }
    .card {
        padding: 13px 12px;
        border-radius: 14px;
    }
    .card-h {
        font-size: 14px;
        flex-wrap: wrap;
        row-gap: 2px;
        margin-bottom: 10px;
    }
    .grid {
        gap: 12px;
    }
    .chart {
        height: 230px;
    }
    .chart.short {
        height: 190px;
    }
    .chart.tall {
        height: 280px;
    }

    /* overview */
    .kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
        margin-bottom: 14px;
    }
    .kpi {
        padding: 10px 12px;
        border-radius: 12px;
    }
    .kpi .v {
        font-size: 24px;
    }
    .kpi .l,
    .kpi .h {
        font-size: 11.5px;
    }
    .orders {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .order {
        padding: 12px 14px;
    }
    .order .t {
        flex-wrap: wrap;
        gap: 2px 10px;
    }
    .order .p {
        font-size: 14px;
    }
    .order .m {
        gap: 4px 14px;
        font-size: 12px;
    }
    .group {
        margin-bottom: 20px;
    }
    .group-h {
        gap: 8px;
        margin-bottom: 10px;
    }
    .group-h h2 {
        font-size: 15.5px;
    }
    .group-h .stat {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px 12px;
    }
    .tiles {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .tile {
        padding: 12px;
        gap: 8px;
    }
    .thumb {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }
    .tile-name {
        font-size: 14px;
    }

    /* equipment card */
    .det-head {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 8px 12px;
        padding: 14px 12px;
    }
    .det-photo {
        width: 64px;
        height: 64px;
        border-radius: 12px;
    }
    .det-photo.ic svg {
        width: 34px;
        height: 34px;
    }
    .det-title h1 {
        font-size: 19px;
    }
    .det-title .sub {
        font-size: 12.5px;
        margin-top: 2px;
    }
    .chips {
        margin-top: 8px;
        gap: 5px;
    }
    .chip {
        font-size: 11.5px;
        padding: 2px 8px;
    }
    .det-state {
        grid-column: 1/-1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        gap: 8px 10px;
        padding-top: 4px;
        border-top: 1px solid var(--line);
    }
    .bigpill {
        font-size: 16px;
        padding: 7px 13px;
        border-radius: 12px;
    }
    .det-state .since {
        font-size: 12.5px;
    }
    .det-pills {
        justify-content: flex-start;
        width: 100%;
    }
    .alerts {
        margin: 10px 0;
        gap: 6px;
    }
    .alert {
        flex-wrap: wrap;
        padding: 9px 12px;
        font-size: 13px;
        gap: 4px 10px;
    }
    .alert > span:nth-child(2) {
        flex: 1 1 0;
        min-width: 0;
    }
    .alert > .muted {
        flex-basis: 100%;
        margin-left: 26px !important;
        font-size: 12px;
    }

    .machine-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 12px;
    }
    .mbox {
        padding: 8px 10px;
    }
    .spindles {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    .spindle {
        padding: 11px 12px;
    }
    .spindle .h {
        flex-wrap: wrap;
        gap: 6px 8px;
    }
    .spindle .body {
        grid-template-columns: 118px minmax(0, 1fr);
        gap: 8px;
    }
    .spindle .body svg {
        width: 118px;
        height: auto;
    }
    .kv {
        font-size: 12.5px;
        gap: 5px 10px;
    }
    .stats {
        gap: 8px;
    }
    .stat {
        padding: 9px 10px;
    }
    .stat .v {
        font-size: 19px;
    }
    .stats.c4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .split2 {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .leds {
        grid-template-columns: 1fr 1fr;
        gap: 2px 10px;
    }
    .leds.two {
        grid-template-columns: 1fr;
    }
    .led {
        font-size: 12px;
    }
    .axes {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .wash-top {
        grid-template-columns: auto 1fr;
        gap: 14px 18px;
    }
    .wash-top .machine-row {
        grid-column: 1/-1;
        order: 3;
    }
    .wash-top .tank-w {
        justify-self: center;
    }
    .gauges svg {
        width: 132px;
        height: auto;
    }
    .flow .st {
        flex: 1 1 76px;
        padding: 6px;
    }
    .subsys {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .members {
        grid-template-columns: 1fr;
    }
    .li {
        flex-wrap: wrap;
    }
    .li .t {
        flex-basis: 100%;
        margin-left: 18px;
    }
    .hb {
        grid-template-columns: 1fr 52px;
        gap: 3px 10px;
    }
    .hb-l {
        grid-column: 1/-1;
        text-align: left;
        white-space: normal;
    }
    .tl-axis {
        font-size: 10.5px;
    }
    .legend {
        gap: 6px 14px;
        font-size: 12px;
    }

    /* tables are shown as cards on phones */
    table.t {
        font-size: 12.5px;
    }
    table.t.resp tr:first-child {
        display: none;
    }
    table.t.resp tr {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 14px;
        padding: 9px 2px;
        border-bottom: 1px solid var(--line);
    }
    table.t.resp td {
        border: 0;
        padding: 0;
        text-align: left;
    }
    table.t.resp td.rt {
        flex-basis: 100%;
    }
    table.t.resp td[data-l]::before {
        content: attr(data-l) ": ";
        color: var(--tx3);
        font-weight: 400;
    }
    table.t.resp.sig td:nth-child(3)::before {
        content: "изменён ";
        color: var(--tx3);
    }
    table.t.resp.sig td:nth-child(2) {
        flex: 1;
    }
    table.t td {
        word-break: break-word;
    }

    details summary .card-h .sp {
        display: none;
    }
    .search {
        width: 100%;
        font-size: 16px;
        margin-top: 6px;
    }
    .login {
        padding: 26px 20px 22px;
        border-radius: 18px;
    }
    .login .srv {
        display: block;
        line-height: 1.6;
    }
    .login .srv .dot {
        margin-right: 6px;
        vertical-align: middle;
    }
    .login .srv .muted {
        margin-left: 4px;
    }
    .login h1 {
        font-size: 18px;
    }
    .login input {
        font-size: 16px;
    }
    .tip {
        max-width: calc(100vw - 16px);
    }
}
@media (max-width: 380px) {
    .top .title {
        display: none;
    }
    .kpi .v {
        font-size: 22px;
    }
    .spindle .body {
        grid-template-columns: 1fr;
    }
    .spindle .body svg {
        margin: 0 auto;
    }
}
