/* Design-Tokens ------------------------------------------------------ */

:root {
  color-scheme: dark;

  --bg:             #0a0a0a;
  --bg-elevated:    #161616;
  --bg-subtle:      #111111;
  --bg-hover:       #1f1f1f;

  --text:           #fafafa;
  --text-muted:     #a1a1aa;
  --text-subtle:    #71717a;

  --border:         #262626;
  --border-strong:  #3f3f46;

  --primary:        #6366f1;
  --primary-hover:  #818cf8;
  --primary-soft:   rgba(99, 102, 241, 0.16);

  --success:        #10b981;
  --success-soft:   rgba(16, 185, 129, 0.16);
  --warning:        #f59e0b;
  --warning-soft:   rgba(245, 158, 11, 0.16);
  --danger:         #f43f5e;
  --danger-soft:    rgba(244, 63, 94, 0.14);
  --abendkasse:      #ec4899;
  --abendkasse-soft: rgba(236, 72, 153, 0.16);
  --vip:             #a855f7;
  --vip-soft:        rgba(168, 85, 247, 0.16);

  --radius:         10px;
  --radius-sm:      7px;
  --radius-xs:      5px;

  --shadow-xs:      0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm:      0 2px 6px rgba(0, 0, 0, 0.5);
  --shadow-md:      0 8px 24px rgba(0, 0, 0, 0.6);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
*:focus { outline: none; }
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; border: 0; }

/* Brand ---------------------------------------------------------------*/

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
}
.brand-center { justify-content: center; display: flex; }
.brand-name { font-size: .92rem; }

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

.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem .95rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: background .1s ease, color .1s ease;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); text-decoration: none; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-xs); }
.btn-danger:hover { background: #e11d48; }

/* App layout -------------------------------------------------------- */

.app { min-height: 100vh; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .85rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Auth ---------------------------------------------------------------*/

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-card {
  width: min(360px, 92vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.auth-sub { margin: .5rem 0 1.5rem; color: var(--text-muted); font-size: .85rem; }
.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: .55rem .75rem;
  border-radius: var(--radius-xs);
  margin-bottom: 1rem;
  font-size: .82rem;
}
.auth-input {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-xs);
  margin-bottom: .75rem;
}
.auth-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-btn { width: 100%; padding: .7rem; font-size: .9rem; }
.auth-back {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .82rem;
}
.auth-back:hover { color: var(--text); }

/* Kontrollpanel --------------------------------------------------------*/

.panel-body { overflow: hidden; }

.panel {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

.panel-buttons {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(3, 1fr);
  height: 100%;
  width: 100%;
}
@media (min-width: 640px) and (orientation: landscape) {
  .panel-buttons { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }
}

.panel-tile {
  position: relative;
  height: 100%;
  width: 100%;
  border-top: 4px solid transparent;
}
@media (min-width: 640px) and (orientation: landscape) {
  .panel-tile { border-top: 0; border-left: 4px solid transparent; }
}
.panel-tile--frei       { border-color: var(--primary); }
.panel-tile--vvk         { border-color: var(--success); }
.panel-tile--oeticket    { border-color: var(--warning); }
.panel-tile--abendkasse  { border-color: var(--abendkasse); }

/* Abendkasse-Panel: nur ein Tile, fuellt den ganzen Screen */
.panel--single .panel-buttons {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.panel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 100%;
  width: 100%;
  border-radius: 0;
  background: var(--bg-elevated);
  border: 0;
  color: var(--text);
  transition: transform .08s ease, background .1s ease;
}
.panel-btn:active { transform: scale(.97); }
.panel-tile--frei .panel-btn:hover       { background: var(--primary-soft); }
.panel-tile--vvk .panel-btn:hover        { background: var(--success-soft); }
.panel-tile--oeticket .panel-btn:hover   { background: var(--warning-soft); }
.panel-tile--abendkasse .panel-btn:hover { background: var(--abendkasse-soft); }

.panel-btn-label { font-size: clamp(1.8rem, 5vw, 3.2rem); font-weight: 700; }
.panel-btn-count { font-size: clamp(3rem, 10vw, 6rem); font-weight: 700; font-variant-numeric: tabular-nums; }

.panel-minus {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  width: clamp(2.5rem, 6vw, 3.5rem);
  height: clamp(2.5rem, 6vw, 3.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.panel-minus:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.panel-minus:disabled { opacity: .3; }

.panel-undo {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: .9rem 1.8rem;
  border-radius: var(--radius);
  background: var(--danger);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 10;
}
.panel-undo:hover { background: #e11d48; }

/* Stations-Chip im Panel */
.panel-station {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .35rem .35rem .7rem;
  background: rgba(10, 10, 10, 0.72);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.panel-station-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.panel-station-switch {
  font-size: .78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: .25rem .6rem;
  border-radius: 999px;
  background: var(--bg-hover);
}
.panel-station-switch:hover { color: var(--text); }

/* Stations-Auswahl -------------------------------------------------- */

.station-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.station { width: min(760px, 100%); text-align: center; }
.station-title {
  margin: 1rem 0 1.75rem;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.station-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) {
  .station-grid { grid-template-columns: repeat(3, 1fr); }
}
.station-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 2rem 1rem;
  min-height: 8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 4px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  transition: transform .08s ease, background .1s ease, border-color .1s ease;
}
.station-btn:active { transform: scale(.98); }
.station-btn--kontrolle  { border-top-color: var(--primary); }
.station-btn--kontrolle:hover  { background: var(--primary-soft); }
.station-btn--abendkasse { border-top-color: var(--abendkasse); }
.station-btn--abendkasse:hover { background: var(--abendkasse-soft); }
.station-btn-label { font-size: 1.5rem; font-weight: 700; }
.station-btn-sub { font-size: .82rem; color: var(--text-muted); }

/* Admin-Ansicht ----------------------------------------------------- */

.admin-body { background: var(--bg); }
.admin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding: 2rem 1.5rem;
  text-align: center;
}

.admin-hero { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.admin-total {
  font-size: clamp(4.5rem, 16vw, 12rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.admin-total-label {
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.admin-cats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: min(1100px, 100%);
}
@media (min-width: 720px) {
  .admin-cats { grid-template-columns: repeat(5, 1fr); }
}
.admin-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 4px solid var(--border-strong);
  border-radius: var(--radius);
}
.admin-cat--frei       { border-top-color: var(--primary); }
.admin-cat--vvk         { border-top-color: var(--success); }
.admin-cat--oeticket    { border-top-color: var(--warning); }
.admin-cat--abendkasse  { border-top-color: var(--abendkasse); }
.admin-cat--vip          { border-top-color: var(--vip); }
.admin-cat-value {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.admin-cat-label {
  font-size: clamp(.8rem, 1.6vw, 1rem);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.admin-stations {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: min(900px, 100%);
}
@media (min-width: 720px) {
  .admin-stations { grid-template-columns: repeat(3, 1fr); }
}
.admin-station {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: left;
}
.admin-station-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin: 0 0 .75rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: .6rem;
}
.admin-station-sum {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.admin-station-rows { display: flex; flex-direction: column; gap: .4rem; }
.admin-station-row {
  display: flex;
  justify-content: space-between;
  font-size: .95rem;
}
.admin-station-row span:first-child { color: var(--text-subtle); }
.admin-station-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

.admin-logout {
  color: var(--text-subtle);
  text-decoration: none;
  font-size: .82rem;
}
.admin-logout:hover { color: var(--text); }

/* Bestätigungs-Dialog ------------------------------------------------ */

.dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 420px;
  width: 92vw;
  box-shadow: var(--shadow-md);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }

.dialog-form { display: flex; flex-direction: column; }

.dialog-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.dialog-header h2 {
  margin: 0;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dialog-body { padding: 1.25rem 1.5rem; }
.confirm-body { margin: 0; color: var(--text-muted); font-size: .9rem; line-height: 1.5; }

.dialog-footer {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .85rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.dialog-footer .spacer { flex: 1; }
