/* ── Variables ── */
:root {
  --bg:           #F5F0E8;
  --surface:      #FFFFFF;
  --green-dark:   #2D6A4F;
  --green-mid:    #52B788;
  --green-light:  #D8F3DC;
  --amber:        #F4A261;
  --amber-light:  #FFF0E0;
  --red-soft:     #FDECEA;
  --red:          #C0392B;
  --purple-soft:  #F3EEF8;
  --purple:       #7B5EA7;
  --blue:         #4A90D9;
  --blue-light:   #EBF4FF;
  --text-primary:   #1A1A2E;
  --text-secondary: #5C6B73;
  --border:       #E0D9CC;
  --shadow:       0 2px 12px rgba(0,0,0,0.06);
  --radius:       16px;
  --nav-h:        64px;
  --header-h:     56px;
  --filter-h:     52px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ── */
#header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--green-dark);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#header h1 {
  color: #fff;
  font-size: 1rem; font-weight: 700; letter-spacing: -0.02em;
  flex: 1;
}
#header .badge-n {
  background: var(--green-mid); color: #fff;
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
#offline-banner {
  display: none; background: var(--amber); color: #fff;
  text-align: center; padding: 6px; font-size: 0.8rem; font-weight: 600;
}
#offline-banner.show { display: block; }

/* ── Filter Bar ── */
#filter-bar {
  position: sticky; top: var(--header-h); z-index: 99;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.filter-select {
  font-family: inherit; font-size: 0.78rem; font-weight: 500;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; color: var(--text-primary);
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235C6B73'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 24px;
}
.filter-select:focus { outline: 2px solid var(--green-mid); }
#filter-campos {
  font-family: inherit; font-size: 0.78rem; font-weight: 500;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; color: var(--text-primary);
  min-width: 160px;
}

/* ── Main Content ── */
#content {
  flex: 1;
  padding: 20px 16px;
  padding-bottom: calc(var(--nav-h) + 20px);
  max-width: 1200px; margin: 0 auto; width: 100%;
}

/* ── Bottom Nav (mobile) ── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 4px 2px;
  transition: color 0.15s;
}
.nav-item .nav-icon { font-size: 1.2rem; line-height: 1; }
.nav-item.active { color: var(--green-dark); }
.nav-item.active .nav-icon { transform: scale(1.15); }

/* ── Sidebar (desktop) ── */
@media (min-width: 768px) {
  #bottom-nav { display: none; }
  #layout { display: flex; }
  #sidebar {
    width: 200px; min-height: calc(100vh - var(--header-h) - 52px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    position: sticky; top: calc(var(--header-h) + 52px);
    height: calc(100vh - var(--header-h) - 52px);
    overflow-y: auto;
  }
  .nav-item {
    flex-direction: row; gap: 10px; justify-content: flex-start;
    padding: 10px 20px; font-size: 0.82rem;
    border-radius: 0; width: 100%;
  }
  .nav-item .nav-icon { font-size: 1.1rem; }
  .nav-item.active { background: var(--green-light); color: var(--green-dark); }
  #content { padding: 24px; max-width: none; }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}
.card-sm { padding: 1rem; border-radius: 12px; }

/* ── KPI Grid ── */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 600px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-secondary);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800;
  line-height: 1; color: var(--green-dark);
}
.kpi-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }
.kpi-card.amber .kpi-value { color: var(--amber); }
.kpi-card.blue .kpi-value { color: var(--blue); }
.kpi-card.purple .kpi-value { color: var(--purple); }

/* ── Section ── */
.section-title {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-secondary);
  margin-bottom: 12px;
}
.section { margin-bottom: 24px; }

/* ── Chart containers ── */
.chart-wrap { position: relative; }
.chart-wrap canvas { max-height: 320px; }
.chart-wrap-tall canvas { max-height: 420px; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* ── Heatmap ── */
.heatmap-wrap { overflow-x: auto; }
.heatmap-table {
  border-collapse: collapse; font-size: 0.78rem;
  min-width: 400px; width: 100%;
}
.heatmap-table th {
  padding: 6px 10px; text-align: center;
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-secondary); white-space: nowrap;
}
.heatmap-table td {
  padding: 4px 6px; text-align: center;
  border-radius: 4px; font-weight: 600; font-size: 0.8rem;
  min-width: 60px;
}
.heatmap-table .row-label {
  text-align: left; font-weight: 500; white-space: nowrap;
  padding-right: 12px; color: var(--text-primary);
  font-size: 0.78rem;
}
.heat-0  { background: #f8f8f8; color: #ccc; }
.heat-1  { background: #e8f5ee; color: #52B788; }
.heat-2  { background: #b7e4c7; color: #2D6A4F; }
.heat-3  { background: #74c69d; color: #1b4332; }
.heat-4  { background: #40916c; color: #fff; }
.heat-5  { background: #2D6A4F; color: #fff; }

/* ── Alert cards ── */
.alert-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .alert-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .alert-grid { grid-template-columns: repeat(3, 1fr); } }
.alert-card {
  border-radius: 12px; padding: 1.2rem;
  border-left: 4px solid;
}
.alert-card.critical { background: var(--red-soft); border-color: var(--red); }
.alert-card.warning  { background: var(--amber-light); border-color: var(--amber); }
.alert-card.monitor  { background: var(--green-light); border-color: var(--green-mid); }
.alert-card .alert-title { font-size: 0.78rem; font-weight: 700; margin-bottom: 6px; }
.alert-card .alert-num { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.alert-card.critical .alert-num { color: var(--red); }
.alert-card.warning  .alert-num { color: var(--amber); }
.alert-card.monitor  .alert-num { color: var(--green-dark); }
.alert-card .alert-text { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }
.alert-card .alert-action { font-size: 0.72rem; font-weight: 600; margin-top: 8px; color: var(--text-primary); }

/* ── Etapa pills ── */
.etapa-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.etapa-pill {
  padding: 6px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
  border: 2px solid transparent; cursor: pointer;
  background: var(--bg); color: var(--text-secondary); border-color: var(--border);
  transition: all 0.15s;
}
.etapa-pill.active {
  background: var(--green-dark); color: #fff; border-color: var(--green-dark);
}

/* ── Propostas cards ── */
.propostas-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 700px) { .propostas-grid { grid-template-columns: 1fr 1fr; } }
.proposta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.proposta-tag {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 10px;
}
.tag-ingressar  { background: var(--blue-light);   color: var(--blue); }
.tag-integrar   { background: var(--green-light);  color: var(--green-dark); }
.tag-permanecer { background: var(--amber-light);  color: #B55E1A; }
.tag-cuidar     { background: var(--red-soft);     color: var(--red); }
.tag-retornar   { background: var(--purple-soft);  color: var(--purple); }
.tag-transversal { background: #EEE; color: #555; }
.proposta-titulo { font-size: 0.92rem; font-weight: 700; margin-bottom: 8px; }
.proposta-problema { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }
.proposta-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge-esforco, .badge-impacto {
  font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}
.esf-baixo  { background: #e6f4ea; color: #2D6A4F; }
.esf-medio  { background: var(--amber-light); color: #B55E1A; }
.esf-alto   { background: var(--red-soft); color: var(--red); }
.imp-alto   { background: var(--green-dark); color: #fff; }
.imp-medio  { background: var(--green-mid); color: #fff; }
.imp-baixo  { background: #ddd; color: #666; }

.propostas-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.proposta-filter-btn {
  padding: 5px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
  color: var(--text-secondary); transition: all 0.15s;
}
.proposta-filter-btn.active {
  background: var(--green-dark); color: #fff; border-color: var(--green-dark);
}

/* ── Tensões ── */
.tensao-list { display: flex; flex-direction: column; gap: 8px; }
.tensao-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg); border-radius: 10px;
  border: 1px solid var(--border);
}
.tensao-badge { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.tensao-critical { background: #ffd6d6; color: var(--red); }
.tensao-high { background: var(--amber-light); color: #B55E1A; }
.tensao-med { background: var(--green-light); color: var(--green-dark); }
.tensao-label { font-size: 0.8rem; flex: 1; }
.tensao-n { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }

/* ── Tabela comparativa ── */
.comp-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.comp-table th {
  background: var(--green-dark); color: #fff;
  padding: 8px 10px; text-align: left; font-weight: 600;
  font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase;
}
.comp-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.comp-table tr:hover td { background: var(--bg); }
.bar-inline {
  display: inline-block; height: 6px; border-radius: 3px;
  background: var(--green-mid); vertical-align: middle;
  margin-left: 6px; min-width: 2px;
}

/* ── Explorar ── */
.explorar-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.explorar-select {
  font-family: inherit; font-size: 0.8rem; font-weight: 500;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; color: var(--text-primary); cursor: pointer;
}
#data-table-wrap { overflow-x: auto; margin-top: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
.data-table th { background: var(--green-dark); color: #fff; padding: 7px 8px; text-align: left; font-size: 0.68rem; white-space: nowrap; }
.data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.data-table tr:nth-child(even) td { background: var(--bg); }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.page-btn {
  padding: 5px 10px; border-radius: 8px; font-size: 0.76rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
  color: var(--text-primary);
}
.page-btn.active { background: var(--green-dark); color: #fff; border-color: var(--green-dark); }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, #f0ebe3 25%, #e5e0d8 50%, #f0ebe3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 120px; margin-bottom: 12px; }
.skel-chart { height: 240px; margin-bottom: 12px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; }

/* ── Tooltip ── */
.tooltip {
  position: absolute; background: rgba(26,26,46,0.92); color: #fff;
  padding: 6px 10px; border-radius: 8px; font-size: 0.75rem; pointer-events: none;
  white-space: nowrap; z-index: 200; display: none;
}

/* ── View transitions ── */
.view { display: none; animation: fadeIn 0.2s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Sub-tabs ── */
.sub-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.sub-tab {
  padding: 10px 16px; font-size: 0.82rem; font-weight: 600;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.sub-tab.active { color: var(--green-dark); border-bottom-color: var(--green-dark); }

/* ── Print ── */
@media print {
  #bottom-nav, #sidebar, #header, #filter-bar { display: none; }
  .view { display: block !important; }
  #content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}

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