/* =======================================================================
   FILADELFIA — Sistema Financeiro
   Estilos compartilhados entre todas as páginas
   ======================================================================= */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eef1f5;
  --border: #e4e8ee;
  --border-strong: #c9d0da;
  --text: #0a0e16;
  --text-dim: #4a5262;
  --text-muted: #6b7280;
  --accent: #1CA7EC;
  --accent-dim: #0d8bc7;
  --accent-text: #0a6e9e;
  --accent-glow: rgba(28, 167, 236, 0.12);
  --accent-bg: rgba(28, 167, 236, 0.08);
  --accent-bg-strong: rgba(28, 167, 236, 0.16);
  --danger: #d92d20;
  --danger-text: #b42318;
  --danger-bg: rgba(217, 45, 32, 0.07);
  --danger-bg-strong: rgba(217, 45, 32, 0.12);
  --success: #109854;
  --success-bg: rgba(16, 152, 84, 0.08);
  --warning: #b45309;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --violet: #7c3aed;
  --violet-bg: rgba(124, 58, 237, 0.1);
  --violet-text: #6d28d9;
  --brand-black: #0a0e16;
  --shadow-sm: 0 1px 3px rgba(10, 14, 22, 0.04);
  --shadow-md: 0 4px 16px rgba(10, 14, 22, 0.08);
  --shadow-lg: 0 20px 60px rgba(10, 14, 22, 0.4);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Archivo', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(28,167,236,0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(28,167,236,0.04), transparent 60%),
    var(--bg);
}

/* Mono font utility */
.mono { font-family: 'JetBrains Mono', monospace; }

/* ============ Topbar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--brand-black);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 2px solid var(--accent);
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text .name { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; color: #fff; }
.brand-text .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #9aa3b2;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: #c9d0da;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav a.active { color: #fff; background: rgba(28,167,236,0.25); font-weight: 600; }

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid #2a2f3a;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.user-chip button {
  background: transparent;
  border: none;
  color: #9aa3b2;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: color 0.15s, background 0.15s;
}
.user-chip button:hover { color: #fff; background: rgba(255,255,255,0.1); }

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: #c9d0da;
}
.sync-badge.connected { color: #6ee7b7; background: rgba(16,152,84,0.15); }
.sync-badge.offline { color: #fca5a5; background: rgba(217,45,32,0.15); }
.sync-badge .sync-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

.last-update {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #c9d0da;
  white-space: nowrap;
}
.last-update .dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============ Page head ============ */
.page-head {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
}
.page-head .kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent-text);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
}
.page-head h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
.page-head h1 .accent { color: var(--accent-text); font-style: italic; }
.page-head .desc {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 13px;
  max-width: 640px;
}

/* ============ Botões ============ */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(28, 167, 236, 0.2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--accent-dim); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
.btn.large { padding: 13px 24px; font-size: 14px; }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); box-shadow: none; }

.btn-danger {
  background: var(--danger); color: #fff;
  box-shadow: 0 2px 6px rgba(217, 45, 32, 0.25);
}
.btn-danger:hover:not(:disabled) { background: #b42318; }

.btn-success {
  background: var(--success); color: #fff;
  box-shadow: 0 2px 6px rgba(16, 152, 84, 0.25);
}
.btn-success:hover:not(:disabled) { background: #0a7a42; }

/* ============ Form elements ============ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* ============ Toggle pills ============ */
.toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
  gap: 2px;
}
.toggle button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.02em;
}
.toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(10, 14, 22, 0.08);
}

/* ============ Modais ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }

.modal .head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
}
.modal .head .title h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.modal .head .title .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.modal .close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.modal .close-btn:hover { background: var(--surface-2); color: var(--text); }
.modal .body { overflow: auto; flex: 1; }
.modal .foot {
  padding: 14px 22px;
  border-top: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-black);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(10, 14, 22, 0.25);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
}
.toast.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 5px 12px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
  white-space: nowrap;
}
.toast button:hover { background: rgba(255, 255, 255, 0.1); }

/* ============ Loading overlay ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.loading-overlay.open { opacity: 1; pointer-events: auto; }
.loading-overlay .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay .text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============ Empty states ============ */
.empty-state {
  padding: 70px 28px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .ico {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.empty-state h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

/* ============ Footer ============ */
footer {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
footer .footer-text {
  text-align: center;
}
footer .footer-version {
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* ============ Utilities ============ */
.hidden { display: none !important; }

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============ Responsividade global ============ */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .nav { display: none; width: 100%; flex-direction: column; gap: 4px; margin-top: 8px; order: 3; }
  .nav.open { display: flex; }
  .nav a { width: 100%; padding: 10px 12px; }
  .menu-toggle { display: inline-flex; }
  .last-update { display: none; }
  .page-head { padding: 20px 16px 14px; }
  .page-head h1 { font-size: 26px; }
  .user-chip .name-hide-mobile { display: none; }
}

@media (max-width: 560px) {
  .page-head h1 { font-size: 22px; }
  .page-head .desc { font-size: 12px; }
  .btn { padding: 8px 14px; font-size: 12px; }
  .btn.large { padding: 11px 20px; font-size: 13px; }
  .toast { bottom: 12px; right: 12px; left: 12px; max-width: none; }
  .modal { max-height: 92vh; border-radius: 12px; }
  .modal .head { padding: 14px 16px; }
  .modal .head .title h3 { font-size: 15px; }
  footer { padding: 16px; font-size: 10px; }
  .topbar-meta { width: 100%; order: 4; margin-top: 6px; }
}
