/* ── Variáveis e reset ───────────────────────────────────────────────────── */
:root {
  --navy:       #1A2B3C;
  --navy-mid:   #243447;
  --navy-light: #2F4260;
  --gold:       #B8920C;
  --gold-light: #D4A820;
  --white:      #FFFFFF;
  --off-white:  #F5F6F8;
  --gray-100:   #EAECF0;
  --gray-200:   #D0D5DD;
  --gray-400:   #98A2B3;
  --gray-600:   #475467;
  --gray-800:   #1D2939;
  --green:      #027A48;
  --green-bg:   #ECFDF3;
  --red:        #B42318;
  --red-bg:     #FEF3F2;
  --amber:      #B54708;
  --amber-bg:   #FFFAEB;
  --blue:       #1849A9;
  --blue-bg:    #EFF8FF;

  --sidebar-w:  240px;
  --header-h:   60px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 8px rgba(0,0,0,.12);

  --bg:         var(--off-white);
  --surface:    var(--white);
  --text:       var(--gray-800);
  --text-muted: var(--gray-600);
  --border:     var(--gray-100);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #111827;
    --surface:  #1F2937;
    --text:     #F9FAFB;
    --text-muted: #9CA3AF;
    --border:   #374151;
    --gray-100: #374151;
    --gray-200: #4B5563;
    --off-white: #111827;
  }
}

:root[data-theme="dark"] {
  --bg:       #111827;
  --surface:  #1F2937;
  --text:     #F9FAFB;
  --text-muted: #9CA3AF;
  --border:   #374151;
  --gray-100: #374151;
  --gray-200: #4B5563;
  --off-white: #111827;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
img { max-width: 100%; }

/* ── Layout principal ────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--gold);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-logo-icon svg { color: var(--white); }

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  letter-spacing: .04em;
}

.sidebar-unidade {
  margin: 12px 16px;
}

.sidebar-unidade select {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--white);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12px;
  appearance: none;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-group-label {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.7);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-radius: 0;
  width: 100%;
  text-align: left;
}

.nav-item:hover, .nav-item.ativo {
  background: rgba(255,255,255,.08);
  color: var(--white);
}

.nav-item.ativo {
  border-left: 3px solid var(--gold);
}

.nav-item svg { flex-shrink: 0; opacity: .8; }

.sidebar-usuario {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}

.usuario-info { flex: 1; overflow: hidden; }
.usuario-nome { font-size: 12px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-perfil { font-size: 10px; color: rgba(255,255,255,.5); }

.btn-logout {
  color: rgba(255,255,255,.5);
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.btn-logout:hover { color: var(--white); }

/* ── Conteúdo principal ──────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-titulo { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-acoes  { display: flex; gap: 8px; }

.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards / tiles ───────────────────────────────────────────────────────── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.tile-valor {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tile-valor.urgente { color: var(--red); }
.tile-valor.ativo   { color: var(--blue); }
.tile-valor.ok      { color: var(--green); }
.tile-valor.alerta  { color: var(--amber); }

/* ── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s, background .15s;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-light); }

.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover:not(:disabled) { background: var(--gold-light); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
}
.btn-danger:hover:not(:disabled) { opacity: .8; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: var(--radius); }

/* ── Tabelas ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:hover { background: var(--gray-100); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card-header-title { font-size: 14px; font-weight: 600; flex: 1; }
.card-body { padding: 20px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-a_fazer      { background: var(--gray-100); color: var(--gray-600); }
.badge-em_andamento { background: var(--blue-bg);  color: var(--blue);  }
.badge-em_revisao   { background: var(--amber-bg); color: var(--amber); }
.badge-concluido    { background: var(--green-bg); color: var(--green); }
.badge-cancelado    { background: var(--gray-100); color: var(--gray-400); }

.badge-prio-urgente { background: var(--red-bg);   color: var(--red);   }
.badge-prio-alta    { background: var(--amber-bg); color: var(--amber); }
.badge-prio-normal  { background: var(--blue-bg);  color: var(--blue);  }
.badge-prio-baixa   { background: var(--gray-100); color: var(--gray-400); }

/* ── Formulários ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,43,60,.08);
}
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.modal-aberto { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.modal-title { font-size: 16px; font-weight: 700; flex: 1; }
.modal-close {
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  background: var(--gray-800);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  max-width: 360px;
}

.toast-visivel { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-warning { background: var(--amber); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 48px; height: 48px;
  background: var(--navy);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.login-titulo { font-size: 20px; font-weight: 700; }
.login-sub    { font-size: 12px; color: var(--text-muted); }

.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-100);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filtros / barra de busca ────────────────────────────────────────────── */
.filtros-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.input-busca {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

/* ── Canvas chart ────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; }
canvas { max-width: 100%; }

/* ── Checklist ───────────────────────────────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.checklist-item.concluido span { text-decoration: line-through; color: var(--text-muted); }

/* ── Barra de progresso ──────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width .3s; }

/* ── Utilidades ──────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-sm    { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-bold  { font-weight: 700; }
.w-full     { width: 100%; }

/* ── Estado vazio ────────────────────────────────────────────────────────── */
.estado-vazio {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.estado-vazio svg { opacity: .3; margin-bottom: 12px; }
.estado-vazio p { font-size: 13px; }

/* ── Tag de prazo ────────────────────────────────────────────────────────── */
.prazo-ok      { color: var(--text-muted); font-size: 12px; }
.prazo-hoje    { color: var(--amber); font-size: 12px; font-weight: 600; }
.prazo-atrasado{ color: var(--red);   font-size: 12px; font-weight: 600; }
