:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --emerald-border: #6ee7b7;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar-grad: linear-gradient(180deg, #0b1220, #111c33 60%, #0e7490);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-2);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-grad);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0ea5e9, #0e7490);
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(14, 116, 144, 0.5);
}

.brand-text strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: #fff;
}

.brand-text span {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.65);
}

.nav { display: grid; gap: 4px; margin-top: 6px; }

.nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(226, 232, 240, 0.8);
  padding: 11px 12px;
  border-radius: 9px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav button .nav-ico { font-size: 17px; width: 20px; text-align: center; }

.nav button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav button.active { background: rgba(255, 255, 255, 0.14); color: #fff; }

.sidebar-foot {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(226, 232, 240, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  line-height: 1.5;
}

/* ---------- Tela de login ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(14,116,144,0.25), transparent 60%), var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.35);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-title { font-size: 22px; font-weight: 800; letter-spacing: 0.3px; }
.auth-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px; margin-bottom: 20px; }
.auth-tabs button { border: 0; background: transparent; padding: 9px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.auth-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.auth-form { display: grid; gap: 14px; }
.auth-btn { justify-content: center; width: 100%; padding: 12px; font-size: 15px; }
.auth-msg { min-height: 18px; font-size: 13px; color: var(--red); font-weight: 600; }
.auth-foot { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Caixa de usuário (sidebar) ---------- */
.user-box { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, #0ea5e9, #0e7490); color: #fff; flex-shrink: 0; }
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11px; color: rgba(226,232,240,0.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.btn-logout { width: 100%; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); color: #e2e8f0; border-radius: 8px; padding: 8px; font-size: 13px; font-weight: 600; }
.btn-logout:hover { background: rgba(255,255,255,0.12); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar .tt { font-size: 14px; font-weight: 600; }
.topbar .badge-count { margin-left: auto; }

.content { padding: 22px; display: grid; gap: 20px; }

/* troca de página suave */
.view-anim { animation: viewfade 0.18s ease; }
@keyframes viewfade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.kpi { transition: transform 0.15s, box-shadow 0.15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12); }
.card { transition: box-shadow 0.15s; }
.nav button { position: relative; }
.nav button.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: #38bdf8;
}

.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.row-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ---------- Hero executivo ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(120deg, #064e3b 0%, #047857 45%, #0e7490 100%);
  box-shadow: 0 18px 40px rgba(6, 78, 59, 0.32);
  overflow: hidden;
}
.hero-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: rgba(255, 255, 255, 0.82); }
.hero-value { font-size: 38px; font-weight: 800; line-height: 1.1; margin-top: 6px; letter-spacing: -0.5px; }
.hero-sub { margin-top: 8px; font-size: 13px; color: rgba(255, 255, 255, 0.88); }
.hero-ico { font-size: 60px; opacity: 0.9; line-height: 1; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.kpi.hl { border-color: var(--emerald-border); background: var(--emerald-soft); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.kpi-ico { font-size: 18px; color: var(--muted); }
.kpi.hl .kpi-ico { color: var(--emerald); }
.kpi-value { margin-top: 10px; font-size: 26px; font-weight: 700; }
.kpi.hl .kpi-value { color: var(--emerald); }

/* ---------- Grid helpers ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- Chart ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 240px;
  padding: 10px 4px 0;
  overflow-x: auto;
}
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 46px; flex: 1; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 70%;
  max-width: 46px;
  background: linear-gradient(180deg, #10b981, #059669);
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height 0.3s;
  position: relative;
}
.chart-bar:hover::after {
  content: attr(data-val);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  margin-bottom: 4px;
}
.chart-x { font-size: 10px; color: var(--muted); }

/* ---------- Donut (distribuição por status) ---------- */
.donut-wrap { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.donut-legend { display: grid; gap: 12px; flex: 1; min-width: 220px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.legend-name { font-size: 14px; font-weight: 500; }
.legend-meta { margin-left: auto; font-weight: 700; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: #1e293b; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #0ea5e955; border-color: #0ea5e9; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: border 0.15s, background 0.15s;
  background: var(--surface);
}
.dropzone:hover, .dropzone.over { border-color: #0ea5e9; background: #f0f9ff; }
.dropzone .dz-ico { font-size: 38px; }
.dropzone .dz-main { margin-top: 12px; font-weight: 600; font-size: 15px; }
.dropzone .dz-sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.dz-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 14px; }
.progress > span { display: block; height: 100%; background: var(--emerald); transition: width 0.2s; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.tright { text-align: right; }
.emerald { color: var(--emerald); font-weight: 600; }
.muted { color: var(--muted); }
.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
}
.badge.green { background: #dcfce7; color: #15803d; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.amber { background: #fef3c7; color: #b45309; }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; color: var(--ink);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.chip:hover { background: #e2e8f0; }

/* ---------- Switch ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background 0.2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + .track { background: var(--emerald); }
.switch input:checked + .track + .thumb { transform: translateX(18px); }

/* ---------- Report ---------- */
.report-doc { max-width: 920px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 0 38px 38px; box-shadow: var(--shadow); overflow: hidden; }
.report-doc::before { content: ""; display: block; height: 6px; margin: 0 -38px 26px; background: linear-gradient(90deg, #047857, #0e7490); }
.report-doc h2 {
  font-size: 16px; margin: 28px 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--line); position: relative;
}
.report-doc h2::after { content: ""; position: absolute; left: 0; bottom: -2px; width: 46px; height: 2px; background: var(--emerald); }

.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 18px; flex-wrap: wrap; }
.doc-brand { display: flex; gap: 14px; align-items: flex-start; }
.doc-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, #0ea5e9, #0e7490); flex-shrink: 0; box-shadow: 0 6px 16px rgba(14, 116, 144, 0.35); }
.doc-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--emerald); }
.doc-head h1 { font-size: 22px; margin: 3px 0 0; letter-spacing: -0.3px; }
.doc-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; max-width: 460px; line-height: 1.5; }
.doc-meta { text-align: right; font-size: 12px; color: var(--ink); display: grid; gap: 4px; }
.doc-meta div { color: var(--muted); }

.report-highlight {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  margin-top: 24px; padding: 22px 24px; border-radius: 14px; color: #fff;
  background: linear-gradient(120deg, #064e3b, #047857 55%, #0e7490);
  box-shadow: 0 14px 32px rgba(6, 78, 59, 0.28);
}
.rh-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255, 255, 255, 0.82); }
.rh-value { font-size: 34px; font-weight: 800; line-height: 1.1; margin-top: 4px; letter-spacing: -0.5px; }
.rh-split { display: flex; gap: 10px; flex-wrap: wrap; }
.rh-chip { background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 9px 14px; display: grid; gap: 2px; min-width: 92px; }
.rh-chip span { font-size: 11px; color: rgba(255, 255, 255, 0.78); text-transform: uppercase; letter-spacing: 0.4px; }
.rh-chip strong { font-size: 15px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { border: 1px solid var(--line); border-radius: 10px; padding: 13px; }
.metric.hl { border-color: var(--emerald-border); background: var(--emerald-soft); }
.metric .m-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); }
.metric .m-value { margin-top: 5px; font-size: 18px; font-weight: 700; }
.metric.hl .m-value { color: var(--emerald); }
.notice { border-left: 4px solid var(--amber); background: #fffbeb; color: #92400e; padding: 12px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5; }
.report-doc ol { padding-left: 20px; line-height: 1.7; font-size: 14px; }
.report-doc footer { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; color: var(--muted); }
.sub-block { border: 1px solid var(--line); border-radius: 10px; margin-top: 14px; overflow: hidden; }
.sub-block .sb-head { background: var(--surface-2); padding: 8px 12px; font-weight: 600; font-size: 13px; }

.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 28px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .kpis, .grid2, .grid3, .filters, .metrics { grid-template-columns: 1fr; }
}

/* ---------- Print ---------- */
@page { size: A4; margin: 14mm; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .report-doc { box-shadow: none; border: 0; max-width: none; padding: 0; border-radius: 0; }
  .report-doc::before { display: none; }
  /* destaque legível mesmo sem impressão de fundos */
  .report-highlight { background: #fff !important; color: #064e3b !important; border: 2px solid #047857; box-shadow: none; }
  .rh-label, .rh-chip span { color: #475569 !important; }
  .rh-value, .rh-chip strong { color: #064e3b !important; }
  .rh-chip { background: #f0fdf4 !important; border-color: #a7f3d0; }
  .report-doc, table, .metric, .sub-block { break-inside: avoid; }
  table { break-inside: auto; }
}
