/* ================================================================
   ObraAnalytics — CSS Principal
   Tema: Dark / Light profissional para construção civil
   ================================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base:        #0f1623;
  --bg-surface:     #151d2e;
  --bg-elevated:    #1c2640;
  --bg-hover:       #243050;
  --border:         #2a3550;
  --border-light:   #334268;
  --text-primary:   #e8edf5;
  --text-secondary: #a0aec0;
  --text-muted:     #5a6a88;
  --accent-blue:    #3b82f6;
  --accent-green:   #10b981;
  --accent-orange:  #f59e0b;
  --accent-purple:  #8b5cf6;
  --accent-red:     #ef4444;
  --accent-cyan:    #06b6d4;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --transition:     0.2s ease;
}

[data-theme="light"] {
  --bg-base:        #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f8fafc;
  --bg-hover:       #edf2f7;
  --border:         #e2e8f0;
  --border-light:   #cbd5e0;
  --text-primary:   #1a202c;
  --text-secondary: #4a5568;
  --text-muted:     #a0aec0;
  --shadow:         0 2px 12px rgba(0,0,0,0.08);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer .status-text { display: none; }
.sidebar.collapsed .badge { display: none !important; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 0 16px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .nav-item i { margin: 0; }

/* Brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  flex-shrink: 0;
}

.brand-name   { font-size: 15px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.brand-tagline{ font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* Nav */
.sidebar-nav  { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.nav-item i  { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.nav-item.active i { color: var(--accent-blue); }

.badge {
  background: var(--accent-blue); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  margin-left: auto;
}

/* Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.status-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; transition: background 0.5s; }
.dot.green  { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.dot.blue   { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }
.dot.red    { background: var(--accent-red); }
.dot.yellow { background: var(--accent-orange); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;          /* essencial para grid/flex filhos não transbordarem */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
  overflow-x: hidden;    /* scroll interno, não deixa vazar */
}
.main-content.sidebar-collapsed { margin-left: 64px; }

/* ── Top Bar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
  background: none; border: none; color: var(--text-secondary);
  font-size: 18px; cursor: pointer; padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.menu-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

.page-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.topbar-stat {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
}
.topbar-stat i { color: var(--accent-orange); }

/* ── Tab Content ──────────────────────────────────────────── */
.tab-content { display: none; padding: 28px; animation: fadeIn 0.2s ease; min-width: 0; overflow-x: auto; }
.tab-content.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* ── Section Header ──────────────────────────────────────── */
.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.section-header h2 i { color: var(--accent-blue); margin-right: 8px; }
.section-header p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.card-header i { color: var(--accent-blue); }
.card-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn i { font-size: 12px; }
.btn-primary   { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-outline   { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-danger-outline { background: transparent; color: var(--accent-red); border-color: var(--accent-red); }
.btn-danger-outline:hover { background: rgba(239,68,68,0.1); }

.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--accent-blue); background: rgba(59,130,246,0.1); }
.btn-danger-icon:hover { color: var(--accent-red); background: rgba(239,68,68,0.1); }

/* ================================================================
   UPLOAD AREA
   ================================================================ */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 50px 30px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-surface);
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent-blue);
  background: rgba(59,130,246,0.05);
}
.upload-area.drag-over { transform: scale(1.01); }
.upload-icon { font-size: 48px; color: var(--accent-blue); margin-bottom: 16px; opacity: 0.7; }
.upload-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.upload-sub   { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.upload-formats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.format-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
}
.format-badge i { margin-right: 4px; }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.data-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
  overflow: hidden;
}
.data-table td.num { text-align: right; font-family: 'JetBrains Mono', monospace; }
.data-table td.strong { font-weight: 600; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr.row-warn td { background: rgba(239,68,68,0.04); color: #f87171; }
.data-table tr.row-warn:hover td { background: rgba(239,68,68,0.08); }
.data-table .empty-row td { text-align: center; color: var(--text-muted); padding: 24px; font-size: 13px; overflow: visible; }

/* Coluna descrição — larga, texto visível em 2 linhas, expande no hover */
.desc-cell {
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  transition: max-height .2s ease;
}
.data-table tr:hover .desc-cell {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}

/* Larguras fixas — tabela Base SINAPI */
#tab-costs .data-table { table-layout: fixed; }

#tab-costs .data-table th:nth-child(1),
#tab-costs .data-table td:nth-child(1) { width: 36%; }   /* Descrição */
#tab-costs .data-table th:nth-child(2),
#tab-costs .data-table td:nth-child(2) { width: 8%;  }   /* Código */
#tab-costs .data-table th:nth-child(3),
#tab-costs .data-table td:nth-child(3) { width: 12%; }   /* Categoria */
#tab-costs .data-table th:nth-child(4),
#tab-costs .data-table td:nth-child(4) { width: 4%;  }   /* UD */
#tab-costs .data-table th:nth-child(5),
#tab-costs .data-table td:nth-child(5) { width: 9%; text-align:right; } /* Custo */
#tab-costs .data-table th:nth-child(6),
#tab-costs .data-table td:nth-child(6) { width: 9%; text-align:right; } /* C/BDI */
#tab-costs .data-table th:nth-child(7),
#tab-costs .data-table td:nth-child(7) { width: 7%;  }   /* Fonte */
#tab-costs .data-table th:nth-child(8),
#tab-costs .data-table td:nth-child(8) { width: 11%; }   /* Data / UF */
#tab-costs .data-table th:nth-child(9),
#tab-costs .data-table td:nth-child(9) { width: 4%; text-align:center; } /* Ações */

/* Linha da tabela — altura mínima confortável */
#tab-costs .data-table td {
  padding: 10px 12px;
}
#tab-costs .data-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* Tabela SICRO — mesmas regras de largura */
#sicro-data-table { table-layout: fixed; width: 100%; }

#sicro-data-table th:nth-child(1),
#sicro-data-table td:nth-child(1) { width: 8%;  }   /* Código */
#sicro-data-table th:nth-child(2),
#sicro-data-table td:nth-child(2) { width: 40%; }   /* Descrição */
#sicro-data-table th:nth-child(3),
#sicro-data-table td:nth-child(3) { width: 14%; }   /* Categoria */
#sicro-data-table th:nth-child(4),
#sicro-data-table td:nth-child(4) { width: 4%;  }   /* UD */
#sicro-data-table th:nth-child(5),
#sicro-data-table td:nth-child(5) { width: 10%; text-align:right; } /* Custo */
#sicro-data-table th:nth-child(6),
#sicro-data-table td:nth-child(6) { width: 10%; }   /* Tipo */
#sicro-data-table th:nth-child(7),
#sicro-data-table td:nth-child(7) { width: 7%;  }   /* Estado */
#sicro-data-table th:nth-child(8),
#sicro-data-table td:nth-child(8) { width: 7%;  }   /* Mês Ref. */

#sicro-data-table .desc-cell {
  white-space: normal;
  -webkit-line-clamp: 2;
}
#sicro-data-table tr:hover .desc-cell {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}

/* ================================================================
   MANUAL TABLE INPUTS
   ================================================================ */
.manual-table-wrap { overflow-x: auto; }
.manual-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manual-table th {
  background: var(--bg-elevated);
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.manual-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.input-cell {
  width: 100%; padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition);
}
.input-cell:focus { outline: none; border-color: var(--accent-blue); }

/* ================================================================
   KPI GRID
   ================================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition);
}
.kpi-card:hover { border-color: var(--border-light); }
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.kpi-icon.blue   { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.kpi-icon.green  { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.kpi-icon.orange { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.kpi-icon.purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.kpi-icon.red    { background: rgba(239,68,68,0.15);  color: var(--accent-red); }
.kpi-value { font-size: 20px; font-weight: 700; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; }
.kpi-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ================================================================
   CHARTS GRID
   ================================================================ */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

/* ================================================================
   STATUS BADGE
   ================================================================ */
.status-badge { display: inline-flex; align-items: center; font-size: 14px; }
.status-badge.found    { color: var(--accent-green); }
.status-badge.not-found{ color: var(--accent-orange); }

/* ================================================================
   TAGS / CHIPS
   ================================================================ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.tag-success { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.tag-warn    { background: rgba(245,158,11,0.15);  color: var(--accent-orange); }
.tag-danger  { background: rgba(239,68,68,0.15);   color: var(--accent-red); }
.tag-outline { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }

/* ================================================================
   TOOLBAR
   ================================================================ */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  flex: 1; min-width: 200px;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.search-box i   { color: var(--text-muted); font-size: 12px; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; width: 100%;
}

/* Destaque de termos de busca */
mark {
  background: #FCD34D;
  color: #000;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* Separador de grupo na tabela */
.group-separator td {
  background: rgba(255,255,255,0.03);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  border-top: 2px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 8px 16px;
  user-select: none;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-group  { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%; padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--accent-blue); }
.form-group input[type="range"] { width: 100%; accent-color: var(--accent-blue); margin-top: 4px; }
.form-group small { font-size: 11px; color: var(--text-muted); display: block; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.range-display { text-align: right; font-size: 12px; color: var(--accent-blue); font-weight: 600; margin-top: 4px; }

.input-with-unit {
  display: flex; align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.input-with-unit input {
  flex: 1; padding: 9px 12px;
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px;
}
.input-with-unit .unit {
  padding: 0 12px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  border-left: 1px solid var(--border);
  height: 100%; display: flex; align-items: center;
}

.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.radio-label input { accent-color: var(--accent-blue); }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-light);
  border-radius: 22px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

.input-sm {
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}
.input-sm:focus { outline: none; border-color: var(--accent-blue); }

/* ================================================================
   SETTINGS GRID
   ================================================================ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }

.theme-switcher { display: flex; gap: 8px; }
.theme-btn {
  flex: 1; padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px; cursor: pointer;
  transition: all var(--transition);
}
.theme-btn:hover { border-color: var(--border-light); }
.theme-btn.active { background: rgba(59,130,246,0.15); border-color: var(--accent-blue); color: var(--accent-blue); }

/* ================================================================
   REPORT OPTIONS
   ================================================================ */
.report-options-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.report-option-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.report-option-card:hover { border-color: var(--accent-blue); transform: translateY(-2px); }
.ro-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 12px;
}
.ro-icon.green  { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.ro-icon.blue   { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.ro-icon.orange { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.ro-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.ro-desc  { font-size: 12px; color: var(--text-muted); }

/* Report preview cards */
.report-summary-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.rsc {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  flex: 1; min-width: 130px;
}
.rsc-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.rsc-value { font-size: 17px; font-weight: 700; margin-top: 4px; font-family: 'JetBrains Mono', monospace; }
.rsc-value.green  { color: var(--accent-green); }
.rsc-value.blue   { color: var(--accent-blue); }
.rsc-value.orange { color: var(--accent-orange); }
.rsc-value.purple { color: var(--accent-purple); }

.report-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.report-meta span { display: flex; align-items: center; gap: 5px; }
.report-meta i { color: var(--accent-blue); }

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:none;opacity:1} }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-header h3 i { color: var(--accent-blue); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; transition: color var(--transition); }
.modal-close:hover { color: var(--text-primary); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ================================================================
   TOAST
   ================================================================ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 380px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
}
.toast.visible { transform: none; }
.toast button { background: none; border: none; color: var(--text-muted); cursor: pointer; margin-left: auto; padding: 0 4px; font-size: 12px; }
.toast-success i { color: var(--accent-green); }
.toast-error   i { color: var(--accent-red); }
.toast-warn    i { color: var(--accent-orange); }
.toast-info    i { color: var(--accent-blue); }
.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error   { border-left: 3px solid var(--accent-red); }
.toast-warn    { border-left: 3px solid var(--accent-orange); }
.toast-info    { border-left: 3px solid var(--accent-blue); }

/* ================================================================
   LOADER OVERLAY
   ================================================================ */
.loader-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000;
  backdrop-filter: blur(6px);
}
.loader-box { text-align: center; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border-light);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.loader-sub  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ================================================================
   ACTION BUTTONS ROW
   ================================================================ */
.action-btns { display: flex; gap: 4px; align-items: center; }

/* ================================================================
   FILTER SELECT
   ================================================================ */
#filterCategoria, #filterStatus {
  padding: 7px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}
#filterCategoria:focus, #filterStatus:focus { outline: none; border-color: var(--accent-blue); }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ================================================================
   SINAPI — Estilos Específicos para Planilhas Públicas
   ================================================================ */

/* Tag de FONTE (SINAPI, SICRO, COMPOSIÇÃO) */
.tag-fonte { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.tag-sinapi  { background: rgba(59,130,246,0.2);  color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.tag-sicro   { background: rgba(16,185,129,0.2);  color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.tag-comp    { background: rgba(245,158,11,0.2);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.tag-outros  { background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }

/* Tabela SINAPI */
.sinapi-table { min-width: 980px; }  /* garante scroll horizontal antes de comprimir */
.sinapi-table th.num-h { text-align: right; }
.sinapi-table td.unit-cell { font-weight: 600; font-size: 11px; color: var(--text-secondary); }
.sinapi-table td.item-num  { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--accent-blue); }
.sinapi-table td.mono      { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* Linha de grupo dentro da tabela */
.group-row td {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 7px 14px;
  border-top: 1px solid var(--border-light);
}
.group-row td i { color: var(--accent-orange); margin-right: 6px; }

/* Linha de COMPOSIÇÃO PRÓPRIA PAI — destaque visual especial */
.composicao-pai-row td {
  background: rgba(245,158,11,0.08) !important;
  border-top: 1px solid rgba(245,158,11,0.25) !important;
  border-bottom: 1px solid rgba(245,158,11,0.15) !important;
  padding: 8px 14px;
}
.composicao-pai-row td strong {
  color: #fbbf24;
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* Linha de total */
.total-footer td {
  background: var(--bg-elevated) !important;
  border-top: 2px solid var(--border-light);
  font-weight: 600;
  padding: 10px 14px;
}

/* Metadados da obra */
.obra-meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(59,130,246,0.05);
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.meta-item { display: flex; align-items: center; gap: 6px; }
.meta-item i { color: var(--accent-blue); }

/* Mini barra de progresso */
.mini-bar { width: 60px; height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--accent-blue); border-radius: 3px; transition: width 0.5s ease; }

/* Formato badge SINAPI */
.format-badge.sinapi { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #60a5fa; }

/* Divisor */
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.divider::before, .divider::after { content:''; flex:1; height:1px; background:var(--border); }
.divider span { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* KPI extra: cyan */
.kpi-icon.cyan { background: rgba(6,182,212,0.15); color: var(--accent-cyan); }

/* Charts grid extra */
.mt-20 { margin-top: 20px; }

/* ================================================================
   CUSTO DIRETO DA OBRA (CDO) — Painel
   ================================================================ */

/* Painel principal CDO */
.cdo-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-orange);
  border-radius: 12px;
  overflow: hidden;
}

.cdo-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  background: linear-gradient(90deg, rgba(249,115,22,0.08), transparent);
  border-bottom: 1px solid var(--border);
}
.cdo-title {
  display: flex; align-items: center; gap: 14px;
}
.cdo-title > i {
  font-size: 28px; color: var(--accent-orange);
  background: rgba(249,115,22,0.1); padding: 10px; border-radius: 8px;
}
.cdo-title h3 {
  font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0;
}
.cdo-title p {
  font-size: 12px; color: var(--text-muted); margin: 4px 0 0;
}

/* KPIs do CDO */
.cdo-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow-x: auto;
}
@media (max-width: 900px) {
  .cdo-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
.cdo-kpi {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  transition: background 0.2s;
  min-width: 0;
}
.cdo-kpi:last-child { border-right: none; }
.cdo-kpi:hover { background: var(--bg-hover); }
.cdo-kpi-main {
  background: rgba(249,115,22,0.05);
}
.cdo-kpi-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.cdo-kpi-label i { color: var(--accent-orange); }
.cdo-kpi-main .cdo-kpi-label i { color: var(--accent-orange); }
.cdo-kpi-value {
  font-size: 22px; font-weight: 800;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.2;
}
.cdo-kpi-main .cdo-kpi-value { color: var(--accent-orange); }
.cdo-kpi-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
.cdo-kpi-sub strong { color: var(--text-secondary); }

/* Grid do corpo CDO — responsivo */
.cdo-body-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr);
  gap: 20px;
  padding: 20px;
  min-width: 0;        /* impede overflow no grid */
}
.cdo-body-grid .card { margin: 0; min-width: 0; }

/* Responsivo: empilha em telas menores */
@media (max-width: 1100px) {
  .cdo-body-grid {
    grid-template-columns: 1fr;
  }
}

/* Mini tabela dentro do CDO */
.mini-table th, .mini-table td {
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.mini-table { min-width: 0; width: 100%; }
.mini-table .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ================================================================
   BASE DE DADOS — Banners e Indicadores
   ================================================================ */

/* Banner de atualização automática da base */
.base-update-banner {
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}
.base-update-inner {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(16,185,129,0.12), rgba(16,185,129,0.04));
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: 10px;
}
.base-update-inner > i {
  font-size: 22px; color: #10b981;
  flex-shrink: 0;
}
.base-update-text {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.base-update-text strong { color: var(--text-primary); }
.base-update-text em { color: var(--accent-blue); font-style: normal; }
.base-update-text span { color: var(--text-muted); font-size: 11px; }
.base-total-badge {
  background: rgba(16,185,129,0.15);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.3);
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.btn-close-banner {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 4px;
  border-radius: 4px; transition: color 0.2s;
}
.btn-close-banner:hover { color: var(--text-primary); }

/* Indicador na topbar */
.base-size-badge {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-hover);
  padding: 3px 8px; border-radius: 10px;
  border: 1px solid var(--border);
  white-space: nowrap;
  cursor: default;
  display: none;
}

/* CDO stat na topbar */
.topbar-stat.cdo-stat {
  border-left: 2px solid var(--accent-orange);
  background: rgba(249,115,22,0.08);
}
.topbar-stat.cdo-stat i { color: var(--accent-orange); }
.stat-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Banner de informações da base de custos */
.base-info-banner {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(59,130,246,0.08), transparent);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 10px;
  margin-bottom: 4px;
}
.base-info-icon {
  font-size: 24px; color: var(--accent-blue);
  background: rgba(59,130,246,0.1);
  padding: 10px; border-radius: 8px; flex-shrink: 0;
}
.base-info-text {
  flex: 1;
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}
.base-info-text strong { color: var(--text-primary); }
.base-stat-badge {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.3);
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
}

/* Botão outline pequeno */
.btn.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ================================================================
   UTILS
   ================================================================ */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }
.mb-16 { margin-bottom: 16px; }

/* ================================================================
   IMPORTAÇÃO SINAPI MENSAL — Card principal
   ================================================================ */

.sinapi-import-card {
  display: flex; gap: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid #10b981;
  border-radius: 12px;
  padding: 24px;
  align-items: flex-start;
}
.sic-left {
  display: flex; gap: 16px; flex: 1;
}
.sic-icon {
  font-size: 32px; color: #10b981;
  background: rgba(16,185,129,0.1);
  padding: 14px; border-radius: 10px;
  flex-shrink: 0; height: fit-content;
}
.sic-text h3 {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary); margin: 0 0 6px;
}
.sic-text p {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6; margin: 0 0 12px;
}
.sic-links {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.btn-link {
  font-size: 12px; color: var(--accent-blue);
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid rgba(59,130,246,0.3);
  border-radius: 6px; transition: all 0.2s;
}
.btn-link:hover { background: rgba(59,130,246,0.1); }
.sic-formats { display: flex; gap: 8px; flex-wrap: wrap; }
.sic-right {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; min-width: 170px; flex-shrink: 0;
}
.base-stat-block {
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 24px; width: 100%;
}
.bsb-value {
  font-size: 32px; font-weight: 800;
  color: #10b981;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.1;
}
.bsb-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.btn-lg { padding: 10px 20px; font-size: 14px; width: 100%; justify-content: center; }
.mt-8 { margin-top: 8px; }

/* Histórico de importações */
.hist-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: var(--bg-hover); }
.hist-icon {
  font-size: 18px; color: #10b981;
  background: rgba(16,185,129,0.1);
  padding: 8px; border-radius: 6px; flex-shrink: 0;
}
.hist-body { flex: 1; }
.hist-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px;
}
.hist-meta {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 3px;
  font-size: 11px; color: var(--text-muted);
}
.hist-meta span { display: inline-flex; align-items: center; gap: 3px; }
.hist-total { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hist-badge {
  background: rgba(16,185,129,0.15); color: #10b981;
  border: 1px solid rgba(16,185,129,0.3);
  padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
}
.hist-date { font-size: 10px; color: var(--text-muted); }

/* ================================================================
   MODAL IMPORTAÇÃO SINAPI — Interno
   ================================================================ */

.modal-lg { max-width: 720px !important; }

/* Passos de instrução */
.sinapi-instructions {
  display: flex; gap: 0; margin-bottom: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.si-step {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; flex: 1;
  border-right: 1px solid var(--border);
}
.si-step:last-child { border-right: none; }
.si-num {
  width: 24px; height: 24px;
  background: #10b981; color: #fff;
  border-radius: 50%; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.si-txt { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.si-txt strong { color: var(--text-primary); font-size: 12.5px; }
.si-txt a { color: var(--accent-blue); }
.si-txt code { background: var(--bg-hover); padding: 1px 5px; border-radius: 3px; font-size: 11px; }

/* Zona de upload */
.sinapi-upload-zone {
  border: 2px dashed rgba(16,185,129,0.4);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(16,185,129,0.03);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sinapi-upload-zone:hover {
  border-color: #10b981;
  background: rgba(16,185,129,0.07);
}
.sinapi-upload-zone i { font-size: 36px; color: #10b981; }
.sinapi-upload-zone span { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.sinapi-upload-zone small { font-size: 11px; color: var(--text-muted); }

/* Preview da importação */
.sinapi-preview {
  min-height: 80px;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.import-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px;
  color: var(--text-muted); font-size: 13px;
}
.import-placeholder i { font-size: 28px; color: rgba(107,114,128,0.4); }
.import-loading {
  padding: 20px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}
.import-loading i { color: #10b981; margin-right: 8px; }
.import-error {
  padding: 16px; background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2); border-radius: 8px; margin: 8px;
  color: #f87171; font-size: 13px; white-space: pre-wrap;
}

/* Summary da importação */
.sinapi-import-summary { padding: 16px; }
.sim-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
.sim-kpi {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; text-align: center;
}
.sim-kpi-val { font-size: 18px; font-weight: 800; color: #10b981; display: block; }
.sim-kpi-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sim-sample { }

/* Progress bar de importação */
.import-progress {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
}
.import-progress-bar-wrap {
  height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; margin-bottom: 6px;
}
.import-progress-bar {
  height: 100%; background: #10b981;
  border-radius: 3px; transition: width 0.3s ease;
}
.import-progress-msg {
  font-size: 11px; color: var(--text-muted); text-align: center;
}

/* Botão danger */
.btn-danger { background: #ef4444; color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-outline { background: transparent; color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.btn-danger-outline:hover { background: rgba(239,68,68,0.08); border-color: #ef4444; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  /* Sidebar no mobile é DRAWER completo — NÃO colapsa para 64px */
  :root { --sidebar-w: 280px; }
  /* Textos e ícones VISÍVEIS quando drawer aberto */
  .brand-text { display: flex !important; }
  .nav-item span { display: inline !important; }
  .sidebar-footer .status-text { display: inline !important; }
  .badge { display: inline-flex !important; }
  .sidebar-brand { justify-content: flex-start; padding: 0 20px; }
  .nav-item { justify-content: flex-start; padding: 13px 20px; gap: 12px; }
  .nav-item i { margin: 0; min-width: 20px; text-align: center; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .report-options-grid { grid-template-columns: 1fr 1fr; }
  .tab-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .report-options-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ================================================================
   TABELA ANALÍTICA — Custo Real e Variação
   ================================================================ */
.real-price { background: rgba(16,185,129,0.05); }
.has-real-price td.real-price { border-left: 2px solid rgba(16,185,129,0.3); }
.price-real { color: #10b981; font-weight: 600; }
.arquivo-price { color: var(--text-secondary); }

.source-badge {
  font-size: 11px; margin-left: 4px; cursor: default;
  opacity: 0.8;
}
.variacao { font-size: 11px; font-weight: 700; padding: 2px 6px;
  border-radius: 4px; display: inline-block; }
.var-alta  { background: rgba(245,158,11,0.15); color: #f59e0b; }
.var-baixa { background: rgba(16,185,129,0.15); color: #10b981; }
.var-ok    { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

/* ================================================================
   PAINEL CDO REAL
   ================================================================ */
.cdo-real-panel {
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(59,130,246,0.05));
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: var(--radius); margin: 16px 0;
  overflow: hidden;
}
.cdo-real-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  background: rgba(16,185,129,0.1);
  border-bottom: 1px solid rgba(16,185,129,0.2);
  font-size: 13px; font-weight: 600; color: #10b981;
}
.cdo-real-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow-x: auto;
}
@media (max-width: 900px) {
  .cdo-real-kpis { grid-template-columns: repeat(2, 1fr); }
}
.cdo-real-kpi {
  padding: 12px 16px;
  border-right: 1px solid rgba(16,185,129,0.15);
  min-width: 0;
}
.cdo-real-kpi:last-child { border-right: none; }
.cdo-real-kpi.main { background: rgba(16,185,129,0.06); }
.cdo-real-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.cdo-real-value { font-size: 18px; font-weight: 800; color: #10b981; }
.cdo-real-kpi.main .cdo-real-value { font-size: 22px; }
.cdo-real-msg {
  padding: 8px 18px; font-size: 12px;
  border-top: 1px solid rgba(16,185,129,0.15);
  color: var(--text-secondary);
}
.cdo-real-empty {
  display: flex; align-items: center; gap: 14px;
  padding: 18px; color: var(--text-secondary); font-size: 13px;
}

/* Badge de variação CDO */
.cdo-var-badge {
  font-size: 14px; font-weight: 800;
  padding: 3px 10px; border-radius: 6px;
  display: inline-block;
}
.cdo-var-badge.var-alta  { background: rgba(245,158,11,0.15); color: #f59e0b; }
.cdo-var-badge.var-baixa { background: rgba(16,185,129,0.15); color: #10b981; }
.cdo-var-badge.var-ok    { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

/* Painel CDO quando base vazia — usa azul ao invés de verde */
.cdo-real-panel:has(.cdo-real-header .fa-info-circle) {
  background: linear-gradient(135deg, rgba(59,130,246,0.07), rgba(139,92,246,0.04));
  border-color: rgba(59,130,246,0.25);
}
.cdo-real-panel:has(.fa-info-circle) .cdo-real-header {
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.2);
  color: #3b82f6;
}
.cdo-real-panel:has(.fa-info-circle) .cdo-real-kpi {
  border-right-color: rgba(59,130,246,0.15);
}
.cdo-real-panel:has(.fa-info-circle) .cdo-real-value {
  color: #3b82f6;
}

@media (max-width: 768px) {
  .cdo-real-kpis { grid-template-columns: 1fr 1fr; }
}

/* ================================================================
   BANCO DE DADOS PERMANENTE — Banner de status
   ================================================================ */
.db-status-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; margin-bottom: 16px;
  border: 1px solid transparent;
}
.db-status-ok {
  background: rgba(16,185,129,0.08);
  border-color: rgba(16,185,129,0.25);
  color: #10b981;
}
.db-status-warn {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.25);
  color: #f59e0b;
}
.db-status-banner i { font-size: 16px; flex-shrink: 0; }
.db-status-banner strong { color: var(--text-primary); }

/* Paginação da tabela de custos */
.costs-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius) var(--radius);
}
.costs-pagination button {
  padding: 6px 14px; font-size: 12px;
}
.costs-pagination button:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* Badge de conexão ao banco */
.db-connected-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.3);
  color: #10b981; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.db-connected-badge::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: #10b981; animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ================================================================
   ORÇAMENTO — Criar Orçamento (Estilo Orçafascio)
   ================================================================ */

/* Grupo de serviço */
.orca-grupo {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Cabeçalho do grupo */
.orca-grupo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(59,130,246,0.08);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.orca-grupo-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: rgba(59,130,246,0.2);
  color: #60a5fa;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.orca-grupo-nome {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Botões de ação dentro dos grupos (pequenos) */
.btn-icon-sm {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  transition: all var(--transition);
  line-height: 1;
}
.btn-icon-sm:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
  border-color: var(--border);
}
.btn-danger-sm:hover {
  color: #f87171 !important;
  background: rgba(239,68,68,0.1) !important;
  border-color: rgba(239,68,68,0.3) !important;
}

/* Tabela do orçamento */
.orca-table {
  table-layout: fixed;
  width: 100%;
  font-size: 12px;
}

.orca-table th {
  font-size: 10px;
  padding: 8px 8px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
}

.orca-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.orca-item-row:hover td {
  background: rgba(255,255,255,0.025);
}

/* Linha de subtotal dentro da tabela */
.orca-subtotal-row td {
  background: rgba(52,211,153,0.04) !important;
  border-top: 1px solid rgba(52,211,153,0.15);
  font-size: 11px;
}

/* Campo de resultado de busca */
#orcaResultados {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#orcaResultados::-webkit-scrollbar { width: 4px; }
#orcaResultados::-webkit-scrollbar-track { background: transparent; }
#orcaResultados::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Item de resultado de busca — hover via JS */
.orca-result-item {
  transition: background 0.12s ease;
}

/* Painel esquerdo (busca) — responsivo */
@media (max-width: 1100px) {
  #orcaPainelGrid {
    grid-template-columns: 340px 1fr;
  }
}

@media (max-width: 860px) {
  #orcaPainelGrid {
    grid-template-columns: 1fr;
  }
  #orcaBuscaPanel {
    position: static !important;
    max-height: 400px !important;
  }
}

/* Totais do orçamento */
#orcaTotaisCard {
  border-top: 2px solid rgba(52,211,153,0.3);
}

/* Inputs editáveis dentro da tabela de orçamento */
.orca-table input[type="number"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  padding: 4px 6px;
  font-size: 12px;
  transition: border-color var(--transition);
}
.orca-table input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: var(--bg-hover);
}

/* Badge de orçamento no sidebar */
#badge-orcamento {
  background: rgba(251,191,36,0.15) !important;
  color: #fbbf24 !important;
  font-size: 9px !important;
}

/* Separador de grupo na tabela de resultados */
#orcaResultados .orca-result-item:last-child {
  border-bottom: none;
}
