* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f7f5;
  color: #14251d;
}
.hidden { display: none !important; }

/* ---------- loading ---------- */
.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #123c2a;
}
.spinner {
  width: 38px; height: 38px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #123c2a;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: #d8aa55;
  display: grid;
  place-items: center;
  font-size: 26px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: #64748b; font-size: 14px; }
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #365446;
  margin-bottom: 16px;
}
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  font-size: 15px;
}
.login-error {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: #23734e;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

/* ---------- top bar ---------- */
.topbar { background: #123c2a; color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 20px 16px; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: #d8aa55;
  color: #123c2a;
  display: grid; place-items: center;
  font-size: 20px;
}
.brand h1 { margin: 0; font-size: 21px; font-weight: 800; }
.saving-status { margin: 2px 0 0; font-size: 13px; color: rgba(209,250,229,0.75); }
.topbar-actions { display: flex; gap: 8px; }
.icon-button {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}
.gold-button {
  background: #d8aa55;
  color: #123c2a;
  border: none;
  padding: 0 16px;
  height: 40px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.summary-grid { margin-top: 22px; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .summary-grid { grid-template-columns: repeat(3, 1fr); } }
.summary-card {
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 14px 16px;
}
.summary-label { margin: 0; font-size: 13px; color: rgba(209,250,229,0.75); }
.summary-value { margin: 4px 0 0; font-size: 21px; font-weight: 800; }
.summary-value.positive { color: #f0ca80; }
.summary-value.negative { color: #fca5a5; }

/* ---------- content ---------- */
.content { max-width: 1120px; margin: 0 auto; padding: 20px 16px; }

.dates-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dates-grid { display: grid; gap: 12px; align-items: end; grid-template-columns: 1fr; }
@media (min-width: 640px) { .dates-grid { grid-template-columns: 1fr auto 1fr auto; } }
.date-label { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; color: #365446; gap: 6px; }
.date-label input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
}
.dates-sep { color: #94a3b8; padding-bottom: 10px; }
.reset-button {
  background: #eef2ff;
  color: #365446;
  border: 1px solid #cbd5e1;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.reset-button:hover { background: #e2e8f0; }
.dates-hint { margin: 12px 0 0; font-size: 13px; color: #64748b; }

.table-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.table-header {
  display: none;
  background: #e8f0eb;
  color: #365446;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 20px;
  gap: 12px;
}
@media (min-width: 768px) {
  .table-header, .investment-row {
    display: grid;
    grid-template-columns: 1.7fr 1.15fr 1.15fr 1fr 1fr 76px;
  }
}
.investment-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid #eef2f0;
}
@media (min-width: 768px) {
  .investment-row { display: grid; align-items: center; gap: 12px; }
  .investment-row > * { min-width: 0; }
}
.row-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 700; overflow-wrap: anywhere; }
.best-badge {
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.mobile-label { font-size: 12px; color: #94a3b8; margin-right: 6px; }
@media (min-width: 768px) { .mobile-label { display: none; } }
.value-cell { font-size: 14px; }
.money-input {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff7e0;
  border: 1px solid #f0d999;
  border-radius: 10px;
  padding: 6px 10px;
}
.money-input span { color: #92400e; font-size: 13px; }
.money-input input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
}
.percent.positive, .text-positive { color: #047857; }
.percent.negative, .text-negative { color: #dc2626; }
.text-muted { color: #94a3b8; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 15px;
  color: #365446;
}
.row-actions button:hover { background: #f1f5f9; }
.row-actions .danger { color: #dc2626; }

.totals-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 16px 20px;
  background: #f8faf9;
  font-size: 14px;
}
@media (min-width: 768px) {
  .totals-row { grid-template-columns: 1.7fr 1.15fr 1.15fr 1fr 1fr 76px; gap: 12px; align-items: center; }
}

.bottom-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}
.fill-status { margin: 0; font-size: 13px; color: #64748b; }
.bottom-actions { display: flex; gap: 8px; }
.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #365446;
}
.file-label { position: relative; }

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-box {
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}
.modal-box-center { text-align: center; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-label { display: block; font-size: 13px; font-weight: 600; color: #365446; margin-bottom: 14px; }
.modal-label input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
}
.modal-money {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 4px 10px;
  margin-top: 6px;
}
.modal-money span { color: #64748b; font-size: 13px; }
.modal-money input { border: none; outline: none; padding: 8px 0; flex: 1; font-size: 14px; }
.save-button {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: #23734e;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.delete-icon {
  width: 52px; height: 52px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fef2f2;
  color: #dc2626;
  display: grid; place-items: center;
  font-size: 24px;
}
.modal-box h2 { font-size: 19px; margin: 4px 0 8px; }
.modal-box-center p { color: #475569; font-size: 14px; margin: 0 0 18px; }
.modal-two-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cancel-button, .delete-button {
  padding: 12px; border-radius: 12px; border: none; font-weight: 700; cursor: pointer;
}
.cancel-button { background: #f1f5f9; color: #334155; }
.delete-button { background: #dc2626; color: #fff; }

/* ---------- abas ---------- */
.tabs { margin-top: 18px; display: flex; gap: 6px; }
.tab {
  background: rgba(255,255,255,0.08);
  color: rgba(209,250,229,0.85);
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.tab:hover { background: rgba(255,255,255,0.14); }
.tab.active { background: #d8aa55; color: #123c2a; }

/* ---------- extrato ---------- */
.extrato-resumo {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.extrato-label { margin: 0; font-size: 13px; color: #64748b; }
.extrato-saldo { margin: 4px 0 0; font-size: 26px; font-weight: 800; }
.extrato-saldo.positive { color: #047857; }
.extrato-saldo.negative { color: #dc2626; }
.extrato-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.extrato-info p { margin: 0; font-size: 13px; color: #64748b; }
.extrato-erro {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.extrato-header { display: none; }
.extrato-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  padding: 12px 16px;
  border-top: 1px solid #edf2ef;
  font-size: 14px;
}
.extrato-row:first-child { border-top: none; }
.extrato-data { order: 1; color: #365446; font-weight: 600; }
.extrato-valor { order: 2; font-weight: 700; text-align: right; white-space: nowrap; }
.extrato-historico { order: 3; grid-column: 1 / -1; overflow-wrap: anywhere; }
.extrato-documento { order: 4; grid-column: 1 / -1; font-size: 12px; }
@media (min-width: 768px) {
  .extrato-header {
    display: grid;
    grid-template-columns: 100px 1fr 160px 150px;
    gap: 12px;
    padding: 12px 16px;
    background: #e8f0eb;
    color: #365446;
    font-size: 13px;
    font-weight: 700;
  }
  .extrato-header span:last-child { text-align: right; }
  .extrato-row { grid-template-columns: 100px 1fr 160px 150px; align-items: center; }
  .extrato-historico, .extrato-documento { grid-column: auto; }
  .extrato-data { order: 1; }
  .extrato-historico { order: 2; }
  .extrato-documento { order: 3; font-size: 13px; }
  .extrato-valor { order: 4; }
}
