/* ============================================================================
   SindIA — sindia-theme.css
   Design System canônico do Eixo 3. Fonte única de verdade da UI/UX.
   ----------------------------------------------------------------------------
   ⚠️ O BLOCO DE VARIÁVEIS (seção 1) É EXTRAÍDO LITERALMENTE DO super_plans.php
   REAL — não reescrito de memória. super_plans.php é a página-referência do
   Eixo 3; este arquivo replica o sistema dele para as demais páginas.
   ----------------------------------------------------------------------------
   REGRA DE TEMA (decisão fechada, Roberto 23-05):
     - light = default + referência canônica (espelha super_plans.php)
     - dark  = variante derivada, ancorada no verde WhatsApp
   Alternância: atributo data-theme no <html>, persistido em
   localStorage['sindia_theme']. Estado inicial sempre data-theme="light".
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. VARIÁVEIS — idênticas ao super_plans.php real (verificação cruzada feita)
   ---------------------------------------------------------------------------- */
:root, [data-theme="light"] {
  --brand:        #D97706;
  --brand-dark:   #B45309;
  --brand-soft:   #FEF3E2;
  --brand-ring:   rgba(217, 119, 6, 0.25);
  --bg:           #f7fafc;
  --bg-grad-1:    radial-gradient(circle at top left, rgba(217,119,6,0.06) 0, transparent 45%);
  --bg-grad-2:    radial-gradient(circle at bottom right, rgba(180,83,9,0.05) 0, transparent 50%);
  --surface:      #ffffff;
  --surface-alt:  #f1f5f9;
  --border:       #e2e8f0;
  --border-strong:#cbd5e1;
  --txt:          #0f172a;
  --txt-muted:    #475569;
  --txt-soft:     #94a3b8;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.04);
  --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:    0 10px 25px rgba(0,0,0,0.06), 0 4px 10px rgba(0,0,0,0.03);
  --radius:       12px;
  --radius-sm:    8px;
  --sidebar-w:    260px;
  /* extensoes do Eixo 3 (nao conflitam com super_plans) */
  --touch-min:    44px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* accents tematicos de area */
  --accent-admin:   #8B5CF6;
  --accent-finance: #3B82F6;
  /* accents funcionais */
  --accent-warn:    #F59E0B;
  --accent-prem:    #B45309;
}
[data-theme="dark"] {
  --brand:        #FBBF24;
  --brand-dark:   #F59E0B;
  --brand-soft:   rgba(217,119,6,0.14);
  --brand-ring:   rgba(251,191,36,0.4);
  --bg:           #060A12;
  --bg-grad-1:    radial-gradient(circle at top left, rgba(217,119,6,0.08) 0, transparent 45%);
  --bg-grad-2:    radial-gradient(circle at bottom right, rgba(10,16,32,0.6) 0, transparent 50%);
  --surface:      #0F1626;
  --surface-alt:  rgba(255,255,255,0.05);
  --border:       rgba(255,255,255,0.10);
  --border-strong:rgba(255,255,255,0.20);
  --txt:          #EFF2F7;
  --txt-muted:    #B0C4D8;
  --txt-soft:     #64748B;
  --success:      #10B981;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.30);
  --shadow:       0 1px 3px rgba(0,0,0,0.40);
  --shadow-lg:    0 10px 25px rgba(0,0,0,0.50);
  /* accents tematicos, tons mais claros para o tema escuro */
  --accent-admin:   #A78BFA;
  --accent-finance: #60A5FA;
  /* accents funcionais */
  --accent-warn:    #F59E0B;
  --accent-prem:    #FBBF24;
}

/* ----------------------------------------------------------------------------
   2. RESET / BASE
   ---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; font-family: var(--font); -webkit-font-smoothing: antialiased; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh; width: 100%;
  background: var(--bg-grad-1), var(--bg-grad-2), var(--bg);
  color: var(--txt);
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
a { color: var(--brand-dark); }
[data-theme="dark"] a { color: var(--brand); }

/* ----------------------------------------------------------------------------
   3. WORDMARK
   ---------------------------------------------------------------------------- */
.brand-text { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; color: var(--txt); }
.brand-text .ia-highlight { color: var(--brand); font-weight: 900; }

/* ----------------------------------------------------------------------------
   4. SIDEBAR + DRAWER + OVERLAY
   ---------------------------------------------------------------------------- */
aside {
  width: min(var(--sidebar-w), 86vw);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100dvh; z-index: 50;
  transform: translateX(-100%); transition: transform .3s ease;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(20px);
}
aside.open { transform: translateX(0); }
.brand-container { padding: 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.mobile-close { position: absolute; right: 12px; top: 12px; width: var(--touch-min); height: var(--touch-min); display: flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--txt-muted); cursor: pointer; }
.mobile-close:hover { color: var(--txt); border-color: var(--border-strong); }
.menu { padding: 16px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: var(--touch-min);
  color: var(--txt-muted); text-decoration: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  transition: all .2s; white-space: nowrap;
}
.menu a:hover { background: var(--surface-alt); color: var(--txt); }
.menu a.active { background: var(--brand-soft); color: var(--brand-dark); }
[data-theme="dark"] .menu a.active { color: var(--brand); }
.menu a svg { width: 18px; height: 18px; flex-shrink: 0; }
.menu-logout { color: var(--danger) !important; margin-top: auto; }
.menu-logout:hover { background: rgba(220,38,38,0.08) !important; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 40; }
.overlay.active { display: block; }

/* ----------------------------------------------------------------------------
   5. MAIN + HEADER
   ---------------------------------------------------------------------------- */
.main { padding: 20px 24px 64px; max-width: 100%; margin-left: 0; transition: margin-left .3s ease; }
header.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.head-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }
.head-titles { min-width: 0; }
.head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
h1 { font-size: clamp(20px, 4.5vw, 26px); font-weight: 800; margin: 0 0 4px; line-height: 1.2; letter-spacing: -0.02em; }
.sub { color: var(--txt-muted); font-size: 13.5px; line-height: 1.4; }
.mobile-menu-btn { display: flex; align-items: center; justify-content: center; width: var(--touch-min); height: var(--touch-min); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--txt); cursor: pointer; flex-shrink: 0; }
.mobile-menu-btn:hover { border-color: var(--border-strong); }

/* ----------------------------------------------------------------------------
   6. TOGGLE DE TEMA
   ---------------------------------------------------------------------------- */
.theme-toggle { width: var(--touch-min); height: var(--touch-min); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--txt-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle .ico-sun  { display: none; }
.theme-toggle .ico-moon { display: block; }
[data-theme="dark"] .theme-toggle .ico-sun  { display: block; }
[data-theme="dark"] .theme-toggle .ico-moon { display: none; }

/* ----------------------------------------------------------------------------
   7. FLASH — 3 variantes
   ---------------------------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; gap: 10px; }
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash.success { background: var(--brand-soft); color: var(--brand-dark); border-color: rgba(37,211,102,0.3); }
[data-theme="dark"] .flash.success { color: var(--brand); }
.flash.error { background: rgba(220,38,38,0.08); color: var(--danger); border-color: rgba(220,38,38,0.3); }
.flash.info  { background: rgba(59,130,246,0.08); color: #1d4ed8; border-color: rgba(59,130,246,0.3); }
[data-theme="dark"] .flash.info { color: #93c5fd; }

/* ----------------------------------------------------------------------------
   8. SEÇÃO + TÍTULO COM BARRINHA VERDE
   ---------------------------------------------------------------------------- */
section { margin-bottom: 36px; }
.section-h2, section > h2 {
  font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--txt);
  display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.section-h2::before, section > h2::before {
  content: ""; width: 3px; height: 14px; background: var(--brand); border-radius: 2px; flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   9. KPI GRID
   ---------------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 28px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 11px; color: var(--txt-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.kpi-val { font-size: clamp(20px, 4vw, 26px); font-weight: 800; margin-top: 6px; color: var(--txt); line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--txt-soft); margin-top: 4px; }

/* ----------------------------------------------------------------------------
   10. CARD
   ---------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }

/* ----------------------------------------------------------------------------
   11. TABELA — vira cards no ≤780px via td::before attr(data-label)
   ---------------------------------------------------------------------------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-alt); font-weight: 700; color: var(--txt-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--brand-soft); }
[data-theme="dark"] tbody tr:hover td { background: rgba(37,211,102,0.05); }
td.actions-cell { white-space: nowrap; }

@media (max-width: 780px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  tr:last-child { border-bottom: none; }
  td { display: flex; gap: 12px; padding: 6px 0; border-bottom: none; font-size: 13.5px; align-items: flex-start; }
  td::before {
    content: attr(data-label); flex: 0 0 38%;
    color: var(--txt-muted); font-size: 10px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em; line-height: 1.4; padding-top: 2px;
  }
  td.no-label::before { display: none; }
  td.no-label { width: 100%; padding-top: 8px; }
  td.actions-cell { white-space: normal; }
  tbody tr:hover td { background: transparent; }
  tbody tr:hover { background: var(--brand-soft); }
  [data-theme="dark"] tbody tr:hover { background: rgba(37,211,102,0.05); }
}

/* ----------------------------------------------------------------------------
   12. BOTÕES
   ---------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; min-height: 40px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; cursor: pointer; transition: background .15s; font-family: var(--font); text-decoration: none; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 12px; }
.btn.btn-secondary { background: var(--surface); color: var(--txt); border: 1px solid var(--border-strong); }
.btn.btn-secondary:hover { background: var(--surface-alt); border-color: var(--brand); }
.btn.btn-danger { background: var(--danger); color: #fff; }
.btn svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------------------------
   13. BADGES — 4 variantes
   ---------------------------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-success { background: var(--brand-soft); color: var(--brand-dark); }
[data-theme="dark"] .badge-success { color: var(--brand); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--warning); }
.badge-danger  { background: rgba(220,38,38,0.10); color: var(--danger); }
.badge-neutral { background: var(--surface-alt); color: var(--txt-muted); }

/* ----------------------------------------------------------------------------
   14. CAMPOS DE FORMULÁRIO
   ---------------------------------------------------------------------------- */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11px; color: var(--txt-muted); margin-bottom: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.field input[type=number], .field input[type=text], .field input[type=date],
.field input[type=email], .field input[type=tel], .field input[type=password],
.field select, .field textarea {
  width: 100%; padding: 10px 12px; min-height: 40px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font); background: var(--surface); color: var(--txt);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--txt-muted); }
.checkbox-row input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }

/* ----------------------------------------------------------------------------
   15. DETAILS / SUMMARY — painéis expansíveis
   ---------------------------------------------------------------------------- */
details.panel summary, details.tenant-edit summary { list-style: none; cursor: pointer; }
details.panel summary::-webkit-details-marker,
details.tenant-edit summary::-webkit-details-marker { display: none; }
details.panel[open] summary, details.tenant-edit[open] summary { background: var(--surface-alt); }
.panel-body, .tenant-edit-panel { margin-top: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); }

/* ----------------------------------------------------------------------------
   16. UTILITÁRIOS
   ---------------------------------------------------------------------------- */
.muted { color: var(--txt-muted); font-size: 12px; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.icon { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ----------------------------------------------------------------------------
   17. RESPONSIVO — sidebar fixa no desktop
   ---------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  aside { transform: translateX(0); }
  .main { margin-left: var(--sidebar-w); padding: 32px 40px; max-width: calc(100vw - var(--sidebar-w)); }
  .mobile-menu-btn, .mobile-close { display: none; }
  .overlay { display: none !important; }
}
@media (max-width: 1023px) { aside { width: min(280px, 86vw); } }
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  td::before { flex-basis: 100%; }
  td { flex-direction: column; gap: 2px; }
}
