:root {
  --bg: #0B0B0E;
  --surface: #17171D;
  --surface-raised: #1F1F27;
  --border: #2A2A34;
  --gold: #D9A94E;
  --gold-dim: #8A7239;
  --emerald: #4FBE8D;
  --red: #E1615A;
  --text: #F1F0ED;
  --text-dim: #A5A3AD;
  --text-faint: #6B6975;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 20px 80px;
}

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.login-title {
  color: var(--gold);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.login-subtitle {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 32px;
}
.login-form { width: 100%; max-width: 320px; }

/* Shared inputs */
input, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: 1px solid var(--gold); }
input[type="password"] {
  text-align: center;
  letter-spacing: 4px;
  font-size: 20px;
}

label.field-label {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
  margin-top: 16px;
}

button.primary {
  width: 100%;
  background: var(--gold);
  color: #1A1508;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
}
button.primary:disabled { opacity: 0.6; cursor: default; }
button.primary:active { opacity: 0.85; }

button.ghost {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gold);
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
}

.error-text { color: var(--red); text-align: center; margin-top: 12px; font-size: 14px; }

/* Header */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.header-title { font-size: 26px; font-weight: 700; margin: 0; }
.header-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.logout-link { color: var(--text-faint); font-size: 13px; cursor: pointer; background: none; border: none; padding: 0; }

/* Fund card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 16px;
  cursor: pointer;
}
.card-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fund-name { font-size: 17px; font-weight: 700; }
.fund-monthly { color: var(--text-dim); font-size: 13px; }
.fund-total { color: var(--gold); font-size: 28px; font-weight: 700; }
.fund-total-label { color: var(--text-faint); font-size: 12px; margin-bottom: 4px; }
.fund-breakdown { color: var(--text-faint); font-size: 11px; margin-bottom: 12px; }
.card-footer-row {
  display: flex; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px;
}

.empty-state { text-align: center; color: var(--text-faint); font-size: 15px; margin-top: 80px; line-height: 1.5; }

/* Detail */
.back-link { color: var(--gold); font-size: 15px; cursor: pointer; background: none; border: none; padding: 0; margin-bottom: 12px; display: block; }
.detail-name { font-size: 24px; font-weight: 700; margin: 0; }
.detail-monthly { color: var(--text-dim); font-size: 13px; margin: 4px 0 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 20px; text-align: center; margin-bottom: 20px;
}
.stat-value { color: var(--gold); font-size: 30px; font-weight: 700; }
.stat-label { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.stat-breakdown { color: var(--text-faint); font-size: 11px; margin-top: 12px; line-height: 1.5; }

.payment-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.payment-date { font-size: 15px; font-weight: 600; }
.payment-note { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.payment-amount { color: var(--emerald); font-size: 16px; font-weight: 700; text-align: right; }
.payment-running { color: var(--text-faint); font-size: 11px; text-align: right; margin-top: 2px; }

/* Floating action button */
.fab {
  position: fixed;
  right: max(20px, calc(50vw - 260px));
  bottom: 28px;
  width: 58px; height: 58px; border-radius: 29px;
  background: var(--gold); color: #1A1508;
  border: none; font-size: 30px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

/* Modal sheet */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 10;
}
.modal-sheet {
  background: var(--surface-raised);
  border-radius: 22px 22px 0 0;
  padding: 24px 20px 32px;
  width: 100%; max-width: 560px;
}
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 16px; }

@media (min-width: 601px) {
  .modal-backdrop { align-items: center; }
  .modal-sheet { border-radius: 22px; max-width: 420px; }
}
