/* ==========================================================================
   Painel Contábil — Design Tokens & Componentes
   Direção visual: minimalista, neutro, muito espaço em branco, hierarquia
   clara. Um único acento de cor (azul-petróleo), status discretos, sem
   gradientes e sem gráficos. Tipografia: Inter (legibilidade > personalidade,
   escolha deliberada para uma ferramenta de uso diário por contadores).
   ========================================================================== */

:root {
  /* Superfícies */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-muted: #FAFBFC;
  --border: #E6E8EC;
  --border-strong: #D8DBE0;

  /* Texto */
  --text-primary: #16181D;
  --text-secondary: #62676F;
  --text-tertiary: #9599A1;
  --text-inverse: #FFFFFF;

  /* Acento (único, usado com moderação) */
  --accent: #1E3A5F;
  --accent-hover: #16304F;
  --accent-soft: #EAF0F7;
  --accent-soft-text: #1E3A5F;

  /* Status — tons abafados, nunca berrantes */
  --status-pending-bg: #FBF2E4;
  --status-pending-text: #92661C;
  --status-progress-bg: #EAF0F7;
  --status-progress-text: #1E3A5F;
  --status-done-bg: #E9F4EC;
  --status-done-text: #276B3E;
  --status-cancelled-bg: #F1F1F3;
  --status-cancelled-text: #6B6F76;
  --status-late-bg: #FBEDEC;
  --status-late-text: #A13F38;

  /* Aguardando cliente — roxo abafado, distinto dos demais status */
  --status-waiting-bg: #F1EBFA;
  --status-waiting-text: #6B3FA0;

  /* Prioridade */
  --priority-high: #A13F38;
  --priority-medium: #92661C;
  --priority-low: #62676F;

  /* Sombra sutil (uso raro) */
  --shadow-sm: 0 1px 2px rgba(16, 20, 27, 0.04);
  --shadow-md: 0 4px 16px rgba(16, 20, 27, 0.07);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

/* Números tabulares em tabelas e prazos */
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: width .18s ease, transform .18s ease;
}

.app-shell.is-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
}

.main-col {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .18s ease;
}

.app-shell.is-collapsed .main-col {
  margin-left: var(--sidebar-w-collapsed);
}

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

.content {
  padding: 28px 32px 56px;
  max-width: 1280px;
  width: 100%;
}

/* ---------------------------------------------------------------------- */
/* Sidebar                                                                 */
/* ---------------------------------------------------------------------- */

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.app-shell.is-collapsed .sidebar-brand-name,
.app-shell.is-collapsed .sidebar-group-label,
.app-shell.is-collapsed .nav-label,
.app-shell.is-collapsed .user-meta {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-group + .sidebar-group {
  margin-top: 18px;
}

.sidebar-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-soft-text);
}

.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.user-card:hover { background: var(--surface-muted); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
  flex-shrink: 0;
}

.user-meta { line-height: 1.25; overflow: hidden; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--text-tertiary); }

/* ---------------------------------------------------------------------- */
/* Componentes                                                             */
/* ---------------------------------------------------------------------- */

.icon-btn {
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--text-primary); }

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text-tertiary);
  font-size: 13.5px;
  max-width: 360px;
  flex: 1;
}
.search-field input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-primary);
  width: 100%;
}
.search-field input::placeholder { color: var(--text-tertiary); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  background: var(--surface);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-sub { font-size: 13px; color: var(--text-secondary); }

/* Tabelas */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover td { background: var(--surface-muted); }
.data-table tbody tr.is-late td { background: var(--status-late-bg); }
.data-table tbody tr.is-late:hover td { background: #F6E1DF; }

/* Badges de status */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge-progress { background: var(--status-progress-bg); color: var(--status-progress-text); }
.badge-done { background: var(--status-done-bg); color: var(--status-done-text); }
.badge-cancelled { background: var(--status-cancelled-bg); color: var(--status-cancelled-text); }
.badge-late { background: var(--status-late-bg); color: var(--status-late-text); }
.badge-waiting { background: var(--status-waiting-bg); color: var(--status-waiting-text); }

.priority-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; margin-right: 7px; }
.priority-high { background: var(--priority-high); }
.priority-medium { background: var(--priority-medium); }
.priority-low { background: var(--priority-low); }

/* Barra de progresso (elemento assinatura, reaproveitado em Dashboard e Fechamentos) */
.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.progress-row { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-row .progress-track { flex: 1; }
.progress-row .progress-pct { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); width: 34px; text-align: right; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.filter-select {
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
}

/* Painel lateral (detalhe da tarefa) */
.side-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 18, 24, 0.28);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.side-panel-overlay.is-open { opacity: 1; pointer-events: auto; }

.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 51;
  transform: translateX(100%);
  transition: transform .2s ease;
  display: flex;
  flex-direction: column;
}
.side-panel.is-open { transform: translateX(0); }

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

/* Stepper de cadastro de empresa */
.step-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-tertiary);
  padding: 7px 12px 7px 8px; border-radius: 999px;
}
.step-pill .step-num {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--border); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
}
.step-pill.is-active { color: var(--accent-soft-text); background: var(--accent-soft); }
.step-pill.is-active .step-num { background: var(--accent); color: #fff; }
.step-pill.is-done .step-num { background: var(--status-done-text); color: #fff; }

.mobile-nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 18, 24, 0.28);
  z-index: 39;
}
.app-shell.is-mobile-open .mobile-nav-overlay { display: block; }

/* Mobile */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 264px;
  }
  .app-shell.is-mobile-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .main-col, .app-shell.is-collapsed .main-col {
    margin-left: 0;
  }
  .content { padding: 18px 16px 40px; }
  .table-scroll { overflow-x: auto; }
  .data-table { min-width: 720px; }
}

.table-scroll { overflow-x: auto; }

/* Modal centralizado (Nova Empresa, Nova Regra, catálogos). O display é
   controlado só via JS (element.style.display), nunca por classe —
   isso evita qualquer disputa de especificidade com o Tailwind. */
.modal-center {
  position: fixed;
  inset: 0;
  z-index: 52;
  align-items: center;
  justify-content: center;
  padding: 20px;
  display: none;
}
