/* Abo-Wächter – eigene Palette: Indigo #4338ca + Warnrot */
:root {
  --indigo-900: #1e1b4b;
  --indigo-700: #4338ca;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-300: #a5b4fc;
  --indigo-100: #e0e7ff;
  --warn: #dc2626;
  --warn-soft: #fee2e2;
  --warn-text: #991b1b;

  --bg: #f4f4fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7fd;
  --border: #e3e3f0;
  --text: #1f2030;
  --text-soft: #5b5d72;
  --text-faint: #8b8da3;
  --accent: var(--indigo-700);
  --accent-strong: var(--indigo-600);
  --shadow: 0 6px 24px rgba(67, 56, 202, .10);
  --shadow-lg: 0 16px 48px rgba(30, 27, 75, .22);
  --radius: 16px;
  --radius-sm: 10px;
  --ring: 0 0 0 3px rgba(99, 102, 241, .45);
}

[data-theme="dark"] {
  --bg: #14131f;
  --bg-soft: #1b1a29;
  --surface: #1f1e2e;
  --surface-2: #262539;
  --border: #34324a;
  --text: #ecebf6;
  --text-soft: #b3b2c8;
  --text-faint: #87859e;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --indigo-100: #2c2a4d;
  --warn: #f87171;
  --warn-soft: #3a1c20;
  --warn-text: #fca5a5;
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(129, 140, 248, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--indigo-700), var(--indigo-600));
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 16px;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, .16);
  border-radius: 13px;
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -.02em;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: .8rem;
  opacity: .85;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .18s ease, transform .18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .28); }
.icon-btn:active { transform: scale(.94); }

.theme-icon--moon { display: none; }
[data-theme="dark"] .theme-icon--sun { display: none; }
[data-theme="dark"] .theme-icon--moon { display: inline-grid; }

/* Main */
.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

/* Übersicht */
.overview {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card--primary {
  background: linear-gradient(140deg, var(--indigo-700), var(--indigo-500));
  border: none;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-card--primary .stat-label { color: rgba(255, 255, 255, .85); }
.stat-card--primary .stat-sub { color: rgba(255, 255, 255, .7); font-size: .78rem; }
.stat-label {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  font-weight: 600;
}
.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-top: 4px;
}
.stat-value-sm {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-top: 4px;
  color: var(--text);
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card--mini { padding: 13px 15px; }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar-meta {
  font-size: .85rem;
  font-weight: 600;
  color: var(--warn-text);
  background: var(--warn-soft);
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(67, 56, 202, .35);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }
.btn-danger {
  background: var(--warn);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.06); }

/* Liste */
.abo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.abo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
.abo-card.is-due {
  border-left-color: var(--warn);
  background: linear-gradient(180deg, var(--warn-soft), var(--surface) 55%);
}
.abo-main { flex: 1 1 200px; min-width: 0; }
.abo-name {
  font-size: 1.06rem;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.abo-meta {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  font-size: .82rem;
  color: var(--text-soft);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--indigo-100);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 600;
  font-size: .76rem;
  white-space: nowrap;
}
[data-theme="dark"] .tag { color: var(--indigo-300); }
.tag--due {
  background: var(--warn-soft);
  color: var(--warn-text);
}
.abo-amounts {
  flex: 0 0 auto;
  text-align: right;
  min-width: 110px;
}
.abo-year {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.abo-year-label {
  display: block;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  font-weight: 600;
}
.abo-month {
  margin-top: 4px;
  font-size: .82rem;
  color: var(--text-soft);
  white-space: nowrap;
}
.abo-actions {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 2px;
}
.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: .84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.mini-btn:hover { background: var(--border); color: var(--text); }
.mini-btn--danger:hover {
  background: var(--warn-soft);
  color: var(--warn-text);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: var(--indigo-100);
  color: var(--accent);
  margin-bottom: 16px;
}
[data-theme="dark"] .empty-icon { color: var(--indigo-300); }
.empty-state h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--text); }
.empty-state p { margin: 0; font-size: .92rem; max-width: 34ch; margin-inline: auto; }

/* Footer */
.app-footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 18px);
  color: var(--text-faint);
  font-size: .78rem;
}
.app-footer p { margin: 0; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 560px) {
  .modal { align-items: center; }
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 19, 31, .55);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.modal-card {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-width: 460px;
  border-radius: 22px 22px 0 0;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
}
@media (min-width: 560px) {
  .modal-card { border-radius: 22px; animation: pop .2s ease; }
}
.modal-card--sm { max-width: 380px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.icon-btn--close {
  background: var(--surface-2);
  color: var(--text-soft);
  width: 38px;
  height: 38px;
}
.icon-btn--close:hover { background: var(--border); color: var(--text); }

.confirm-text {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: .95rem;
}

/* Form */
.field { margin-bottom: 14px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 400px) {
  .field-row { grid-template-columns: 1fr; }
}
.field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input,
.field select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.field input::placeholder { color: var(--text-faint); }
.field-hint {
  display: block;
  margin-top: 5px;
  font-size: .76rem;
  color: var(--text-faint);
}
.field-error {
  display: block;
  margin-top: 5px;
  font-size: .78rem;
  color: var(--warn);
  font-weight: 600;
  min-height: 1em;
}
.field input.invalid { border-color: var(--warn); }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.modal-actions .btn { flex: 1 1 auto; min-width: 120px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%) translateY(20px);
  background: var(--indigo-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
[data-theme="dark"] .toast { background: var(--indigo-600); }
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Animationen */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
@keyframes pop { from { transform: scale(.95); opacity: .4; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* Fokus sichtbar generell */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.modal-backdrop:focus-visible { outline: none; }
