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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273549;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --income: #22c55e;
  --expense: #ef4444;
  --primary: #f59e0b;
  --border: #334155;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ---- Auth ---- */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}

.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active { background: var(--primary); color: #1c1300; }

.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }

label { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }

input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input:focus { border-color: var(--primary); }

.primary-btn {
  background: var(--primary);
  color: #1c1300;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.primary-btn:active { opacity: 0.85; }

.error-msg { color: var(--expense); font-size: 13px; margin-top: 12px; }

/* ---- App ---- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

.greeting { font-size: 18px; font-weight: 600; }

.icon-btn {
  background: var(--surface);
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.balance-card {
  margin: 0 20px 20px;
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border-radius: 20px;
  padding: 24px;
}

.balance-label { font-size: 13px; opacity: 0.85; }
.balance-value { font-size: 32px; font-weight: 700; margin: 4px 0 18px; color: #1c1300; }

.balance-row { display: flex; gap: 12px; }

.balance-chip {
  flex: 1;
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
}

.balance-chip span { display: block; opacity: 0.85; margin-bottom: 4px; color: #1c1300; }
.balance-chip strong { font-size: 15px; }
.balance-chip.income strong { color: #14532d; }
.balance-chip.expense strong { color: #7f1d1d; }

.filters {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

.filter-btn.active { background: var(--primary); color: #1c1300; border-color: var(--primary); }

.transactions-list {
  padding: 0 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-msg { color: var(--text-muted); text-align: center; padding: 40px 0; font-size: 14px; }

.tx-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tx-info { display: flex; align-items: center; gap: 12px; min-width: 0; }

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tx-icon.receita { background: rgba(34,197,94,0.15); }
.tx-icon.despesa { background: rgba(239,68,68,0.15); }

.tx-text { min-width: 0; }
.tx-desc { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--text-muted); }

.tx-amount { font-size: 14px; font-weight: 700; white-space: nowrap; }
.tx-amount.receita { color: var(--income); }
.tx-amount.despesa { color: var(--expense); }

.tx-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #1c1300;
  font-size: 28px;
  border: none;
  box-shadow: 0 8px 20px rgba(245,158,11,0.4);
  cursor: pointer;
}

/* ---- Modal ---- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.modal-content {
  background: var(--surface);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 { font-size: 18px; }

.type-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.type-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

.type-btn.income.active { background: rgba(34,197,94,0.15); border-color: var(--income); color: var(--income); }
.type-btn.expense.active { background: rgba(239,68,68,0.15); border-color: var(--expense); color: var(--expense); }

#transaction-form { display: flex; flex-direction: column; gap: 14px; }

@media (min-width: 480px) {
  .modal { align-items: center; justify-content: center; }
  .modal-content { max-width: 400px; border-radius: 20px; }
}

/* ---- View tabs ---- */

.view-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}

.view-tab-btn {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 8px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.view-tab-btn.active { background: var(--primary); color: #1c1300; border-color: var(--primary); }

/* ---- Calculadora de Frete ---- */

.calc-scroll { padding: 0 20px 120px; }

.calc-intro { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

.calc-section {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.calc-section h2 { font-size: 15px; margin-bottom: 14px; }

.calc-hint { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.calc-grid label { font-size: 12px; }

.calc-full { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); margin-top: 14px; }

textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}

textarea:focus { border-color: var(--primary); }

.calc-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.calc-actions .primary-btn, .calc-actions .secondary-btn { flex: 1; margin-top: 0; }

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-btn:active { opacity: 0.85; }

.calc-results {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.calc-results h2 { font-size: 15px; margin-bottom: 14px; }

.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.calc-result-row strong { color: var(--text); font-size: 13px; }

.calc-result-row.highlight-cost strong { color: var(--primary); }

.calc-alert {
  background: rgba(239,68,68,0.15);
  color: var(--expense);
  border: 1px solid var(--expense);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 14px;
}

.calc-final, .calc-min {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
}

.calc-final {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  color: #1c1300;
}

.calc-final span { font-size: 13px; font-weight: 600; }
.calc-final strong { font-size: 20px; }

.calc-min {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.calc-min span { font-size: 12px; color: var(--text-muted); }
.calc-min strong { font-size: 15px; color: var(--income); }

.calc-lancar { width: 100%; margin-top: 16px; }

.calc-formulas {
  color: var(--text-muted);
  font-size: 12px;
  padding-top: 4px;
}

.calc-formulas h3 { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.calc-formulas ul { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

@media (min-width: 480px) {
  .calc-grid { grid-template-columns: 1fr 1fr 1fr; }
}
