* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --text: #1f2937;
  --text-muted: #6b7280;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* hidden-Attribut muss auch gegen display:flex-Regeln gewinnen */
[hidden] {
  display: none !important;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.hint {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */

button {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text);
}

button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
}

button.ghost:hover {
  background: var(--bg);
}

button.danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

button.danger-text {
  color: var(--danger);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  text-align: center;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-card button {
  margin-top: 1rem;
}

/* ---------- Formularelemente ---------- */

label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* ---------- Dashboard-Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 1.25rem;
}

/* ---------- Summenkarte ---------- */

.total-card {
  text-align: center;
}

.total-label {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.total-amount {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
}

.total-yearly {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Diagramm ---------- */

.chart {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chart-row {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  gap: 0.6rem;
}

.chart-label {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-track {
  background: var(--bg);
  border-radius: 6px;
  height: 20px;
  overflow: hidden;
}

.chart-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 6px;
}

.chart-amount {
  font-size: 0.9rem;
  text-align: right;
  color: var(--text-muted);
}

/* ---------- Abo-Liste ---------- */

.subscription-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.sub-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.sub-item:last-child {
  border-bottom: none;
}

.sub-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  background: var(--bg);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  color: var(--text-muted);
}

.badge.due {
  background: #fef3c7;
  color: #92400e;
}

.sub-price {
  font-size: 0.95rem;
}

.sub-meta,
.sub-notes {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sub-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---------- Empty State ---------- */

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
}

.empty-state p {
  margin-bottom: 0.5rem;
}

.empty-state button {
  margin-top: 0.75rem;
}

/* ---------- Dialoge ---------- */

dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  margin: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ---------- Banner ---------- */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fee2e2;
  color: #991b1b;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
}

.banner button {
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  padding: 0 0.3rem;
}

/* ---------- Mobil ---------- */

@media (max-width: 480px) {
  .sub-item {
    flex-direction: column;
  }

  .sub-actions {
    align-self: flex-end;
  }

  .chart-row {
    grid-template-columns: 80px 1fr 80px;
  }

  .total-amount {
    font-size: 2rem;
  }
}
