/* ============================================================================
   Observatório de Indicadores — Design System
   ========================================================================== */
:root {
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-050: #eff6ff;
  --nav: #0f2a4a;
  --nav-2: #16345c;
  --ink: #1e2430;
  --muted: #6b7280;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #e9ecf3;
  --green: #059669;
  --green-050: #d1fae5;
  --amber: #b45309;
  --amber-050: #fef3c7;
  --red: #dc2626;
  --red-050: #fee2e2;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-md: 0 6px 20px rgba(16,24,40,.08);
  --shadow-lg: 0 18px 40px -12px rgba(16,24,40,.22);
  --sidebar-w: 250px;

  /* aliases (nomes antigos usados em alguns pontos do código) */
  --obs-navy: var(--nav);
  --obs-navy-light: var(--nav-2);
  --obs-green: var(--green);
  --obs-accent: var(--brand);
  --obs-bg: var(--bg);
  --obs-card-radius: var(--radius);
}

* { -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -.006em;
}
h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { color: var(--brand); }

/* ---------- Login ---------- */
.obs-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(255,255,255,.15), transparent 60%),
    linear-gradient(135deg, var(--nav) 0%, var(--nav-2) 55%, var(--brand-strong) 130%);
  padding: 1rem;
}
.obs-login-card {
  background: #fff; border-radius: 22px; padding: 2.5rem 2.25rem;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.6);
}
.obs-login-logo {
  width: 62px; height: 62px; border-radius: 16px; margin: 0 auto 1.1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff; font-size: 1.7rem; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.obs-login .form-control { border-radius: var(--radius-sm); padding: .6rem .85rem; }

/* ---------- App shell (sidebar + content) ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh; position: sticky; top: 0; flex-shrink: 0;
  background: linear-gradient(185deg, var(--nav-2), var(--nav) 55%, #081b34);
  color: rgba(255,255,255,.72);
  padding: .4rem .8rem 1.2rem;
  display: flex; flex-direction: column;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  font-size: 1.05rem; font-weight: 750; color: #fff; letter-spacing: -.02em;
  padding: 1.15rem .5rem 1.15rem; margin-bottom: .3rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .tile {
  width: 38px; height: 38px; border-radius: 11px; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  box-shadow: 0 6px 14px -6px var(--brand);
}
.sidebar-brand small { display: block; font-weight: 400; font-size: .68rem; opacity: .7; }

.sidebar-nav { display: flex; flex-direction: column; gap: .18rem; padding-top: .6rem; flex: 1; }
.sidebar-nav .nav-item {
  color: rgba(255,255,255,.68); text-decoration: none;
  padding: .66rem .85rem; display: flex; align-items: center; gap: .75rem;
  font-size: .88rem; font-weight: 500; border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-item .ic { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: .85; }
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav .nav-item.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff; font-weight: 600; box-shadow: 0 8px 18px -8px var(--brand);
}
.sidebar-nav .nav-item.active .ic { opacity: 1; }
.sidebar-nav .nav-divider {
  border-top: 1px solid rgba(255,255,255,.08); margin: .6rem .5rem; padding-top: .2rem;
}
.sidebar-nav .nav-section-label {
  display: block; font-size: .66rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: rgba(255,255,255,.4); padding: 0 .85rem .35rem;
}
.sidebar-nav .nav-item-sm { padding: .45rem .85rem; font-size: .82rem; }
.sidebar.collapsed .nav-section-label { display: none; }

.sidebar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin: .5rem auto 0; flex-shrink: 0;
  background: rgba(255,255,255,.08); border: none; border-radius: 50%;
  color: rgba(255,255,255,.75); font-size: .9rem; transition: background .15s ease;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Sidebar recolhida (desktop) ---------- */
.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-brand .label,
.sidebar.collapsed .nav-item .label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
.sidebar.collapsed .nav-item .ic { width: auto; }
.sidebar.collapsed #sidebarCollapseIcon { display: inline-block; transform: rotate(180deg); }

.content-wrap { min-width: 0; flex: 1; }
.topbar {
  background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: .85rem 1.6rem; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10; gap: 1rem;
}
.topbar h1 { font-size: 1.02rem; font-weight: 650; margin: 0; color: var(--ink); }
.page { padding: 1.6rem; max-width: 1360px; }

.user-chip {
  border-radius: 999px; padding: .35rem .8rem .35rem .45rem; border: 1px solid var(--line);
  background: #fff; display: flex; align-items: center; gap: .55rem; font-size: .85rem; box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem;
}

/* ---------- Cards ---------- */
.card, .obs-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); background: var(--card);
}
.card .card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.15rem; font-weight: 600; }
.card .card-body { padding: 1.15rem; }
.obs-card .card-title, .card .card-title { font-weight: 650; color: var(--nav); font-size: .95rem; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 550; padding: .5rem .95rem; }
.btn-sm { border-radius: 9px; padding: .32rem .7rem; }
.btn-primary, .btn-obs-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 6px 16px -8px var(--brand);
}
.btn-primary:hover, .btn-obs-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-light { background: #fff; border-color: var(--line); }
.btn-light:hover { background: var(--brand-050); border-color: var(--line); }
.btn-outline-primary { border-radius: var(--radius-sm); }
.btn-outline-secondary { border-radius: var(--radius-sm); }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--line); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .16);
}
.form-label { font-size: .85rem; font-weight: 550; color: #374151; }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: var(--brand-050); margin: 0; }
.table > :not(caption) > * > * { padding: .7rem .95rem; }
.table thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line);
}
.table td { border-color: var(--line); vertical-align: middle; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; border-radius: 8px; padding: .32em .6em; }

/* ---------- Stat / KPI cards ---------- */
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; height: 100%; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease;
  position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--accent, var(--brand)); }
.stat-value { font-size: 1.65rem; font-weight: 750; line-height: 1; letter-spacing: -.03em; color: var(--nav); }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; margin-bottom: .35rem; }

.stat-card-dark {
  background: linear-gradient(135deg, var(--nav) 0%, var(--nav-2) 100%);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; height: 100%;
  box-shadow: var(--shadow-sm);
}

/* ---------- Gauge circular (% de preenchimento) ---------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; padding: .5rem 0 .25rem; }
.gauge {
  --pct: 0;
  position: relative; width: 168px; height: 168px;
  border-radius: 50%;
  background: conic-gradient(var(--gauge-color, var(--brand)) calc(var(--pct) * 1%), var(--line) 0);
  display: flex; align-items: center; justify-content: center;
}
.gauge::before {
  content: ""; position: absolute; inset: 15px; border-radius: 50%; background: var(--card);
  box-shadow: inset 0 1px 3px rgba(16,24,40,.06);
}
.gauge-center { position: relative; z-index: 1; text-align: center; }
.gauge-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; color: var(--nav); line-height: 1; }
.gauge-caption { font-size: .74rem; color: var(--muted); margin-top: .2rem; }

.gauge-wrap-sm { padding: .2rem 0 0; }
.gauge-sm { width: 96px; height: 96px; }
.gauge-sm::before { inset: 9px; }
.gauge-value-sm { font-size: 1.1rem; }

/* ---------- Breakdown list (barrinhas coloridas por item) ---------- */
.breakdown-item { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; }
.breakdown-item .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.breakdown-item .info { flex: 1; min-width: 0; }
.breakdown-item .info .t { font-size: .84rem; font-weight: 550; color: var(--ink); }
.breakdown-item .info .s { font-size: .74rem; color: var(--muted); }
.breakdown-item .n { font-size: .84rem; font-weight: 650; color: var(--nav); white-space: nowrap; }

/* ---------- Heatmap de atividade por mês ---------- */
.heatmap-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; }
.heatmap-cell {
  aspect-ratio: 1; border-radius: 6px; background: var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 650; color: var(--muted);
}
.heatmap-cell[data-level="1"] { background: color-mix(in srgb, var(--brand) 25%, var(--line)); color: #fff; }
.heatmap-cell[data-level="2"] { background: color-mix(in srgb, var(--brand) 55%, var(--line)); color: #fff; }
.heatmap-cell[data-level="3"] { background: var(--brand); color: #fff; }
.heatmap-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; margin-top: .35rem; }
.heatmap-labels span { text-align: center; font-size: .62rem; color: var(--muted); }

/* ---------- Cards "pasta" (acesso rápido por secretaria) ---------- */
.folder-card {
  display: block; text-decoration: none; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); padding: 1.1rem;
  box-shadow: var(--shadow-sm); transition: box-shadow .18s ease, transform .18s ease;
}
.folder-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.folder-card .icon-tile { margin-bottom: .8rem; width: 46px; height: 46px; font-size: 1.35rem; }
.folder-card .name { font-size: .92rem; font-weight: 600; color: var(--ink); margin-bottom: .15rem; }
.folder-card .meta { font-size: .76rem; color: var(--muted); }

/* ---------- Hero / welcome banner ---------- */
.hero {
  border-radius: 20px; color: #fff; padding: 1.6rem 1.8rem; margin-bottom: 1.25rem;
  background:
    radial-gradient(700px 300px at 100% -40%, rgba(255,255,255,.12), transparent 55%),
    linear-gradient(120deg, var(--nav), var(--nav-2) 70%, var(--brand-strong));
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.hero h2 { font-size: 1.35rem; font-weight: 750; margin: 0 0 .3rem; }
.hero p { margin: 0; opacity: .85; font-size: .9rem; }
.hero .pill {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); color: #fff;
  border-radius: 999px; padding: .5rem .95rem; font-size: .82rem; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .45rem;
}

/* ---------- Icon tiles ---------- */
.icon-tile {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.tile-blue { background: #dbeafe; color: #2563eb; }
.tile-green { background: var(--green-050); color: var(--green); }
.tile-amber { background: var(--amber-050); color: var(--amber); }
.tile-red { background: var(--red-050); color: var(--red); }
.tile-slate { background: #e2e8f0; color: #475569; }

/* ---------- Quick list ---------- */
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .1rem; border-bottom: 1px solid var(--line); font-size: .88rem;
}
.qlist li:last-child { border-bottom: 0; }

/* ---------- Períodos (filtro de mês/período) ---------- */
.periodo-btn { border-radius: var(--radius-sm); flex: 0 0 auto; white-space: nowrap; }
.periodo-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.periodos-linha { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

/* ---------- Indicador (linha de lançamento) ---------- */
.indicador-row {
  background: linear-gradient(135deg, var(--green) 0%, #047857 100%);
  border-radius: 14px; color: #fff; padding: .95rem 1.15rem; margin-bottom: .6rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease;
}
.indicador-row:hover { box-shadow: var(--shadow-md); }
.indicador-row .nome { font-size: .95rem; font-weight: 550; }
.indicador-row .unidade { font-size: .76rem; opacity: .85; }
.indicador-row input.quantidade {
  width: 96px; border-radius: var(--radius-sm); border: none;
  padding: .5rem .6rem; font-size: 1.05rem; text-align: center; font-weight: 600;
}
.indicador-row .btn-detalhe {
  background: rgba(255,255,255,.16); border: none; color: #fff;
  border-radius: var(--radius-sm); width: 40px; height: 40px;
  transition: background .15s ease;
}
.indicador-row .btn-detalhe:hover { background: rgba(255,255,255,.3); }

.categoria-header {
  background: var(--nav); color: #fff; border-radius: var(--radius) var(--radius) 0 0;
  padding: .75rem 1.15rem; font-weight: 650; font-size: .92rem;
  cursor: pointer; user-select: none;
}
.categoria-header .chevron { display: inline-block; transition: transform .15s ease; font-size: .8em; }
.categoria-header[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.categoria-header[aria-expanded="true"] { border-radius: var(--radius) var(--radius) 0 0; }
.categoria-header:not([aria-expanded="true"]) { border-radius: var(--radius); }

.sidebar-toggle {
  display: none; background: transparent; border: none; font-size: 1.3rem;
  color: var(--ink); line-height: 1; padding: .3rem .4rem; border-radius: 8px;
}
.sidebar-toggle:hover { background: var(--brand-050); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 1040;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 768px) {
  .sidebar-toggle { display: inline-block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -100%; z-index: 1050;
    transition: left .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar.collapsed { width: 100%; }
  .sidebar.collapsed .label { display: block; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; }
  .sidebar-collapse-btn { display: none; }
  .content-wrap { width: 100%; }
  .page { padding: 1.1rem; }
}
