:root {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-2: #273548;
  --text: #F1F5F9;
  --muted: #94A3B8;
  --accent: #2DD4BF;
  --accent-strong: #14B8A6;
  --danger: #EF4444;
  --ok: #22C55E;
  --warn: #F59E0B;
  --border: #334155;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);

  --font-stack: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface); padding: 2px 6px; border-radius: 4px; }
strong { color: var(--text); }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.18);
}
.brand-name { font-size: 16px; }
.brand-large { font-size: 22px; margin-bottom: 4px; }
.brand-large .brand-name { font-size: 22px; }

.app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header .brand { flex-shrink: 0; }
.app-nav {
  display: flex;
  gap: 18px;
  flex: 1;
  margin-left: 12px;
}
.app-nav a {
  color: var(--text);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
}
.app-nav a:hover { background: var(--surface-2); text-decoration: none; }
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-email { color: var(--muted); font-size: 13px; }

.scenario-picker { position: relative; }
.scenario-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
}
.scenario-btn:hover { background: var(--bg); }
.scenario-btn .caret { color: var(--muted); }
.scenario-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.scenario-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  max-height: 70vh;
  overflow-y: auto;
}
.scenario-list { list-style: none; padding: 6px 0; margin: 0; }
.scenario-item { padding: 6px 12px; }
.scenario-item.active { background: rgba(45, 212, 191, 0.07); }
.scenario-pick {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
}
.scenario-pick:hover { color: var(--accent); }
.scenario-name { flex: 1; }
.active-flag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(45, 212, 191, 0.15);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.scenario-actions { display: flex; gap: 10px; padding-top: 4px; padding-left: 18px; }
.scenario-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.logout-form { margin: 0; display: inline; }
.logout-form-inline { margin-top: 18px; text-align: center; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card-wide { max-width: 560px; }
.auth-card .brand-large { margin-bottom: 8px; }
.auth-card p { margin: 6px 0 18px 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #042F2E;
}
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-error {
  background: rgba(239, 68, 68, 0.10);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.35);
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
input[type="text"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.steps {
  margin: 14px 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}
.steps li { margin-bottom: 6px; }

.totp-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
  align-items: center;
  margin: 16px 0 20px 0;
  padding: 18px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.totp-qr img {
  width: 100%;
  max-width: 180px;
  height: auto;
  background: white;
  padding: 8px;
  border-radius: 8px;
}
.totp-manual { display: flex; flex-direction: column; gap: 6px; }
.totp-secret {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  word-break: break-all;
  user-select: all;
}

.totp-form input { letter-spacing: 4px; font-family: var(--font-mono); font-size: 18px; text-align: center; }
.totp-form button { margin-top: 14px; }

.stub {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.stub h1 { margin: 0 0 8px 0; font-size: 24px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toolbar .weeks-selector { display: flex; align-items: center; gap: 8px; }
.toolbar .weeks-selector select { width: auto; min-width: 110px; }
.toolbar .cenario-info { color: var(--muted); font-size: 14px; }
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.weekly-grid-wrap { overflow-x: auto; margin-bottom: 24px; }
.weekly-grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.weekly-grid th, .weekly-grid td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.weekly-grid th:first-child, .weekly-grid td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  font-weight: 500;
}
.weekly-grid thead th { background: var(--surface-2); font-weight: 600; }
.weekly-grid .week-h.current { background: rgba(45, 212, 191, 0.15); color: var(--accent); }
.weekly-grid .week-h.past { color: var(--muted); }
.weekly-grid .week-h.future { color: var(--text); }
.weekly-grid .week-label { font-size: 13px; }
.weekly-grid .week-id { font-size: 11px; opacity: 0.6; margin-top: 2px; }
.weekly-grid tr:last-child td { border-bottom: none; }
.weekly-grid .row-vendas td { color: var(--ok); font-weight: 500; }
.weekly-grid .row-vendas td:first-child { color: var(--text); }
.weekly-grid .row-saldo td { font-weight: 600; background: var(--surface-2); }
.weekly-grid .row-saldo td:first-child { background: var(--surface); }
.weekly-grid td.amount { font-family: var(--font-mono); font-size: 13px; }
.weekly-grid td.pos { color: var(--ok); }
.weekly-grid td.neg { color: var(--danger); }
.weekly-grid td.cost { color: var(--text); }

.empty-hint { padding: 20px; text-align: center; }

.entries-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.entries-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.entries-col h3 { margin: 0 0 12px 0; font-size: 16px; color: var(--text); }
.entries-list { list-style: none; padding: 0; margin: 0; }
.entries-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.entries-list li:last-child { border-bottom: none; }
.entry-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.entry-line + .entry-line { margin-top: 4px; font-size: 13px; }
.entry-actions { margin-top: 6px; display: flex; gap: 12px; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.paid { background: rgba(34, 197, 94, 0.15); color: #4ADE80; }
.badge.planned { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.badge.recur { background: rgba(45, 212, 191, 0.15); color: var(--accent); }

dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
dialog.modal h2 { margin: 0 0 16px 0; font-size: 20px; }
dialog.modal .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
dialog.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 600px) {
  .app-header { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .app-nav { order: 3; width: 100%; margin: 0; flex-wrap: wrap; }
  .user-menu { margin-left: auto; }
  .totp-grid { grid-template-columns: 1fr; text-align: center; }
  .totp-qr img { margin: 0 auto; }
  .container { padding: 18px; }
  .entries-grid { grid-template-columns: 1fr; }
  dialog.modal .form-row { grid-template-columns: 1fr; }
}

.funil .lab-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.lab-tag {
  background: var(--warn);
  color: #1F2937;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.funnel-floor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
}
.sdr-floor { border-color: rgba(45, 212, 191, 0.4); }
.closer-floor { border-color: rgba(34, 197, 94, 0.4); }

.floor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.floor-header h2 { margin: 0; font-size: 18px; }

.floor-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.floor-row .form-label { flex: 1 1 180px; margin: 0; }
.floor-row .form-label input { width: 100%; }

.results-row { padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); }

.kpi-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.kpi-inline .kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-inline .kpi-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.kpi-inline .kpi-value.strong { color: var(--accent); font-size: 24px; }
.kpi-inline input[type="number"] { width: 80px; font-family: var(--font-mono); }

.team-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 14px 0;
}
.team-table th, .team-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.team-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.team-table th.num, .team-table td.num { text-align: right; }
.team-table tr:last-child td { border-bottom: none; }
.team-table input[type="number"] { width: 90px; text-align: right; font-family: var(--font-mono); }
.team-table .center { text-align: center; }

.funnel-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 12px 0;
}

.funnel-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.pedrra .kpi-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-card-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-card-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; }
.kpi-card-value.strong { color: var(--accent); font-size: 26px; }
.kpi-card-value.pos { color: var(--ok); }
.kpi-card-value.neg { color: var(--danger); }
.kpi-card-foot { font-size: 11px; }

.chart-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chart-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.chart-controls select { width: auto; padding: 6px 10px; font-size: 13px; }
.chart-status { margin-left: auto; font-size: 12px; }

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  height: 320px;
  position: relative;
}
.chart-wrap canvas { max-height: 280px; }

.projection-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.projection-table-wrap h3 { margin: 0 0 12px 0; font-size: 16px; }
.projection-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.projection-table th, .projection-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.projection-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.projection-table th.num, .projection-table td.num { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.projection-table tr:last-child td { border-bottom: none; }
.projection-table tr.past td { color: var(--muted); }
.projection-table tr.current td { background: rgba(45, 212, 191, 0.07); }
.projection-table tr.current td:first-child { color: var(--accent); font-weight: 600; }
.projection-table tr.future td { }
.projection-table td.pos { color: var(--ok); }
.projection-table td.neg { color: var(--danger); }
.projection-table input[type="number"] { width: 110px; text-align: right; font-family: var(--font-mono); padding: 6px 8px; }

@media (max-width: 800px) {
  .pedrra .kpi-bar { grid-template-columns: 1fr 1fr; }
}

.settings-page .settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}
.settings-page h2 { margin: 0 0 12px 0; font-size: 18px; }
.settings-page p { margin: 4px 0 14px 0; }

.settings-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; max-width: 440px; }
.settings-form label.form-label { width: 100%; margin: 0; }
.settings-form button { margin-top: 6px; }
.settings-status { font-size: 13px; color: var(--accent); margin-left: 12px; }

.checkbox-label { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }

.settings-form-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  flex-wrap: wrap;
}
.settings-form-inline input, .settings-form-inline select { width: auto; min-width: 160px; }

.cat-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.cat-group { background: var(--bg); padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.cat-group h3 { margin: 0 0 8px 0; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
.cat-group ul { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.cat-group li { padding: 3px 0; }

.audit-table-wrap { max-height: 480px; overflow-y: auto; }
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table th, .audit-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
.audit-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.action-create { background: rgba(34, 197, 94, 0.15); color: #4ADE80; }
.action-update { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.action-delete { background: rgba(239, 68, 68, 0.15); color: #FCA5A5; }
.action-activate { background: rgba(45, 212, 191, 0.15); color: var(--accent); }
.action-duplicate { background: rgba(45, 212, 191, 0.10); color: var(--accent); }
