/* Budget Profi — minimal CSS, mobile-first
   Design language inspired by the budget-profi.store product screenshots:
   pink/magenta accent, white background, card-based layout, pastel
   category colors (lavender, pink, cream, mint, light blue).
*/

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --muted-2: #999999;
  --primary: #e91e63;          /* pink 500 — accent / CTA */
  --primary-soft: #fce4ec;     /* pink 50 — backgrounds, hover */
  --primary-fg: #ffffff;
  --border: #ececec;
  --error: #d32f2f;
  --error-bg: #ffebee;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-sm: 6px;

  /* Pastel category colors (mirrors the spreadsheet columns in the screenshots) */
  --cat-lavender: #d1c4e9;
  --cat-pink:     #f8bbd0;
  --cat-cream:    #fff59d;
  --cat-mint:     #b2dfdb;
  --cat-blue:     #bbdefb;
  --cat-gray:     #e0e0e0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ----- top bar --------------------------------------------------------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--fg);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.brand-suffix { color: var(--primary); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: center;
  font-size: 0.95rem;
}
.nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
}
.nav a:hover { background: var(--bg-soft); }
.nav a.active { color: var(--primary); font-weight: 600; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted-2);
  font-size: 0.8rem;
}

/* ----- typography ----------------------------------------------------- */

h1 { font-size: 1.85rem; font-weight: 700; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.5rem; }
h3 { font-size: 1rem;    font-weight: 600; margin: 0 0 0.25rem; }
.lead { color: var(--muted); margin: 0 0 1.5rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.label-uppercase {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-2);
}

/* ----- auth pages ----------------------------------------------------- */

.auth-card {
  max-width: 400px;
  margin: 2.5rem auto;
  background: var(--card-bg);
  padding: 1.75rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.auth-card h1 { margin-top: 0; }

/* ----- forms --------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 0.85rem; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}
.form input, .form select, .form textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form .form-row { display: grid; gap: 0.85rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 540px) { .form .form-row { grid-template-columns: 1fr; } }

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

/* ----- buttons -------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: var(--primary-fg);
  text-decoration: none;
  transition: filter 0.1s, background 0.1s;
}
.btn:hover { filter: brightness(0.95); }
.btn-secondary {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-link {
  background: none;
  color: var(--primary);
  padding: 0.4rem 0.6rem;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.btn-danger { background: transparent; color: var(--error); padding: 0.4rem 0.6rem; }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.link-button {
  background: none;
  border: 0;
  padding: 0.25rem 0.5rem;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  text-decoration: underline;
}

.inline { display: inline; }

/* ----- alerts --------------------------------------------------------- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #ffcdd2; }

/* ----- generic cards -------------------------------------------------- */

.card {
  background: var(--card-bg);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ----- stat tile row (sum + count) ----------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 540px) { .stat-row { grid-template-columns: 1fr; } }
.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.stat-tile::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}
.stat-tile .stat-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-2);
  margin-bottom: 0.4rem;
}
.stat-tile .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
}
.stat-tile .stat-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

/* ----- account grid + cards ----------------------------------------- */

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.account-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-card);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.1s, box-shadow 0.1s;
}
.account-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.account-card .stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}
.account-card.archived { opacity: 0.55; }
.account-card .acct-type {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-2);
}
.account-card .acct-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}
.account-card .acct-balance {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg);
  margin-top: 0.25rem;
  letter-spacing: -0.01em;
}
.account-card .acct-balance .currency {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.2rem;
}
.account-card .acct-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}
.account-card .archived-tag {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted-2);
  background: var(--bg-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

/* pastel color helpers — used as .cat-lavender, .cat-pink, etc.
   Mapped per account type so each type has a recognizable accent
   (echoes the spreadsheet column colors in the budget-profi.store
   product screenshots: lavender/pink/cream/mint/blue). */
.cat-lavender { --cat-color: #b39ddb; }
.cat-pink     { --cat-color: #f48fb1; }
.cat-cream    { --cat-color: #ffd54f; }
.cat-mint     { --cat-color: #4db6ac; }
.cat-blue     { --cat-color: #64b5f6; }
.cat-gray     { --cat-color: #bdbdbd; }

/* type → pastel mapping (must match ALLOWED_TYPES in accounts.py) */
.cat-checking { --cat-color: #4db6ac; }  /* mint  — girokonto */
.cat-savings  { --cat-color: #64b5f6; }  /* blue  — sparkonto */
.cat-cash     { --cat-color: #ffd54f; }  /* cream — bargeld  */
.cat-credit   { --cat-color: #f48fb1; }  /* pink  — kreditkarte */
.cat-paypal   { --cat-color: #b39ddb; }  /* lavender — paypal */
.cat-other    { --cat-color: #bdbdbd; }  /* gray  — sonstiges */

/* category type → pastel (income = mint, expense = pink — same as the
   product screenshots' green-vs-pink budget column convention) */
.cat-income   { --cat-color: #4db6ac; }
.cat-expense  { --cat-color: #f48fb1; }

/* category tree: top-level cards in a grid, subcategories in indented rows below */
.category-tree {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.subcategory-list {
  /* span all grid columns + indent + slightly narrower */
  grid-column: 1 / -1;
  margin-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-left: 2px dashed var(--border);
  padding-left: 1rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 600px) {
  .subcategory-list { margin-left: 0.5rem; padding-left: 0.6rem; }
}
.subcategory-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  position: relative;
}
.subcategory-row.archived { opacity: 0.55; }
.subcategory-row .sub-stripe {
  width: 3px;
  align-self: stretch;
  background: var(--cat-color, var(--primary));
  border-radius: 2px;
  opacity: 0.6;
}
.subcategory-row .sub-info { flex: 1; min-width: 0; }
.subcategory-row .sub-name {
  font-weight: 600;
  color: var(--fg);
  font-size: 0.98rem;
}
.subcategory-row .sub-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.15rem;
}
.subcategory-row .sub-type {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted-2);
}
.subcategory-row .sub-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}

.account-card .stripe { background: var(--cat-color, var(--primary)); }

/* empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

/* ----- TODO list (placeholder dashboard) ----------------------------- */

.todo-list { list-style: none; padding: 0; }
.todo-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.todo-list li:last-child { border-bottom: 0; }
.todo-bullet { color: var(--muted); }
.todo-label { flex: 1; }
.todo-path {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
}

/* ----- transactions page -------------------------------------------- */

.stat-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 720px) {
  .stat-row-3 { grid-template-columns: 1fr; }
}

/* dashboard: 4 stat tiles (smaller) + 2-column layout below */
.stat-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 1000px) {
  .stat-row-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .stat-row-4 { grid-template-columns: 1fr; }
}
.stat-tile.stat-net::before    { background: #6a1b9a; }
.stat-tile.stat-net.negative .stat-value { color: #c62828; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
.dash-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;  /* allow flex children to shrink */
}

/* compact account list (per-account balance + monthly delta) */
.account-list-compact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.account-list-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}
.account-list-row .acct-stripe {
  width: 4px;
  align-self: stretch;
  background: var(--cat-color, var(--primary));
  border-radius: 2px;
}
.account-list-row .acct-info { flex: 1; min-width: 0; }
.account-list-row .acct-name {
  font-weight: 600;
  color: var(--fg);
  font-size: 0.98rem;
}
.account-list-row .acct-type {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted-2);
}
.account-list-row .acct-month-delta {
  text-align: right;
  min-width: 7rem;
}
.account-list-row .month-delta {
  font-weight: 600;
  font-size: 0.9rem;
}
.account-list-row .month-delta.income  { color: #00897b; }
.account-list-row .month-delta.expense { color: #c2185b; }
.account-list-row .acct-current-balance {
  text-align: right;
  font-weight: 700;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  min-width: 7rem;
  white-space: nowrap;
}
.account-list-row .acct-current-balance.negative { color: #c62828; }
.account-list-row .acct-current-balance .currency {
  font-size: 0.7em;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.15rem;
}

/* top-categories list with proportional bars */
.cat-share-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.cat-share-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cat-share-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
}
.cat-share-name { font-weight: 600; color: var(--fg); }
.cat-share-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #c2185b;
}
.cat-share-amount.income { color: #00897b; }
.cat-share-bar {
  position: relative;
  height: 10px;
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}
.cat-share-bar .cat-share-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--share, 0%);
  background: var(--bar-color, var(--primary));
  border-radius: 99px;
  transition: width 0.3s;
}
.cat-share-bar .cat-share-pct {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cat-share-meta { font-size: 0.78rem; }
.stat-tile.stat-income::before  { background: #4db6ac; }
.stat-tile.stat-expense::before { background: #f48fb1; }
.stat-tile.stat-balance::before { background: var(--primary); }
.stat-tile.negative .stat-value { color: #c62828; }
.stat-tile .stat-value .currency {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.2rem;
}

/* inline forms: filter + quick-add — flow as compact rows on wide screens */
.form-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.form-inline .form-actions { grid-column: 1 / -1; }

/* quick-add tx form: 2 rows of inline fields */
.tx-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.tx-form .tx-desc-label,
.tx-form .tx-notes-label {
  grid-column: span 2;
}
@media (max-width: 600px) {
  .tx-form .tx-desc-label,
  .tx-form .tx-notes-label { grid-column: 1 / -1; }
}
.tx-form .form-actions { grid-column: 1 / -1; }

/* transaction list table */
.tx-list-card { padding: 1rem 1.25rem; }
.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.tx-table th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-2);
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.tx-table th.num { text-align: right; }
.tx-table td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tx-table tr.tx-row:hover { background: var(--bg-soft); }
.tx-table .tx-row td:first-child {
  border-left: 3px solid var(--cat-color, var(--primary));
}
.tx-date { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-account { white-space: nowrap; }
.tx-category { color: var(--muted); font-size: 0.9rem; }
.tx-desc { min-width: 12rem; }
.tx-notes { color: var(--muted-2); font-size: 0.82rem; margin-top: 0.15rem; }
.tx-amount {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-amount.income  { color: #00897b; }
.tx-amount.expense { color: #c2185b; }
.tx-actions {
  white-space: nowrap;
  text-align: right;
}
.tx-actions form { display: inline; }
