/* ═══════════════════════════════════════════════════════════
   SGI APJ Locações — identidade BRANCO + VERMELHO APJ
   Tema claro (padrão) em :root · tema escuro em [data-theme="dark"]
   Semântica: --brand = vermelho de MARCA (acento/identidade)
              --danger = vermelho de ESTADO (erro/atraso, mais escuro + ⚠)
              --amber  = atenção · --green = sucesso
   ═══════════════════════════════════════════════════════════ */

:root {
  /* superfícies */
  --bg: #f7f7f8;
  --bg-2: #f1f2f5;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #eef0f3;
  --border: #e3e5ea;
  --border-soft: #ebedf1;

  /* texto */
  --text: #1d2129;
  --text-2: #4b5361;
  --text-3: #656d7c;

  /* MARCA — vermelho APJ */
  --brand: #d92b2b;
  --brand-hover: #b91c1c;
  --brand-soft: rgba(217, 43, 43, 0.08);
  --brand-border: rgba(217, 43, 43, 0.32);
  --brand-glow: rgba(217, 43, 43, 0.30);

  /* estados */
  --green: #16a34a;
  --green-text: #15803d;
  --green-soft: rgba(22, 163, 74, 0.10);
  --green-border: rgba(22, 163, 74, 0.30);

  --amber: #d97706;
  --amber-text: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.10);
  --amber-border: rgba(217, 119, 6, 0.35);

  --danger-solid: #b91c1c;         /* dots/ícones/barras de perigo */
  --danger-text: #991b1b;          /* texto de perigo (mais escuro que a marca) */
  --danger-soft: rgba(185, 28, 28, 0.08);
  --danger-border: rgba(185, 28, 28, 0.32);

  --blue: #0284c7;
  --blue-text: #0369a1;
  --blue-soft: rgba(2, 132, 199, 0.09);
  --blue-border: rgba(2, 132, 199, 0.30);

  /* gradientes de barra */
  --grad-green: linear-gradient(90deg, #15803d, #22c55e);
  --grad-amber: linear-gradient(90deg, #b45309, #d97706);
  --grad-danger: linear-gradient(90deg, #7f1d1d, #b91c1c);

  /* glows do fundo */
  --glow-a: rgba(217, 43, 43, 0.04);
  --glow-b: rgba(2, 132, 199, 0.03);

  /* header (vidro) */
  --topbar-glass: rgba(247, 247, 248, 0.78);

  /* nav mobile (vidro) */
  --nav-glass: rgba(255, 255, 255, 0.92);
  --nav-shadow: 0 -8px 24px rgba(16, 20, 28, 0.08);
  --sidebar-grad: linear-gradient(180deg, #ffffff, #fafafb);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.06), 0 10px 28px rgba(16, 20, 28, 0.10);
  --shadow-soft: 0 1px 2px rgba(16, 20, 28, 0.05), 0 4px 14px rgba(16, 20, 28, 0.06);
  --row-hover: rgba(17, 20, 26, 0.028);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-2: #12151b;
  --surface: #171a21;
  --surface-2: #1c2029;
  --surface-3: #222734;
  --border: #262b36;
  --border-soft: #1f2430;

  --text: #e8eaf0;
  --text-2: #9aa3b2;
  --text-3: #828d9e;

  --brand: #ef4444;
  --brand-hover: #dc2626;
  --brand-soft: rgba(239, 68, 68, 0.12);
  --brand-border: rgba(239, 68, 68, 0.38);
  --brand-glow: rgba(239, 68, 68, 0.30);

  --green: #22c55e;
  --green-text: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --green-border: rgba(34, 197, 94, 0.30);

  --amber: #f5a524;
  --amber-text: #f5a524;
  --amber-soft: rgba(245, 165, 36, 0.12);
  --amber-border: rgba(245, 165, 36, 0.35);

  --danger-solid: #f87171;
  --danger-text: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.32);

  --blue: #38bdf8;
  --blue-text: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.12);
  --blue-border: rgba(56, 189, 248, 0.30);

  --grad-green: linear-gradient(90deg, #15803d, #22c55e);
  --grad-amber: linear-gradient(90deg, #b45309, #f5a524);
  --grad-danger: linear-gradient(90deg, #991b1b, #ef4444);

  --glow-a: rgba(239, 68, 68, 0.05);
  --glow-b: rgba(56, 189, 248, 0.04);

  --topbar-glass: rgba(15, 17, 21, 0.72);

  --nav-glass: rgba(16, 19, 26, 0.92);
  --nav-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  --sidebar-grad: linear-gradient(180deg, #12151b, #10131a);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.2);
  --row-hover: rgba(255, 255, 255, 0.018);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--glow-a), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, var(--glow-b), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

strong, b, .kpi-num, .market-card strong, .feed-time, .mk-delta,
.delta, .pend-ok, .lock-time, .ph-date { font-variant-numeric: tabular-nums; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

/* ── Layout raiz ─────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--sidebar-grad);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px 16px;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; border-bottom: 1px solid var(--border-soft); }
.brand-mark {
  width: 44px; height: 44px; border-radius: 11px;
  background: linear-gradient(145deg, #e84a4a, var(--brand) 55%, var(--brand-hover));
  color: #ffffff;
  font-weight: 800; font-size: 15px; letter-spacing: 0.02em;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 14.5px; letter-spacing: -0.01em; }
.brand-text span { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding-top: 16px; flex: 1; position: relative; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10.5px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
  position: relative; z-index: 1;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active {
  color: var(--brand);
  font-weight: 600;
}
.nav a.active:hover { background: none; }

/* indicador deslizante da nav (posicionado via JS) */
.nav-pill {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 0;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--brand-soft), transparent 145%);
  border: 1px solid var(--brand-border);
  box-sizing: border-box;
  opacity: 0; pointer-events: none; z-index: 0;
}
.nav-pill.ready {
  transition: top .32s cubic-bezier(.3, .8, .3, 1), height .32s cubic-bezier(.3, .8, .3, 1),
              left .32s cubic-bezier(.3, .8, .3, 1), width .32s cubic-bezier(.3, .8, .3, 1);
}
.nav-pill.bar {
  background: linear-gradient(90deg, var(--brand), #f05252);
  border: 0; border-radius: 0 0 3px 3px;
}
.nav-ic { width: 20px; height: 20px; flex: 0 0 20px; }

.sidebar-foot { border-top: 1px solid var(--border-soft); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-soft); border: 1px solid var(--brand-border);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--brand);
}
.user-chip div { display: flex; flex-direction: column; }
.user-chip strong { font-size: 13px; }
.user-chip span { font-size: 11px; color: var(--text-3); }

/* ── Main / topbar ───────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px 13px;
  position: sticky; top: 0; z-index: 25;
  background: var(--topbar-glass);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border-bottom: 1px solid var(--border-soft);
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-sub { font-size: 12.5px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 13px;
  white-space: nowrap;
}

/* ── Toggle claro/escuro ─────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-2); cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand-border); background: var(--brand-soft); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }

.content { padding: 20px 28px 30px; display: flex; flex-direction: column; gap: 18px; flex: 1; }

/* ── Views (router) ──────────────────────────────────────── */
.view { display: none; flex-direction: column; gap: 18px; }
.view.active { display: flex; }

/* entrada em cascata (aplicada via JS a cada troca de rota) */
.stg { animation: stgIn .45s cubic-bezier(.22, .68, .3, 1) both; }
@keyframes stgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15.5px; font-weight: 700; }
.card-hint { font-size: 11.5px; color: var(--text-3); }
.card-note { margin-top: 12px; font-size: 12.5px; color: var(--text-2); border-left: 3px solid var(--brand); padding-left: 10px; }

/* ── Dots & badges ───────────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; }
.dot-green { background: var(--green); }
.dot-red { background: var(--danger-solid); }
.dot-amber { background: var(--amber); }
.dot-blue { background: var(--blue); }
.pulse { position: relative; }
.pulse::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  background: inherit; opacity: .5;
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.6); opacity: .55; }
  70%, 100% { transform: scale(1.9); opacity: 0; }
}

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600;
  padding: 4.5px 11px; border-radius: 999px;
  border: 1px solid; white-space: nowrap;
}
.badge.sm { font-size: 10.5px; padding: 3px 9px; }
.badge-green { color: var(--green-text); background: var(--green-soft); border-color: var(--green-border); }
.badge-red { color: var(--danger-text); background: var(--danger-soft); border-color: var(--danger-border); }
/* perigo NUNCA se confunde com a marca: ⚠ obrigatório (exceto quando já há dot) */
.badge-red::before { content: "⚠"; font-size: 11px; line-height: 1; }
.badge-red:has(.dot)::before { content: none; }
.badge-amber { color: var(--amber-text); background: var(--amber-soft); border-color: var(--amber-border); }
.badge-blue { color: var(--blue-text); background: var(--blue-soft); border-color: var(--blue-border); }

/* ── KPIs ────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.kpi-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kpi-num { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-dim { color: var(--text-3); font-size: 19px; font-weight: 700; }
.delta { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 7px; }
.delta.up { color: var(--green-text); background: var(--green-soft); }
.delta.down-good { color: var(--green-text); background: var(--green-soft); }
.delta.warn { color: var(--danger-text); background: var(--danger-soft); }
.delta.neutral { color: var(--text-2); background: var(--surface-3); }
.spark { width: 100%; height: 30px; }
.mini-bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mini-bar span { display: block; height: 100%; border-radius: inherit; background: var(--grad-green); }
.kpi-foot { font-size: 11.5px; color: var(--text-3); }
.kpi-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 600; padding: 3.5px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); }
.tag-red { background: var(--danger-soft); color: var(--danger-text); }
.link { color: var(--brand); text-decoration: none; font-weight: 600; }
.link:hover { color: var(--brand-hover); text-decoration: underline; }

/* ── Cockpit de mercado ──────────────────────────────────── */
.market-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.market-card {
  display: flex; align-items: baseline; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  min-width: 0;
  box-shadow: var(--shadow-soft);
}
.mk-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.market-card strong { font-size: 16.5px; font-weight: 800; }
.mk-delta { font-size: 11.5px; font-weight: 600; margin-left: auto; }
.mk-delta.up { color: var(--green-text); }
.mk-delta.flat { color: var(--text-3); }

/* ── Grades ──────────────────────────────────────────────── */
.grid-2-1 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; align-items: stretch; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Gráfico SVG (linha principal = vermelho da marca) ───── */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart-hit { fill: transparent; pointer-events: all; cursor: pointer; }
.chart-guide line {
  stroke: var(--brand-border); stroke-width: 1; stroke-dasharray: 3 4;
  opacity: 0; transition: opacity .15s ease;
}
.chart-guide.on line { opacity: 1; }
.chart-tip {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -100%) translateY(-14px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 13px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1px;
  white-space: nowrap; pointer-events: none; z-index: 5;
  opacity: 0; transition: opacity .16s ease, left .16s ease, top .16s ease;
}
.chart-tip.show { opacity: 1; }
.chart-tip strong { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.chart-tip span { font-size: 14.5px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.chart-grid line { stroke: var(--border-soft); stroke-width: 1; }
.chart-grid text { fill: var(--text-3); font-size: 11px; text-anchor: end; font-family: var(--font); }
.chart-x text { fill: var(--text-2); font-size: 12px; text-anchor: middle; font-family: var(--font); }
.chart-line { stroke: var(--brand); }
.chart-pt circle { r: 4.5; fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; transition: r .15s ease; }
.chart-pt .pt-hot { fill: var(--brand); r: 5.5; }
.chart-pt circle.hov { r: 6.5; }
.chart-val text { fill: var(--text-2); font-size: 12px; font-weight: 600; text-anchor: middle; font-family: var(--font); }
.chart-val .val-hot { fill: var(--brand); font-weight: 800; font-size: 13.5px; }

/* ── Notícias ────────────────────────────────────────────── */
.news { list-style: none; display: flex; flex-direction: column; }
.news li { padding: 11px 0; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 4px; }
.news li:last-child { border-bottom: 0; padding-bottom: 0; }
.news li:first-child { padding-top: 0; }
.news-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); }
.news p { font-size: 13px; font-weight: 500; line-height: 1.45; }
.news-src { font-size: 11px; color: var(--text-3); }

/* ── Tabelas ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 12px 10px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-sub { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.td-neg { color: var(--danger-text); }
.td-dim { color: var(--text-3); }
tfoot td { border-top: 2px solid var(--border); border-bottom: 0; padding-top: 13px; font-size: 13.5px; }
.total-val { color: var(--text); font-size: 15px; }

.w-margin { min-width: 150px; }
.margin-cell { display: flex; align-items: center; gap: 10px; }
.margin-cell b { font-size: 13px; min-width: 36px; text-align: right; }
.margin-bar { flex: 1; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.margin-bar span { display: block; height: 100%; border-radius: inherit; }
.m-green { background: var(--grad-green); }
.m-amber { background: var(--grad-amber); }
.m-red { background: var(--grad-danger); }

/* ── Frota ───────────────────────────────────────────────── */
.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; cursor: default;
}
.chip-on { color: var(--brand); background: var(--brand-soft); border-color: var(--brand-border); }
.toolbar-hint { font-size: 12px; color: var(--text-3); }

.fleet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.machine { display: flex; flex-direction: column; gap: 4px; }
.machine:hover { border-color: var(--brand-border); }
.machine-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.machine-art { width: 104px; height: 62px; }
.machine-art.amber { color: var(--brand); opacity: .9; }
.machine h3 { font-size: 15.5px; font-weight: 700; }
.machine-id { font-size: 11.5px; color: var(--text-3); margin-bottom: 10px; }

.hour-block { display: flex; flex-direction: column; gap: 6px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 10px; }
.hour-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--text-3); }
.hour-row strong { font-size: 17px; color: var(--text); font-weight: 800; }
.prog { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.prog span, .p-green, .p-amber, .p-red { display: block; height: 100%; border-radius: inherit; }
.p-green { background: var(--grad-green); }
.p-amber { background: var(--grad-amber); }
.p-red { background: var(--grad-danger); }
.hour-hint { font-size: 11.5px; color: var(--text-3); }
.hint-red { color: var(--danger-text); font-weight: 600; }
.hint-amber { color: var(--amber-text); font-weight: 600; }

.machine-meta { display: flex; flex-direction: column; gap: 8px; }
.machine-meta div { display: flex; flex-direction: column; gap: 1px; }
.machine-meta dt { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.machine-meta dd { font-size: 12.5px; color: var(--text-2); }

/* ── Apontamento (split) ─────────────────────────────────── */
.split { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.split-caption { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.split-caption strong { color: var(--brand); }
.split-office { display: flex; flex-direction: column; gap: 14px; }

/* O celular é um objeto físico: fica SEMPRE escuro, nos 2 temas.
   Variáveis re-escopadas aqui para não herdar o tema claro. */
.phone {
  --text: #e8eaf0;
  --text-2: #9aa3b2;
  --text-3: #8a94a6;
  --border: #262b36;
  --border-soft: #1f2430;
  --surface-3: #222734;
  --brand: #ef4444;
  --brand-hover: #dc2626;
  --brand-soft: rgba(239, 68, 68, 0.14);
  --brand-border: rgba(239, 68, 68, 0.40);
  --brand-glow: rgba(239, 68, 68, 0.35);
  --green: #22c55e;
  --green-text: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --green-border: rgba(34, 197, 94, 0.30);
  color: var(--text);

  width: 320px; max-width: 100%;
  margin: 0 auto;
  background: #05070a;
  border: 1px solid #2c313d;
  border-radius: 38px;
  padding: 12px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.35),
    0 12px 26px -6px rgba(0,0,0,.35),
    0 34px 64px -18px rgba(0,0,0,.5),
    inset 0 0 0 2px #10141b;
  position: relative;
}
.phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 112px; height: 24px; background: #05070a;
  border-radius: 0 0 16px 16px; z-index: 2;
}
.phone-notch::after {
  /* alto-falante */
  content: ""; position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  width: 42px; height: 5px; border-radius: 3px;
  background: #171c26; box-shadow: inset 0 1px 1px rgba(0,0,0,.6);
}
.phone-screen {
  background: linear-gradient(180deg, #14171e, #101319);
  border-radius: 27px;
  padding: 12px 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
}
.ph-status {
  display: flex; justify-content: space-between; align-items: center;
  color: #cdd3de; padding: 2px 4px 0; min-height: 22px;
}
.ph-time { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.ph-status-ics { display: flex; align-items: center; gap: 6px; }
.ph-status-ics svg { height: 11px; width: auto; fill: currentColor; display: block; }
.ph-head { display: flex; justify-content: space-between; align-items: center; }
.ph-brand { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.ph-mark {
  background: var(--brand); color: #ffffff; font-size: 9.5px; font-weight: 800;
  border-radius: 6px; padding: 3px 6px;
}
.ph-date { font-size: 11px; color: var(--text-3); }

.ph-machine {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand-soft); border: 1px solid var(--brand-border);
  border-radius: 12px; padding: 9px 11px;
}
.ph-machine-ic { width: 48px; height: 30px; color: var(--brand); flex: 0 0 48px; }
.ph-machine div { display: flex; flex-direction: column; }
.ph-machine strong { font-size: 13px; }
.ph-machine span { font-size: 11px; color: var(--text-2); }

.ph-label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.ph-photo { display: flex; flex-direction: column; gap: 6px; }
.ph-photo-thumb { width: 100%; height: 92px; color: var(--brand); }
.ph-photo-ok { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--green); font-weight: 600; }
.ic-inline { width: 14px; height: 14px; flex: 0 0 14px; }

.ph-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-field { display: flex; flex-direction: column; gap: 5px; }
.ph-input {
  background: #0b0e13; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 13px;
}
.ph-num { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ph-unit { font-size: 11.5px; color: var(--text-3); }
.ph-select { align-items: center; color: var(--text-2); }
.ph-select span { font-size: 12.5px; }
.ph-caret { width: 16px; height: 16px; color: var(--text-3); flex: 0 0 16px; }

.ph-canhoto {
  display: flex; align-items: center; gap: 9px;
  background: var(--green-soft); border: 1px solid var(--green-border);
  border-radius: 10px; padding: 9px 11px; color: var(--green);
}
.ph-canhoto div { display: flex; flex-direction: column; }
.ph-canhoto strong { font-size: 12.5px; }
.ph-canhoto span { font-size: 10.5px; color: var(--text-2); }

.ph-btn {
  border: 0; cursor: pointer;
  background: linear-gradient(145deg, #f05252, var(--brand) 60%, var(--brand-hover));
  color: #ffffff; font-family: var(--font);
  font-size: 14.5px; font-weight: 800;
  border-radius: 12px; padding: 13px;
  box-shadow: 0 5px 16px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .15s ease, filter .15s ease;
}
.ph-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ph-btn:active { transform: translateY(0); }
.ph-foot { text-align: center; font-size: 10.5px; color: var(--text-3); }

/* Pendências */
.pend-list { list-style: none; display: flex; flex-direction: column; }
.pend-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft);
}
.pend-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.pend-list li:first-child { padding-top: 0; }
.pend-list li div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pend-list strong { font-size: 13.5px; }
.pend-list li div span { font-size: 11.5px; color: var(--text-3); }
.pend-ok { font-size: 12px; color: var(--green-text); font-weight: 600; white-space: nowrap; }
.pend-late { background: linear-gradient(90deg, var(--amber-soft), transparent); border-radius: 10px; margin: 0 -8px; padding: 11px 8px !important; }
.btn-cobrar {
  border: 1px solid var(--amber-border); cursor: pointer;
  background: var(--amber-soft); color: var(--amber-text);
  font-family: var(--font); font-size: 12px; font-weight: 700;
  border-radius: 8px; padding: 7px 15px;
  transition: background .15s ease, filter .15s ease;
}
.btn-cobrar:hover { filter: brightness(1.08); }
.btn-cobrar.sent { border-color: var(--green-border); background: var(--green-soft); color: var(--green-text); cursor: default; }

/* Feed */
.feed { list-style: none; display: flex; flex-direction: column; }
.feed li { display: flex; gap: 12px; padding: 9.5px 0; border-bottom: 1px solid var(--border-soft); align-items: baseline; }
.feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.feed li:first-child { padding-top: 0; }
.feed-time { font-size: 11px; color: var(--text-3); font-weight: 600; white-space: nowrap; min-width: 76px; }
.feed p { font-size: 12.5px; color: var(--text-2); }
.feed strong { color: var(--text); }

/* ── Manutenção ──────────────────────────────────────────── */
.alert-card {
  display: flex; align-items: center; gap: 15px;
  border-color: var(--danger-border);
  background: linear-gradient(90deg, var(--danger-soft), var(--surface) 55%);
}
.alert-ic { width: 30px; height: 30px; color: var(--danger-solid); flex: 0 0 30px; }
.alert-card div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.alert-card strong { font-size: 14.5px; }
.alert-card div span { font-size: 12.5px; color: var(--text-2); }

.ruler-list { display: flex; flex-direction: column; gap: 20px; }
.ruler-item { display: flex; flex-direction: column; gap: 7px; }
.ruler-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ruler-head strong { font-size: 13.5px; }
.ruler-val { font-size: 12.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ruler { position: relative; height: 12px; border-radius: 999px; background: var(--surface-3); overflow: visible; }
.ruler-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.ruler-zone {
  position: absolute; right: 0; top: 0; bottom: 0; width: 15%;
  background: repeating-linear-gradient(-45deg, var(--danger-border) 0 5px, var(--danger-soft) 5px 10px);
  border-radius: 0 999px 999px 0;
}
.ruler-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--border); }
.ruler-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.ruler-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); }

.os-card { display: flex; flex-direction: column; gap: 9px; }
.os-head { display: flex; align-items: center; gap: 10px; }
.os-head strong { font-size: 14px; letter-spacing: .02em; }
.os-status { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.os-card h3 { font-size: 15px; }
.os-desc { font-size: 12.5px; color: var(--text-2); }
.os-items { list-style: none; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 4px 13px; }
.os-items li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-2); }
.os-items li:last-child { border-bottom: 0; }
.os-items b { font-variant-numeric: tabular-nums; color: var(--text); }
.os-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.os-foot strong { color: var(--text); font-size: 15px; }
.os-resp { font-size: 11.5px; color: var(--text-3); }

.hist { list-style: none; display: flex; flex-direction: column; }
.hist li { display: flex; align-items: center; gap: 12px; padding: 10.5px 0; border-bottom: 1px solid var(--border-soft); }
.hist li:last-child { border-bottom: 0; padding-bottom: 0; }
.hist li:first-child { padding-top: 0; }
.hist-date { font-size: 11.5px; color: var(--text-3); font-weight: 700; min-width: 44px; font-variant-numeric: tabular-nums; }
.hist p { flex: 1; font-size: 13px; color: var(--text-2); }
.hist b { font-variant-numeric: tabular-nums; font-size: 13px; }

/* ── Contratos ───────────────────────────────────────────── */
.pipeline {
  display: flex; align-items: stretch; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
}
.pipe-step {
  flex: 1; min-width: 108px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-soft);
}
.pipe-count { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pipe-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.pipe-hot { border-color: var(--brand-border); background: var(--brand-soft); }
.pipe-hot .pipe-count { color: var(--brand); }
.pipe-hot .pipe-label { color: var(--brand); }
.pipe-arrow { align-self: center; color: var(--text-3); font-size: 19px; flex: 0 0 auto; }

.lock-card {
  border-color: var(--brand-border);
  background: linear-gradient(135deg, var(--brand-soft), var(--surface) 60%);
  display: flex; flex-direction: column; gap: 13px;
}
.lock-head { display: flex; align-items: center; gap: 14px; }
.lock-ic {
  width: 42px; height: 42px; flex: 0 0 42px; color: var(--brand);
  background: var(--brand-soft); border: 1px solid var(--brand-border);
  border-radius: 12px; padding: 8px;
}
.lock-head div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lock-head strong { font-size: 15px; }
.lock-head div span { font-size: 12.5px; color: var(--text-2); }
.lock-example {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  display: flex; flex-direction: column; gap: 3px;
}
.lock-time { font-size: 11px; font-weight: 700; color: var(--text-3); }
.lock-example p { font-size: 13px; color: var(--text-2); line-height: 1.55; }
.lock-example strong { color: var(--danger-text); }
.lock-example b { color: var(--text); }

/* ── Rodapé ──────────────────────────────────────────────── */
.app-foot {
  margin-top: auto;
  padding: 14px 28px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px; color: var(--text-3);
  text-align: center;
}
.app-foot strong { color: var(--brand); font-weight: 700; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600;
  border-radius: 12px; padding: 12px 20px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60; max-width: min(92vw, 420px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ═══════════════════ RESPONSIVO ═══════════════════ */

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .fleet-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  /* Sidebar vira bottom-nav */
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; flex: none;
    flex-direction: row; align-items: center;
    padding: 0;
    border-right: 0; border-top: 1px solid var(--border);
    background: var(--nav-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--nav-shadow);
  }
  .brand, .sidebar-foot { display: none; }
  .nav {
    flex-direction: row; flex: 1; gap: 0; padding: 0;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .nav a {
    flex-direction: column; gap: 4px; flex: 1;
    padding: 9px 4px 8px;
    font-size: 10px; border-radius: 0; border: 0;
  }
  .nav a.active { background: none; }
  .nav-ic { width: 22px; height: 22px; flex-basis: 22px; }

  .main { padding-bottom: 76px; }
  .topbar { padding: 13px 16px 11px; flex-wrap: nowrap; gap: 8px; }
  .topbar-title { flex: 1; min-width: 0; }
  .topbar-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 14px 16px 22px; gap: 14px; }
  .app-foot { padding: 12px 16px 16px; }
  .toast { bottom: 88px; }
}

/* ── Selo "ao vivo" (KPI de faturamento) ─────────────────── */
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.live-mini {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--green-text); background: var(--green-soft);
  border: 1px solid var(--green-border);
  border-radius: 999px; padding: 2px 9px 2px 7px;
  text-transform: uppercase; white-space: nowrap;
}
.live-mini .dot { width: 6px; height: 6px; flex-basis: 6px; }

/* ── Splash de entrada ───────────────────────────────────── */
.splash {
  display: none; position: fixed; inset: 0; z-index: 100;
  place-items: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--glow-a), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, var(--glow-b), transparent 55%),
    var(--bg);
  transition: opacity .45s ease;
}
html[data-splash="on"] .splash { display: grid; }
.splash.out { opacity: 0; pointer-events: none; }
.splash-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: splashIn .55s cubic-bezier(.2, .7, .3, 1) both;
}
.splash-mark {
  width: 68px; height: 68px; border-radius: 17px;
  background: linear-gradient(145deg, #e84a4a, var(--brand) 55%, var(--brand-hover));
  color: #ffffff; font-weight: 800; font-size: 23px; letter-spacing: .02em;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,.25);
  margin-bottom: 10px;
}
.splash-inner strong { font-size: 18.5px; letter-spacing: -0.01em; color: var(--text); }
.splash-inner span { font-size: 12px; color: var(--text-3); }
.splash-bar {
  width: 176px; height: 3px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden; margin-top: 18px;
}
.splash-bar span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #f05252);
  animation: splashBar 1.15s cubic-bezier(.45, .05, .35, 1) .1s forwards;
}
@keyframes splashBar { to { width: 100%; } }
@keyframes splashIn { from { opacity: 0; transform: scale(.94); } }

/* ── Acessibilidade: sem movimento ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .fleet-grid { grid-template-columns: 1fr; }
  .market-strip { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kpi-num { font-size: 24px; }
  .live-chip { display: none; }
  .phone { width: 100%; max-width: 320px; }
  .pipe-step { min-width: 96px; }
  .card { padding: 15px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
}
