/* ── Fonte: sistema local (zero request externo) ──────────────────────── */
/* Inter via local() — usa a Inter instalada no sistema ou fallback system-ui */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: local('Inter'), local('Inter-Regular'),
       local('Inter Variable'), local('InterVariable');
}

/* ── Variáveis do tema Orbita ─────────────────────────────────────────── */
:root {
  --bg:           #0A0E1A;
  --surface:      #141B2D;
  --surface-2:    #1A2540;
  --sidebar:      #0D1324;
  --border:       #1E2D4A;
  --accent:       #4F9CF9;
  --accent-dim:   #2563EB;
  --accent-glow:  rgba(79,156,249,0.15);
  --success:      #10B981;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --positive:      #22C55E;
  --negative:      #EF4444;
  --text:         #E2E8F0;
  --text-muted:   #64748B;
  --text-dim:     #94A3B8;
  --sidebar-w:    240px;
  --topbar-h:     64px;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

/* ── Tema Claro ───────────────────────────────────────────────────────── */
body.theme-light {
  --bg:          #F0F2F7;
  --surface:     #FFFFFF;
  --surface-2:   #F4F6FB;
  --border:      #DDE2EE;
  --accent:      #2563EB;
  --accent-dim:  #1D4ED8;
  --accent-glow: rgba(37,99,235,0.10);
  --text:        #1A2540;
  --text-muted:  #64748B;
  --text-dim:    #94A3B8;
  --shadow:      0 4px 24px rgba(0,0,0,0.10);
}
body.theme-light .sidebar              { background: #0D1324; border-right-color: rgba(255,255,255,.06); }
body.theme-light .sidebar-brand        { border-bottom-color: rgba(255,255,255,.1); }
body.theme-light .sidebar-brand-text   { color: #E2E8F0; }
body.theme-light .nav-section-title    { color: rgba(255,255,255,.35); }
body.theme-light .nav-item             { color: rgba(255,255,255,.7); }
body.theme-light .nav-item:hover,
body.theme-light .nav-item.active      { background: rgba(255,255,255,.1); color: #fff; }
body.theme-light .sidebar-footer       { border-top-color: rgba(255,255,255,.1); color: rgba(255,255,255,.6); }
body.theme-light .workspace-switcher   { border-color: rgba(255,255,255,.12); color: rgba(255,255,255,.8); }
body.theme-light .topbar               { border-bottom-color: var(--border); }
body.theme-light ::-webkit-scrollbar-track { background: var(--bg); }
body.theme-light ::-webkit-scrollbar-thumb { background: var(--border); }

/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #7AB5FB; }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79,156,249,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(79,156,249,0.05) 0%, transparent 50%),
    var(--bg);
}

.login-box {
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
}

.login-brand {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.login-logo svg {
  width: 48px;
  height: 48px;
}

.login-logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text);
}

.login-tagline {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-tabs {
  display: flex;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.login-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-size: 14px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 12px;
}
.btn-primary:hover { background: #3B82F6; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,156,249,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  display: none;
}
.login-error.show { display: block; }

/* ══════════════════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════════════════ */

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

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

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

.sidebar-brand svg { width: 32px; height: 32px; flex-shrink: 0; }

.sidebar-brand-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--text);
}

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

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-weight: 500;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(79,156,249,0.2);
}

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

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

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

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

.logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--danger); }

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

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

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.date-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-filters label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.date-input {
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.date-input:focus { border-color: var(--accent); }

.period-btns { display: flex; gap: 4px; }

.period-btn {
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.period-btn:hover  { border-color: var(--accent); color: var(--accent); }
.period-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

.sync-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.sync-btn:hover { background: #3B82F6; }
.sync-btn.syncing { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

/* ── Content area ─────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: clamp(16px, 1.8vw, 28px);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-value.positive { color: var(--positive); }
.card-value.negative { color: var(--negative); }
.card-value.accent   { color: var(--accent); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Tabela ───────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-title { font-size: 15px; font-weight: 700; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(30,45,74,0.5);
  font-size: 13px;
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(79,156,249,0.04); }

.td-positive { color: var(--positive); font-weight: 600; }
.td-negative { color: var(--negative); font-weight: 600; }
.td-muted    { color: var(--text-muted); }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--danger);  }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-accent  { background: var(--accent-glow);    color: var(--accent);  }
.badge-muted   { background: var(--surface-2);      color: var(--text-muted); }

/* ── DRE ──────────────────────────────────────────────────────────────── */
.dre-table td:first-child { font-weight: 500; }
.dre-formula-row td             { font-weight: 700; background: rgba(79,156,249,0.05); }
.dre-formula-row td:first-child { color: var(--accent); }
.dre-total-row td   { font-weight: 800; font-size: 15px; background: rgba(79,156,249,0.08); color: var(--text); border-top: 2px solid var(--accent); }
.dre-text-row td    { color: var(--text-muted); font-style: italic; font-size: 12px; padding: 6px 16px; }

/* ── Fluxo de Caixa ───────────────────────────────────────────────────── */
.cashflow-positive { color: var(--success); }
.cashflow-negative { color: var(--danger); }

/* ── Inputs de formulário ─────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

/* ── Toast notifications ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: #065F46; border: 1px solid var(--success); color: #A7F3D0; }
.toast-error   { background: #7F1D1D; border: 1px solid var(--danger);  color: #FCA5A5; }
.toast-info    { background: #1E3A5F; border: 1px solid var(--accent);  color: #BFDBFE; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Loading / spinner ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3  { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-dim); }
.empty-state p   { font-size: 13px; }

/* ── Gráfico canvas ───────────────────────────────────────────────────── */
.chart-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

canvas { display: block; }

/* ── Month selector ───────────────────────────────────────────────────── */
.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-select {
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* ── Dashboard drag & drop ────────────────────────────────────────────── */
.dash-slot { transition: opacity .2s, outline .1s; }
.dash-slot[draggable="true"] { cursor: grab; }
.dash-slot[draggable="true"]:active { cursor: grabbing; }
.dash-slot.drag-over { outline: 2px solid var(--accent) !important; }

/* ── Hamburger button ─────────────────────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s;
}
.hamburger:hover { background: var(--surface-2); }

/* Overlay escuro ao abrir sidebar no mobile */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99;
}
#sidebar-overlay.active { display: block; }

/* ── Responsividade ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hamburger visível */
  .hamburger { display: flex; align-items: center; justify-content: center; }

  /* Sidebar vira drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main ocupa tela toda */
  .main { margin-left: 0; }

  /* Topbar compacta */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }

  /* Filtros de data ocultos no mobile — abre por botão */
  .date-filters { display: none; }
  .period-btns  { display: none; }

  /* Barra de busca menor */
  #global-search { width: 140px !important; font-size: 12px !important; }

  /* Content padding menor */
  .content { padding: 12px; }

  /* Cards em coluna única no mobile */
  .cards-grid { grid-template-columns: 1fr !important; }

  /* Grids de 2+ colunas viram 1 coluna */
  .dash-grid,
  [style*="grid-template-columns: repeat(auto-fill"] {
    grid-template-columns: 1fr !important;
  }

  /* Tabelas: scroll horizontal */
  .table-wrap, .overflow-x-auto, [style*="overflow-x:auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 480px; }

  /* Kanban: scroll horizontal */
  [style*="overflow-x: auto"][style*="display:flex"] { overflow-x: auto !important; }

  /* Botões grandes no mobile */
  .btn { min-height: 40px; }

  /* Filtros colapsados */
  .filters-bar { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 480px) {
  .topbar-title { font-size: 13px; }
  #global-search { display: none !important; }
  .content { padding: 10px; }
  .cards-grid { grid-template-columns: 1fr !important; }
  .login-card { padding: 20px; }
}
