:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1b2333;
  --muted: #7a8699;
  --border: #e7eaf0;
  --brand: #1c247a;
  --accent: #2563eb;
  --accent-d: #1d4ed8;
  --accent-soft: #eaf1ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --anna-bg: #e7f6ef;   --anna-tx: #0d7a4f;
  --moritz-bg: #eaf1ff; --moritz-tx: #2563eb;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 8px rgba(16,24,40,.05);
}
* { box-sizing: border-box; -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
/* Markieren/Kopieren nur in Eingabefeldern erlauben (wie SomniaPlaner) */
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; -moz-user-select: text; user-select: text; }
input, textarea, [contenteditable="true"] { cursor: text; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 780px; margin: 0 auto; padding: 18px 20px 80px; }

/* ---- Logo-Banner (scrollt beim Runterscrollen weg) ---- */
.logobar { text-align: center; padding: 22px 20px 16px; }
.logobar img { height: 110px; width: auto; mix-blend-mode: multiply; }

/* ---- sticky Toolbar als schwebende Navi-Karte (Variante C); etwas breiter als
   der Content -> Hierarchie (Header ueber Inhalt) ---- */
.topbar { position: sticky; top: 10px; z-index: 30; padding: 0 16px; }
.topbar-in {
  max-width: 860px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px; padding: 4px 14px; min-height: 52px;
}
.brand-name { color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; text-decoration: none; transition: .15s; }
.brand-name:hover { color: var(--accent); }
.tabs { display: flex; gap: 2px; margin-right: auto; }
.tab {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 14px 12px; border-bottom: 3px solid transparent; white-space: nowrap; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; padding: 8px; border-radius: 8px;
  color: var(--muted); text-decoration: none; background: transparent; border: none;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); }
.iconbtn svg { width: 19px; height: 19px; display: block; }
/* Controlbar-Icons (Imprimir/Exportar): umrandet wie "Hoy", damit sie sich abheben */
.cb-right .iconbtn { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.cb-right .iconbtn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

/* ---- control bar: Monatswechsler ZENTRIERT, Hoy rechts ---- */
.controlbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 18px 0 22px; }
.cb-right { justify-self: end; }
/* Monat exakt zentriert; Hoy haengt absolut rechts daneben (verschiebt den Monat nicht) */
.cb-center { justify-self: center; position: relative; display: inline-flex; align-items: center; }
.cb-hoy { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 10px; }

/* Monatswechsler: umrandete Gruppe (bordered) */
.monthnav { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.monthnav .m {
  display: inline-flex; align-items: center; justify-content: center; width: 140px; padding: 7px 0;
  font-size: 14px; font-weight: 700; text-transform: capitalize; white-space: nowrap;
}
.navchip {
  display: inline-flex; align-items: center; justify-content: center; width: 36px;
  color: var(--muted); text-decoration: none; font-size: 18px; line-height: 1; transition: .15s;
}
.navchip:first-child { border-right: 1px solid var(--border); }
.navchip:last-child { border-left: 1px solid var(--border); }
.navchip:hover { background: var(--accent-soft); color: var(--accent); }

/* "Hoy" — sekundaerer umrandeter Button */
.todaybtn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 650;
  color: var(--text); text-decoration: none; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); white-space: nowrap; transition: .15s;
}
.todaybtn:hover { background: var(--accent-soft); color: var(--accent); }
.todaybtn.disabled { opacity: .4; pointer-events: none; }

/* segmented (mes/trim/año/all) — bordered, Solid-Aktiv (fuer das spaetere Feature) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; border-left: 1px solid var(--border); white-space: nowrap; transition: .15s; }
.seg a:first-child { border-left: none; }
.seg a:hover { background: var(--accent-soft); color: var(--accent); }
.seg a.active { background: var(--accent); color: #fff; }
.page-title { margin: 0; font-size: 16px; font-weight: 700; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }
.pill.asist { background: #eef1f5; color: #54607a; }
.entry.inactive { opacity: .55; }

/* ---- summary cards ---- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card.accent { background: linear-gradient(135deg, var(--accent), #3b82f6); color: #fff; border-color: transparent; }
.card.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; border-color: transparent; }
.card.red { background: linear-gradient(135deg, #e2725b, #c0392b); color: #fff; border-color: transparent; }
.card.accent .label, .card.blue .label, .card.red .label { color: rgba(255,255,255,.85); }
.card .sub { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.card.accent .sub, .card.blue .sub, .card.red .sub { color: rgba(255,255,255,.82); }

/* Prozent-Anzeige (Anteil Anna) auf der Liquidación */
.pctrow { display: flex; gap: 14px; margin-bottom: 22px; }
.pct {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.pct-l { display: flex; flex-direction: column; gap: 2px; }
.pct-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.pct-range { font-size: 11px; color: var(--muted); }
.pct-val { font-size: 20px; font-weight: 750; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---- entries ---- */
.entries { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.entry { display: flex; align-items: center; gap: 14px; padding: 11px 18px; border-top: 1px solid var(--border); }
.entry:first-child { border-top: none; }
.entry.clickable { cursor: pointer; }
.entry.clickable:hover { background: #f7f9fc; }
.entry.is-last { background: #fff7e6; box-shadow: inset 3px 0 0 #f59e0b; }
.entry.clickable.is-last:hover { background: #ffefcf; }
.lasttag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #b45309; background: #fdebc8; padding: 2px 7px; border-radius: 999px; }
.entry .date { flex: 0 0 64px; color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.entry-by { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-weight: 400; font-size: 12px; }
.entry-by svg { width: 12px; height: 12px; }
.entry .who { flex: 0 0 auto; display: flex; align-items: center; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.pill.anna { background: var(--anna-bg); color: var(--anna-tx); }
.pill.moritz { background: var(--moritz-bg); color: var(--moritz-tx); }
.entry .name { flex: 1 1 auto; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .amount { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.entry .amount.neg { color: var(--danger); }
.entry-head { background: #f7f9fc; cursor: default; }
.entry-head .date, .entry-head .who, .entry-head .name, .entry-head .amount {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.entry-head .who { flex: 0 0 64px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Angemeldeter Nutzer im Header: Klartext, Link zum eigenen Profil */
.userchip { font-size: 14px; font-weight: 650; color: var(--text); white-space: nowrap; margin-right: 6px; text-decoration: none; cursor: pointer; transition: .15s; }
.userchip:hover { color: var(--accent); }
/* Inhalts-Aktionen (Print/Export) links in der Controlbar, beim Monats-Kontext */
.cb-left { justify-self: start; display: flex; align-items: center; gap: 2px; }
/* Angezeigtes Initial-/Reset-Passwort (einmalig fuer den Titular) */
.pw-shown { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--accent-soft); border: 1px solid #c9d9fb; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px; }
.pw-shown-l { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pw-code { font-size: 22px; font-weight: 800; letter-spacing: .08em; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent-d); }
/* Info im Bearbeiten-Dialog: wer/wann erfasst + wer/wann zuletzt bearbeitet */
.edit-info { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: var(--radius-s); padding: 9px 12px; margin-bottom: 16px; line-height: 1.55; }
.edit-info b { color: var(--text); font-weight: 650; }
/* Profil-Sidecard: getrennte Abschnitte E-Mail / Contraseña */
.profile-sec { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.profile-sec:last-of-type { border-bottom: none; }
.profile-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }

/* Vertragszeile: Periode zuerst, darunter die beschrifteten Konditionen */
.contract-main { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.contract-period { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.contract-terms { font-size: 13px; color: var(--muted); }
.contract-terms b { color: var(--text); font-weight: 650; }

/* ---- buttons ---- */
.addrow { margin-top: 18px; display: flex; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px;
  border-radius: var(--radius-s); font-size: 15px; font-weight: 650; border: none; cursor: pointer;
  text-decoration: none; font-family: inherit; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: #eef1f5; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-lg { padding: 13px 24px; font-size: 16px; }

/* ---- slide-over panel ---- */
.overlay { position: fixed; inset: 0; background: rgba(20,28,45,.45); opacity: 0; visibility: hidden; transition: .2s; z-index: 40; }
.overlay.open { opacity: 1; visibility: visible; }
.panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 400px; max-width: 92vw; background: var(--surface);
  box-shadow: -8px 0 30px rgba(16,24,40,.18); transform: translateX(100%); transition: transform .25s ease;
  z-index: 50; display: flex; flex-direction: column; padding: 24px;
}
.panel.open { transform: translateX(0); }
.panel h3 { margin: 0 0 18px; font-size: 19px; font-weight: 700; }
.profile-role { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; margin-bottom: 10px; }
.panel form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--border); border-radius: var(--radius-s);
  font-size: 15px; font-family: inherit; color: var(--text); background: var(--surface);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.panel-actions { display: flex; gap: 10px; margin-top: 4px; }
.panel-actions .btn-primary { flex: 1; }
#deleteWrap { margin-top: auto; }
.confirm { display: none; background: var(--danger-soft); border-radius: var(--radius-s); padding: 12px; margin-top: 10px; text-align: center; font-size: 14px; }
.confirm.show { display: block; }
.confirm .btn { margin-top: 8px; }

/* Export-Auswahl im Panel */
.export-opt {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-s); text-decoration: none;
  color: var(--text); font-weight: 650; margin-bottom: 10px;
}
.export-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.export-sub { color: var(--muted); font-weight: 500; font-size: 13px; }

/* ---- responsive ---- */
@media (max-width: 560px) {
  .summary { grid-template-columns: 1fr; }
  .entry .date { flex-basis: 52px; }
  .panel { width: 100%; }
  .controlbar { flex-wrap: wrap; }
  .topbar-in { gap: 10px; }
  .brand-name { display: none; }   /* Platz fuer Tabs; Identitaet kommt vom Logo-Banner */
  .pctrow { flex-direction: column; }
}

/* ---- Druckansicht (Liquidación) ---- */
@media print {
  body { background: #fff; }
  .topbar, .controlbar, .addrow, .overlay, .panel { display: none !important; }
  .logobar { padding: 0 0 8px; }
  .logobar img { height: 40px; mix-blend-mode: normal; }
  .app { max-width: 100%; padding: 8px 0 0; }
  .print-period { display: block !important; font-size: 16px; font-weight: 700; margin: 4px 0 16px; }
  .card { box-shadow: none; border: 1px solid #d9dce3; }
  .card.accent, .card.blue, .card.red { background: #fff !important; color: var(--text) !important; }
  .card.accent .label, .card.blue .label, .card.red .label { color: var(--muted) !important; }
  .card.accent .value, .card.blue .value, .card.red .value { color: var(--text) !important; }
  .card.accent .sub, .card.blue .sub, .card.red .sub { color: var(--muted) !important; }
  .entries { box-shadow: none; border: 1px solid #d9dce3; }
  .entry { break-inside: avoid; }
}
.print-period { display: none; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 360px; text-align: center; }
.login-card img { height: 110px; width: auto; margin-bottom: 10px; mix-blend-mode: multiply; }
.login-title { font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -.01em; margin-bottom: 20px; }
.login-card input, .login-card select {
  width: 100%; height: 46px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: var(--radius-s);
  font-size: 16px; font-family: inherit; text-align: center; background: var(--surface); color: var(--text);
}
.login-card input:focus, .login-card select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { margin-bottom: 16px; padding: 11px 14px; border-radius: var(--radius-s); background: var(--danger-soft); border: 1px solid #f3c2c2; color: var(--danger); font-size: 13.5px; font-weight: 600; text-align: center; }
.login-note { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--accent-soft); border: 1px solid #c9d9fb; color: var(--accent-d); font-size: 13.5px; font-weight: 600; line-height: 1.45; text-align: center; }
