/* Gemeinsame Grundlagen. Farben/Schrift kommen als CSS-Variablen aus /theme.css (instance.json). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font, system-ui, sans-serif);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text, #001e46);
  background: var(--bg, #f6f5f1);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: .01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.upper { text-transform: uppercase; letter-spacing: .06em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grow { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  font: inherit; font-weight: 600; font-size: 1rem;
  border-radius: var(--radius, 8px); border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-text); }
.btn--primary:not(:disabled):hover { background: var(--accent); color: var(--primary); }
.btn--secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn--secondary:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }
.btn--highlight { background: var(--highlight); color: var(--highlight-text); }
.btn--highlight:not(:disabled):hover { filter: brightness(.95); color: var(--highlight-text); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:not(:disabled):hover { background: var(--danger); color: #fff; }
.btn--link { background: none; border: 0; color: var(--primary); text-decoration: underline; padding: 6px 4px; min-height: 0; font-weight: 500; }
.btn--block { width: 100%; }
.btn--small { min-height: 36px; padding: 6px 12px; font-size: .92rem; }
.btn__spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 50%; color: inherit; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-weight: 600; font-size: .95rem; }
.field__hint { font-size: .85rem; color: var(--muted); }
.field__error { font-size: .85rem; color: var(--danger); }
.input {
  font: inherit; font-size: 16px; /* verhindert iOS-Zoom */
  padding: 11px 12px; min-height: 46px; width: 100%;
  border: 1.5px solid var(--border); border-radius: var(--radius, 8px);
  background: var(--surface); color: var(--text);
}
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.input--area { min-height: 110px; resize: vertical; }
.field--error .input { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }

/* Hinweise */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius, 8px); border: 1px solid; font-size: .95rem; }
.notice__body { flex: 1; }
.notice__body > :last-child { margin-bottom: 0; }
.notice__close { background: none; border: 0; cursor: pointer; color: inherit; padding: 2px; }
.notice--info { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.notice--success { background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.notice--error { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.notice--warn { background: color-mix(in srgb, var(--highlight) 30%, var(--surface)); border-color: var(--highlight); }

/* Karten */
.card { background: var(--surface); border-radius: calc(var(--radius, 8px) + 2px); padding: 18px; box-shadow: 0 1px 2px rgba(0, 20, 50, .06), 0 0 0 1px rgba(0, 20, 50, .05); }

/* Sheet / Dialog */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 20, 40, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out;
}
.sheet {
  background: var(--surface); width: 100%; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; animation: slideup .2s ease-out; outline: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet__head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 20px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet__title { flex: 1; font-size: 1.15rem; margin: 0; }
.sheet__body { padding: 6px 20px 22px; }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 520px; border-radius: 14px; }
  .sheet--wide { max-width: 760px; }
}

/* Avatar */
.avatar { border-radius: 50%; object-fit: cover; flex: none; background: #fff; border: 2px solid rgba(255,255,255,.85); }
.avatar--initials { display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--primary) 12%, #fff); color: var(--primary); font-weight: 700; border-color: transparent; }
.ev .avatar--initials { background: rgba(255,255,255,.92); }

/* Spinner */
.spinner { display: flex; justify-content: center; padding: 32px; }
.spinner__dot { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); white-space: nowrap; }
.badge--success { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.badge--warn { background: color-mix(in srgb, var(--highlight) 45%, transparent); color: var(--primary); }
.badge--danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.badge--muted { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }

/* Tabs, Kontobewegungen */
.tabs { display: flex; gap: 6px; margin: 4px 0 18px; overflow-x: auto; }
.tab { flex: none; padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); font: inherit; font-weight: 600; color: var(--primary); cursor: pointer; }
.tab--active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.tx-plus { color: var(--success); font-weight: 700; }
.tx-minus { color: var(--danger); font-weight: 700; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(30px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
