/* ═══════════════════════════════════════════════
   COP — Global Styles
   ═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

html, body { overflow-x: hidden; max-width: 100%; }

:root {
  --primary:   #326274;
  --primary-d: #264d5c;
  --primary-l: #e8f4f8;
  --success:   #28a745;
  --warning:   #f59e0b;
  --danger:    #dc3545;
  --info:      #3b82f6;
  --bg:        #f0f4f5;
  --card:      #ffffff;
  --border:    #e5e7eb;
  --text:      #1f2937;
  --sub:       #6b7280;
  --mute:      #9ca3af;
  --radius:    8px;
  --shadow:    0 1px 4px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── LAYOUT ─────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: #fff;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(45,106,127,0.25);
  padding-top: env(safe-area-inset-top);
}
.app-header .inner {
  max-width: 1800px; margin: 0 auto;
  padding: env(safe-area-inset-top) 24px 0;
  display: flex; align-items: stretch; gap: 0;
}
.app-header .logo {
  padding: 13px 20px 13px 0;
  margin-right: 20px;
  border-right: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.app-header .logo-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.app-header .logo-text { line-height: 1.2; }
.app-header .logo-text strong { display: block; font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .03em; }
.app-header .logo-text span  { font-size: 13px; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: .1em; }

.nav-tabs {
  display: flex; align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav-tabs::-webkit-scrollbar { height: 0; display: none; }
.nav-tabs a {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 100%;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px; font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-tabs a:hover    { color: #fff; }
.nav-tabs a.active   { color: #fff; border-bottom-color: #fff; }
.nav-tabs a[draggable] { cursor: grab; }
.nav-tabs a[draggable]:hover::before { content: '⠿'; margin-right: 4px; font-size: 13px; opacity: .5; }
.nav-tabs a.nav-drop-before { border-left: 3px solid #c4a96d; margin-left: -3px; }
.nav-tabs a.nav-dragging { opacity: .35; }
.nav-tabs a .badge-n {
  background: var(--danger); color: #fff;
  border-radius: 50%; width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
.header-right .user-name { font-size: 13px; color: rgba(255,255,255,0.7); }
.header-right .btn-logout {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; padding: 5px 12px;
  color: rgba(255,255,255,0.85); font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  text-decoration: none;
}

.page-content {
  max-width: 1800px; margin: 0 auto;
  padding: 24px;
}

/* ── CARDS ──────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h3 {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-header h3::before {
  content: ''; display: inline-block;
  width: 3px; height: 18px;
  background: var(--primary); border-radius: 2px;
}
.card-body { padding: 18px; }

/* ── KPI CARDS ──────────────────────────────── */
.kpi-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.kpi-card {
  flex: 1; min-width: 120px;
  border-radius: 8px; padding: 18px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.kpi-card .kpi-val  { font-size: 34px; font-weight: 800; color: #fff; line-height: 1; }
.kpi-card .kpi-lbl  { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.9); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; line-height: 1.3; }

/* ── TABLES ─────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  padding: 9px 11px; text-align: left;
  font-size: 13px; font-weight: 700; color: var(--sub);
  text-transform: uppercase; letter-spacing: .06em;
  background: #f9fafb; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 9px 11px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.tbl tbody tr:hover { background: #f9fafb; }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ─────────────────────────────────── */
.badge {
  display: inline-block; border-radius: 20px;
  padding: 2px 10px; font-size: 13px; font-weight: 700;
  white-space: nowrap; border: 1px solid transparent;
}
.badge-ativo        { background:#d4edda; color:#155724; border-color:#28a74544; }
.badge-bloqueado    { background:#f8d7da; color:#721c24; border-color:#dc354544; }
.badge-nao-iniciado { background:#fff3cd; color:#856404; border-color:#ffc10744; }
.badge-em-andamento { background:#cce5ff; color:#004085; border-color:#4a90d944; }
.badge-concluido    { background:#d4edda; color:#155724; border-color:#28a74544; }
.badge-atrasado     { background:#f8d7da; color:#721c24; border-color:#dc354544; }
.badge-aprovado     { background:#d1f0e8; color:#0d503a; border-color:#20c99744; }
.badge-revisao      { background:#e2d9f3; color:#4a235a; border-color:#6f42c144; }
.badge-espera       { background:#e8e8e8; color:#555;    border-color:#aaa4; }
.badge-captacao     { background:#fde8cc; color:#7a3e00; border-color:#fd7e1444; }
.badge-orcamento    { background:#d6eaf8; color:#1a5276; border-color:#2e86c144; }
.badge-orc-enviado  { background:#d5f5e3; color:#1d6a3a; border-color:#27ae6044; }
.badge-alta  { background:#fde8e8; color:#c0392b; border-color:#e74c3c44; }
.badge-media { background:#fef9e7; color:#9a7d0a; border-color:#f1c40f44; }
.badge-baixa { background:#eafaf1; color:#1e8449; border-color:#2ecc7144; }
.badge-vitalicio   { background:#ede9fe; color:#4c1d95; border-color:#6f42c144; }
.badge-assinatura  { background:#fef3c7; color:#92400e; border-color:#f59e0b44; }

/* ── FORMS ──────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--sub); text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: 5px;
}
.form-control {
  width: 100%; border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 11px;
  font-size: 14px; color: var(--text);
  background: #fafafa; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); background: #fff; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row .full { grid-column: 1/-1; }

/* ── BUTTONS ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 7px; padding: 8px 18px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-outline  { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-ghost    { background: #f1f3f5; color: var(--sub); border-color: var(--border); }
.btn-danger   { background: #fde8e8; color: var(--danger); border-color: #e74c3c44; }
.btn-success  { background: #d4edda; color: #155724; border-color: #28a74544; }
.btn-warning  { background: #fff3cd; color: #856404; border-color: #ffc10744; }
.btn-sm { padding: 4px 11px; font-size: 13px; }
.btn-lg { padding: 11px 28px; font-size: 15px; }

/* ── MODAL ──────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 1000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; padding: 28px;
  width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close {
  background: #f1f3f5; border: none; border-radius: 6px;
  width: 30px; height: 30px; cursor: pointer;
  font-size: 20px; color: var(--sub); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 8px; padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── ALERTS ─────────────────────────────────── */
.alert {
  border-radius: 8px; padding: 11px 14px;
  font-size: 14px; margin-bottom: 14px;
  display: flex; gap: 8px; align-items: flex-start;
}
.alert-info    { background:#eff6ff; border:1px solid #bfdbfe; color:#1e40af; }
.alert-success { background:#f0fdf4; border:1px solid #bbf7d0; color:#166534; }
.alert-warning { background:#fef9c3; border:1px solid #fde047; color:#854d0e; }
.alert-danger  { background:#fef2f2; border:1px solid #fecaca; color:#991b1b; }

/* ── TOOLBAR ────────────────────────────────── */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center; margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; font-size: 13px; color: var(--text);
  background: #fff; font-family: inherit; outline: none;
}
.toolbar input { min-width: 200px; flex: 1; }

/* ── PROGRESS BAR ───────────────────────────── */
.progress { height: 6px; background: #e5e7eb; border-radius: 3px; width: 54px; display:inline-block; vertical-align:middle; }
.progress-bar { height: 100%; border-radius: 3px; }

/* ── GANTT ──────────────────────────────────── */
.gantt-wrap { overflow-x: auto; }
.gantt-table { border-collapse: collapse; min-width: 100%; }
.gantt-table th, .gantt-table td { border: 1px solid #f0f0f0; padding: 0; }
.gantt-label { min-width: 200px; max-width: 200px; padding: 6px 12px !important; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-month { background: var(--primary) !important; color: #fff !important; font-size: 13px; font-weight: 700; padding: 6px 8px !important; text-align: center; white-space: nowrap; }
.gantt-day   { width: 28px; min-width: 28px; max-width: 28px; text-align: center; font-size: 13px; padding: 3px 1px !important; color: var(--sub); }
.gantt-day.today  { background: var(--primary) !important; color: #fff !important; font-weight: 800; }
.gantt-day.weekend { background: #f8f9fa !important; color: var(--mute) !important; }
.gantt-cell { width: 28px; min-width: 28px; max-width: 28px; height: 32px; position: relative; }
.gantt-cell.today-col  { background: #e8f4fc !important; }
.gantt-cell.weekend-col { background: #fafafa !important; }
.gantt-bar { position: absolute; top: 50%; transform: translateY(-50%); height: 12px; border-radius: 3px; opacity: .85; }

/* ── CHAT (Dúvidas) ─────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; min-height: 520px; }
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 13px; cursor: pointer;
  transition: all .15s;
}
.ticket-item:hover, .ticket-item.active { border-color: var(--primary); background: var(--primary-l); }
.ticket-item .t-subject { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-item .t-meta { font-size: 13px; color: var(--sub); display: flex; justify-content: space-between; }
.chat-window { display: flex; flex-direction: column; }
.chat-messages { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg-bubble { max-width: 80%; }
.msg-bubble.user  { align-self: flex-start; }
.msg-bubble.admin { align-self: flex-end; }
.msg-bubble .bubble-inner {
  border-radius: 0 10px 10px 10px;
  padding: 10px 13px; font-size: 14px; line-height: 1.5;
}
.msg-bubble.user  .bubble-inner { background: #f3f4f6; color: var(--text); }
.msg-bubble.admin .bubble-inner { background: var(--primary); color: #fff; border-radius: 10px 0 10px 10px; }
.msg-meta { font-size: 13px; color: var(--mute); margin-top: 3px; }
.msg-bubble.admin .msg-meta { text-align: right; }
.chat-input-area { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input-area textarea { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; font-size: 14px; font-family: inherit; resize: none; outline: none; }

/* ── LOGIN ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-d) 0%, var(--primary) 100%);
}
.login-box {
  background: #fff; border-radius: 14px; padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box h1 { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.login-box p  { font-size: 14px; color: var(--sub); margin-bottom: 28px; }
.login-logo { text-align: center; margin-bottom: 24px; font-size: 36px; }

/* ── POPUP NOTIFICATION ─────────────────────── */
#popup-notification {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  max-width: 360px; width: 100%;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  padding: 18px 20px; display: none;
}
#popup-notification.show { display: block; animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

/* ── UTILITIES ──────────────────────────────── */
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.text-mute{color:var(--mute)}.text-sub{color:var(--sub)}.text-sm{font-size:13px}
.fw-600{font-weight:600}.fw-700{font-weight:700}
.d-flex{display:flex}.gap-1{gap:8px}.gap-2{gap:14px}.align-center{align-items:center}
.ml-auto{margin-left:auto}
.empty-state { padding: 48px 24px; text-align: center; color: var(--mute); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }
.empty-state-icon { width:56px;height:56px;margin:0 auto 14px;display:flex;align-items:center;justify-content:center;border-radius:14px;background:linear-gradient(135deg,#f1f7f9,#e8f1f4);color:#2d6a7f; }
.empty-state-icon svg { width:30px;height:30px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round; }
.empty-state-title { font-size:16px;font-weight:700;color:#1a2e35;margin:0 0 6px;line-height:1.3; }
.empty-state-desc { font-size:13.5px;color:var(--sub);line-height:1.55;max-width:380px;margin:0 auto 18px; }
.empty-state-action { display:inline-flex;align-items:center;gap:6px;padding:9px 18px;border-radius:8px;background:linear-gradient(135deg,#1e4f61,#2d6a7f);color:#fff;font-size:14px;font-weight:700;text-decoration:none;border:none;cursor:pointer;font-family:inherit;transition:transform .12s,box-shadow .12s;box-shadow:0 2px 8px rgba(45,106,127,.18); }
.empty-state-action:hover { transform:translateY(-1px);box-shadow:0 4px 14px rgba(45,106,127,.28); }
.empty-state-action.ghost { background:#fff;color:#2d6a7f;border:1px solid rgba(45,106,127,.25);box-shadow:none; }
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.overflow-x{overflow-x:auto}

/* ═══════════════════════════════════════════════
   RESPONSIVO MOBILE
   ═══════════════════════════════════════════════ */

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mob-admin, .mob-logout { display: none !important; }

@media (max-width: 768px) {

  .app-header .inner {
    flex-wrap: wrap;
    padding: 0 max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .app-header .logo {
    flex: 1;
    padding: 11px 0;
    margin-right: 0;
    border-right: none;
  }
  .header-right { display: none !important; }
  .hamburger    { display: flex !important; }

  .nav-tabs {
    display: none !important;
    flex-direction: column !important;
    width: 100%;
    background: var(--primary-d);
    border-top: 1px solid rgba(255,255,255,.12);
    padding: 6px 0 10px;
    order: 10;
    align-items: stretch;
  }
  .nav-tabs.open {
    display: flex !important;
  }
  .nav-tabs a {
    padding: 12px 20px;
    border-bottom: none !important;
    font-size: 14px;
    height: auto;
    color: rgba(255,255,255,.75);
    width: 100%;
  }
  .nav-tabs a.active { background: rgba(255,255,255,.1); color: #fff; }
  .nav-tabs a:hover  { background: rgba(255,255,255,.07); color: #fff; }

  .mob-admin, .mob-logout {
    display: flex !important;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.1);
    color: rgba(255,255,255,.6) !important;
  }
  .mob-logout { color: rgba(255,120,120,.9) !important; }
  .mob-hide   { display: none !important; }

  .page-content { padding: 14px; }

  .kpi-grid { gap: 10px; }
  .kpi-grid .kpi-card { min-width: calc(50% - 5px) !important; padding: 14px; }
  .kpi-card .kpi-value { font-size: 24px; }

  .table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  .form-row, .grid-2, .grid-3 { grid-template-columns: 1fr !important; }

  .modal-box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
  }
  .modal-overlay { align-items: flex-end !important; }

  .gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-charts { grid-template-columns: 1fr; }
  .perfil-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .kpi-grid .kpi-card         { min-width: 100% !important; }
  .app-header .logo-text span { display: none; }
  .page-content               { padding: 12px; }
}

/* ── DASHBOARD CHARTS ───────────────── */
.dash-charts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-top: 20px; }

/* ── LOADING OVERLAY ────────────────── */
#cop-loading{display:none;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:99999;align-items:center;justify-content:center;flex-direction:column;gap:14px;backdrop-filter:blur(2px)}
#cop-loading.show{display:flex}
#cop-loading .spinner{width:40px;height:40px;border:4px solid rgba(255,255,255,.25);border-top-color:#fff;border-radius:50%;animation:cop-spin .7s linear infinite}
#cop-loading .spinner-text{color:#fff;font-size:14px;font-weight:700;font-family:inherit}
@keyframes cop-spin{to{transform:rotate(360deg)}}
.btn.loading{pointer-events:none;opacity:.7}
.btn.loading::after{content:'';display:inline-block;width:14px;height:14px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:cop-spin .6s linear infinite;margin-left:6px;vertical-align:middle}

/* ── Escritório / Equipe ── */
.section-card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:24px; }
.section-card .sc-head { padding:14px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:12px; }
.section-card .sc-head h3 { font-size:14px; font-weight:700; display:flex; align-items:center; gap:8px; }
.user-table { width:100%; border-collapse:collapse; }
.user-table th { font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--sub); padding:8px 14px; text-align:left; border-bottom:2px solid var(--border); white-space:nowrap; }
.user-table td { padding:10px 14px; border-bottom:1px solid var(--border); font-size:14px; vertical-align:middle; }
.user-table tr:last-child td { border-bottom:none; }
.user-table tr:hover td { background:#f9fafb; }

/* ═══════════════════════════════════════════════
   A14 — DARK MODE
   Ativado via <html data-theme="dark">. Toggle no header.
   Persistência em localStorage('cop-theme'). Inline script no
   <head> evita FOUC.
   ═══════════════════════════════════════════════ */
:root[data-theme="dark"] {
  --primary:    #5ab4d4;
  --primary-d:  #3d8aa8;
  --primary-l:  #1c3540;
  --bg:         #0f1620;
  --card:       #1a2330;
  --border:     #2d3848;
  --text:       #e5e9ef;
  --sub:        #97a3b6;
  --mute:       #6b7889;
  --shadow:     0 1px 4px rgba(0,0,0,.45);
}

/* Body + base */
:root[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* Header (mantém teal escuro pra ancorar identidade — só ajusta sombra) */
:root[data-theme="dark"] .app-header { box-shadow: 0 2px 12px rgba(0,0,0,.5); }

/* Breadcrumb bar (sistema/escritorio header) */
:root[data-theme="dark"] body > div[style*="background:#fff"][style*="border-bottom"] {
  background: var(--card) !important;
  border-bottom-color: var(--border) !important;
}

/* Cards / sections */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .section-card,
:root[data-theme="dark"] .dash-box,
:root[data-theme="dark"] .dash-num,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .modal-box,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .box,
:root[data-theme="dark"] .stats-card,
:root[data-theme="dark"] .crm-table,
:root[data-theme="dark"] .crm-empty,
:root[data-theme="dark"] .tbl,
:root[data-theme="dark"] .tbl-wrap,
:root[data-theme="dark"] .filtros,
:root[data-theme="dark"] .form-group input,
:root[data-theme="dark"] .ext-tbl,
:root[data-theme="dark"] .info-pill,
:root[data-theme="dark"] .ticket-item,
:root[data-theme="dark"] .login-box,
:root[data-theme="dark"] .kpi,
:root[data-theme="dark"] .chart-box,
:root[data-theme="dark"] .btn-csv,
:root[data-theme="dark"] .pad-card,
:root[data-theme="dark"] .pad-textarea,
:root[data-theme="dark"] .pad-link-row input,
:root[data-theme="dark"] .pad-add-link,
:root[data-theme="dark"] .pad-save-bar,
:root[data-theme="dark"] .horas-filtros select,
:root[data-theme="dark"] .horas-filtros button { background: var(--card) !important; border-color: var(--border) !important; color: var(--text) !important; }
:root[data-theme="dark"] .card-header,
:root[data-theme="dark"] .section-card .sc-head,
:root[data-theme="dark"] .dash-box-head { border-bottom-color: var(--border); }
/* Dashboard administrativo — separadores internos (eram #f5f5f5 / #f8f8f8 = brancos) */
:root[data-theme="dark"] .atv-row,
:root[data-theme="dark"] .member-row,
:root[data-theme="dark"] .entrega-row { border-bottom-color: #232c3a !important; }
:root[data-theme="dark"] .atv-text { color: var(--text); }
:root[data-theme="dark"] .atv-text strong { color: #fff; }
:root[data-theme="dark"] .atv-time,
:root[data-theme="dark"] .member-role { color: var(--sub); }
/* CRM / Clientes / Tabelas — texto escuro hardcoded vira claro em dark */
:root[data-theme="dark"] .crm-table th,
:root[data-theme="dark"] .crm-table td { color: var(--text); border-color: var(--border) !important; }
:root[data-theme="dark"] .crm-table th { background: #131c28 !important; }
:root[data-theme="dark"] .crm-table tr:hover td,
:root[data-theme="dark"] .crm-table tr:nth-child(even) td { background: #1f2a38 !important; }
:root[data-theme="dark"] .crm-table .acoes button:hover { background: #2a3548 !important; }
/* Inputs/selects/buscas com background:#fff hardcoded */
:root[data-theme="dark"] [style*="background:#fff"]:not(img):not(button.btn-primary):not(.btn-primary):not(.badge):not([class*="avatar"]):not([style*="border-radius:50%"]) { background: var(--card) !important; }
/* Texts com cor escura hardcoded (sobre fundo dark = invisível) */
:root[data-theme="dark"] [style*="color:#1a2e35"],
:root[data-theme="dark"] [style*="color: #1a2e35"],
:root[data-theme="dark"] [style*="color:#0f172a"],
:root[data-theme="dark"] [style*="color: #0f172a"],
:root[data-theme="dark"] [style*="color:#1f2937"],
:root[data-theme="dark"] [style*="color: #1f2937"],
:root[data-theme="dark"] [style*="color:#2d3748"],
:root[data-theme="dark"] [style*="color: #2d3748"],
:root[data-theme="dark"] [style*="color:#374151"],
:root[data-theme="dark"] [style*="color: #374151"],
:root[data-theme="dark"] [style*="color:#3a5560"],
:root[data-theme="dark"] [style*="color: #3a5560"],
:root[data-theme="dark"] [style*="color:#0a5"],
:root[data-theme="dark"] [style*="color:#155e75"],
:root[data-theme="dark"] [style*="color: #155e75"],
:root[data-theme="dark"] [style*="color:#0c4a6e"] { color: var(--text) !important; }
/* Cinza-médio (fica apagado em dark) → cor mais clara */
:root[data-theme="dark"] [style*="color:#5a7380"],
:root[data-theme="dark"] [style*="color: #5a7380"],
:root[data-theme="dark"] [style*="color:#6b7280"],
:root[data-theme="dark"] [style*="color: #6b7280"],
:root[data-theme="dark"] [style*="color:#7a8d96"],
:root[data-theme="dark"] [style*="color: #7a8d96"],
:root[data-theme="dark"] [style*="color:#666"],
:root[data-theme="dark"] [style*="color: #666"],
:root[data-theme="dark"] [style*="color:#777"],
:root[data-theme="dark"] [style*="color: #777"],
:root[data-theme="dark"] [style*="color:#888"],
:root[data-theme="dark"] [style*="color: #888"],
:root[data-theme="dark"] [style*="color:#96adb5"],
:root[data-theme="dark"] [style*="color: #96adb5"],
:root[data-theme="dark"] [style*="color:#9ca3af"],
:root[data-theme="dark"] [style*="color: #9ca3af"],
:root[data-theme="dark"] [style*="color:#999"],
:root[data-theme="dark"] [style*="color: #999"] { color: var(--sub) !important; }
/* Headings claros sobre fundo escuro (ficam invisíveis quando heading tinha cor própria escura) */
:root[data-theme="dark"] h1, :root[data-theme="dark"] h2, :root[data-theme="dark"] h3, :root[data-theme="dark"] h4 { color: var(--text); }
/* Backgrounds light comum em painéis (cor próxima de #fff, #f5..., #f7...) */
:root[data-theme="dark"] [style*="background:#f1f7f9"],
:root[data-theme="dark"] [style*="background: #f1f7f9"],
:root[data-theme="dark"] [style*="background:#f5f8fa"],
:root[data-theme="dark"] [style*="background: #f5f8fa"],
:root[data-theme="dark"] [style*="background:#f8f9fa"],
:root[data-theme="dark"] [style*="background: #f8f9fa"],
:root[data-theme="dark"] [style*="background:#f7fafb"],
:root[data-theme="dark"] [style*="background: #f7fafb"],
:root[data-theme="dark"] [style*="background:#fafafa"],
:root[data-theme="dark"] [style*="background:#fafcfc"] { background: #1f2a38 !important; }

/* Tables */
:root[data-theme="dark"] .tbl th { background: #131c28; border-bottom-color: var(--border); }
:root[data-theme="dark"] .tbl td { border-bottom-color: #232c3a; }
:root[data-theme="dark"] .tbl tbody tr:hover { background: #1f2a38; }
:root[data-theme="dark"] .user-table th,
:root[data-theme="dark"] .user-table td { border-color: var(--border); }
:root[data-theme="dark"] .user-table tr:hover td { background: #1f2a38; }

/* Forms */
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="tel"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select {
  background: #0e1620;
  color: var(--text);
  border-color: var(--border);
}
:root[data-theme="dark"] .form-control:focus,
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] textarea:focus,
:root[data-theme="dark"] select:focus { background: #131e2c; border-color: var(--primary); }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: var(--mute); }
:root[data-theme="dark"] .toolbar input,
:root[data-theme="dark"] .toolbar select { background: #0e1620; color: var(--text); border-color: var(--border); }

/* Buttons */
:root[data-theme="dark"] .btn-outline { background: var(--card); color: var(--primary); border-color: var(--primary); }
:root[data-theme="dark"] .btn-ghost { background: #232c3a; color: var(--sub); border-color: var(--border); }
:root[data-theme="dark"] .btn-danger { background: #3a1d20; color: #ff8a8a; border-color: #5a2a30; }
:root[data-theme="dark"] .btn-success { background: #1e3a26; color: #8ad9a3; border-color: #2a5a36; }
:root[data-theme="dark"] .btn-warning { background: #3a2e10; color: #ffd97a; border-color: #5a4a18; }

/* Modals */
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.7); }
:root[data-theme="dark"] .modal-box { background: var(--card); color: var(--text); }
:root[data-theme="dark"] .modal-header { border-bottom-color: var(--border); }
:root[data-theme="dark"] .modal-footer { border-top-color: var(--border); }
:root[data-theme="dark"] .modal-close { background: #232c3a; color: var(--sub); }

/* Modais que usam estilo inline com background:#fff */
:root[data-theme="dark"] [class*="modal"][style*="background:#fff"],
:root[data-theme="dark"] [class*="modal"] [style*="background:#fff"] { background: var(--card) !important; color: var(--text); }

/* Alerts */
:root[data-theme="dark"] .alert-info    { background:#142235; border-color:#1f3a5a; color:#88b5e8; }
:root[data-theme="dark"] .alert-success { background:#152a1d; border-color:#244a32; color:#8ad9a3; }
:root[data-theme="dark"] .alert-warning { background:#332a10; border-color:#5a4a18; color:#ffd97a; }
:root[data-theme="dark"] .alert-danger  { background:#2e1518; border-color:#5a2a30; color:#ff9090; }

/* Badges (escurece um pouco mas mantém legibilidade) */
:root[data-theme="dark"] .badge-ativo,
:root[data-theme="dark"] .badge-concluido,
:root[data-theme="dark"] .badge-aprovado    { background:#1e3a26; color:#8ad9a3; border-color:#2a5a36; }
:root[data-theme="dark"] .badge-bloqueado,
:root[data-theme="dark"] .badge-atrasado,
:root[data-theme="dark"] .badge-alta        { background:#3a1d20; color:#ff8a8a; border-color:#5a2a30; }
:root[data-theme="dark"] .badge-nao-iniciado,
:root[data-theme="dark"] .badge-media,
:root[data-theme="dark"] .badge-assinatura  { background:#332a10; color:#ffd97a; border-color:#5a4a18; }
:root[data-theme="dark"] .badge-em-andamento,
:root[data-theme="dark"] .badge-orcamento   { background:#142235; color:#88b5e8; border-color:#1f3a5a; }
:root[data-theme="dark"] .badge-revisao,
:root[data-theme="dark"] .badge-vitalicio   { background:#251a36; color:#b9a3e0; border-color:#3a2a52; }
:root[data-theme="dark"] .badge-espera      { background:#232c3a; color:#97a3b6; border-color:#3a4456; }
:root[data-theme="dark"] .badge-captacao    { background:#3a2410; color:#ffb074; border-color:#5a3818; }
:root[data-theme="dark"] .badge-orc-enviado,
:root[data-theme="dark"] .badge-baixa       { background:#1e3a26; color:#8ad9a3; border-color:#2a5a36; }

/* Skeleton (shimmer fica claro demais no dark — escurece) */
:root[data-theme="dark"] .skeleton,
:root[data-theme="dark"] [class*="skel"] { background: #1f2a38 !important; }

/* Popup notification (header.php) */
:root[data-theme="dark"] #popup-notification {
  background: var(--card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
}

/* Inline divs com background:#fff espalhados (defensivo — só pinta texto preto) */
:root[data-theme="dark"] [style*="background:#fff"]:not([class*="modal"]):not([style*="border-radius:50%"]) {
  background: var(--card) !important;
}
:root[data-theme="dark"] [style*="background:#f9fafb"],
:root[data-theme="dark"] [style*="background:#f7fafb"],
:root[data-theme="dark"] [style*="background:#f0f4f5"],
:root[data-theme="dark"] [style*="background:#f1f3f5"] { background: #131c28 !important; }
:root[data-theme="dark"] [style*="background:#fafafa"],
:root[data-theme="dark"] [style*="background:#fdfdfd"] { background: #1a2330 !important; }

/* A5 — Badge "🧪 Beta" no header pra escritórios em programa beta */
.beta-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #7c3aed, #3b82f6);
  color: #fff; font-size: 13px; font-weight: 800;
  padding: 3px 9px; border-radius: 99px;
  letter-spacing: .03em; text-decoration: none;
  cursor: help; line-height: 1.2;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 1px 4px rgba(124,58,237,.35);
  white-space: nowrap;
}
.beta-badge:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(124,58,237,.5); }
:root[data-theme="dark"] .beta-badge { box-shadow: 0 1px 6px rgba(124,58,237,.6); }

/* Toggle button no header */
.theme-toggle {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; padding: 5px 10px;
  color: rgba(255,255,255,0.85); font-size: 14px;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 28px; line-height: 1;
}
.theme-toggle:hover { background: rgba(255,255,255,0.2); }
:root[data-theme="dark"] .theme-toggle { background: rgba(255,255,255,0.08); }

/* Suaviza transição entre temas */
html, body, .card, .section-card, .tbl, .user-table, .modal-box, .form-control, input, textarea, select, .alert, .badge {
  transition: background-color .18s, color .18s, border-color .18s;
}

/* ─── A14 dark — defensivos pra elementos que escaparam ─────────────────────── */
/* Cards/divs com background branco hardcoded inline */
:root[data-theme="dark"] [style*="background:#fff"],
:root[data-theme="dark"] [style*="background: #fff"],
:root[data-theme="dark"] [style*="background:white"],
:root[data-theme="dark"] [style*="background-color:#fff"] {
  background: var(--card) !important;
  color: var(--text);
}
/* Texto inline preto/escuro hardcoded (override pra texto claro) */
:root[data-theme="dark"] [style*="color:#000"],
:root[data-theme="dark"] [style*="color: #000"],
:root[data-theme="dark"] [style*="color:#1a"],
:root[data-theme="dark"] [style*="color: #1a"],
:root[data-theme="dark"] [style*="color:#1f"],
:root[data-theme="dark"] [style*="color:#2"],
:root[data-theme="dark"] [style*="color:#3"] { color: var(--text) !important; }
/* tons cinza-escuro de subtítulo viram cinza-claro */
:root[data-theme="dark"] [style*="color:#5a"],
:root[data-theme="dark"] [style*="color:#6"],
:root[data-theme="dark"] [style*="color:#4"] { color: var(--sub) !important; }
/* labels/specific elements */
:root[data-theme="dark"] label,
:root[data-theme="dark"] .form-group label,
:root[data-theme="dark"] .field-label { color: var(--sub) !important; }
/* table rows striping no dark */
:root[data-theme="dark"] table tr td,
:root[data-theme="dark"] table tr th { color: var(--text); }
:root[data-theme="dark"] .tipo-chip,
:root[data-theme="dark"] .tipo-chip * { color: var(--text) !important; }
/* fundos cinza claros típicos */
:root[data-theme="dark"] [style*="background:#f"],
:root[data-theme="dark"] [style*="background: #f"],
:root[data-theme="dark"] [style*="background:#e"],
:root[data-theme="dark"] [style*="background: #e"] {
  background: #1f2a38 !important;
}
/* exceções: cores de status (verde, vermelho, amarelo, azul) NÃO devem virar dark */
:root[data-theme="dark"] [style*="background:#d4edda"],
:root[data-theme="dark"] [style*="background:#d1fae5"] { background: #1e3a26 !important; color: #8ad9a3 !important; }
:root[data-theme="dark"] [style*="background:#f8d7da"],
:root[data-theme="dark"] [style*="background:#fee2e2"] { background: #3a1d20 !important; color: #ff8a8a !important; }
:root[data-theme="dark"] [style*="background:#fff3cd"],
:root[data-theme="dark"] [style*="background:#fef3c7"] { background: #332a10 !important; color: #ffd97a !important; }
:root[data-theme="dark"] [style*="background:#e8f4f"],
:root[data-theme="dark"] [style*="background:#cce5ff"] { background: #142235 !important; color: #88b5e8 !important; }
/* badge dentro de td */
:root[data-theme="dark"] td .badge { color: inherit; }
/* divs que são headers de seção */
:root[data-theme="dark"] .sc-head,
:root[data-theme="dark"] .ch,
:root[data-theme="dark"] .modal-header { background: var(--card); border-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .sc-head h3,
:root[data-theme="dark"] .ch .ct,
:root[data-theme="dark"] .modal-header h3,
:root[data-theme="dark"] .card h3,
:root[data-theme="dark"] .section-card h3 { color: var(--text); }
/* tipos-projeto.php elements */
:root[data-theme="dark"] .etapa-row,
:root[data-theme="dark"] .macro-head,
:root[data-theme="dark"] .tipo-head,
:root[data-theme="dark"] .tipo-desc { background: var(--card); color: var(--text); }
:root[data-theme="dark"] .etapa-row:hover { background: #1f2a38; }
:root[data-theme="dark"] .etapa-nome { color: var(--text); }
:root[data-theme="dark"] .etapa-desc-mini,
:root[data-theme="dark"] .etapa-meta { color: var(--sub); }
:root[data-theme="dark"] .macro-head { color: #5ab4d4; }
/* dossiê do cliente */
:root[data-theme="dark"] .dossie-head,
:root[data-theme="dark"] .dossie-card { background: var(--card); border-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .dossie-card .hd { border-bottom-color: var(--border); }
:root[data-theme="dark"] .dossie-list th { background: #131c28; color: var(--sub); }
:root[data-theme="dark"] .dossie-list td { border-bottom-color: var(--border); color: var(--text); }
:root[data-theme="dark"] .dossie-kpi .k { background: var(--card); border-color: var(--border); color: var(--text); }
/* CRM / outros cards */
:root[data-theme="dark"] .stat-box,
:root[data-theme="dark"] .stat-card { background: var(--card) !important; border-color: var(--border); color: var(--text); }
/* Hub cards já cobertos no hub.php */
