@import url('tokens.css');

/* ========================================================== */
/* Base                                                          */
/* ========================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .font-display { font-family: var(--font-display); letter-spacing: -0.01em; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.mono { font-family: var(--font-mono); letter-spacing: 0.01em; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.hidden { display: none !important; }

/* ========================================================== */
/* Marca / fechadura — elemento assinatura                      */
/* ========================================================== */
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #2a2214, var(--surface-2) 70%);
  border: 1px solid var(--border);
  position: relative;
  display: grid; place-items: center;
}
.brand-mark::before {
  content: '';
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-wash-2);
}
.brand-mark::after {
  content: '';
  position: absolute;
  width: 2.5px; height: 9px;
  background: var(--gold);
  bottom: 8px;
  border-radius: 2px;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand-name small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }

/* ========================================================== */
/* Shell: sidebar + topbar + conteúdo                           */
/* ========================================================== */
.shell { min-height: 100%; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  z-index: 40;
}
.sidebar-head { padding: 4px 8px 22px; }
.nav-group { margin-top: 10px; }
.nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.nav-item .ic { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--gold-wash); color: var(--gold); }
.nav-item.active .ic { opacity: 1; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); }

.topbar {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w);
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 30;
}
.topbar-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 24px 40px;
  max-width: 1180px;
}

.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--gold);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Navegação inferior — mobile */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--bottombar-h);
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  z-index: 40;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--text-faint); font-size: 10.5px; font-weight: 600;
}
.bottom-nav a .ic { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--gold); }

@media (max-width: 880px) {
  .sidebar { display: none; }
  .topbar { left: 0; padding: 0 16px; }
  .main { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px calc(var(--bottombar-h) + 28px); }
  .bottom-nav { display: flex; }
}

/* ========================================================== */
/* Cards / stats                                                 */
/* ========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 880px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { padding: 18px; }
.stat-label { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin-top: 8px; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ========================================================== */
/* Botões                                                        */
/* ========================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease, background .12s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); color: #171206; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-subtle { background: var(--surface-2); color: var(--text-dim); }
.btn-subtle:hover { color: var(--text); }
.btn-danger { background: var(--danger-wash); color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ========================================================== */
/* Formulários                                                   */
/* ========================================================== */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: var(--font-body);
  transition: border-color .12s ease;
}
.input.mono, textarea.mono { font-family: var(--font-mono); }
.input:focus, select:focus, textarea:focus { border-color: var(--gold-soft); outline: none; }
.input::placeholder { color: var(--text-faint); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }
.help-text { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.error-text { font-size: 12.5px; color: var(--danger); margin-top: 10px; display: none; }
.error-text.show { display: block; }

/* ========================================================== */
/* Gráfico de receita (dashboard)                                */
/* ========================================================== */
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.chart-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ========================================================== */
/* Badges / categorias                                           */
/* ========================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-gold { background: var(--gold-wash); color: var(--gold); border-color: transparent; }
.badge-success { background: var(--success-wash); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-wash); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-wash); color: var(--warning); border-color: transparent; }

/* ========================================================== */
/* Tabela (desktop) ↔ cartões empilhados (mobile)                */
/* ========================================================== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--border-soft);
}
table.data td { padding: 13px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-hover); }

@media (max-width: 760px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
  table.data td { padding: 4px 0; border-bottom: none; }
  table.data td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 10.5px; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px;
  }
}

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-faint); }
.empty-state .brand-mark { margin: 0 auto 16px; width: 48px; height: 48px; }
.empty-state .brand-mark::before { width: 12px; height: 12px; }
.empty-state .brand-mark::after { height: 12px; bottom: 11px; }
.empty-state h4 { color: var(--text-dim); margin: 0 0 6px; font-size: 14px; }

/* ========================================================== */
/* Segredo do cofre — revelar/ocultar                            */
/* ========================================================== */
.secret-field { display: flex; align-items: center; gap: 8px; }
.secret-mask { font-family: var(--font-mono); letter-spacing: 3px; color: var(--text-faint); }
.secret-value { font-family: var(--font-mono); color: var(--gold); }
.reveal-btn { color: var(--text-faint); background: none; border: none; cursor: pointer; padding: 4px; display: inline-flex; }
.reveal-btn:hover { color: var(--gold); }

/* ========================================================== */
/* Modal                                                          */
/* ========================================================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,6,10,0.6);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-pop);
  animation: sheet-up .18s ease-out;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-lg); margin-bottom: 0; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { background: none; border: none; color: var(--text-faint); cursor: pointer; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.close-x:hover { background: var(--surface-hover); color: var(--text); }

/* ========================================================== */
/* Toast                                                          */
/* ========================================================== */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 880px) { .toast-stack { left: 16px; right: 16px; top: auto; bottom: calc(var(--bottombar-h) + 14px); } }
.toast {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; min-width: 220px; box-shadow: var(--shadow-card);
  animation: toast-in .16s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================================== */
/* Login                                                          */
/* ========================================================== */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--gold-wash), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 376px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; }
.auth-brand .brand-mark { width: 52px; height: 52px; }
.auth-brand .brand-mark::before { width: 14px; height: 14px; }
.auth-brand .brand-mark::after { height: 13px; width: 3px; bottom: 13px; }
.auth-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; text-align: center; }
.auth-sub { font-size: 12.5px; color: var(--text-faint); text-align: center; margin-top: 2px; }

/* ========================================================== */
/* Utilidades de layout                                          */
/* ========================================================== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-head h2 { margin: 0; font-size: 19px; }
.filters-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-filter {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.chip-filter.active { background: var(--gold-wash); border-color: transparent; color: var(--gold); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
