:root {
  --bg: #0d1117;
  --bg-2: #161b22;
  --panel: #1a2230;
  --panel-2: #212c3d;
  --border: #2a3548;
  --text: #e6edf3;
  --muted: #8b97a8;
  --accent: #4f8cff;
  --accent-2: #36d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --biz: #4f8cff;
  --priv: #c084fc;
  --fin: #36d399;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #18243a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0 0 .2em; font-weight: 700; }
.muted { color: var(--muted); font-size: .9rem; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 340px; text-align: center;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 44px; }
.login-card h1 { margin-top: 8px; }
.login-card form { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
.login-card input, .login-card button { padding: 12px 14px; border-radius: 10px; font-size: 1rem; }
.login-card input { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); }
.login-card button { background: var(--accent); color: #fff; border: none; font-weight: 600; }
.login-card .error { color: var(--danger); font-size: .85rem; min-height: 1em; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px; background: rgba(13,17,23,.8); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.3rem; }
.tabs { display: flex; gap: 6px; margin-left: 10px; flex-wrap: wrap; }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font-size: .92rem; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: #fff; background: var(--accent); }
.user-menu { margin-left: auto; display: flex; gap: 8px; }
.logout {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 8px 14px; border-radius: 9px;
}
.logout:hover { color: var(--text); border-color: var(--muted); }
.modal-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.modal-hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.modal-msg { font-size: .85rem; min-height: 1em; margin-top: 4px; }
.modal-msg.ok { color: var(--accent-2); }
.modal-msg.err { color: var(--danger); }

/* ---------- Layout ---------- */
#app { max-width: 1080px; margin: 0 auto; padding: 26px 22px 80px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.primary { background: var(--accent); color: #fff; border: none; padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 10px 16px; border-radius: 10px; }

/* ---------- Hero ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  background: linear-gradient(135deg, #1b2942, #16203a);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 20px;
}
.hero-label { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--accent); font-weight: 700; }
.hero h1 { font-size: 1.6rem; margin: 6px 0; }
.hero-ring { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.ring { transform: rotate(-90deg); width: 120px; height: 120px; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent-2); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .8s ease; }
.ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; }

/* ---------- Section heads & Hero-Area (Hauptgoals) ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 14px; }
.hero-area { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 20px; }
.hero-card {
  display: flex; align-items: center; gap: 18px; cursor: pointer;
  background: linear-gradient(135deg, #1b2942, #16203a);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 20px 22px;
  transition: transform .15s ease, border-color .15s ease;
}
.hero-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.hero-card.cat-business { border-left-color: var(--biz); }
.hero-card.cat-privat { border-left-color: var(--priv); }
.hero-card.cat-finanzen { border-left-color: var(--fin); }
.hero-card.done { opacity: .6; }
.ring-wrap { position: relative; flex-shrink: 0; line-height: 0; }
.ring-wrap .ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; }
.hero-card-body { min-width: 0; }
.hero-card-title { font-size: 1.25rem; font-weight: 800; margin: 4px 0; }
.hero-cta { grid-column: 1/-1; text-align: center; padding: 34px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.hero-cta button { margin-top: 12px; }

/* ---------- KPI cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.card .k-label { color: var(--muted); font-size: .8rem; }
.card .k-value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.card .k-sub { font-size: .78rem; margin-top: 4px; }
.up { color: var(--accent-2); } .down { color: var(--danger); }

/* ---------- Breakdown bars ---------- */
.breakdown { display: flex; flex-direction: column; gap: 12px; }
.bd-row { display: flex; flex-direction: column; gap: 5px; }
.bd-top { display: flex; justify-content: space-between; font-size: .88rem; }
.bd-track { height: 9px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.bd-fill { height: 100%; border-radius: 6px; background: var(--accent); transition: width .6s ease; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 14px;
}
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; }
.row .r-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.row .r-amount { font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.tag.saas, .tag.business { background: rgba(79,140,255,.16); color: #7fb0ff; }
.tag.wartung, .tag.finanzen { background: rgba(54,211,153,.16); color: #5fe0b0; }
.tag.sonstige, .tag.privat { background: rgba(192,132,252,.16); color: #d0a8ff; }
.tag.inactive { background: rgba(139,151,168,.16); color: var(--muted); }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 1rem; padding: 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--bg-2); }

.mrr-summary {
  display: flex; align-items: center; gap: 20px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; flex-wrap: wrap;
}
.mrr-summary .big { font-size: 2rem; font-weight: 800; }
.mrr-summary .bd-track { flex: 1; min-width: 180px; height: 12px; }

/* ---------- Goals ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--muted); padding: 6px 14px; border-radius: 20px; font-size: .85rem; font-weight: 600; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.goal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; border-left: 3px solid var(--accent);
}
.goal-card.cat-business { border-left-color: var(--biz); }
.goal-card.cat-privat { border-left-color: var(--priv); }
.goal-card.cat-finanzen { border-left-color: var(--fin); }
.goal-card.done { opacity: .6; }
.goal-card .gc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.goal-card .gc-title { font-weight: 700; font-size: 1.05rem; }
.goal-card .gc-deadline { font-size: .8rem; color: var(--muted); }
.goal-card .gc-deadline.soon { color: var(--warn); }
.goal-card .gc-deadline.over { color: var(--danger); }
.milestones { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.ms { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.ms input { accent-color: var(--accent-2); }
.ms.done span { text-decoration: line-through; color: var(--muted); }
.gc-actions { display: flex; gap: 6px; margin-top: auto; }
.gc-notes { font-size: .85rem; color: var(--muted); white-space: pre-wrap; }

/* ---------- Finance bars ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; overflow-x: auto; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 46px; }
.bar-stack { display: flex; flex-direction: column-reverse; justify-content: flex-end; height: 140px; width: 28px; gap: 2px; }
.bar { width: 28px; border-radius: 4px 4px 0 0; }
.bar.inc { background: var(--accent-2); }
.bar.exp { background: var(--danger); }
.bar-label { font-size: .72rem; color: var(--muted); }

.upcoming { display: flex; flex-direction: column; gap: 8px; }
.up-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.up-row:last-child { border-bottom: none; }

.empty { color: var(--muted); text-align: center; padding: 30px; font-size: .95rem; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); width: 460px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 1.1rem; }
#modalForm { padding: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; background: var(--bg-2);
  border: 1px solid var(--border); color: var(--text); font-size: .95rem; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.ms-editor { display: flex; flex-direction: column; gap: 6px; }
.ms-edit-row { display: flex; gap: 6px; }
.ms-edit-row input[type=text] { flex: 1; }
.ms-add { font-size: .85rem; color: var(--accent); background: none; border: none; align-self: flex-start; padding: 4px 0; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
