:root {
  --color-bg: #f5f6fa;
  --color-surface: #ffffff;
  --color-text: #1e2430;
  --color-muted: #6b7280;
  --color-border: #e2e5eb;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.topbar nav a {
  color: var(--color-text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.topbar nav a.active, .topbar nav a:hover { background: var(--color-bg); text-decoration: none; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

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

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-box .value { font-size: 1.6rem; font-weight: 700; color: var(--color-primary); }
.stat-box .label { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.25rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { color: var(--color-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn.danger { background: transparent; color: var(--color-danger); border-color: var(--color-danger); }
.btn.success { background: transparent; color: var(--color-success); border-color: var(--color-success); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
input[type=text], input[type=url], input[type=password], input[type=datetime-local], textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--color-text);
}
input:focus, textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.help-text { font-size: 0.78rem; color: var(--color-muted); margin-top: 0.25rem; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.archived { background: #f3f4f6; color: #6b7280; }
.badge.expired { background: #fee2e2; color: #991b1b; }

.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.qr-box { text-align: center; }
.qr-box canvas { max-width: 100%; height: auto; }

.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-bar input { flex: 1; min-width: 180px; }

.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.chart-bars .bar { flex: 1; background: var(--color-primary); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-bars-labels { display: flex; gap: 3px; font-size: 0.65rem; color: var(--color-muted); margin-top: 0.3rem; }
.chart-bars-labels span { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.copy-field { display: flex; gap: 0.4rem; }
.copy-field input { flex: 1; }

/* Responsive: Tabelle auf kleinen Screens als Karten darstellen */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  table thead { display: none; }
  table, table tbody, table tr, table td { display: block; width: 100%; }
  table tr { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 0.75rem; padding: 0.5rem; background: #fff; }
  table td { border-bottom: none; padding: 0.35rem 0.2rem; }
  table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--color-muted);
    font-weight: 600;
  }
}
