/* Abo-Tracker – gemeinsames Stylesheet fuer Login, Dashboard und Admin-Bereich */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --warning: #d97706;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #131c2e;
    --surface-2: #1a2438;
    --border: #2a3550;
    --text: #e6ecf7;
    --text-muted: #94a3b8;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e2749;
    --danger: #f87171;
    --danger-soft: #2a1a1f;
    --success: #34d399;
    --warning: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }

a {
  color: var(--accent);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.topbar nav {
  display: flex;
  gap: 0.35rem;
}

.topbar nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 550;
  font-size: 0.9rem;
}

.topbar nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topbar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Zwei gleich breite Karten nebeneinander, die unterhalb von ~700px umbrechen.
   Breite Datentabellen bekommen dagegen die volle Seitenbreite – bei sieben
   Spalten muesste man sonst innerhalb der Karte seitwaerts scrollen. */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  align-items: start;
  margin-top: 1.25rem;
}

/* Im Grid sorgt schon gap fuer den Abstand – der Geschwister-Margin von
   gestapelten Karten wuerde die zweite Spalte sonst nach unten versetzen. */
.split > .card + .card {
  margin-top: 0;
}

/* ---------- Karten ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
}

.card + .card {
  margin-top: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
}

.kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.kpi-note {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Tabelle ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-inactive td {
  opacity: 0.55;
}

.sub-name {
  font-weight: 600;
}

.sub-provider {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Badges & Punkte ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-admin {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.badge-inactive {
  color: var(--text-muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

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

button,
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

button:hover,
.btn:hover {
  background: var(--surface-2);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0.25rem;
  text-decoration: underline;
}

.btn-link:hover {
  background: none;
}

.actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
  white-space: nowrap;
}

/* ---------- Formulare ---------- */

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input,
select,
textarea {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

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

textarea {
  resize: vertical;
  min-height: 60px;
}

.field {
  margin-bottom: 0.85rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox input {
  width: auto;
}

.checkbox label {
  margin: 0;
  color: var(--text);
  font-weight: 500;
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar select {
  width: auto;
  min-width: 150px;
}

/* ---------- Meldungen ---------- */

.message {
  border-radius: 9px;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  margin-bottom: 0.9rem;
  border: 1px solid transparent;
}

.message-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.message-success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

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

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.auth-head {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-head .brand {
  justify-content: center;
  margin-bottom: 0.5rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}

.tabs button {
  border: none;
  background: transparent;
  padding: 0.45rem;
  border-radius: 8px;
  color: var(--text-muted);
}

.tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

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

.chart-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.chart-legend {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.legend-item .legend-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item .legend-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- Faelligkeiten ---------- */

.due-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.due-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.due-list li:last-child {
  border-bottom: none;
}

.due-date {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 78px;
  flex: none;
}

.due-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.due-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(520px, calc(100vw - 2rem));
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

dialog .dialog-body {
  padding: 1.25rem;
}

dialog .dialog-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

dialog .dialog-foot {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
