:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e2e4eb;
  --text: #14162b;
  --text-muted: #666b85;

  /* Paleta extraída do logo Logus Química */
  --navy: #0a0e42;
  --navy-2: #14184f;
  --maroon: #b2001c;
  --pink: #f8155d;
  --skyblue: #53d7fe;

  --primary: var(--navy);
  --primary-hover: var(--navy-2);
  --accent: var(--skyblue);

  --green: #16a34a;
  --amber: #d97706;
  --orange: #ea580c;
  --red: var(--maroon);

  --radius: 10px;
  font-synthesis: none;

  /* ---------- Tokens de modernização (aditivo) ---------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(10, 14, 66, 0.06);
  --shadow-sm: 0 2px 8px rgba(10, 14, 66, 0.07);
  --shadow-md: 0 6px 20px rgba(10, 14, 66, 0.10);
  --shadow-lg: 0 16px 40px rgba(10, 14, 66, 0.16);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 160ms;
  --focus-ring: 0 0 0 3px rgba(83, 215, 254, 0.45);
  --font-heading: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

/* ---------- Fundamentos modernos (aditivo) ---------- */
::selection { background: var(--skyblue); color: var(--navy); }

*:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar, .modal::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}
.sidebar::-webkit-scrollbar-thumb:hover, .modal::-webkit-scrollbar-thumb:hover { background: #c9cce0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 3px solid var(--maroon);
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.brand-logo { height: 76px; width: auto; display: block; }
.brand-name { font-family: var(--font-heading); font-weight: 800; font-size: 17px; letter-spacing: 0.01em; color: var(--navy); border-left: 1px solid var(--border); padding-left: 12px; }

/* Abas: no desktop, linha esticada ocupando toda a largura (sem rolagem).
   No celular (ver media query abaixo), viram uma barra fixa embaixo, estilo app. */
.tabs {
  display: flex;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
  border-top: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 12px 8px;
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab-btn:hover { background: var(--bg); color: var(--text); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); background: transparent; }
.tab-ico { display: none; font-size: 15px; line-height: 1; }
.tab-ico svg { display: block; }
.tab-label-short { display: none; }
.sidebar-menu-label { display: none; }
.sidebar-logout-mobile { display: none; }

/* ---------- Menu lateral (desktop) ----------
   No desktop, as abas ficam numa coluna fixa à esquerda em vez de uma
   linha horizontal no topo. No celular (media query max-width:700px lá
   embaixo) continua tudo como já era: barra fixa embaixo, uma logo só. */
@media (min-width: 701px) {
  .app-shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    align-items: start;
    min-height: 100vh;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
  }
  .sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 26px 16px 20px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand .brand-logo { height: 92px; filter: drop-shadow(var(--shadow-xs)); }
  .sidebar-brand .brand-name {
    border-left: none;
    padding-left: 0;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-align: center;
    line-height: 1.3;
  }
  .btn-menu-fechar { display: none; }
  .main-col { display: flex; flex-direction: column; min-width: 0; }
  .topbar .brand { display: none; }
  .btn-menu-mobile { display: none; }

  .sidebar-menu-label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 16px 14px 4px;
  }
  .sidebar .tabs {
    display: flex;
    flex-direction: column;
    max-width: none;
    margin: 0;
    padding: 4px 10px 10px;
    border-top: none;
    gap: 1px;
  }
  .sidebar .tab-btn {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 0 8px 8px 0;
    border-bottom: none;
    margin-bottom: 0;
    border-left: 3px solid transparent;
    text-align: left;
    font-size: 13px;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .sidebar .tab-btn:hover { background: rgba(10, 14, 66, 0.04); color: var(--text); }
  .sidebar .tab-btn.active {
    background: rgba(10, 14, 66, 0.06);
    border-left-color: var(--navy);
    color: var(--navy);
    font-weight: 800;
  }
  .sidebar .tab-ico { display: inline-flex; color: var(--text-muted); flex: none; }
  .sidebar .tab-btn:hover .tab-ico { color: var(--text); }
  .sidebar .tab-btn.active .tab-ico { color: var(--navy); }
  .sidebar .tab-label-short { display: none; }
}

/* ---------- Busca única (busca em tudo) ---------- */
.topbar-busca { position: relative; flex: 1; max-width: 320px; }
.topbar-busca input[type=search] {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.topbar-busca input[type=search]:focus { outline: none; border-color: var(--skyblue); background: var(--surface); }
.busca-resultados {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
  max-height: 420px;
  overflow-y: auto;
  z-index: 40;
  padding: 6px;
}
.busca-resultados.open { display: block; }
.busca-grupo-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}
.busca-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.busca-item:hover { background: var(--bg); }
.busca-item-titulo { font-size: 13px; font-weight: 600; color: var(--text); }
.busca-item-sub { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.busca-vazio { padding: 14px 8px; font-size: 13px; color: var(--text-muted); text-align: center; }

@media (max-width: 700px) {
  .topbar-busca { max-width: 90px; }
  .busca-resultados { position: fixed; left: 8px; right: 8px; top: 60px; max-height: 65vh; }
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.conn-status.online .dot { background: var(--green); }
.conn-status.local .dot { background: var(--amber); }
.conn-status.error .dot { background: var(--maroon); }

.topbar-right { display: flex; align-items: center; gap: 14px; white-space: nowrap; }

.user-badge { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-nome { font-size: 13px; font-weight: 600; color: var(--text); }
.user-papel {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--navy);
  background: #eef2ff;
  padding: 3px 8px;
  border-radius: 999px;
}
.btn-logout { padding: 6px 12px; font-size: 12px; }
.btn-instalar { border-color: var(--skyblue); color: var(--navy); font-weight: 700; }
.btn-instalar:hover { background: #eafcff; }
.instalar-passos { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.instalar-passos li { font-size: 13px; line-height: 1.5; }

/* Layout */
.app { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 800px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

.dash-grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) {
  .dash-grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dash-grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  border-top: 3px solid var(--skyblue);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }
}
.card-num { font-family: var(--font-heading); font-size: 28px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.card-label { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }
.card-alert { border-top-color: var(--maroon); background: linear-gradient(180deg, rgba(178, 0, 28, 0.035), var(--surface) 60%); }
.card-alert .card-num { color: var(--maroon); }

@media (max-width: 700px) {
  /* No celular os cards ficam em 2 colunas — se sobrar um ímpar (o último
     card sozinho na linha), ele estica pra ocupar a linha toda em vez de
     deixar aquele vão vazio do lado. */
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Panel block */
.panel-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}
.panel-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.panel-block-header.wrap { flex-wrap: wrap; }
.panel-block-header h2 { margin: 0; font-family: var(--font-heading); font-size: 16px; font-weight: 800; color: var(--navy); }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--navy-2); box-shadow: var(--shadow-sm); }
.btn-small { padding: 6px 12px; font-size: 13px; }

/* Form */
.form-block h2 { margin-top: 0; font-family: var(--font-heading); font-size: 16px; font-weight: 800; color: var(--navy); }
.form-hint { color: var(--text-muted); font-size: 13px; margin-top: -6px; margin-bottom: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
label.full { margin-bottom: 16px; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--skyblue); box-shadow: var(--focus-ring); }
textarea { resize: vertical; }

.form-actions { display: flex; align-items: center; gap: 14px; }
.form-msg { font-size: 13px; color: var(--green); font-weight: 600; }
.form-msg.error {
  color: var(--maroon);
  background: #fee2e2;
  border: 1px solid var(--maroon);
  border-radius: 8px;
  padding: 8px 12px;
  display: inline-block;
}

/* Destaca o campo que falta preencher quando o envio é bloqueado */
.urgencia-picker.campo-invalido { outline: 2px solid var(--maroon); outline-offset: 4px; border-radius: 8px; }
textarea.campo-invalido { outline: 2px solid var(--maroon); outline-offset: -1px; }

/* Foto da ficha de papel */
.foto-block {
  background: var(--bg);
  border: 1px dashed var(--skyblue);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}
.foto-label { display: block; font-weight: 700; color: var(--navy); font-size: 14px; margin-bottom: 4px; }
.foto-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; }
.foto-input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.btn-foto {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
}
.btn-foto:hover { background: var(--navy-2); }
.foto-preview-wrap { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.foto-preview { max-height: 120px; max-width: 160px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.foto-preview-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.btn-ia {
  background: linear-gradient(135deg, var(--navy), #2b1a6b);
  color: #fff;
  border: none;
}
.btn-ia:hover { filter: brightness(1.15); }
.btn-ia:disabled { opacity: 0.6; cursor: wait; }
.ia-msg { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ia-msg.ok { color: var(--green); }
.ia-msg.warn { color: var(--amber); }
.ia-msg.error { color: var(--maroon); }

.compras-block {
  background: var(--bg);
  border: 1px dashed var(--skyblue);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.compras-block .form-grid { margin-bottom: 8px; }
.nf-link { font-size: 13px; font-weight: 600; color: var(--navy); text-decoration: none; }
.nf-link:hover { text-decoration: underline; }

.nf-ia-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }

/* Resultado de sugestões da IA (causa provável, resumo da diretoria) */
.ia-resultado {
  background: linear-gradient(135deg, #f2f0ff, #eef9ff);
  border: 1px solid #dcd6ff;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  margin-top: 10px;
}
.ia-bloco-sugestao { margin-bottom: 16px; }
.resumo-ia-conteudo p { margin: 0; }
.resumo-ia-conteudo .ia-resultado { margin-top: 0; }

.order-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.modal-foto { max-width: 100%; border-radius: 8px; margin-bottom: 14px; display: block; border: 1px solid var(--border); }
.muted { color: var(--text-muted); font-style: italic; }

/* Toggle Sim/Não */
.toggle-field { display: flex; flex-direction: column; gap: 6px; }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.toggle-yn { display: flex; gap: 6px; }
.yn-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.yn-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Urgência picker */
.urgencia-picker { display: flex; gap: 8px; }
.urg-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
}
.urg-btn[data-val="Baixa"].active { background: #eef2ff; border-color: #4338ca; color: #4338ca; }
.urg-btn[data-val="Média"].active { background: #fef3c7; border-color: #92400e; color: #92400e; }
.urg-btn[data-val="Alta"].active { background: #fee2e2; border-color: var(--maroon); color: var(--maroon); }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { padding: 8px 10px; }
#osBusca, #cronoBusca { min-width: 200px; }

/* Order list */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.order-item:hover { border-color: var(--skyblue); box-shadow: var(--shadow-sm); }
@media (hover: hover) {
  .order-item:hover { transform: translateX(2px); }
}
.order-main { flex: 1; min-width: 0; }
.order-title { font-weight: 700; font-size: 14px; color: var(--text); }
.order-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  opacity: 0.85;
}
/* Urgência / prioridade da OS */
.badge-Baixa { background: #eef2ff; color: #4338ca; }
.badge-Média { background: #fef3c7; color: #92400e; }
.badge-Alta { background: #ffedd5; color: #c2410c; }

/* Status das OS */
.status-EmAberto { background: #dbeafe; color: #1e40af; }
.status-Programado { background: #fef9c3; color: #854d0e; }
.status-Concluído { background: #dcfce7; color: #166534; }
.status-Cancelada { background: #f3f4f6; color: #6b7280; }

/* Status do cronograma preventivo */
.status-OK { background: #dcfce7; color: #166534; }
.status-PRÓXIMA { background: #e0f2fe; color: #075985; }
.status-URGENTE { background: #fef3c7; color: #92400e; }
.status-ATRASADA { background: #fee2e2; color: #991b1b; }

/* Prioridade do cronograma preventivo */
.prioridade-BAIXA { background: #dcfce7; color: #166534; }
.prioridade-MÉDIA { background: #fef3c7; color: #92400e; }
.prioridade-ALTA { background: #ffedd5; color: #c2410c; }
.prioridade-CRÍTICA { background: #fee2e2; color: #991b1b; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ---------- Status dos turnos no Painel (checklist da caldeira) ---------- */
.dash-turnos-status { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-turnos-status .badge { font-size: 12.5px; padding: 6px 12px 6px 11px; }
.badge-pendente { background: var(--bg); color: var(--text-muted); border: 1px dashed var(--border); }
.badge-pendente::before { background: var(--text-muted); opacity: 0.5; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10,14,66,0.55);
  align-items: center; justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-overlay.open { display: flex; animation: modalFade var(--dur) var(--ease); }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { animation: modalPop 220ms var(--ease); }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-muted);
}
.modal h3 { margin-top: 0; font-family: var(--font-heading); font-weight: 800; color: var(--navy); }
.modal h4 { font-family: var(--font-heading); font-weight: 800; color: var(--navy); margin-bottom: 10px; }
.modal-row { margin-bottom: 10px; font-size: 14px; }
.modal-row b { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.hist-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.hist-item { font-size: 13px; padding: 8px 10px; background: var(--bg); border-radius: 6px; }
.hist-item.hist-empty { color: var(--text-muted); }
.hist-tec { color: var(--text-muted); }

/* Tela de login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, var(--maroon) 140%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(10, 14, 66, 0.35);
  animation: loginRise 420ms var(--ease);
}
@keyframes loginRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { height: 128px; width: auto; margin-bottom: 14px; }
.login-card h1 { margin: 0 0 4px; font-family: var(--font-heading); font-size: 21px; font-weight: 800; color: var(--navy); }
.login-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.login-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.login-form input:focus {
  outline: none;
  border-color: var(--skyblue);
  box-shadow: var(--focus-ring);
}
.login-form .btn-primary { margin-top: 4px; }
.login-msg { font-size: 13px; color: var(--text-muted); text-align: center; }
.login-msg.error { color: var(--maroon); font-weight: 600; }
.login-demo-wrap { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.login-demo-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; }
.login-demo-btns { display: flex; flex-direction: column; gap: 8px; }

/* Rankings (aba Diretoria) */
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  transition: background var(--dur) var(--ease);
}
@media (hover: hover) {
  .rank-item:hover { background: rgba(10, 14, 66, 0.06); }
}
.rank-count {
  font-weight: 700;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}

/* ---------- Gráficos (aba Diretoria) ---------- */
.panel-block-chart { border-top: 3px solid var(--skyblue); }

.chart-box { min-height: 60px; }
.chart-box-wide { width: 100%; }

/* Rosca (donut) */
.chart-donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.chart-donut-svgbox { position: relative; width: 170px; height: 170px; flex-shrink: 0; }
.chart-donut-svg { width: 100%; height: 100%; display: block; }
.chart-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.chart-donut-center strong { font-family: var(--font-heading); font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1; }
.chart-donut-center span { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.chart-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; }
.chart-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chart-legend-label { flex: 1; color: var(--text); }
.chart-legend-value { color: var(--text-muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }

/* Barras horizontais */
.chart-bar-wrap { display: flex; flex-direction: column; gap: 12px; }
.chart-bar-row { display: grid; grid-template-columns: 110px 1fr 30px; align-items: center; gap: 10px; }
.chart-bar-label {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-bar-track { background: var(--bg); border-radius: 999px; height: 12px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.chart-bar-value { font-size: 12.5px; font-weight: 700; color: var(--navy); text-align: right; }

/* Variante "larga": usada quando o valor mostrado é um texto maior
   (ex: "8 · R$ 5.240"), não só um número curto */
.chart-bar-wrap-wide .chart-bar-row { grid-template-columns: 90px 1fr auto; }
.chart-bar-wrap-wide .chart-bar-value { white-space: nowrap; font-size: 13.5px; }
.chart-bar-wrap-wide .chart-bar-track { height: 16px; }

/* Linha / área (tendência) */
.chart-trend-wrap { display: flex; flex-direction: column; gap: 6px; }
.chart-trend-svg { width: 100%; height: 180px; display: block; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-trend-area { fill: rgba(83, 215, 254, 0.22); stroke: none; }
.chart-trend-line { stroke: var(--navy); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-trend-dot { fill: var(--navy); }
.chart-trend-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); padding: 0 2px; }

@media (max-width: 700px) {
  .chart-donut-wrap { justify-content: center; }
  .chart-bar-row { grid-template-columns: 84px 1fr 26px; }
  .chart-bar-wrap-wide .chart-bar-row { grid-template-columns: 70px 1fr auto; }
  .chart-bar-wrap-wide .chart-bar-value { font-size: 12px; }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .sidebar-menu-label { display: none; }

  /* Topbar em duas linhas: menu + logo (maior) + status/usuário em cima,
     busca ocupando a largura toda embaixo. O botão de Sair sai daqui —
     agora fica dentro do menu suspenso, junto com as outras opções. */
  .topbar-inner { padding: 10px 12px; gap: 6px 8px; flex-wrap: wrap; }
  .btn-menu-mobile { order: 1; }
  .brand { order: 2; }
  .topbar-right { order: 3; margin-left: auto; }
  .topbar-busca { order: 4; flex: 1 1 100%; max-width: none; margin-top: 2px; }
  .brand-logo { height: 48px; }
  .brand-name { display: none; }
  .user-nome { display: none; }
  .user-papel { padding: 2px 6px; font-size: 10.5px; }
  .conn-status { gap: 0; }
  .conn-status .conn-label { display: none; }
  .btn-instalar-label { display: none; }
  .btn-instalar { padding: 6px 8px; }
  .user-badge .btn-logout { display: none; }

  /* Botão de menu (sanduíche) no topo — abre a lista suspensa com as abas */
  .btn-menu-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 16px;
    color: var(--navy);
    cursor: pointer;
  }

  /* ---------- Menu suspenso (lista) no celular ----------
     Fechado: nada aparece (sem barra fixa embaixo). Aberto (classe
     .menu-mobile-aberto em #appShell): a aside vira um painel que desce
     por baixo da topbar, cobrindo a tela, com a lista de abas. */
  .sidebar { border-bottom: 1px solid var(--border); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12); }
  .app-shell.menu-mobile-aberto .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    background: var(--surface);
    overflow-y: auto;
  }
  .app-shell.menu-mobile-aberto .sidebar-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .app-shell.menu-mobile-aberto .sidebar-brand .brand-logo { height: 42px; }
  .app-shell.menu-mobile-aberto .sidebar-brand .brand-name {
    display: block;
    font-size: 13px;
    text-align: left;
  }
  .app-shell.menu-mobile-aberto .btn-menu-fechar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
  }
  .app-shell.menu-mobile-aberto .sidebar .tabs {
    display: flex;
    flex-direction: column;
    max-width: none;
    margin: 0;
    padding: 8px;
    border-top: none;
    gap: 2px;
  }
  .app-shell.menu-mobile-aberto .sidebar .tab-btn {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 13px 12px;
    border-radius: 8px;
    border-bottom: none;
    margin-bottom: 0;
    border-left: 3px solid transparent;
    text-align: left;
    font-size: 15px;
  }
  .app-shell.menu-mobile-aberto .sidebar .tab-btn.active {
    background: rgba(10, 14, 66, 0.06);
    border-left-color: var(--navy);
  }
  .app-shell.menu-mobile-aberto .sidebar .tab-ico { display: inline-flex; color: var(--text-muted); }
  .app-shell.menu-mobile-aberto .sidebar .tab-btn.active .tab-ico { color: var(--navy); }
  .app-shell.menu-mobile-aberto .sidebar .tab-label { display: inline; }
  .app-shell.menu-mobile-aberto .sidebar .tab-label-short { display: none; }

  /* Sair — fica no fim da lista suspensa, separado por uma linha */
  .app-shell.menu-mobile-aberto .sidebar-logout-mobile {
    display: block;
    margin-top: auto;
    padding: 8px;
    border-top: 1px solid var(--border);
  }
  .app-shell.menu-mobile-aberto .sidebar-logout-mobile .tab-btn-logout {
    width: 100%;
    color: var(--maroon);
  }
  .app-shell.menu-mobile-aberto .sidebar-logout-mobile .tab-btn-logout .tab-ico { color: var(--maroon); }
  .app-shell.menu-mobile-aberto .sidebar-logout-mobile .tab-btn-logout:hover { background: rgba(178, 0, 28, 0.06); }
}

/* ---------- Avisos (comunicação rápida com a diretoria) ---------- */

/* Bloco de envio (Painel, produção/manutenção/encarregado) */
.aviso-envio-block { border-top: 3px solid var(--maroon); }
.aviso-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.aviso-form textarea { width: 100%; resize: vertical; min-height: 44px; }
.aviso-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.aviso-urgente-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.aviso-urgente-check input { width: 16px; height: 16px; accent-color: var(--maroon); cursor: pointer; }

/* Card da Diretoria */
.panel-block-avisos { border-top: 3px solid var(--maroon); }
.avisos-badge {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--maroon);
  border-radius: 999px;
  padding: 3px 9px;
  vertical-align: middle;
}
.avisos-list { display: flex; flex-direction: column; gap: 8px; }
.aviso-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.aviso-item.aviso-urgente { border-left-color: var(--maroon); background: #fff5f5; }
.aviso-item.aviso-lido { opacity: 0.6; }
.aviso-item-main { flex: 1; min-width: 0; }
.aviso-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.aviso-tag-urgente {
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: var(--maroon);
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}
.aviso-item-autor { font-weight: 700; font-size: 13.5px; color: var(--text); }
.aviso-item-papel { font-size: 11px; color: var(--text-muted); }
.aviso-item-data { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }
.aviso-item-msg { font-size: 13.5px; color: var(--text); margin: 0; white-space: pre-wrap; }
.aviso-marcar-lido { flex-shrink: 0; white-space: nowrap; }

@media (max-width: 700px) {
  .aviso-item { flex-direction: column; }
  .aviso-item-data { margin-left: 0; }
}

/* ---------- Alerta de recorrência ---------- */
.panel-block-recorrencia { border-top: 3px solid var(--maroon); }
.badge-recorrencia { background: #fde2e2; color: var(--maroon); font-weight: 700; }

/* ---------- Aba Caldeira ---------- */
.panel-block-caldeira { border-top: 3px solid var(--orange); }

.ficha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.ficha-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}
.ficha-item b {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.ficha-item span { font-size: 14px; color: var(--text); font-weight: 600; }

.nr13-alerta {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border-left: 3px solid var(--border);
}
.nr13-alerta.nr13-ok { background: #dcfce7; color: #166534; border-left-color: var(--green); }
.nr13-alerta.nr13-proxima { background: #fef3c7; color: #92400e; border-left-color: var(--amber); }
.nr13-alerta.nr13-atrasada { background: #fee2e2; color: #991b1b; border-left-color: var(--maroon); }

.checklist-itens {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}
.checklist-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}
.checklist-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.checklist-item-texto { font-size: 13.5px; color: var(--text); flex: 1; min-width: 200px; }
.checklist-item-toggle { display: flex; gap: 6px; flex-shrink: 0; }
.checklist-item-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.checklist-item-btn[data-val="ok"].active { background: var(--green); border-color: var(--green); color: #fff; }
.checklist-item-btn[data-val="problema"].active { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.checklist-item.tem-problema { border-color: var(--maroon); background: #fff5f5; }
.checklist-item-obs {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.checklist-resumo { font-size: 12.5px; color: var(--text-muted); }
.checklist-resumo.tem-problema { color: var(--maroon); font-weight: 600; }

@media (max-width: 700px) {
  .checklist-item-row { flex-direction: column; align-items: flex-start; }
}

/* ---------- Usuários e acesso ---------- */
.panel-block-usuarios { border-top: 3px solid var(--navy); }
.badge-papel-producao { background: #eef2ff; color: #4338ca; }
.badge-papel-caldeira { background: #fde8ea; color: var(--maroon); }
.badge-papel-manutencao { background: #e0f2fe; color: #075985; }
.badge-papel-encarregado { background: #fef3c7; color: #92400e; }
.badge-papel-diretoria { background: #fce7f3; color: #9d174d; }
.badge-inativo { background: #f3f4f6; color: #6b7280; }
.badge-ativo { background: #dcfce7; color: #15803d; }

/* ---------- Colaboradores cadastrados (lista simples nome/e-mail) ---------- */
.panel-block-colaboradores { border-top: 3px solid var(--navy); }
.colab-table-wrap { overflow-x: auto; }
.colab-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.colab-table th, .colab-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.colab-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 700; }
.colab-table tbody tr:hover { background: var(--surface-alt, #f8fafc); }
.colab-table td.empty-state { white-space: normal; }

/* ---------- Exportar relatórios (PDF / Excel) ---------- */
.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.dir-export-actions { margin: 0 0 12px; }

/* ---------- Histórico de alterações ---------- */
.panel-block-historico { border-top: 3px solid var(--navy); }
.badge-historico-insert { background: #dcfce7; color: #15803d; }
.badge-historico-update { background: #dbeafe; color: #1e40af; }
.badge-historico-delete { background: #fee2e2; color: #b91c1c; }
.badge-historico-senha { background: #fef3c7; color: #92400e; }
