/* =============================================================
   PIN Home-Pilot — Haupt-Stylesheet
   Farbpalette: #4F7CAC | #5BC0EB | #7ED7C1 | #FFD166
   ============================================================= */

/* --- CSS Variablen ------------------------------------------ */
:root {
  --c-primary:      #4F7CAC;
  --c-secondary:    #5BC0EB;
  --c-mint:         #7ED7C1;
  --c-yellow:       #FFD166;
  --c-sidebar-bg:   #1B2D42;
  --c-sidebar-hover:#243850;
  --c-sidebar-act:  #4F7CAC;
  --c-bg:           #F0F4F8;
  --c-surface:      #FFFFFF;
  --c-border:       #E2E8F0;
  --c-text:         #2D3748;
  --c-text-muted:   #718096;
  --c-danger:       #E53E3E;
  --c-danger-bg:    #FFF5F5;
  --c-success:      #38A169;
  --c-success-bg:   #F0FFF4;
  --c-warning:      #D69E2E;
  --c-warning-bg:   #FFFFF0;
  --c-positive:     #38A169;
  --c-negative:     #E53E3E;
  --sidebar-width:  240px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 2px 8px rgba(0,0,0,.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);
  --transition:     all .2s ease;
}

/* --- Reset & Base ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

/* --- Login Page --------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--c-sidebar-bg) 0%, #2A5298 60%, #4F7CAC 100%);
  padding: 1rem;
}
.login-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo svg { width: 56px; height: 56px; }
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-sidebar-bg);
  margin-top: .5rem;
}
.login-logo h1 span { color: var(--c-primary); }
.login-logo p { color: var(--c-text-muted); font-size: .85rem; }
.login-error {
  background: var(--c-danger-bg);
  border: 1px solid #FEB2B2;
  color: var(--c-danger);
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .875rem;
}

/* --- Layout ------------------------------------------------- */
.layout {
  display: flex;
  min-height: 100vh;
}
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--c-sidebar-bg);
}
.content-area {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* --- Sidebar ------------------------------------------------ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--c-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo svg { width: 40px; height: 40px; flex-shrink: 0; }
.brand-pin  { display: block; font-size: .65rem; font-weight: 700; color: var(--c-yellow); letter-spacing: .12em; text-transform: uppercase; }
.brand-name { display: block; font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-menu {
  flex: 1;
  padding: 1rem .75rem;
}
.menu-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
  padding: .5rem .5rem .25rem;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: .15rem;
}
.menu-item:hover {
  background: var(--c-sidebar-hover);
  color: #fff;
}
.menu-item.active {
  background: var(--c-sidebar-act);
  color: #fff;
}
.menu-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; }
.menu-icon svg { width: 18px; height: 18px; }
.menu-text { font-size: .875rem; font-weight: 500; }
.menu-divider { height: 1px; background: rgba(255,255,255,.08); margin: .75rem 0; }
.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { display: block; font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .7rem; color: rgba(255,255,255,.5); }
.logout-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.5);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { background: rgba(255,255,255,.1); color: var(--c-danger); }
.logout-btn svg { width: 16px; height: 16px; }

/* --- Cards -------------------------------------------------- */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--c-sidebar-bg);
}
.card-body { padding: 1.25rem; }
.card-body.no-pad { padding: 0; }

/* --- Stat Cards --------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: rgba(79,124,172,.12); color: var(--c-primary); }
.stat-icon.sky    { background: rgba(91,192,235,.12); color: var(--c-secondary); }
.stat-icon.mint   { background: rgba(126,215,193,.12); color: #2E9E88; }
.stat-icon.yellow { background: rgba(255,209,102,.15); color: #C68B00; }
.stat-icon.red    { background: rgba(229,62,62,.1);   color: var(--c-danger); }
.stat-info {}
.stat-label { font-size: .75rem; font-weight: 500; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--c-sidebar-bg); line-height: 1.2; margin-top: .15rem; }
.stat-value.positive { color: var(--c-positive); }
.stat-value.negative { color: var(--c-negative); }

/* --- Tables ------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--c-bg);
  padding: .65rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(79,124,172,.04); }
.amount-positive { color: var(--c-positive); font-weight: 600; }
.amount-negative { color: var(--c-negative); font-weight: 600; }
.amount-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--c-primary);   color: #fff; }
.btn-primary:hover   { background: #3D6A99; }
.btn-secondary { background: var(--c-secondary); color: #fff; }
.btn-secondary:hover { background: #46AEDD; }
.btn-success   { background: var(--c-success);   color: #fff; }
.btn-success:hover   { background: #2F8A5C; }
.btn-danger    { background: var(--c-danger);    color: #fff; }
.btn-danger:hover    { background: #C53030; }
.btn-warning   { background: var(--c-yellow);    color: var(--c-sidebar-bg); }
.btn-warning:hover   { background: #EFC055; }
.btn-outline {
  background: transparent;
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
}
.btn-outline:hover { background: rgba(79,124,172,.08); }
.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
}
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { padding: .45rem; }
.btn-icon.btn-danger { background: var(--c-danger-bg); color: var(--c-danger); border: none; }
.btn-icon.btn-danger:hover { background: var(--c-danger); color: #fff; }
.btn-icon.btn-primary { background: rgba(79,124,172,.1); color: var(--c-primary); border: none; }
.btn-icon.btn-primary:hover { background: var(--c-primary); color: #fff; }

/* --- Forms -------------------------------------------------- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}
.form-control {
  display: block;
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s ease;
  outline: none;
}
.form-control:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(79,124,172,.12); }
.form-control.error { border-color: var(--c-danger); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* --- Badges ------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-primary { background: rgba(79,124,172,.12);  color: var(--c-primary); }
.badge-sky     { background: rgba(91,192,235,.15);  color: #2080B0; }
.badge-mint    { background: rgba(126,215,193,.2);  color: #2E9E88; }
.badge-yellow  { background: rgba(255,209,102,.2);  color: #C68B00; }
.badge-red     { background: rgba(229,62,62,.1);    color: var(--c-danger); }
.badge-green   { background: rgba(56,161,105,.1);   color: var(--c-success); }
.badge-gray    { background: var(--c-bg);            color: var(--c-text-muted); }
.badge-ausgabe { background: rgba(229,62,62,.08); color: var(--c-danger); }
.badge-einnahme{ background: rgba(56,161,105,.08); color: var(--c-success); }

/* --- Modals ------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--c-sidebar-bg); }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--c-text-muted);
  transition: var(--transition);
  font-size: 1.2rem;
  line-height: 1;
}
.modal-close:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

/* --- Alerts ------------------------------------------------- */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: .15rem; }
.alert-danger  { background: var(--c-danger-bg);  color: var(--c-danger);  border: 1px solid #FEB2B2; }
.alert-success { background: var(--c-success-bg); color: var(--c-success); border: 1px solid #9AE6B4; }
.alert-warning { background: var(--c-warning-bg); color: var(--c-warning); border: 1px solid #F6E05E; }
.alert-info    { background: rgba(91,192,235,.1); color: #2080B0; border: 1px solid rgba(91,192,235,.3); }

/* --- Account Cards ------------------------------------------ */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.account-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.account-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--acc-color, var(--c-primary));
}
.account-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.account-card.selected { border-color: var(--acc-color, var(--c-primary)); }
.acc-type-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-text-muted);
  margin-bottom: .5rem;
}
.acc-name { font-size: 1rem; font-weight: 700; color: var(--c-sidebar-bg); }
.acc-bank { font-size: .8rem; color: var(--c-text-muted); margin-top: .1rem; }
.acc-balance {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: .75rem;
  font-variant-numeric: tabular-nums;
}
.acc-balance.positive { color: var(--c-positive); }
.acc-balance.negative { color: var(--c-negative); }
.acc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .5rem;
  font-size: .75rem;
  color: var(--c-text-muted);
}
.acc-actions {
  display: flex;
  gap: .4rem;
  margin-top: .75rem;
}

/* --- Charts ------------------------------------------------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.chart-wrap { position: relative; }
canvas { max-width: 100%; }

/* --- Upload Zone ------------------------------------------- */
.upload-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--c-primary);
  background: rgba(79,124,172,.04);
  color: var(--c-primary);
}
.upload-zone svg { width: 36px; height: 36px; margin-bottom: .5rem; opacity: .6; }
.upload-zone p { font-size: .875rem; }
.upload-zone strong { color: var(--c-primary); }

/* --- Categorie Table --------------------------------------- */
.cat-badge {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-weight: 500;
}
.cat-ausgabe-var  { background: rgba(229,62,62,.08);  color: #C53030; }
.cat-ausgabe-fix  { background: rgba(229,62,62,.15);  color: #9B2C2C; }
.cat-ausgabe-sond { background: rgba(255,209,102,.2); color: #C68B00; }
.cat-einnahme-var { background: rgba(56,161,105,.08); color: #276749; }
.cat-einnahme-fix { background: rgba(56,161,105,.15); color: #22543D; }
.cat-einnahme-sond{ background: rgba(91,192,235,.15); color: #2080B0; }

/* --- Settings --------------------------------------------- */
.settings-top {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .5rem 0;
}
.settings-row + .settings-row {
  border-top: 1px solid var(--c-border);
  margin-top: .5rem;
  padding-top: 1rem;
}

/* --- Filter Bar -------------------------------------------- */
.filter-bar {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.filter-bar label { font-size: .8rem; font-weight: 600; color: var(--c-text-muted); white-space: nowrap; }
.filter-bar .form-control { width: auto; min-width: 140px; }

/* --- Empty State ------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--c-text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: .35; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--c-text); margin-bottom: .35rem; }
.empty-state p { font-size: .875rem; }

/* --- Toast ------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  background: var(--c-sidebar-bg);
  color: #fff;
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: .6rem;
  pointer-events: all;
  animation: toastIn .25s ease;
  max-width: 360px;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { background: var(--c-success); }
.toast.error   { background: var(--c-danger); }
.toast.warning { background: var(--c-warning); color: var(--c-sidebar-bg); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* --- Loading spinner --------------------------------------- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  border-radius: var(--radius);
}
.loading-overlay .spinner { border-color: rgba(79,124,172,.3); border-top-color: var(--c-primary); width: 32px; height: 32px; }

/* --- Misc -------------------------------------------------- */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
hr { border: none; border-top: 1px solid var(--c-border); margin: 1rem 0; }
.tag-steuer { font-size: .7rem; background: rgba(255,209,102,.2); color: #C68B00; padding: .1rem .4rem; border-radius: 4px; font-weight: 600; }
