@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0e14;
  --bg-elevated: #111520;
  --card: #151a28;
  --card-hover: #1b2236;
  --border: #1f2740;
  --border-light: #2a3352;
  --text: #e2e6f0;
  --text-muted: #6b7394;
  --accent-green: #00d68f;
  --accent-purple: #a855f7;
  --accent-red: #f43f5e;
  --accent-ff: #f43f5e;
  --accent-bd: #a855f7;
  --green: #00d68f;
  --yellow: #facc15;
  --red: #f43f5e;
  --purple: #a855f7;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Fira Code', 'Consolas', monospace;
  --radius: 10px;
  --glow-green: 0 0 20px rgba(0, 214, 143, 0.15);
  --glow-purple: 0 0 20px rgba(168, 85, 247, 0.15);
  --glow-red: 0 0 20px rgba(244, 63, 94, 0.15);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 230px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.sidebar-logo-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo-text span {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-top: -1px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  margin: 1px 0;
}

.sidebar nav a:hover {
  background: rgba(168, 85, 247, 0.06);
  color: var(--text);
  text-decoration: none;
}

.sidebar nav a.active {
  color: var(--text);
  border-left-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
}

.sidebar nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar nav a.active svg,
.sidebar nav a:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  margin-left: 230px;
  padding: 32px 40px;
  max-width: 1440px;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ===== Section Headers ===== */
.section-title {
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* ===== Cards / Kacheln ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-purple));
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.card:hover::before {
  opacity: 1;
}

.card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  font-weight: 600;
}

.card-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-value.ff { color: var(--accent-red); }
.card-value.bd { color: var(--accent-purple); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-paid { background: rgba(0, 214, 143, 0.12); color: var(--green); }
.badge-pending { background: rgba(250, 204, 21, 0.12); color: var(--yellow); }
.badge-cancelled { background: rgba(244, 63, 94, 0.12); color: var(--red); }

.badge-ff { background: rgba(244, 63, 94, 0.12); color: var(--accent-red); }
.badge-bd { background: rgba(168, 85, 247, 0.12); color: var(--accent-purple); }

.badge-stripe { background: rgba(99, 91, 255, 0.12); color: #818cf8; }
.badge-paypal { background: rgba(0, 156, 222, 0.12); color: #38bdf8; }
.badge-vorkasse { background: rgba(107, 115, 148, 0.12); color: var(--text-muted); }

/* ===== Table ===== */
.table-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-elevated);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color 0.15s;
}

th:hover {
  color: var(--accent-purple);
}

th.sorted-asc::after { content: ' \u25B2'; font-size: 9px; color: var(--accent-green); }
th.sorted-desc::after { content: ' \u25BC'; font-size: 9px; color: var(--accent-green); }

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tr:hover td {
  background: rgba(168, 85, 247, 0.03);
}

td.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* Summenzeile */
.totals-row td {
  font-weight: 600;
  background: rgba(0, 214, 143, 0.05);
  border-top: 2px solid var(--border-light);
  font-family: var(--mono);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-info {
  font-family: var(--mono);
  font-size: 12px;
}

.pagination-buttons {
  display: flex;
  gap: 5px;
}

.pagination-buttons button {
  background: var(--card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 13px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: all 0.15s;
}

.pagination-buttons button:hover:not(:disabled) {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--accent-purple);
}

.pagination-buttons button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.pagination-buttons button.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
  box-shadow: var(--glow-purple);
}

/* ===== Modal / Popup ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(244, 63, 94, 0.1);
}

.modal-section {
  margin-bottom: 24px;
}

.modal-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-purple);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.detail-item label {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-item span {
  font-family: var(--mono);
  font-size: 13px;
}

/* ===== Top Spenders List ===== */
.top-list {
  list-style: none;
}

.top-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.top-list .rank {
  font-family: var(--mono);
  color: var(--accent-green);
  width: 28px;
  font-weight: 600;
}

.top-list .name { flex: 1; }

.top-list .amount {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent-green);
}

/* ===== Loading / Error ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: 8px;
  padding: 16px;
  color: var(--red);
  font-size: 13px;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-box img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.login-box h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}

.login-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.login-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font);
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-purple);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.login-error.show {
  display: block;
}

/* ===== PWA Install Banner ===== */
.install-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border-light);
  padding: 16px 20px;
  z-index: 300;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.install-banner.show {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.install-banner-text {
  font-size: 13px;
  flex: 1;
}

.install-banner-text strong {
  display: block;
  margin-bottom: 2px;
}

.install-banner-text span {
  color: var(--text-muted);
  font-size: 12px;
}

.install-btn {
  padding: 8px 20px;
  background: var(--accent-purple);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
}

.install-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  line-height: 1;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }

  .sidebar-logo-text,
  .sidebar nav a span,
  .sidebar-footer {
    display: none;
  }

  .sidebar-logo {
    padding: 14px;
    justify-content: center;
  }

  .sidebar-logo img {
    width: 28px;
    height: 28px;
  }

  .sidebar nav a {
    justify-content: center;
    padding: 13px;
  }

  .main {
    margin-left: 60px;
    padding: 20px;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .modal {
    width: 95%;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Username clickable ===== */
.user-link {
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px dotted var(--text-muted);
  transition: color 0.15s;
}

.user-link:hover {
  color: var(--accent-purple);
  text-decoration: none;
}

/* ===== Sub-table in modal ===== */
.modal table { font-size: 12px; }
.modal th { font-size: 10px; }
.modal td { padding: 8px 12px; }
