/* Eventtek Tickets – Karminrot-Theme */
:root {
  --primary: #960018;
  --primary-dark: #6e0012;
  --primary-darker: #48000b;
  --primary-light: #c4203c;
  --primary-tint: #fbecee;
  --primary-tint-2: #f3cfd5;
  --ink: #2b1a1f;
  --muted: #7d6870;
  --line: #e6dadd;
  --bg: #f7f3f4;
  --card: #ffffff;
  --ok: #1f8a4c;
  --info: #1f5fa8;
  --warn: #c99a06;
  --bad: #c0262d;
  --stolen: #6b2c91;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(72, 0, 11, .06), 0 4px 14px rgba(72, 0, 11, .07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--primary); }

/* ---------- Kopfzeile / Navigation ---------- */
.topbar {
  background: linear-gradient(180deg, #2a2a2a, #1e1e1e);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 9px 20px;
  flex-wrap: nowrap;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.brand { flex-shrink: 0; color: #fff; text-decoration: none; font-weight: 700; font-size: 20px; white-space: nowrap; letter-spacing: .2px; }
.brand small { font-weight: 400; opacity: .7; font-size: 14px; }
.brand-mark { color: var(--primary-light); }
.nav { display: flex; flex-wrap: nowrap; gap: 2px; align-items: center; flex: 1; white-space: nowrap; }
.nav a, .nav-dd-toggle {
  color: #fff; text-decoration: none; font: inherit; font-size: 15px; background: none; border: 0; cursor: pointer;
  padding: 7px 12px; border-radius: 6px; transition: background .15s; white-space: nowrap;
}
.nav a:hover, .nav-dd-toggle:hover { background: rgba(255,255,255,.10); }
.nav a.active, .nav-dd-toggle.active { background: var(--primary); }
.nav a.active:hover, .nav-dd-toggle.active:hover { background: var(--primary-light); }
.nav a.logout { margin-left: auto; opacity: .75; }
.nav-sep { width: 1px; height: 20px; background: rgba(255,255,255,.18); margin: 0 8px; }
.nav-dd { position: relative; }
.nav-dd-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; z-index: 60;
  background: #262626; border-radius: 8px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.nav-dd.open .nav-dd-menu { display: block; }
@media (hover: hover) and (min-width: 861px) { .nav-dd:hover .nav-dd-menu { display: block; } .nav-dd-menu::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; } }
.nav-dd-menu a { display: block; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 24px; margin-left: auto; cursor: pointer; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .nav-toggle { display: block; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; flex-wrap: wrap; }
  .nav-open .nav { display: flex; }
  .nav-sep { width: 100%; height: 1px; margin: 6px 0; }
  .nav-dd-toggle { display: none; }
  .nav-dd-menu { display: block; position: static; background: none; box-shadow: none; padding: 0; }
  .nav a.logout { margin-left: 0; }
}

/* ---------- Seite ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 22px 16px 60px; }
.page.wide { max-width: 1400px; }
.page-title { font-size: 24px; margin: 4px 0 18px; color: var(--primary-dark); }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px; border: 1px solid var(--line);
}
.card h2 { font-size: 17px; margin: 0 0 14px; color: var(--primary-dark); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Formulare ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=email],
input[type=password], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid #d6c7cb; border-radius: 7px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(150,0,24,.15);
}
textarea { min-height: 120px; resize: vertical; }
.grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 15px; }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; border: 0; border-radius: 7px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; margin-top: 16px; padding: 13px; font-size: 17px; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary-tint-2); }
.btn-ghost:hover { background: var(--primary-tint); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #961c22; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #166b3a; }
.btn-sm { padding: 6px 11px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Hinweise ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.alert-success { background: #e7f5ec; border-color: #b8e0c7; color: #14532d; }
.alert-error   { background: #fbe9ea; border-color: #f0bcc0; color: #7f1d1d; }
.alert-info    { background: var(--primary-tint); border-color: var(--primary-tint-2); color: var(--primary-dark); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 2px solid var(--line); padding: 8px 10px; white-space: nowrap; }
.tbl td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: middle; }
.tbl tr:hover td { background: #fcf8f9; }
.tbl input, .tbl select { padding: 6px 8px; font-size: 14px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-0 { background: #e7f5ec; color: var(--ok); }
.badge-1 { background: #e6eef8; color: var(--info); }
.badge-2 { background: #f1ecd9; color: #806200; }
.badge-8 { background: #f0e6f6; color: var(--stolen); }
.badge-3 { background: #fff4d6; color: #7a5600; }
.badge-cancel { background: #eee; color: #777; text-decoration: line-through; }

/* ---------- Kennzahlen ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; color: var(--primary-dark); line-height: 1.2; }
.stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- Filterleiste / Pagination ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { flex: 1 1 160px; }
.filters label { margin-top: 0; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.pagination a, .pagination span { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Scanner ---------- */
.scan-input { font-size: 22px !important; text-align: center; letter-spacing: .05em; padding: 14px !important; }
.result {
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  min-height: 230px; margin-top: 16px; border-radius: 12px; padding: 20px;
  font-size: 30px; font-weight: 800; color: #fff; background: #b9aeb1; transition: background .15s;
}
.result .code { font-size: 18px; font-weight: 600; opacity: .9; font-family: ui-monospace, Menlo, Consolas, monospace; }
.result .sub { font-size: 17px; font-weight: 500; opacity: .95; margin-top: 6px; }
.result.idle { background: #b9aeb1; }
.result.ok { background: var(--ok); }
.result.special { background: var(--info); }
.result.used { background: var(--bad); }
.result.invalid { background: var(--warn); color: #241a00; }
.result.stolen { background: var(--stolen); }
.result.error { background: #444; }
.result.sold { background: var(--primary); }
.counter-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.counter { font-size: 15px; color: var(--muted); }
.counter b { font-size: 22px; color: var(--primary-dark); }
#log { max-height: 340px; overflow-y: auto; font-size: 14px; }
#log .entry { padding: 6px 10px; border-left: 4px solid; margin-bottom: 4px; background: #faf6f7; border-radius: 0 6px 6px 0; }
#log .entry time { color: var(--muted); margin-right: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; }
#log .e-ok { border-color: var(--ok); } #log .e-special { border-color: var(--info); }
#log .e-used { border-color: var(--bad); } #log .e-invalid { border-color: var(--warn); }
#log .e-stolen { border-color: var(--stolen); } #log .e-error { border-color: #444; }
#log .e-sold { border-color: var(--primary); } #log .e-info { border-color: var(--line); }

/* Mobile Kamera */
#reader { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 10px; overflow: hidden; background: #111; }
#reader video { width: 100% !important; display: block; }

/* Login */
.login-box { max-width: 380px; margin: 60px auto; }

/* Druckansicht der Bestellbestätigung */
@media print {
  .topbar, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

/* ---------- PDF-Ansicht ---------- */
.pdf-modal { position: fixed; inset: 0; z-index: 5000; background: rgba(20, 10, 12, .6); display: flex; align-items: center; justify-content: center; padding: 20px; }
.pdf-modal[hidden] { display: none; }
.pdf-box { background: #fff; border-radius: 12px; width: min(1100px, 100%); height: 100%; display: flex; flex-direction: column; overflow: hidden; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.pdf-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pdf-bar b { color: var(--primary-dark); }
.pdf-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pdf-box iframe { flex: 1; border: 0; width: 100%; background: #525659; }
.pdf-loading { position: absolute; inset: 56px 0 0; display: flex; align-items: center; justify-content: center; color: #fff; background: #525659; font-weight: 600; pointer-events: none; }
@media (max-width: 600px) { .pdf-modal { padding: 0; } .pdf-box { border-radius: 0; } }

/* ---------- Tickets verwalten: kompakt, ohne Querscrollen ---------- */
form.inline { display: inline; }
.danger-text { color: var(--bad) !important; }
.tbl-tickets td.actions { text-align: right; white-space: nowrap; }
.tbl-tickets .edit-row td { background: var(--primary-tint); }
.tbl-tickets tbody.tk:hover td { background: #fcf8f9; }
.tbl-tickets tbody.tk .edit-row:hover td, .tbl-tickets tbody.tk:hover .edit-row td { background: var(--primary-tint); }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 14px; padding: 6px 4px 10px; }
.edit-grid > div { min-width: 0; }
.edit-grid label { margin: 6px 0 4px; }
.edit-grid input, .edit-grid select { width: 100%; height: 40px; padding: 6px 10px; font-size: 14px; box-sizing: border-box; }
.edit-grid .edit-btns { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; }
@media (max-width: 760px) { .edit-grid { grid-template-columns: 1fr; } .edit-grid .edit-btns { justify-content: stretch; } .edit-grid .edit-btns .btn { flex: 1; } }
@media (max-width: 1000px) {
  .tbl-tickets td.actions .btn { padding: 6px 8px; }
  .tbl-tickets [data-edit] { font-size: 0; } .tbl-tickets [data-edit]::before { content: "✎"; font-size: 14px; }
  .tbl-tickets .edit-btns [data-edit] { font-size: inherit; } .tbl-tickets .edit-btns [data-edit]::before { content: none; }
}
/* Handy: Zeilen als Karten */
@media (max-width: 760px) {
  .tbl-tickets thead { display: none; }
  .tbl-tickets, .tbl-tickets tbody, .tbl-tickets tr, .tbl-tickets td { display: block; width: 100%; }
  .tbl-tickets tbody.tk { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; display: block; }
  .tbl-tickets td { border: 0; padding: 4px 12px; text-align: left !important; }
  .tbl-tickets td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .tbl-tickets td.actions { padding: 8px 12px 12px; white-space: normal; }
  .tbl-tickets tr.edit-row[hidden] { display: none; }
}

/* Aktionsspalten dürfen umbrechen statt die Tabelle zu verbreitern */
.tbl td.actions { white-space: normal; }
.tbl td.actions .btn, .tbl td.actions form { margin: 2px 0 2px 2px; }

/* Alle Tabellen: auf dem Handy als Karten statt Querscrollen */
@media (max-width: 760px) {
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr.tbl-head { display: none; }
  .tbl.stack tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 0; }
  .tbl.stack td { border: 0; padding: 3px 12px; text-align: left !important; white-space: normal; }
  .tbl.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .tbl.stack td.actions { padding-top: 8px; }
  .tbl.stack td:empty { display: none; }
  .table-wrap { overflow-x: visible; }
}
.tbl code, .card code { word-break: break-all; }
/* lange Werte (URLs, E-Mails) umbrechen statt ins Nachbarfeld zu laufen */
.grid > div, .grid-2 > div { min-width: 0; overflow-wrap: anywhere; }
.tbl td code, .tbl td .small { overflow-wrap: anywhere; }
@media (max-width: 600px) { .btn { white-space: normal; text-align: center; } select { max-width: 100%; } }

/* Abschnittsüberschrift auf Seiten mit mehreren Bereichen */
.section-title { font-size: 19px; color: var(--primary-dark); margin: 28px 0 12px; scroll-margin-top: 70px; }
.section-title:first-of-type { margin-top: 4px; }

/* GiroCode-Test (Einstellungen) */
.gc-test summary { cursor: pointer; color: var(--primary); font-weight: 600; margin-top: 6px; }
.gc-wrap { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; align-items: flex-start; }
.gc-qr svg { width: 200px; height: 200px; display: block; border: 1px solid var(--line); border-radius: 6px; }
.gc-raw { background: #f7f2f3; padding: 8px 10px; border-radius: 6px; font-size: 12px; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
