@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f1f5;
  --border: #e0e2ea;
  --text: #1a1d27;
  --text-dim: #6b7085;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --green: #00a67e;
  --green-bg: rgba(0,166,126,0.10);
  --yellow: #d4a017;
  --yellow-bg: rgba(212,160,23,0.10);
  --orange: #d35400;
  --orange-bg: rgba(211,84,0,0.10);
  --red: #c0392b;
  --red-bg: rgba(192,57,43,0.10);
  --blue: #0770c2;
  --blue-bg: rgba(7,112,194,0.10);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Tab nav ─────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}

.tab-nav a {
  padding: 8px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-dim);
  transition: all 0.2s;
}

.tab-nav a:hover { background: var(--surface2); color: var(--text); }
.tab-nav a.active { background: var(--accent); color: white; }

/* ── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header h1 span {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 15px;
  margin-left: 8px;
}

.badge-quarter {
  background: var(--accent);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.badge-year {
  background: var(--accent);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.last-update {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.kpi-card.accent::before { background: var(--accent); }
.kpi-card.green::before { background: var(--green); }
.kpi-card.yellow::before { background: var(--yellow); }
.kpi-card.blue::before { background: var(--blue); }
.kpi-card.orange::before { background: var(--orange); }

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
}

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

/* ── Faixa indicator ─────────────────────────────────────── */
.faixa-indicator {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.faixa-indicator h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Progress bar ────────────────────────────────────────── */
.progress-track {
  position: relative;
  height: 40px;
  background: var(--surface2);
  border-radius: 10px;
  overflow: visible;
  margin: 20px 0 12px;
  display: flex;
}

.progress-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  position: relative;
  transition: all 0.3s;
}

.progress-segment:first-child { border-radius: 10px 0 0 10px; }
.progress-segment:last-child { border-radius: 0 10px 10px 0; }

.seg-red { background: rgba(192,57,43,0.12); }
.seg-yellow { background: rgba(212,160,23,0.12); }
.seg-green { background: rgba(0,166,126,0.15); }
.seg-blue { background: rgba(108,92,231,0.12); }

.progress-marker {
  position: absolute;
  top: -8px;
  width: 4px;
  height: 56px;
  background: var(--accent);
  border-radius: 2px;
  z-index: 10;
  box-shadow: 0 0 10px rgba(108,92,231,0.4);
  transition: left 0.5s ease;
}

.progress-marker-label {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.faixa-labels {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.faixa-label-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.faixa-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ── Section title ───────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Monthly input section ───────────────────────────────── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.month-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: border-color 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.month-card:hover { border-color: var(--accent); }

.month-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.month-name { font-size: 16px; font-weight: 700; }
.month-target { font-size: 13px; color: var(--text-dim); }
.month-target strong { color: var(--text); }

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.input-group label {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 80px;
}

.input-group input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-dim); font-weight: 400; font-size: 14px; }

.month-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.month-stat {
  background: var(--surface2);
  padding: 10px 12px;
  border-radius: 8px;
}

.month-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.month-stat-value {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
}

/* ── Status badge ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.below { background: var(--red-bg); color: var(--red); }
.status-badge.pre { background: var(--yellow-bg); color: var(--yellow); }
.status-badge.meta { background: var(--green-bg); color: var(--green); }
.status-badge.super { background: var(--blue-bg); color: var(--accent); }
.status-badge.pending { background: var(--surface2); color: var(--text-dim); }

/* ── Commission table ────────────────────────────────────── */
.commission-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.commission-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.commission-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.commission-table td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.commission-table tr:last-child td { border-bottom: none; }
.commission-table tr.active-row { background: rgba(108,92,231,0.06); }
.commission-table tr.active-row td { font-weight: 600; }

/* ── Chart section ───────────────────────────────────────── */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  height: 220px;
  padding-bottom: 30px;
  justify-content: center;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 140px;
}

.bars-wrapper {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 180px;
}

.bar {
  width: 36px;
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease;
  position: relative;
  min-height: 4px;
}

.bar-meta {
  background: linear-gradient(180deg, rgba(108,92,231,0.5), rgba(108,92,231,0.15));
  border: 1px solid rgba(108,92,231,0.3);
}

.bar-result {
  background: linear-gradient(180deg, rgba(0,166,126,0.6), rgba(0,166,126,0.15));
  border: 1px solid rgba(0,166,126,0.4);
}

.bar-result.negative {
  background: linear-gradient(180deg, rgba(211,84,0,0.6), rgba(211,84,0,0.15));
  border: 1px solid rgba(211,84,0,0.4);
}

.bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.bar-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-dot { width: 12px; height: 12px; border-radius: 3px; }

/* ── Projections ─────────────────────────────────────────── */
.projection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

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

.scenario-card {
  background: var(--surface2);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.scenario-card.active { border-color: var(--accent); background: rgba(108,92,231,0.05); }
.scenario-icon { font-size: 24px; margin-bottom: 6px; }
.scenario-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.scenario-psqls { font-size: 20px; font-weight: 800; }
.scenario-need { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.scenario-commission { font-size: 14px; font-weight: 600; margin-top: 6px; color: var(--green); }

/* ── Needs cards ─────────────────────────────────────────── */
.needs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.need-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.need-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.need-card.pre::before { background: var(--yellow); }
.need-card.meta::before { background: var(--green); }
.need-card.super::before { background: var(--accent); }

.need-title { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.need-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.need-detail { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.need-daily { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; }

/* ── Actions row ─────────────────────────────────────────── */
.actions-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { border-color: var(--accent); background: var(--surface2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: #5a4bd1; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ── Info box ────────────────────────────────────────────── */
.info-box {
  background: rgba(0,166,126,0.06);
  border: 1px solid rgba(0,166,126,0.2);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}

.info-box strong { color: var(--green); }

/* ── Print helpers ───────────────────────────────────────── */
.print-value { display: none; font-size: 16px; font-weight: 700; color: var(--text); padding: 10px 0; }
.print-stamp { display: none; text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .needs-grid { grid-template-columns: 1fr; }
  .bar-chart { gap: 12px; }
  .bar { width: 28px; }
  .header { flex-direction: column; align-items: flex-start; }
}

/* ── Auth ─────────────────────────────────────────────────── */
.auth-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-dim);
}
.auth-bar button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.auth-bar button:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Save indicator ──────────────────────────────────────── */
.save-status {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
  padding: 4px 10px;
}
.save-status.saving { color: var(--yellow); }
.save-status.saved { color: var(--green); }
.save-status.error { color: var(--red); }
