/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #1e293b;
  background: rgba(15, 23, 42, 0.9);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 18px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-active {
  outline: 2px solid rgba(147, 197, 253, 0.55);
}

/* ---------- User chip ---------- */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 6px 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  background: #1f2937;
}

.avatar.fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-weight: 600;
  line-height: 1.1;
}

.user-role {
  font-size: 12px;
  color: #93c5fd;
  line-height: 1.1;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1200px;
  margin: 22px auto;
  padding: 0 16px;
}

.page-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.full-width { grid-column: 1 / -1; }

.card {
  background: #111827;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 16px;
}

.card h1, .card h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

/* ---------- Typography helpers ---------- */
.big {
  font-size: 20px;
  font-weight: 700;
}

.muted { color: #94a3b8; }

.small { font-size: 12px; }

/* ---------- Forms / Inputs ---------- */
.filters,
.entry-form,
.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filters { margin-bottom: 12px; }
.entry-form { align-items: flex-end; }
.inline-form { align-items: center; }

.filters label,
.entry-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

select,
input[type="date"],
input[type="datetime-local"],
input[type="text"] {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 150px;
}

.inline-form input[type="text"] { min-width: 240px; }

.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

.btn-primary {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.btn-secondary {
  background: #1f2937;
  color: white;
}

.btn-success {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}

.btn-danger {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

/* ---------- Flash messages ---------- */
.flash-list {
  margin-bottom: 14px;
  display: grid;
  gap: 8px;
}

.flash {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
}

.flash-success {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.45);
}

.flash-danger {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.45);
}

.flash-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
}

.flash-info {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.45);
}

/* ---------- Stats ---------- */
.stats-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

/* Optional: alte Karten weiterhin möglich */
.stats-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mini-card {
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #334155;
  background: #0b1220;
}

.mini-card.good { border-color: rgba(68, 199, 103, 0.55); }
.mini-card.evil { border-color: rgba(227, 79, 79, 0.55); }

.count {
  font-size: 28px;
  font-weight: 800;
}

.percent {
  font-size: 14px;
  color: #cbd5e1;
}

/* ---------- Chart ---------- */
.chart-wrap {
  margin-top: 12px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  min-height: 280px;
}

/* Chart kleiner */
.chart-wrap.chart-small {
  max-width: 560px;
  height: 340px;
  margin: 12px auto 0 auto;
}

/* ---------- Recent list ---------- */
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.recent-item {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1220;
}

/* ---------- Badges ---------- */
.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-good {
  background: rgba(68, 199, 103, 0.15);
  border: 1px solid rgba(68, 199, 103, 0.5);
  color: #86efac;
}

.badge-evil {
  background: rgba(227, 79, 79, 0.15);
  border: 1px solid rgba(227, 79, 79, 0.5);
  color: #fca5a5;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th,
.table td {
  border-bottom: none;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.table thead th { font-weight: 700; }

.table thead tr,
.table tbody tr {
  position: relative;
}

/* durchgehende Linie pro Zeile */
.table thead tr::after,
.table tbody tr::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #334155;
}

.table td .btn {
  position: relative;
  z-index: 1;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.role-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Quick add (Results) ---------- */
.quick-add {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.quick-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-field select,
.quick-field input {
  min-width: 240px;
}

.quick-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-btn {
  padding: 14px 18px;
  font-size: 16px;
  border-radius: 12px;
  min-width: 160px;
}

details.advanced {
  flex-basis: 100%;
  margin-top: 6px;
}

details.advanced summary {
  cursor: pointer;
  user-select: none;
  margin-top: 6px;
}

.advanced-row {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

/* ---------- Separators ---------- */
.sep {
  border: 0;
  border-top: 1px solid #334155;
  margin: 18px 0;
}

/* ---------- Date/Datetime: Icon sichtbar, Picker bleibt klickbar, kein “Breiterwerden” ---------- */
input[type="date"],
input[type="datetime-local"]{
  color-scheme: dark;

  /* eigenes helles Icon (ohne extra padding-right!) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e2e8f0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px 18px;
}

/* Hover: cyan + glow */
input[type="date"]:hover:not(:disabled),
input[type="datetime-local"]:hover:not(:disabled){
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

/* Native Indicator: unsichtbar, aber klickbar – und feste Breite, damit nix “auseinanderzieht” */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator{
  opacity: 0;
}

/* Wenn disabled (Ansicht "Gesamt"): Icon komplett ausblenden wie vorher */
input[type="date"]:disabled,
input[type="datetime-local"]:disabled{
  background-image: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .page-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .stats-head { flex-direction: column; }
  .stats-cards { grid-template-columns: 1fr; }
}