/* ==========================================================================
   Painel de Produção OGG
   Industrial fosco: grafite + off-white, azul OGG como destaque,
   verde/âmbar/vermelho reservados para estado das máquinas.
   ========================================================================== */

:root {
    --bg: #F3F5F7;
    --surface: #FFFFFF;
    --surface-2: #F7F9FA;
    --sunken: #EDF0F3;
    --line: #DCE2E7;
    --line-strong: #C3CCD4;
    --text: #15202B;
    --text-2: #4A5866;
    --text-3: #8593A0;

    --sidebar: #1C2329;
    --sidebar-2: #252E35;
    --sidebar-text: #C9D2D9;
    --sidebar-muted: #7E8B95;

    --accent: #1856A6;          /* azul OGG */
    --accent-soft: #E7EFF9;
    --brand-orange: #F2A21B;
    --brand-green: #168A3D;

    --ok: #15803D;   --ok-soft: #E6F4EA;   --ok-line: #B7DEC2;
    --warn: #B45309; --warn-soft: #FDF3E1; --warn-line: #F1D19A;
    --bad: #C2312A;  --bad-soft: #FBEAE8;  --bad-line: #F0BDB8;
    --idle: #1856A6; --idle-soft: #E7EFF9;
    --off: #6B7885;  --off-soft: #ECEFF2;

    /* miniatura da máquina */
    --m-body: #E4E8EC;
    --m-body-2: #D3D9DF;
    --m-edge: #AEB8C1;
    --m-dark: #2B3238;
    --m-paper: #FFFFFF;

    --radius: 10px;             /* contêineres */
    --radius-sm: 7px;           /* controles */
    --radius-xs: 4px;           /* etiquetas internas */
    /* sombras tingidas com o azul-grafite do fundo, luz vindo de cima */
    --shadow: 0 1px 2px rgba(21, 32, 43, .05), 0 2px 6px -2px rgba(21, 32, 43, .06);
    --shadow-lift: 0 14px 30px -14px rgba(21, 32, 43, .28), 0 2px 6px -2px rgba(21, 32, 43, .08);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
    --ease: cubic-bezier(.2, .7, .2, 1);
    --z-topbar: 5; --z-sidebar: 10; --z-toast: 50;
    --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-head: 'Outfit', 'Geist', system-ui, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #12171B;
    --surface: #1A2126;
    --surface-2: #1F272D;
    --sunken: #151B1F;
    --line: #2C363E;
    --line-strong: #3B4750;
    --text: #E6EBEF;
    --text-2: #A9B5BF;
    --text-3: #6F7D88;
    --sidebar: #0D1114;
    --sidebar-2: #171D22;
    --accent: #5B9BE8;
    --accent-soft: #1B2A3D;
    --ok: #4CC07A;   --ok-soft: #16301F;   --ok-line: #24553A;
    --warn: #E9A84A; --warn-soft: #33270F; --warn-line: #5C4520;
    --bad: #F0776F;  --bad-soft: #3A1B19;  --bad-line: #6A2E2A;
    --idle: #5B9BE8; --idle-soft: #1B2A3D;
    --off: #8996A1;  --off-soft: #222A30;
    /* cores das máquinas (--m-*): iguais às do tema claro — a máquina não muda de cor com o tema */
    --shadow: 0 1px 2px rgba(4, 8, 12, .35);
    --shadow-lift: 0 16px 34px -14px rgba(4, 8, 12, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; font-weight: 600; letter-spacing: -.018em; text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
:where(a, button, input, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; transition: top .2s var(--ease); }
.skip:focus { top: 12px; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100dvh; }
.sidebar {
    width: 236px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
.brand { display: block; padding: 20px 20px 14px; border-bottom: 1px solid var(--sidebar-2); }
/* a marca tem um "O" azul-marinho: fica numa placa clara, sem a margem branca do arquivo original */
.brand img { width: 118px; display: block; background: #fff; border-radius: 9px; padding: 7px 11px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 6px 16px -8px rgba(0, 0, 0, .6); transition: transform .2s var(--ease); }
.brand:hover img { transform: translateY(-1px); }
.brand-sub { display: block; margin-top: 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); font-weight: 500; transition: background-color .15s, color .15s;
}
.nav a:active { transform: translateY(1px); }
.nav a:hover { background: var(--sidebar-2); }
.nav a.active { background: var(--sidebar-2); color: #fff; box-shadow: inset 3px 0 0 var(--brand-orange); }
.nav-badge { margin-left: auto; background: var(--brand-orange); color: #1C2329; font-size: 11px; padding: 0 7px; border-radius: 10px; }
.sidebar-machines { padding: 6px 10px; border-top: 1px solid var(--sidebar-2); overflow-y: auto; flex: 1; }
.sidebar-machines .label { font-size: 12px; font-weight: 500; color: var(--sidebar-muted); padding: 12px 12px 6px; }
.side-machine { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--sidebar-text); font-size: 13px; }
.side-machine:hover, .side-machine.active { background: var(--sidebar-2); }
.side-machine .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { padding: 12px 14px 16px; border-top: 1px solid var(--sidebar-2); display: flex; flex-direction: column; gap: 8px; }
.conn-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sidebar-muted); }
.conn-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.conn-pill.ok .dot { background: #3FB56A; }
.conn-pill.bad .dot { background: #E5534B; }
.ghost-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--sidebar-2); color: var(--sidebar-text); padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; }
.ghost-btn:hover { background: var(--sidebar-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 16px 28px; border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
    position: sticky; top: 0; z-index: var(--z-topbar);
}
.topbar h1 { font-size: 22px; letter-spacing: -.025em; }
.topbar p { margin: 2px 0 0; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--font-mono); font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mode-tag { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.mode-tag.live { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.mode-tag.mock { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.view { padding: 24px 28px 56px; display: flex; flex-direction: column; gap: 20px; max-width: 1600px; width: 100%; margin-inline: auto; }
.view:focus { outline: none; }
/* entrada em cascata ao abrir cada tela (só os blocos da tela; atualizações não repetem) */
.view > * { animation: rise .42s var(--ease) both; }
.view > *:nth-child(2) { animation-delay: .04s; }
.view > *:nth-child(3) { animation-delay: .08s; }
.view > *:nth-child(4) { animation-delay: .12s; }
.view > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--text-3); }
.card-head .hint { font-size: 12px; color: var(--text-3); }
.card-body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.grid-2-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

/* ---------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kpi-color, var(--line-strong)); }
.kpi .label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi .value { font-family: var(--font-head); font-size: 30px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1.15; }
.kpi .foot { font-size: 12px; color: var(--text-3); }
.kpi.blue { --kpi-color: var(--accent); }
.kpi.orange { --kpi-color: var(--brand-orange); }
.kpi.green { --kpi-color: var(--brand-green); }
.kpi.warn { --kpi-color: var(--warn); }
.kpi.bad { --kpi-color: var(--bad); }
.kpi.bad .value { color: var(--bad); }

/* ---------------------------------------------------------------- estado */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; border: 1px solid transparent; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.printing { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.pill.idle { color: var(--idle); background: var(--idle-soft); }
.pill.alert { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.pill.stopped, .pill.error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.pill.offline, .pill.unknown { color: var(--off); background: var(--off-soft); }
.dot-state { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--off); }
.dot-state.printing { background: #3FB56A; box-shadow: 0 0 0 3px rgba(63, 181, 106, .2); }
.dot-state.idle { background: #5B9BE8; }
.dot-state.alert { background: #E9A84A; }
.dot-state.stopped, .dot-state.error { background: #E5534B; }

.job-state { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.js-5 { color: var(--ok); background: var(--ok-soft); }
.js-6, .js-8 { color: var(--bad); background: var(--bad-soft); }
.js-3 { color: var(--idle); background: var(--idle-soft); }
.js-4 { color: var(--warn); background: var(--warn-soft); }
.js-7, .js-9, .js-1, .js-2 { color: var(--text-2); background: var(--sunken); }

.bar { height: 8px; background: var(--sunken); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 4px; transition: width .6s ease; }
.bar.stopped > i { background: var(--bad); }
.bar.unknown > i { background: repeating-linear-gradient(45deg, var(--line-strong) 0 6px, transparent 6px 12px); width: 100% !important; }
.bar.thin { height: 5px; }

.alert-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); padding: 2px 8px; border-radius: var(--radius-sm); }
.alert-chip .ic { width: 14px; height: 14px; }
.inc-list { display: flex; flex-wrap: wrap; gap: 6px; }
.inc-list.full { flex-direction: column; align-items: flex-start; }
.inc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: var(--radius-sm); border: 1px solid; max-width: 100%; }
.inc-chip .ic { width: 14px; height: 14px; flex: none; }
.inc-chip b { font-weight: 600; white-space: nowrap; }
.inc-chip span { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.inc-list.full .inc-chip { white-space: normal; }
.inc-bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.inc-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.inc-info { color: var(--text-2); background: var(--sunken); border-color: var(--line); }
.stop-banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad); }
.stop-banner .ic { width: 22px; height: 22px; margin-top: 2px; }
.stop-banner b { display: block; font-size: 15px; }
.stop-banner span { color: var(--text-2); font-size: 12.5px; }
.occ { padding: 4px 0 8px; }
.occ h3 { font-size: 13px; padding: 12px 18px 6px; color: var(--text-2); font-weight: 600; }
.ok-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); }
.ok-chip .ic { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- frota */
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.machine-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; overflow: hidden; }
.machine-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--state-c, transparent); }
.machine-card.state-printing { --state-c: var(--ok); }
.machine-card.state-alert { --state-c: var(--warn); }
.machine-card.state-stopped, .machine-card.state-error { --state-c: var(--bad); }
.machine-card.state-offline { --state-c: var(--off); }
.machine-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.machine-card:active { transform: translateY(0); }
.machine-card.state-alert { border-color: var(--warn-line); }
.machine-card.state-stopped, .machine-card.state-error { border-color: var(--bad-line); }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px 0; }
.mc-top h3 { font-size: 15px; }
.mc-top .ip { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.mc-thumb { padding: 4px 12px 0; height: 150px; display: flex; align-items: center; justify-content: center; }
.mc-thumb svg { width: 100%; height: 100%; }
.mc-body { padding: 4px 16px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mc-job { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-job.none { color: var(--text-3); font-weight: 500; }
.mc-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); gap: 8px; }
.mc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--text-2); }
.mc-foot .counts { display: flex; gap: 12px; }
.mc-foot b { color: var(--text); font-weight: 600; }

/* miniatura SVG */
.mx-beacon { transform-origin: center; }
.state-printing .mx-beacon { animation: pulse 1.6s ease-in-out infinite; }
.state-alert .mx-beacon, .state-stopped .mx-beacon, .state-error .mx-beacon { animation: blink 1s steps(2, start) infinite; }
.mx-sheet { opacity: 0; }
.feeding .mx-sheet { animation: feed 2.4s linear infinite; }
.feeding .mx-sheet.s2 { animation-delay: .8s; }
.feeding .mx-sheet.s3 { animation-delay: 1.6s; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes blink { to { opacity: .2; } }
@keyframes feed {
    0% { transform: translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateX(var(--run, 150px)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .state-printing .mx-beacon, .state-alert .mx-beacon, .state-stopped .mx-beacon, .feeding .mx-sheet { animation: none; }
    .feeding .mx-sheet.s2 { opacity: 1; transform: translateX(calc(var(--run, 150px) / 2)); }
}

/* ---------------------------------------------------------------- atividade */
.activity { display: flex; flex-direction: column; }
.activity-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line); color: var(--text); transition: background-color .15s; }
.activity-row:last-child { border-bottom: 0; }
.activity-row:hover { background: var(--surface-2); }
.activity-row .t { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-row .s { font-size: 12px; color: var(--text-2); }
.activity-row .r { text-align: right; font-size: 12px; color: var(--text-2); min-width: 92px; }
.activity-row .r b { display: block; font-size: 15px; color: var(--text); font-family: var(--font-head); }
.empty { padding: 32px 18px 36px; text-align: center; color: var(--text-3); font-size: 13px; text-wrap: pretty; }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }

/* ---------------------------------------------------------------- máquina */
.stage { overflow: hidden; }
.m3d {
    position: relative; height: 400px;
    background: radial-gradient(ellipse 70% 80% at 50% 30%, var(--surface) 0%, var(--surface-2) 55%, var(--sunken) 100%);
}
.m3d-canvas { display: block; width: 100%; height: 100%; }
.m3d-canvas.static { pointer-events: none; }
.m3d-fallback { position: absolute; inset: 40px 8%; display: flex; align-items: center; justify-content: center; }
.m3d-fallback svg { width: 100%; height: 100%; }
.m3d-badge { position: absolute; top: 14px; left: 16px; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.m3d-name { font-family: var(--font-head); font-weight: 600; font-size: 15px; }
.m3d-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.m3d-hint { position: absolute; left: 16px; bottom: 12px; font-size: 12px; color: var(--text-3); pointer-events: none; }
.m3d-tip {
    position: absolute; z-index: 3; pointer-events: none; max-width: 270px;
    display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border-radius: var(--radius-sm);
    background: var(--sidebar); color: #fff; font-size: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.m3d-tip span { color: #B9C4CC; }
.m3d-tip em { font-style: normal; color: #F2C46B; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.back:hover { color: var(--accent); }
.hero { display: grid; grid-template-columns: minmax(260px, 420px) minmax(0, 1fr); gap: 0; overflow: hidden; }
.hero-visual { background: var(--surface-2); border-right: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.hero-visual svg { width: 100%; height: 190px; }
.hero-visual .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 12px; }
.hero-visual .facts dt { color: var(--text-3); }
.hero-visual .facts dd { margin: 0; font-weight: 600; }
.hero-main { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hero-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.hero-head h2 { font-size: 22px; }
.job-spot { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.job-spot .title { font-family: var(--font-head); font-size: 18px; font-weight: 600; word-break: break-word; }
.job-spot .big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.job-spot .big .pct { font-family: var(--font-head); font-size: 40px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.job-spot .bar { height: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.job-spot .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; }
.stat .k { font-size: 11.5px; color: var(--text-3); }
.stat .v { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; word-break: break-word; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 14px; cursor: pointer; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s, border-color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: var(--sunken); padding: 0 6px; border-radius: 8px; margin-left: 4px; color: var(--text-2); }

.timeline { list-style: none; margin: 0; padding: 6px 18px 12px; }
.timeline li { display: grid; grid-template-columns: 140px 12px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: start; font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text-3); font-family: var(--font-mono); font-size: 12px; }
.timeline .dot-state { margin-top: 5px; }

.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

/* ---------------------------------------------------------------- tabelas */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { opacity: .5; margin-left: 4px; }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.data .title-cell { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
table.data .prog { min-width: 120px; }
table.data .prog .bar { margin-top: 4px; }

/* ---------------------------------------------------------------- filas */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.input, .select {
    height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .input:focus-visible, .select:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.search { position: relative; }
.search .ic { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.search .input { padding-left: 34px; width: 260px; max-width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--surface); border: 0; border-right: 1px solid var(--line); padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text-2); transition: background-color .15s, color .15s; }
.seg button:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }

.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; }
.lane { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 120px; }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); }
.lane-head .n { font-size: 12px; color: var(--text-2); background: var(--surface); padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); }
.lane-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.job-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.job-card .t { font-weight: 600; font-size: 13px; word-break: break-word; }
.job-card .m { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.job-card .q { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 0 6px; border-radius: 3px; }
.lane.l-printing .lane-head { box-shadow: inset 0 3px 0 var(--ok); }
.lane.l-waiting .lane-head { box-shadow: inset 0 3px 0 var(--idle); }
.lane.l-held .lane-head { box-shadow: inset 0 3px 0 var(--warn); }
.lane.l-done .lane-head { box-shadow: inset 0 3px 0 var(--line-strong); }

/* ---------------------------------------------------------------- relatórios */
.report-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; }
.report-bar .left { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface);
    cursor: pointer; font-weight: 500; color: var(--text); white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s, filter .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad-line); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; }
.rank { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 9px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.rank-row:last-child { border-bottom: 0; }
.rank-row .bar { grid-column: 1 / -1; }
.rank-row .bar > i { background: var(--accent); }
.rank-row .n { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- impressoras */
.form-grid { display: grid; grid-template-columns: 1fr 1.4fr 1fr auto auto; gap: 12px; align-items: end; }
.test-result { margin-top: 12px; font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid; }
.test-result.ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.test-result.bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.limit { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; }
.limit .ic { color: var(--ok); margin-top: 2px; }
.limit b { display: block; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--sidebar); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: 0 12px 30px -10px rgba(4, 8, 12, .5); z-index: var(--z-toast); max-width: 380px; animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast.bad { background: var(--bad); }

.skeleton { background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); min-height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- responsivo */
@media (max-width: 1180px) {
    .grid-2, .grid-2-even { grid-template-columns: minmax(0, 1fr); }
    .board { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
    .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 10; flex-direction: row; align-items: center; overflow-x: auto; }
    .brand { border: 0; padding: 10px 12px; }
    .brand img { width: 80px; padding: 4px 7px; border-radius: 7px; }
    .brand-sub, .sidebar-machines, .sidebar-foot .conn-pill span:last-child { display: none; }
    .nav { flex-direction: row; padding: 6px; }
    .nav a { padding: 8px 10px; }
    .nav a span { display: none; }
    .sidebar-foot { flex-direction: row; border: 0; padding: 8px 12px; margin-left: auto; }
    .ghost-btn span { display: none; }
    .topbar { position: static; padding: 14px 16px; }
    .view { padding: 16px 16px 40px; }
    .hero { grid-template-columns: minmax(0, 1fr); }
    .m3d { height: 280px; }
    .m3d-hint { display: none; }
    .hero-visual { border-right: 0; border-bottom: 1px solid var(--line); }
    .fleet { grid-template-columns: minmax(0, 1fr); }
    .board { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .search .input { width: 100%; }
    .job-spot .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .timeline li { grid-template-columns: 1fr; gap: 2px; }
    .timeline li .dot-state { display: none; }
}

/* ---------------------------------------------------------------- impressão (relatórios) */
@media print {
    :root { --bg: #fff; --surface: #fff; --surface-2: #fff; }
    .sidebar, .topbar-right, .no-print, .tabs { display: none !important; }
    .app { display: block; }
    .topbar { position: static; border: 0; padding: 0 0 12px; }
    .view { padding: 0; max-width: none; }
    .card, .kpi { box-shadow: none; break-inside: avoid; }
    .grid-2, .grid-2-even { grid-template-columns: 1fr 1fr; }
    table.data th { position: static; }
}

/* ordem das máquinas (tela Impressoras) */
table.data td.ord { white-space: nowrap; width: 1%; padding-right: 4px; }
table.data td.ord .grip { display: inline-flex; vertical-align: middle; color: var(--text-3); cursor: grab; margin-right: 2px; }
table.data td.ord .grip .ic { width: 16px; height: 16px; }
table.data td.ord .btn { padding: 0 6px; }
table.data td.ord .btn[disabled] { opacity: .3; pointer-events: none; }
table.data tr[draggable="true"] { cursor: default; }
table.data tr.dragging td { opacity: .45; }
table.data tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
table.data tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

/* gavetas (página da máquina) */
.trays { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tray { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); min-width: 0; }
.tray.in-use { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tray-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; }
.tray-head .tags { display: flex; gap: 4px; flex-shrink: 0; }
.tray .tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.tray .tag.use { background: var(--accent-soft); color: var(--accent); }
.tray .tag.low { background: var(--warn-soft); color: var(--warn); }
.tray .tag.empty { background: var(--bad-soft); color: var(--bad); }
.tray .tag.off { background: var(--surface-2); color: var(--text-3); }
.tray-media { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-media.none { color: var(--text-3); font-weight: 500; font-style: italic; }
.tray-spec { font-size: 12.5px; color: var(--text-2); }
.tray-bar { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin-top: 4px; }
.tray-bar i { display: block; height: 100%; background: var(--ok); border-radius: 999px; transition: width .4s ease; }
.tray.low .tray-bar i { background: var(--warn); }
.tray.empty .tray-bar i, .tray.off .tray-bar i { background: var(--bad); }
.tray-lvl { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tray-bar.unk i { background: repeating-linear-gradient(45deg, var(--line-strong) 0 6px, var(--line) 6px 12px); }

/* data dos jobs (filas) */
.job-card .m.when { color: var(--text-3); font-size: 11.5px; align-items: center; gap: 4px; }
.job-card .m.when .ic { width: 13px; height: 13px; }
.job-card .m.stale { color: var(--warn); font-size: 11.5px; }

/* ao vivo: barra desliza entre leituras; cartão pulsa quando a máquina começa a imprimir */
.bar[data-live] i { transition: width .25s linear; }
.machine-card.just-started { animation: started-pulse 1.3s ease-out 3; border-color: var(--ok-line); }
@keyframes started-pulse {
    0% { box-shadow: 0 0 0 0 rgba(63, 181, 106, .55), var(--shadow); }
    100% { box-shadow: 0 0 0 16px rgba(63, 181, 106, 0), var(--shadow); }
}
@media (prefers-reduced-motion: reduce) {
    .machine-card.just-started { animation: none; }
    .bar[data-live] i { transition: none; }
}

/* impressos do dia */
.printed-sum { margin-top: 12px; font-size: 13.5px; color: var(--text-2); }
.printed-sum b { color: var(--text); }
.filters .seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
table.data.printed mark { background: var(--warn-soft); color: inherit; padding: 0 1px; border-radius: 3px; }
table.data.printed td:nth-child(2) { white-space: nowrap; }

/* ==========================================================================
   Suprimentos (página da máquina)
   ========================================================================== */
.supplies { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.supply { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.supply-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.supply .tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.supply .tag.low { background: var(--warn-soft); color: var(--warn); }
.supply.low { border-color: var(--warn-line); }
.supply.low .tray-bar i { background: var(--warn); }
.supply.rec:not(.low) .tray-bar i { background: var(--text-3); }

/* ==========================================================================
   Conferência do dia (Impressos do dia)
   ========================================================================== */
table.data.audit td { vertical-align: top; }
.audit-ok, .audit-warn, .audit-info { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.audit-ok { color: var(--ok); }
.audit-warn { color: var(--warn); }
.audit-info { color: var(--text-2); }
.audit-ok .ic, .audit-warn .ic { width: 15px; height: 15px; }
.gaps { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.gap { font-family: var(--font-mono); font-size: 12px; background: var(--warn-soft); color: var(--warn); padding: 1px 7px; border-radius: var(--radius-xs); white-space: nowrap; }
.gap .subtle { color: inherit; opacity: .75; font-family: var(--font); }
.audit-note { margin: 4px 18px 16px; max-width: 90ch; }

/* ==========================================================================
   Utilização (Relatórios)
   ========================================================================== */
.util { display: flex; flex-direction: column; gap: 18px; }
.util-row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 6px 18px; align-items: center; }
.util-name { display: flex; flex-direction: column; font-size: 13px; line-height: 1.35; }
.util-name .subtle { font-size: 12px; }
.util-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--sunken); }
.util-bar i { display: block; height: 100%; transition: width .5s var(--ease); }
.util-bar i + i { box-shadow: -1px 0 0 var(--surface); }
.util-legend { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--text-2); }
.util-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.u-key { display: inline-flex; align-items: center; gap: 6px; }
.u-key i { width: 9px; height: 9px; border-radius: 3px; }
.util-stops { grid-column: 2; font-size: 12px; }
.u-printing, .u-key.u-printing i { background: var(--ok); }
.u-stopped, .u-key.u-stopped i { background: var(--bad); }
.u-idle, .u-key.u-idle i { background: color-mix(in srgb, var(--idle) 45%, var(--sunken)); }
.u-offline, .u-key.u-offline i { background: var(--line-strong); }
.u-key.u-printing, .u-key.u-stopped, .u-key.u-idle, .u-key.u-offline { background: none; }

/* ==========================================================================
   Senha da tela Impressoras
   ========================================================================== */
.lock-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.lock-row .muted { font-size: 13px; }
.lock-state { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.lock-state.on { background: var(--ok-soft); color: var(--ok); }
.lock-state.off { background: var(--warn-soft); color: var(--warn); }
.lock-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(380px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 60px -20px rgba(4, 8, 12, .45); }
.dlg::backdrop { background: rgba(13, 17, 20, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlg-in .22s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg form { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg h3 { font-size: 18px; }
.dlg p { margin: -4px 0 0; font-size: 13px; min-height: 1em; }
.dlg p.bad { color: var(--bad); }
.dlg .input { width: 100%; }
.dlg-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ==========================================================================
   Modo TV (#/tv): tela de produção, sem menu, letras grandes
   ========================================================================== */
body.tv .sidebar, body.tv .topbar, body.tv .skip { display: none; }
body.tv .view { max-width: none; padding: 0; gap: 0; min-height: 100dvh; }
body.tv .toast { font-size: 18px; padding: 14px 20px; max-width: 520px; }
.tv-wrap { display: flex; flex-direction: column; height: 100dvh; padding: 18px 22px 22px; gap: 16px;
    background: radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--accent) 10%, var(--bg)) 0%, var(--bg) 60%); }
.tv-head { display: flex; align-items: center; gap: 24px; }
.tv-logo { height: 42px; background: #fff; border-radius: 9px; padding: 6px 10px; }
.tv-kpis { display: flex; gap: 12px; flex: 1; justify-content: center; flex-wrap: wrap; }
.tv-kpi { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 16px; border-left: 2px solid var(--line-strong); }
.tv-kpi span { font-size: 14px; color: var(--text-2); }
.tv-kpi b { font-family: var(--font-head); font-size: 34px; font-weight: 600; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tv-kpi b small { font-size: 20px; color: var(--text-3); font-weight: 500; }
.tv-kpi.warn { border-color: var(--warn); } .tv-kpi.warn b { color: var(--warn); }
.tv-kpi.bad { border-color: var(--bad); } .tv-kpi.bad b { color: var(--bad); }
.tv-right { display: flex; align-items: center; gap: 6px; }
.tv-clock { font-family: var(--font-mono); font-size: 40px; font-weight: 500; letter-spacing: -.02em; margin-right: 8px; font-variant-numeric: tabular-nums; }
.tv-right .btn { opacity: .55; }
.tv-right .btn:hover { opacity: 1; }
.tv-grid { flex: 1; min-height: 0; display: grid; gap: 16px;
    grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr)); }
.tv-tile { position: relative; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 14px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.tv-tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--state-c, var(--line-strong)); }
.tv-tile.state-printing { --state-c: var(--ok); }
.tv-tile.state-idle { --state-c: var(--idle); }
.tv-tile.state-alert { --state-c: var(--warn); border-color: var(--warn-line); }
.tv-tile.state-stopped, .tv-tile.state-error { --state-c: var(--bad); border-color: var(--bad-line); }
.tv-tile.state-offline { --state-c: var(--off); opacity: .8; }
.tv-tile.just-started { animation: started-pulse 1.3s ease-out 3; }
/* nome sempre inteiro (quebra em até 2 linhas); estado e fila numa linha própria, embaixo */
.tv-top { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tv-name { font-size: clamp(19px, 1.55vw, 30px); line-height: 1.15; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.tv-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tv-status .pill { font-size: clamp(13px, .85vw, 16px); padding: 4px 12px; }
.tv-q { font-size: clamp(13px, .85vw, 16px); color: var(--text-2); }
/* avisos: faixas grandes, coloridas pela gravidade */
.tv-alerts { display: flex; flex-direction: column; gap: 6px; }
.tv-alert { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; padding: 7px 12px; border-radius: 10px;
    border: 1px solid; font-size: clamp(13px, .9vw, 17px); min-width: 0; line-height: 1.25; }
.tv-alert .ic { width: 20px; height: 20px; grid-row: span 2; }
.tv-alert b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-alert span { font-size: .86em; }
.tv-alert span { color: var(--text); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-alert.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.tv-alert.bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-line); }
.tv-more { font-size: clamp(12px, .8vw, 15px); color: var(--text-2); padding-left: 4px; }
.tv-tile.has-warn { border-color: var(--warn-line); }
.tv-tile.has-bad { border-color: var(--bad-line); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 35%, transparent), var(--shadow); }
.tv-thumb { flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tv-tile > :not(.tv-thumb) { flex-shrink: 0; }   /* só a miniatura encolhe: nome, avisos, job e rodapé ficam inteiros */
.tv-thumb svg { width: 100%; height: 100%; max-height: 340px; }
.tv-stop { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; background: var(--bad); color: #fff;
    font-size: clamp(16px, 1.15vw, 22px); animation: tv-stop-pulse 2s ease-in-out infinite; min-width: 0; }
.tv-stop .ic { width: 26px; height: 26px; flex: none; }
.tv-stop div { display: flex; flex-direction: column; min-width: 0; }
.tv-stop span { font-size: .72em; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes tv-stop-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad) 30%, transparent); } }
.tv-job { display: flex; flex-direction: column; gap: 8px; }
.tv-job .t { font-weight: 600; font-size: clamp(16px, 1.15vw, 21px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-job.none { color: var(--text-3); font-size: clamp(16px, 1.1vw, 20px); font-weight: 500; padding: 6px 0; }
.tv-big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tv-big b { font-family: var(--font-head); font-size: clamp(38px, 3.4vw, 64px); font-weight: 600; line-height: .95; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.tv-big > span { color: var(--text-2); font-size: clamp(14px, 1vw, 18px); }
.tv-job .bar { height: 12px; border-radius: 6px; }
.tv-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--text-2); font-size: clamp(13px, .95vw, 17px); }
.tv-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.tv-chips .inc-chip { font-size: 13px; }
.tv-foot { display: flex; gap: 18px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-2); font-size: clamp(13px, .95vw, 17px); margin-top: auto; }
.tv-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
    .tv-wrap { height: auto; min-height: 100dvh; }
    .tv-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); grid-template-rows: none; }
    .tv-tile { min-height: 380px; }
    .tv-head { flex-wrap: wrap; }
}
@media (max-width: 640px) {
    .tv-wrap { padding: 12px 16px 16px; }
    .tv-head { gap: 12px; }
    .tv-logo { height: 34px; padding: 4px 8px; }
    .tv-right { margin-left: auto; }
    .tv-clock { font-size: 28px; }
    .tv-kpis { order: 3; flex-basis: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .tv-kpi { padding: 4px 10px; }
    .tv-kpi b { font-size: 26px; }
    .tv-tile { min-height: 0; padding: 14px 16px 12px; }
    .tv-thumb { flex: none; height: 150px; }
    .tv-top .pill { padding: 3px 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .view > *, .toast, .dlg[open], .tv-tile.just-started, .tv-stop { animation: none; }
    html { scroll-behavior: auto; }
}
@media (max-width: 860px) {
    .util-row { grid-template-columns: minmax(0, 1fr); }
    .util-legend, .util-stops { grid-column: 1; }
    .lock-row { grid-template-columns: auto minmax(0, 1fr); }
    .lock-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media print { .view > * { animation: none; } }

/* bandejas de saída e contadores (página da máquina / relatórios) */
.supply.out.full { border-color: var(--bad-line); }
.supply.out.full .tray-bar i { background: var(--bad); }
.supply.out.ok .tray-bar i { background: var(--idle); }
table.data.meters td { padding-top: 8px; padding-bottom: 8px; }
table.data.meters tr.grp td { border-top: 2px solid var(--line); }

/* contadores no quadro da máquina (coluna da esquerda) */
.hero-meters { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.hm-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; margin-bottom: 6px; }
.hm-head .subtle { font-size: 11.5px; }
.hero-meters table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hero-meters th { font-weight: 500; color: var(--text-3); font-size: 11px; padding: 0 0 4px; text-align: left; }
.hero-meters td { padding: 4px 0; border-top: 1px dashed var(--line); }
.hero-meters td:first-child { color: var(--text-2); padding-right: 8px; }
.hero-meters .r { text-align: right; padding-left: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hero-meters td.num { font-weight: 600; }

/* acesso pela web (tela Impressoras) */
.users-form { grid-template-columns: 1fr 1fr 1fr auto; }
@media (max-width: 860px) { .users-form { grid-template-columns: minmax(0, 1fr); } }
a.ghost-btn { text-decoration: none; }

/* avisos menores: discretos (não pedem ação agora) */
.inc-quiet { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-3); background: var(--surface-2);
    border: 1px dashed var(--line); padding: 1px 8px; border-radius: 999px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inc-quiet b { font-weight: 600; color: var(--text-2); }
.inc-minor { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 4px; }
.inc-minor > .subtle { font-size: 11.5px; width: 100%; }

/* página da máquina: blocos imprimindo/fila · retidos · impressos hoje */
.work-blocks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 12px; align-items: start; }
.work-blocks .lane-body { max-height: 520px; overflow-y: auto; }
.work-blocks .l-done .lane-body { gap: 0; padding: 4px 0; }
.done-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 6px 12px; font-size: 13px; border-bottom: 1px solid var(--line); }
.done-row:last-child { border-bottom: 0; }
.done-row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-row .r { font-variant-numeric: tabular-nums; color: var(--text-2); }
.done-row.cancel .t { text-decoration: line-through; color: var(--text-3); }
@media (max-width: 1000px) { .work-blocks { grid-template-columns: 1fr; } }
