/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e17;
  --bg-card: #141925;
  --bg-card-hover: #1a2030;
  --bg-input: #1a2030;
  --bg-modal: #141925;
  --border: #1e2738;
  --text: #f0f2f5;
  --text-secondary: #8a93a6;
  --text-muted: #5a6478;
  --green: #00d084;
  --green-dim: rgba(0, 208, 132, 0.15);
  --red: #ff4d6a;
  --red-dim: rgba(255, 77, 106, 0.15);
  --blue: #4da6ff;
  --blue-dim: rgba(77, 166, 255, 0.15);
  --yellow: #ffc233;
  --purple: #a78bfa;
  --orange: #fb923c;
  --nav-height: 72px;
  --top-bar-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== LOGIN SCREEN ===== */
#screen-login {
  display: none;
  height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0a0e17 0%, #0f1a2e 50%, #0a0e17 100%);
}
#screen-login.active { display: flex; }

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--green), #00b874);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #0a0e17;
  margin-bottom: 16px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--green);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--green), #00b874);
  border: none;
  border-radius: 12px;
  color: #0a0e17;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* ===== TOP BAR ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-height);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), #00b874);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #0a0e17;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-card);
  border-radius: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--bg-card-hover); }

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== APP SHELL ===== */
#app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  flex: 1;
  overflow: hidden;
}
.screen.active { display: flex; }

#app-shell .screen {
  padding-top: var(--top-bar-height);
  padding-bottom: var(--nav-height);
}

.screen-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 24px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.screen-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===== HERO CARD (Net Worth) ===== */
.hero-card {
  background: linear-gradient(135deg, #141e30 0%, #1a2940 100%);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

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

.hero-amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.hero-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== STAT ROW ===== */
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card.income .stat-icon {
  background: var(--green-dim);
  color: var(--green);
}

.stat-card.expense .stat-icon {
  background: var(--red-dim);
  color: var(--red);
}

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

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

.stat-card.income .stat-value { color: var(--green); }
.stat-card.expense .stat-value { color: var(--red); }

/* ===== SECTIONS ===== */
.section {
  margin-bottom: 24px;
}

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

.section-header h3, .section-title {
  font-size: 16px;
  font-weight: 600;
}

.section-period {
  font-size: 12px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* ===== CATEGORY CHART ===== */
.category-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.cat-info { flex: 1; min-width: 0; }

.cat-name {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
}

.cat-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ===== TRANSACTION LIST ===== */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.txn-date-group {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 6px;
}

.txn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(30, 39, 56, 0.5);
}
.txn-item:last-child { border-bottom: none; }

.txn-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.txn-details { flex: 1; min-width: 0; }

.txn-desc {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-cat {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.txn-amount {
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.txn-amount.credit { color: var(--green); }
.txn-amount.debit { color: var(--text); }

.txn-bank-badge {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  text-align: right;
}

/* ===== FILTERS ===== */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.filter-select {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a93a6' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6 6.5-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ===== BUDGETS ===== */
.budget-summary {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.budget-total-bar {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}

.budget-total-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--green);
  transition: width 0.6s ease, background 0.3s;
}
.budget-total-fill.warning { background: var(--yellow); }
.budget-total-fill.danger { background: var(--red); }

.budget-total-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.budget-item {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
}

.budget-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.budget-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.budget-item-icon {
  font-size: 18px;
}

.budget-item-name {
  font-size: 14px;
  font-weight: 600;
}

.budget-item-amounts {
  text-align: right;
}

.budget-item-spent {
  font-size: 14px;
  font-weight: 600;
}

.budget-item-limit {
  font-size: 11px;
  color: var(--text-muted);
}

.budget-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.btn-secondary:active { background: var(--bg-card-hover); }

/* Budget Edit Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-modal);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  max-height: 70vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.budget-edit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.budget-edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.budget-edit-row span {
  font-size: 18px;
}

.budget-edit-row label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.budget-edit-row input {
  width: 100px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: right;
  outline: none;
}

/* ===== SUBSCRIPTIONS ===== */
.sub-summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.sub-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.sub-summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.sub-summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
}
.sub-summary-value.income { color: var(--green); }

.section-title {
  margin-bottom: 12px;
}

.subscription-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.sub-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg);
}

.sub-details { flex: 1; min-width: 0; }

.sub-name {
  font-size: 14px;
  font-weight: 600;
}

.sub-freq {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sub-amount {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.sub-amount.out { color: var(--red); }
.sub-amount.in { color: var(--green); }

/* ===== ACCOUNTS ===== */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.account-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.account-card[data-bank="raiffeisen"]::before { background: #FFE500; }
.account-card[data-bank="erste"]::before { background: #CC0000; }
.account-card[data-bank="aik"]::before { background: #003087; }

.account-bank {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.account-card[data-bank="raiffeisen"] .account-bank { color: #FFE500; }
.account-card[data-bank="erste"] .account-bank { color: #CC0000; }
.account-card[data-bank="aik"] .account-bank { color: #6699ff; }

.account-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.account-iban {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
  margin-bottom: 12px;
}

.account-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.account-balance {
  font-size: 22px;
  font-weight: 700;
}

.account-available {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-connect {
  width: 100%;
  padding: 16px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: 14px;
  color: var(--green);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-connect:active { background: var(--bg-card); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 8px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--green);
}

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 250;
  white-space: nowrap;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== SCROLLBAR ===== */
.screen-content::-webkit-scrollbar { width: 0; }

/* ===== RESPONSIVE: larger screens ===== */
@media (min-width: 481px) {
  .hero-amount { font-size: 42px; }
  .stat-value { font-size: 18px; }
}
