/* G4 Cotton — interface industrial: neutra, legível, cor só para transmitir estado. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f4;
  --border: #dde3e9;
  --border-strong: #c7d0d9;
  --text: #17202b;
  --text-2: #4b5866;
  --text-3: #7a8795;
  --brand: #1f6f5c;
  --brand-2: #185a4b;
  --brand-soft: #e3f1ed;
  --focus: #2f7de1;

  --ok: #15803d;        --ok-soft: #e4f4ea;
  --stop: #d92d20;      --stop-soft: #fdecea;
  --danger: #b91c1c;    --danger-soft: #fce8e8;
  --warn: #b45309;      --warn-soft: #fdf3dc;
  --info: #1d4ed8;      --info-soft: #e5edfd;
  --muted: #64748b;     --muted-soft: #eceff3;
  --manual: #a16207;    --manual-soft: #fbf2d9;
  --auto: #1d4ed8;      --auto-soft: #e5edfd;

  --sidebar: #141c24;
  --sidebar-2: #1c2631;
  --sidebar-text: #c3ccd6;
  --sidebar-active: #ffffff;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-3: 0 18px 40px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 24px;
  --sidebar-w: 236px;
  --topbar-h: 60px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141a; --surface: #151d25; --surface-2: #19232c; --surface-3: #1f2a35;
    --border: #273440; --border-strong: #34434f; --text: #e6ebf0; --text-2: #aab6c2; --text-3: #7d8a97;
    --brand: #3fae90; --brand-2: #56c2a4; --brand-soft: #16332c;
    --ok: #3fb96b; --ok-soft: #143222; --stop: #f47272; --stop-soft: #3b1c1c;
    --danger: #f26666; --danger-soft: #3b1d1f; --warn: #e9a23b; --warn-soft: #3a2d15;
    --info: #6c9cf5; --info-soft: #1b2a47; --muted: #8b99a8; --muted-soft: #222d38;
    --manual: #e3b341; --manual-soft: #372d14; --auto: #6c9cf5; --auto-soft: #1b2a47;
    --sidebar: #0b1116; --sidebar-2: #131b22;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 4px 14px rgba(0,0,0,.45); --shadow-3: 0 18px 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141a; --surface: #151d25; --surface-2: #19232c; --surface-3: #1f2a35;
  --border: #273440; --border-strong: #34434f; --text: #e6ebf0; --text-2: #aab6c2; --text-3: #7d8a97;
  --brand: #3fae90; --brand-2: #56c2a4; --brand-soft: #16332c;
  --ok: #3fb96b; --ok-soft: #143222; --stop: #f47272; --stop-soft: #3b1c1c;
  --danger: #f26666; --danger-soft: #3b1d1f; --warn: #e9a23b; --warn-soft: #3a2d15;
  --info: #6c9cf5; --info-soft: #1b2a47; --muted: #8b99a8; --muted-soft: #222d38;
  --manual: #e3b341; --manual-soft: #372d14; --auto: #6c9cf5; --auto-soft: #1b2a47;
  --sidebar: #0b1116; --sidebar-2: #131b22;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 4px 14px rgba(0,0,0,.45); --shadow-3: 0 18px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- casca ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 6px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2d8a72, #1a5a4b);
  display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: #8fa0b0; letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7f8f; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; color: var(--sidebar-text);
  font-weight: 500; text-decoration: none; min-height: 42px; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: rgba(63, 174, 144, .16); color: var(--sidebar-active); box-shadow: inset 3px 0 0 #3fae90; }
.nav a svg.lucide { width: 19px; height: 19px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #243140; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: #e1e7ed; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2a3947; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #cfe7df; flex: none; }
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: 11px; color: #8fa0b0; }
.side-btn { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; background: none;
  border: 0; color: var(--sidebar-text); cursor: pointer; min-height: 40px; text-align: left; }
.side-btn:hover { background: var(--sidebar-2); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 var(--gutter); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .clock { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.mobile-only { display: none !important; }
.content { padding: var(--gutter); display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.bottom-nav { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-sm.btn-icon { width: 32px; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 0 12px; min-height: 34px; cursor: pointer; font-weight: 550; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; line-height: 18px; white-space: nowrap; background: var(--muted-soft); color: var(--muted);
}
.badge svg.lucide { width: 14px; height: 14px; }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-stop { background: var(--stop-soft); color: var(--stop); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-manual { background: var(--manual-soft); color: var(--manual); }
.b-auto { background: var(--auto-soft); color: var(--auto); }
.b-muted { background: var(--muted-soft); color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.input, select.input, textarea.input {
  min-height: 40px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); width: 100%; min-width: 0;
}
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.input[readonly] { background: var(--surface-2); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid; font-weight: 500; }
.alert svg.lucide { margin-top: 1px; }
.alert b { font-weight: 700; }
.alert.a-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.a-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert.a-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert .alert-text { color: var(--text); font-weight: 400; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.kpi-icon svg.lucide { width: 21px; height: 21px; }
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi > div:last-child { min-width: 0; }
.i-ok { background: var(--ok-soft); color: var(--ok); }
.i-stop { background: var(--stop-soft); color: var(--stop); }
.i-info { background: var(--info-soft); color: var(--info); }
.i-warn { background: var(--warn-soft); color: var(--warn); }
.i-danger { background: var(--danger-soft); color: var(--danger); }
.i-muted { background: var(--muted-soft); color: var(--muted); }

/* ---------- cartões dos descaroçadores ---------- */
.machines { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.mcard { display: flex; flex-direction: column; overflow: hidden; }
.mcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; }
.mcard-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mcard-title .num { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); display: grid;
  place-items: center; font-weight: 750; font-size: 15px; flex: none; }
.mcard-title b { display: block; font-size: 14px; white-space: nowrap; }
.mcard-title span { font-size: 12px; color: var(--text-3); }
.mstate { margin: 0 16px; border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.mstate svg.lucide { width: 26px; height: 26px; }
.mstate .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; opacity: .8; }
.mstate .value { font-size: 20px; font-weight: 750; line-height: 1.15; }
.mstate .since { font-size: 12px; opacity: .85; }
.s-ok { background: var(--ok-soft); color: var(--ok); }
.s-stop { background: var(--stop-soft); color: var(--stop); }
.s-off { background: var(--muted-soft); color: var(--muted); background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(127,127,127,.08) 8px 16px); }
.s-warn { background: var(--warn-soft); color: var(--warn); }
.s-unk { background: var(--surface-3); color: var(--text-2); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); margin: 14px 16px 0;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.metric { background: var(--surface); padding: 10px 12px; min-width: 0; }
.metric .m-label { font-size: 11px; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 5px; }
.metric .m-label svg.lucide { width: 13px; height: 13px; }
.metric .m-value { font-size: 19px; font-weight: 700; white-space: nowrap; }
.metric .m-value small { font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.metric.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric .stale { color: var(--text-3); }
.metric .fail { font-size: 13px; font-weight: 600; color: var(--warn); }
.mbar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.mbar > i { display: block; height: 100%; background: var(--info); border-radius: 3px; }
.mcard-foot { margin-top: auto; padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.today-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.today-bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.updated { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.live-btn { width: 100%; justify-content: center; }

/* ---------- ao vivo ---------- */
.live-overlay { padding: 16px; }
.live-win { background: #000; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-3); display: flex;
  flex-direction: column; max-width: 100%; max-height: 100%; position: relative; }
.live-head { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); min-width: 0; }
.live-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.live-when { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.live-actions { margin-left: auto; display: flex; gap: 2px; flex: none; }
.live-grid { display: grid; gap: 2px; justify-content: center; align-content: center; background: #000; flex: 1; min-height: 0; }
.live-tile { position: relative; background: #0b0f13; overflow: hidden; }
.live-tile img { display: block; width: 100%; height: 100%; }
.live-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px; color: #c9d2da; font-size: 13px; text-align: center; }
.live-float { display: none; position: absolute; top: 8px; right: 8px; align-items: center; gap: 8px; z-index: 2; }
.live-float-close { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff;
  display: grid; place-items: center; cursor: pointer; }
.live-win.is-full { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  border-radius: 0; box-shadow: none; }
.live-win.is-full .live-head { display: none; }
.live-win.is-full .live-float { display: flex; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- tabelas ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; font-weight: 650; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { display: inline-flex; vertical-align: middle; opacity: .5; }
.table th.sorted .sort { opacity: 1; color: var(--brand); }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .val-miss { color: var(--text-3); font-style: italic; font-size: 12px; }
.table-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; padding: 12px 18px; }
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager .info { color: var(--text-2); font-size: 13px; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg.lucide { width: 30px; height: 30px; opacity: .6; }

/* comparativo de indicadores */
.kpi-table td:first-child, .kpi-table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.kpi-table th:first-child { background: var(--surface-2); z-index: 2; }
.kpi-table tr.total td { font-weight: 700; background: var(--surface-2); }

/* ---------- filtros ---------- */
.filters { display: flex; flex-direction: column; gap: 14px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters-row .field { flex: 0 1 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 550; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.more-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
  padding-top: 14px; border-top: 1px dashed var(--border); }
.numrange { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 6px; }
.numrange .input:last-child[disabled] { opacity: .45; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- gráficos e linha do tempo ---------- */
.chart { width: 100%; height: 320px; }
.chart.tall { height: 420px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tl-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.tl-toolbar .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-range { font-weight: 650; color: var(--text); font-size: 14px; }
#tl-chart { width: 100%; min-height: 360px; touch-action: pan-y; }
.tl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.detail-panel .dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.detail-panel .dl dt { color: var(--text-3); }
.detail-panel .dl dd { margin: 0; font-weight: 600; text-align: right; }
.thumb { width: 100%; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; background: var(--surface-3); }
.def-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; font-size: 13px; color: var(--text-2); }
.def-list b { color: var(--text); }

/* ---------- capturas ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.shot { overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.shot img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; background: var(--surface-3); display: block; }
.shot .meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }

/* ---------- status do coletor ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .s-label { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.stat .s-value { font-size: 18px; font-weight: 700; }
.stat .s-sub { font-size: 12px; color: var(--text-3); }

/* ---------- configurações ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 12px 14px; font-weight: 600; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; min-height: 44px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.roi-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.roi-stage { position: relative; width: 100%; background: #000; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; }
.roi-stage img { width: 100%; display: block; }
.roi-stage .placeholder { aspect-ratio: 1366 / 768; display: grid; place-items: center; color: #9aa7b4; text-align: center; padding: 20px; }
.roi-box { position: absolute; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); pointer-events: none; }
.roi-box.sel { border-width: 3px; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.roi-box span { position: absolute; left: -2px; top: -18px; background: var(--c); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
.roi-list { display: flex; flex-direction: column; gap: 6px; }
.roi-item { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; font-size: 13px; background: var(--surface); }
.roi-item.on { border-color: var(--brand); background: var(--brand-soft); }
.roi-item i.sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.roi-coords { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

/* ---------- modal, toast, carregamento ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 16, 22, .55); z-index: 100; display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-3); width: min(560px, 100%);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal img.full { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); image-rendering: pixelated; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--brand)); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; animation: rise .2s ease; }
.toast .t-body { flex: 1; min-width: 0; word-break: break-word; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
.sk-card { height: 300px; }
.sk-line { height: 14px; margin: 8px 0; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  background: #111820; color: #f1f5f9; font-size: 12px; font-weight: 500; line-height: 1.4; padding: 7px 10px; border-radius: 7px;
  width: max-content; max-width: 260px; white-space: normal; z-index: 50; box-shadow: var(--shadow-2); text-transform: none; letter-spacing: 0;
}
.tip-icon { display: inline-flex; color: var(--text-3); cursor: help; vertical-align: middle; }
.tip-icon svg.lucide { width: 14px; height: 14px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 20%, transparent), transparent), var(--bg); }
.login-card { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.login-card .brand { color: var(--text); padding: 0; }
.login-card .brand-sub { color: var(--text-3); }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-foot { font-size: 12px; color: var(--text-3); text-align: center; }

/* ---------- responsividade ---------- */
@media (max-width: 1280px) {
  .machines { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 72px; }
  .sidebar { padding: 14px 10px; align-items: center; }
  .brand { padding: 4px 0 14px; }
  .brand-text, .nav-label, .nav a span, .user-chip .who, .side-btn span { display: none; }
  .nav a, .side-btn { justify-content: center; padding: 10px; width: 48px; }
  .nav a.active { box-shadow: none; }
  .user-chip { padding: 6px; justify-content: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roi-layout { grid-template-columns: minmax(0, 1fr); }
  .charts-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); gap: 16px; }
  .topbar h1 { font-size: 17px; }
  .topbar .clock { display: none; }
  .machines { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; }
  .kpi-value { font-size: 18px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 14px rgba(0,0,0,.06);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; min-height: 52px;
    font-size: 11px; font-weight: 600; color: var(--text-3); text-decoration: none; background: none; border: 0; cursor: pointer; }
  .bottom-nav .active { color: var(--brand); }
  .bottom-nav svg.lucide { width: 22px; height: 22px; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .filters-row .field { flex: 1 1 130px; }
  .filters-row .field:has(.seg), .filters-row .field:has(.chips) { flex-basis: 100%; }
  .filters .seg { display: flex; width: 100%; flex-wrap: nowrap; }
  .filters .seg button { flex: 1; padding: 0 6px; font-size: 13px; }
  .filters-row .btn-group { width: 100%; }
  .filters-row .btn-group .btn-primary { flex: 1; }
  .numrange { grid-template-columns: 1fr 1fr 1fr; }
  .chart { height: 280px; }
  #tl-chart { min-height: 320px; }
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .live-overlay { padding: 0; place-items: stretch; }
  .live-win { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .live-when { display: none; }
  .toasts { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  /* tabela vira lista de cartões */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; padding: 8px 12px; background: var(--surface); }
  table.cards td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; white-space: normal; text-align: right; }
  table.cards td::before { content: attr(data-l); color: var(--text-3); font-weight: 600; font-size: 12px; text-align: left; }
  table.cards td.num { text-align: right; }
  .table-wrap.cards-wrap { overflow: visible; padding: 10px 12px 0; }
  .roi-coords { grid-template-columns: repeat(2, 1fr); }
  .tl-toolbar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}
