/* ===== NewGas Portal — base tokens (v2) ===== */
:root {
  /* Brand palette (Guia da Marca) */
  --metano: #1e2f39;
  --etano: #224964;
  --propano: #5bc8ba;
  --propano-tint: #d8f1ec;
  --propano-deep: #2a9b8b;
  --laranja: #eb8a09;
  --iris: #6666e8;
  --amarelo: #e5de51;

  --accent: var(--propano);
  --accent-tint: var(--propano-tint);
  --accent-deep: var(--propano-deep);

  /* Neutrals */
  --ink-900: #1e2f39;
  --ink-800: #2a3d48;
  --ink-700: #46565f;
  --ink-500: #6c7a82;
  --ink-400: #8b969c;
  --ink-300: #bcc4c8;
  --ink-200: #dfe4e6;
  --ink-100: #ecf0f1;
  --ink-50:  #f4f6f7;
  --paper:   #fafaf8;
  --white:   #ffffff;

  /* Semantic */
  --ok: #2a9b8b;
  --warn: #c97407;
  --alert: #d94f3e;
  --info: #6666e8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(30,47,57,0.04);
  --shadow-lg: 0 10px 30px rgba(30,47,57,0.10);

  /* Charts */
  --chart-grid: #ecf0f1;
  --chart-text: #8b969c;
  --chart-prog: #224964;

  /* Density (overridden by .density-compact) */
  --pad-card: 20px;
  --pad-cell-y: 12px;
  --pad-cell-x: 12px;
  --content-pad: 28px 32px 60px;
}
.density-compact {
  --pad-card: 14px;
  --pad-cell-y: 8px;
  --pad-cell-x: 10px;
  --content-pad: 20px 24px 48px;
}

/* ===== Dark theme (Tweaks) ===== */
.theme-dark {
  color-scheme: dark;
  --ink-900: #edf2f3;
  --ink-800: #dbe4e7;
  --ink-700: #b5c2c8;
  --ink-500: #8da0a8;
  --ink-400: #6e828b;
  --ink-300: #47616e;
  --ink-200: #2b4250;
  --ink-100: #243945;
  --ink-50:  #1f333e;
  --paper:   #0f1c23;
  --white:   #172932;
  --propano-tint: rgba(91,200,186,0.14);
  --propano-deep: #7fd6c9;
  --warn: #f0a339;
  --chart-grid: #243945;
  --chart-text: #6e828b;
  --chart-prog: #7fa8c9;
}
.theme-dark { color: var(--ink-900); }
.theme-dark .sidebar { background: #0b161c; }
.theme-dark .legend .sw.dash { border-top-color: var(--chart-prog); }

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: 'Urbanist', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-900);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ===== App shell ===== */
.app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}
.app.nav-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--metano);
  color: var(--ink-100);
  /* sidebar é sempre escura — tokens locais fixos, independentes do tema */
  --ink-100: #ecf0f1;
  --ink-200: #dfe4e6;
  --ink-300: #bcc4c8;
  --ink-400: #8b969c;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  overflow-y: auto;
  scrollbar-width: none;
  position: relative;
  z-index: 10;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 14px;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.sidebar__brand .brand-full {
  width: 100%;
  max-width: 150px;
  height: auto;
  display: block;
}
.sidebar__brand .brand-mini {
  display: none;
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--propano) 0%, var(--etano) 100%);
  place-items: center;
  font-weight: 800;
  color: var(--metano);
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar__toggle {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-300);
  background: rgba(255,255,255,0.05);
  transition: background 120ms, color 120ms;
}
.sidebar__toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar__toggle .ic { width: 16px; height: 16px; transition: transform 200ms ease; transform: rotate(180deg); }

/* ----- Sidebar recolhida ----- */
.app.nav-collapsed .sidebar { padding: 20px 10px 14px; overflow: visible; }
.app.nav-collapsed .sidebar__logo {
  flex-direction: column;
  gap: 12px;
  padding: 0 0 16px;
  justify-content: center;
}
.app.nav-collapsed .sidebar__brand { flex: 0; justify-content: center; }
.app.nav-collapsed .brand-full { display: none; }
.app.nav-collapsed .brand-mini { display: grid; }
.app.nav-collapsed .sidebar__toggle .ic { transform: rotate(0deg); }

.app.nav-collapsed .sidebar__section-label {
  color: transparent;
  user-select: none;
  padding: 12px 0 4px;
  text-align: center;
  overflow: hidden;
}
.app.nav-collapsed .sidebar__footer { display: none; }

.app.nav-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.app.nav-collapsed .nav-item.active::before { left: -10px; }
.app.nav-collapsed .nav-item .lbl {
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  flex: none;
  background: #0b161c;
  color: #fff;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 100;
}
.app.nav-collapsed .nav-item .lbl::before {
  content: '';
  position: absolute;
  left: -5px; top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: #0b161c;
  border-left: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app.nav-collapsed .nav-item:hover .lbl { opacity: 1; visibility: visible; }

/* ----- Menu retrátil (mobile / off-canvas) ----- */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 22, 28, 0.55);
  z-index: 40;
  opacity: 0;
  transition: opacity 200ms ease;
}

@media (max-width: 860px) {
  .app,
  .app.nav-collapsed { grid-template-columns: minmax(0, 1fr); }

  .topbar__menu { display: grid; }

  /* Sidebar vira gaveta deslizante, sempre em largura cheia */
  .app .sidebar,
  .app.nav-collapsed .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    padding: 20px 14px 14px;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    z-index: 50;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
  }
  .app.nav-open .sidebar { transform: translateX(0); }

  /* No drawer sempre mostramos o menu expandido, ignorando o estado recolhido */
  .app.nav-collapsed .brand-full { display: block; }
  .app.nav-collapsed .brand-mini { display: none; }
  .app.nav-collapsed .sidebar__logo { flex-direction: row; gap: 8px; padding: 0 6px 18px; }
  .app.nav-collapsed .sidebar__brand { flex: 1; justify-content: flex-start; }
  .app.nav-collapsed .sidebar__footer { display: block; }
  .app.nav-collapsed .sidebar__section-label { color: var(--ink-400); text-align: left; padding: 14px 6px 6px; }
  .app.nav-collapsed .nav-item { justify-content: flex-start; padding-left: 12px; padding-right: 12px; }
  .app.nav-collapsed .nav-item .lbl {
    position: static; transform: none; opacity: 1; visibility: visible;
    background: none; box-shadow: none; border: none; padding: 0;
    font-weight: 500; font-size: inherit; pointer-events: auto;
  }
  .app.nav-collapsed .nav-item .lbl::before { display: none; }

  /* O botão chevron da sidebar fecha a gaveta no mobile */
  .app.nav-collapsed .sidebar__toggle .ic,
  .sidebar__toggle .ic { transform: rotate(180deg); }

  .nav-backdrop { display: block; visibility: hidden; }
  .app.nav-open .nav-backdrop { visibility: visible; opacity: 1; }
}

/* Role banner inside sidebar */
.sidebar__role {
  display: flex; align-items: center; gap: 8px;
  margin: 0 2px 12px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,0.05);
  font-size: 11px;
  color: var(--ink-300);
}
.sidebar__role .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--propano); flex-shrink: 0; }
.sidebar__role b { color: white; font-size: 11.5px; }

.sidebar__section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-400);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,0.70);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  line-height: 1.25;
  transition: background 120ms, color 120ms;
  position: relative;
  width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active {
  background: rgba(91,200,186,0.16);
  color: white;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px;
  background: var(--propano);
  border-radius: 0 3px 3px 0;
}
.nav-item .ic { width: 17px; height: 17px; opacity: 0.85; flex-shrink: 0; }
.nav-item span.lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .badge {
  background: var(--laranja);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar__footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10.5px;
  color: var(--ink-400);
}

/* ----- Main + Topbar ----- */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--paper); min-width: 0; }

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--ink-200);
  background: var(--white);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar__menu {
  display: none;
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 9px;
  place-items: center;
  color: var(--ink-700);
  background: var(--ink-50);
  transition: background 120ms, color 120ms;
}
.topbar__menu:hover { background: var(--ink-100); color: var(--ink-900); }
.topbar__menu .ic { width: 18px; height: 18px; }
.topbar__crumbs {
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-500);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.topbar__crumbs > * { flex-shrink: 0; }
.topbar__crumbs b { color: var(--ink-900); font-weight: 700; flex-shrink: 1 !important; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1240px) { .topbar__crumbs .crumb-parent, .topbar__crumbs .crumb-sep { display: none; } }

.topbar__spacer { flex: 1; min-width: 8px; }

.topbar__search {
  display: flex; align-items: center;
  gap: 8px;
  background: var(--ink-50);
  padding: 8px 12px;
  border-radius: 10px;
  flex: 0 1 260px;
  min-width: 120px;
  color: var(--ink-500);
  font-size: 13px;
}
.topbar__search input {
  background: transparent; border: none; outline: none;
  flex: 1; min-width: 0; color: var(--ink-900);
}
@media (max-width: 1180px) {
  .topbar .topbar__search { display: none; }
}

.unit-select {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--ink-200);
  background: var(--white);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-900);
  max-width: 250px;
}

/* Role switch */
.role-switch { display: flex; background: var(--ink-50); border-radius: 999px; padding: 3px; gap: 2px; flex-shrink: 0; }
.role-switch button {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--ink-500);
  display: flex; align-items: center; gap: 6px;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}
.role-switch button.active { background: var(--metano); color: white; }
.role-switch button .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.role-switch button.active .dot { background: var(--propano); opacity: 1; }

.topbar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 5px 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--ink-200);
  flex-shrink: 0;
}
.topbar__user .name { font-size: 12.5px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.topbar__user .role { font-size: 10.5px; color: var(--ink-500); line-height: 1.15; white-space: nowrap; }
.topbar__user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--etano); color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
@media (max-width: 1320px) { .topbar__user .name, .topbar__user .role { display: none; } .topbar__user { padding: 5px; border: none; } }

/* ----- Content area ----- */
.content { flex: 1; overflow-y: auto; padding: var(--content-pad); }
.content > * { max-width: 1440px; margin-left: auto; margin-right: auto; }

/* ----- Page header ----- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -0.02em; }
.page-head .sub { color: var(--ink-500); font-size: 13.5px; margin-top: 4px; text-wrap: pretty; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600; font-size: 13px;
  border: 1px solid transparent;
  transition: background 120ms, border-color 120ms, transform 80ms;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--metano); color: white; }
.btn.primary:hover { background: #16242c; }
.btn.accent { background: var(--accent); color: var(--metano); }
.btn.accent:hover { filter: brightness(0.92); }
.btn.ghost { background: transparent; color: var(--ink-700); border-color: var(--ink-200); }
.btn.ghost:hover { background: var(--ink-50); }
.btn .ic { width: 14px; height: 14px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ----- Card ----- */
.card {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
  min-width: 0;
}
.card.tight { padding: calc(var(--pad-card) - 4px); }
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.card__head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.card__head .meta { font-size: 12px; color: var(--ink-500); }

/* Legend */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-500); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; }
.legend .sw.dash { height: 0; border-top: 1.5px dashed var(--etano); background: none; }

/* ----- KPI ----- */
.kpi {
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.kpi__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-500); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 84px;
}
.kpi__value {
  font-size: clamp(19px, 1.6vw + 8px, 26px);
  font-weight: 800; letter-spacing: -0.02em;
  margin-top: 8px; line-height: 1.05;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi__value .unit { font-size: 0.55em; color: var(--ink-500); font-weight: 600; margin-left: 4px; letter-spacing: 0; }
.kpi__delta { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; margin-top: 8px; color: var(--ink-500); }
.kpi__delta.up { color: var(--ok); }
.kpi__delta.down { color: var(--alert); }
.kpi__delta .ic { flex-shrink: 0; }
.kpi__sub { font-size: 12px; color: var(--ink-500); margin-top: 6px; }
.kpi__spark { position: absolute; right: 14px; top: 14px; opacity: 0.7; }

/* ----- Grid ----- */
.grid { display: grid; gap: 14px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-12-8 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.cols-8-4 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1240px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .cols-8-4, .cols-12-8, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--pad-card) * -1 + 4px); padding: 0 calc(var(--pad-card) - 4px); scrollbar-width: thin; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-500);
  font-weight: 700;
  padding: 9px var(--pad-cell-x);
  border-bottom: 1px solid var(--ink-200);
  background: var(--ink-50);
  white-space: nowrap;
}
.table thead th:first-child { border-radius: 8px 0 0 8px; }
.table thead th:last-child { border-radius: 0 8px 8px 0; }
.table tbody td {
  padding: var(--pad-cell-y) var(--pad-cell-x);
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--ink-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .sub-line { font-size: 11px; color: var(--ink-500); margin-top: 1px; }

/* Header fixo em tabelas longas (RF-007): região de scroll própria, o thead
   já tem fundo opaco (var(--ink-50)) e fica preso ao topo da região — não
   sobrepõe filtros/menu/toolbar. */
.table-wrap.sticky { max-height: 66vh; overflow: auto; }
.table-wrap.sticky thead th {
  position: sticky; top: 0; z-index: 2;
  /* Com border-collapse:collapse o border-bottom do th não acompanha o sticky
     em Chrome/Safari; o box-shadow garante o separador em todos os navegadores. */
  box-shadow: inset 0 -1px 0 var(--ink-200);
}

/* Grupo de checkboxes inline (RF-011 — combustível com múltipla seleção). */
.field .checks-inline > div, .field .checks-inline ul {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none;
}
.field .checks-inline label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; text-transform: none; letter-spacing: 0;
  color: var(--ink-700); font-weight: 500;
}
.field .checks-inline input { width: auto; }

/* ----- Pills / Tags ----- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--ink-100); color: var(--ink-700);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: rgba(42,155,139,0.10); color: var(--ok); }
.pill.warn { background: rgba(235,138,9,0.12); color: var(--warn); }
.pill.alert { background: rgba(217,79,62,0.10); color: var(--alert); }
.pill.info { background: rgba(102,102,232,0.10); color: var(--info); }
.pill.brand { background: var(--propano-tint); color: var(--propano-deep); }
.pill.outline { background: transparent; border: 1px solid var(--ink-200); color: var(--ink-700); }

/* ----- Form ----- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-500); font-weight: 700;
}
.field input, .field select, .field textarea {
  border: 1px solid var(--ink-200);
  background: var(--white);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color 120ms, box-shadow 120ms;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--propano);
  box-shadow: 0 0 0 3px rgba(91,200,186,0.18);
}
.field input:disabled { background: var(--ink-50); color: var(--ink-500); }

/* ----- Misc ----- */
.divider { height: 1px; background: var(--ink-200); margin: 16px 0; }
.muted { color: var(--ink-500); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace; font-size: 0.92em; }
.tabular { font-variant-numeric: tabular-nums; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.section-title .count { color: var(--ink-500); font-size: 13px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ink-200); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tabs button {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink-900); }
.tabs button.active { color: var(--metano); border-bottom-color: var(--propano); }

svg.chart { width: 100%; display: block; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-500); font-size: 13px; }
.empty .ic, .empty svg { color: var(--ink-300); margin-bottom: 4px; }
.empty h3 { color: var(--ink-700); font-size: 14px; font-weight: 600; margin: 8px 0 4px; }
.empty p { margin: 0; font-size: 13px; color: var(--ink-500); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,47,57,0.42);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 200;
  animation: fadein 160ms ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white);
  border-radius: 18px;
  width: min(640px, calc(100vw - 40px));
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .modal__head { margin-bottom: 16px; }
.modal .modal__sub { color: var(--ink-500); font-size: 13px; }

/* Banner */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: rgba(102,102,232,0.06);
  color: var(--ink-800);
  border-left: 3px solid var(--iris);
  text-wrap: pretty;
}
.banner .ic { flex-shrink: 0; margin-top: 1px; }
.banner.warn { background: rgba(235,138,9,0.07); border-left-color: var(--laranja); }
.banner.alert { background: rgba(217,79,62,0.06); border-left-color: var(--alert); }
.banner.brand { background: var(--propano-tint); border-left-color: var(--propano); }
.banner b { color: var(--ink-900); }

/* QDC timeline (contract detail) */
.qdc-timeline { display: flex; border-radius: 10px; overflow: hidden; height: 44px; border: 1px solid var(--ink-200); }
.qdc-timeline .seg {
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 14px;
  font-size: 12px;
  border-right: 1px solid var(--ink-200);
}
.qdc-timeline .seg:last-child { border-right: none; }
.qdc-timeline .seg b { font-size: 13px; }
.qdc-timeline .seg.current { background: var(--propano-tint); }
.qdc-timeline .seg .lbl { font-size: 10.5px; color: var(--ink-500); }

/* Composition stacked bar (fatura) */
.comp-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; }
.comp-bar span { height: 100%; }
.comp-legend { display: flex; flex-direction: column; gap: 0; margin-top: 14px; }
.comp-legend .row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--ink-100); font-size: 13px; }
.comp-legend .row:last-child { border-bottom: none; }
.comp-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.comp-legend .lbl { flex: 1; min-width: 0; }
.comp-legend .lbl small { display: block; color: var(--ink-500); font-size: 11px; }
.comp-legend .val { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.comp-legend .pct { color: var(--ink-500); font-size: 11.5px; width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Adições do portal server-rendered ===== */
.chart-host { width: 100%; min-height: 200px; }
.chart-empty { display: grid; place-items: center; height: 200px; color: var(--ink-400); font-size: 13px; }
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.bar-track { height: 6px; background: var(--ink-100); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 10px 18px; font-size: 13px; }
.kv dt { color: var(--ink-500); }
.kv dd { margin: 0; font-weight: 600; }
/* ===== Barra de filtros (R2) =====
   Com JS, a filtragem é automática e o botão "Filtrar" some: no lugar dele fica
   um indicador do que está ativo. Sem JS, o botão continua lá e a tela funciona
   exatamente como antes. */
.filters-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters-bar select,
.filters-bar input[type="date"] { min-width: 0; }

/* Indicador (substitui o botão quando a filtragem é automática). */
.filters-bar__status {
  display: none; align-items: center; gap: 7px; margin-left: auto;
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-500); background: var(--ink-50); border: 1px solid var(--ink-100);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.filters-bar__status .ic { width: 14px; height: 14px; flex-shrink: 0; }
.filters-bar__status .contagem {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--metano); font-size: 11px; font-weight: 700;
}
.filters-bar__status.ativo {
  color: var(--accent-deep); background: var(--accent-tint); border-color: transparent;
}
.filters-bar__limpar {
  color: inherit; text-decoration: underline; text-underline-offset: 2px;
  font-weight: 600; opacity: 0.75;
}
.filters-bar__limpar:hover { opacity: 1; }

.filters-bar.is-auto .filters-bar__status { display: inline-flex; }
.filters-bar.is-auto .filters-bar__submit,
.filters-bar.is-auto .filters-bar__limpar-nojs { display: none; }

/* Enquanto a listagem recarrega: evita clique duplo e sinaliza o trabalho. */
.filters-bar.is-loading { opacity: 0.55; pointer-events: none; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.tabs a { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-500); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink-900); }
.tabs a.active { color: var(--metano); border-bottom-color: var(--propano); }

/* Botão de download das tabelas (2.1). */
.export-btn { display: inline-flex; gap: 6px; align-items: center; }

/* Variante compacta, para alternâncias dentro de um card (1.1 — unidade/grupo). */
.tabs.sm { margin-bottom: 0; }
.tabs.sm a, .tabs.sm button { padding: 6px 10px; font-size: 12px; }

/* ===== Formulários ===== */
.messages { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; border: 1px solid transparent; }
.messages li.success { background: rgba(42,155,139,0.10); color: var(--ok); border-color: rgba(42,155,139,0.25); }
.messages li.error { background: rgba(217,79,62,0.10); color: var(--alert); border-color: rgba(217,79,62,0.25); }
.messages li.warning { background: rgba(235,138,9,0.12); color: var(--warn); border-color: rgba(235,138,9,0.28); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field .help { font-size: 11.5px; color: var(--ink-500); }
.field .err { font-size: 11.5px; color: var(--alert); font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--alert); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-700); cursor: pointer; }
.check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--metano); }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-list label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ink-100); }
.form-actions .spacer { flex: 1; }

.form-section { margin-top: 8px; }
.form-section > h3 { font-size: 14px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }

.formset .formset-row { position: relative; border: 1px solid var(--ink-200); border-radius: var(--r-sm); padding: 14px; margin-bottom: 12px; background: var(--ink-50); }
.formset .formset-row .del { position: absolute; top: 10px; right: 12px; }
.formset .add-row { margin-top: 4px; }

/* Matriz de permissões */
.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { padding: 11px 12px; border-bottom: 1px solid var(--ink-100); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; font-weight: 600; }
.matrix thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-500); }
.matrix input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--metano); cursor: pointer; }

/* ===== Relatório Operacional ===== */
.relatorio {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}
.relatorio__sidebar {
  background: var(--metano);
  color: var(--white);
  border-radius: var(--r-md);
  padding: 14px 12px;
  position: sticky;
  top: 12px;
}
.relatorio__brand img { display: block; margin: 0 auto 12px; filter: brightness(0) invert(1); opacity: 0.95; }
.relatorio__cliente-card {
  background: rgba(255,255,255,0.08);
  border-radius: var(--r-sm);
  padding: 10px;
  margin-bottom: 12px;
}
.relatorio__cliente-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.7; }
.relatorio__cliente-nome { font-size: 12px; font-weight: 600; margin-top: 4px; line-height: 1.3; }
.relatorio__filtros .field { margin-bottom: 10px; }
.relatorio__filtros label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.75; }
.relatorio__filtros select {
  width: 100%;
  margin-top: 4px;
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 6px 8px;
}
.relatorio__main { min-width: 0; }
.relatorio__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.relatorio__head h1 { font-size: 22px; margin: 0; }
.relatorio__kpis {
  background: rgba(91,200,186,0.12);
  border-radius: var(--r-md);
  padding: 12px;
  margin-bottom: 14px;
}
.relatorio__kpis-title { font-size: 11px; font-weight: 700; margin-bottom: 8px; }
.relatorio__kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.relatorio__kpi {
  background: var(--white);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  text-align: center;
}
.relatorio__kpi .lbl { display: block; font-size: 10px; font-weight: 700; }
.relatorio__kpi .val { display: block; font-size: 14px; font-weight: 700; margin-top: 2px; }
.relatorio__kpi--mensal .lbl { color: var(--propano-deep); }
.relatorio__kpi--diario .lbl { color: var(--accent-deep); }
.relatorio__legenda { font-size: 10px; font-style: italic; margin-top: 10px; color: var(--ink-500); line-height: 1.5; }
.relatorio__graficos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.relatorio__grafico .card__head h3 { font-size: 12px; }
.relatorio__aviso {
  text-align: right;
  font-size: 11px;
  font-style: italic;
  color: var(--alert);
  padding: 4px 12px 10px;
}
.relatorio__nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.relatorio__nav-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  background: var(--accent-deep);
  color: var(--white);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  padding: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.relatorio__nav-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--white); }
.relatorio__welcome { margin-bottom: 0; }
.relatorio__welcome h2 { margin: 0 0 8px; font-size: 18px; }
.relatorio__welcome p { margin: 0 0 8px; color: var(--ink-500); line-height: 1.5; }
.relatorio__matrizes .table { font-size: 11px; }
.relatorio__titulo-supridor { color: var(--propano-deep); }
.relatorio__titulo-distrib { color: var(--etano); }
@media (max-width: 960px) {
  .relatorio { grid-template-columns: 1fr; }
  .relatorio__sidebar { position: static; }
  .relatorio__graficos, .relatorio__kpis-grid, .relatorio__nav-grid { grid-template-columns: 1fr; }
}

/* ===== Paginação ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pagination__info,
.pagination__page { font-size: 12.5px; color: var(--ink-500); }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }

/* ===== Botão destrutivo ===== */
.btn.danger { background: var(--alert); color: #fff; }
.btn.danger:hover { background: #b83e2f; }

/* ===== Mensagem global "info" ===== */
.messages li.info { background: rgba(102,102,232,0.10); color: var(--info); border-color: rgba(102,102,232,0.25); }

/* Requisitos de senha (help_text do Django vem como <ul>) */
.field .help ul { margin: 4px 0 0; padding-left: 18px; }

/* ===== Autenticação (telas standalone — login, MFA, reset de senha) ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 30% -10%, #26414f 0%, #1e2f39 45%, #16242c 100%);
}
.auth-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.auth-logo { width: 100%; display: flex; justify-content: center; }
.auth-logo img {
  width: 220px; max-width: 75%; height: auto; display: block;
  mix-blend-mode: screen;
}
.auth-card {
  width: 100%;
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .sub { color: var(--ink-500); font-size: 13px; margin: 0 0 20px; line-height: 1.55; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-700); margin: 0 0 6px; text-transform: none; letter-spacing: 0; }
.auth-card .field { display: block; margin-bottom: 16px; }
.auth-card input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  background: var(--ink-50);
  font-size: 14px;
  outline: none;
}
.auth-card input:focus { border-color: var(--accent); background: var(--white); }
.auth-card input.auth-code {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 22px; letter-spacing: 8px; text-align: center;
}
.auth-card .btn.accent {
  width: 100%; justify-content: center;
  padding: 11px; font-weight: 700; margin-top: 4px;
  text-decoration: none;
}
.auth-err {
  background: rgba(217,79,62,0.10); color: var(--alert);
  border: 1px solid rgba(217,79,62,0.25);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
}
.auth-msg {
  background: var(--ink-50); color: var(--ink-700);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
}
.auth-field-err { color: var(--alert); font-size: 13px; margin: 6px 0 0; }
.auth-help { margin: 8px 0 0; }
.auth-help ul { margin: 0; padding-left: 18px; color: var(--ink-500); font-size: 12px; line-height: 1.6; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 18px; }
.auth-remember { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-700); font-weight: 500; cursor: pointer; margin: 0; }
.auth-remember input { width: auto; margin: 0; accent-color: var(--accent); }
.auth-forgot { font-size: 12.5px; color: var(--propano-deep); font-weight: 600; }
.auth-forgot:hover { text-decoration: underline; }
.auth-resend { margin-top: 16px; text-align: center; font-size: 12.5px; color: var(--ink-500); }
.auth-resend form { display: inline; }
.auth-resend button { color: var(--propano-deep); font-weight: 600; font-size: 12.5px; }
.auth-resend button:hover { text-decoration: underline; }
.auth-resend button:disabled { color: var(--ink-400); cursor: default; text-decoration: none; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--ink-400); font-size: 11.5px; }
.auth-foot a { color: var(--ink-400); font-size: 12px; }
.auth-foot a:hover { text-decoration: underline; }

/* Campo de senha com botão mostrar/ocultar */
.auth-pass { position: relative; }
.auth-pass input { padding-right: 74px; }
.auth-pass-toggle {
  position: absolute; top: 50%; right: 7px; transform: translateY(-50%);
  font-size: 11.5px; font-weight: 700; color: var(--ink-500);
  padding: 5px 8px; border-radius: 6px;
  transition: background 120ms, color 120ms;
}
.auth-pass-toggle:hover { background: var(--ink-100); color: var(--ink-700); }
