:root {
  --ndt-black: #111111;
  --ndt-text: #222222;
  --ndt-muted: #54595f;
  --ndt-accent: #610202;
  --ndt-red: #b30000;
  --ndt-red-bright: #f90000;
  --ndt-yellow: #ffd500;
  --ndt-white: #ffffff;
  --ndt-soft: #f2f2f2;
  --ndt-line: #e5e2e9;
  --radius: 12px;
  --font-display: "Inter", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --font-accent: "Syne", "Inter", sans-serif;
}

* { box-sizing: border-box; }

/* Fix: .shell { display:grid } must not override [hidden] */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ndt-text);
  background: var(--ndt-soft);
}

body.is-login {
  background:
    linear-gradient(180deg, rgba(17, 17, 17, 0.55), rgba(97, 2, 2, 0.72)),
    url("/brand/hero-ndt.jpg") center/cover no-repeat fixed;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.btn-primary {
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  background: var(--ndt-red);
  color: var(--ndt-white);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-primary:hover { background: var(--ndt-red-bright); }

/* Default action buttons in panels/tables */
.panel-head > button,
.toolbar > button:not(.btn-soft):not(.btn-ghost),
.row-actions > button:not(.btn-soft):not(.btn-ghost) {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--ndt-red);
  color: var(--ndt-white);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid var(--ndt-black);
  border-radius: 999px;
  padding: 12px 22px;
  background: transparent;
  color: var(--ndt-black);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.btn-soft {
  border: 1px solid var(--ndt-line);
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--ndt-white);
  color: var(--ndt-text);
  font-weight: 600;
  cursor: pointer;
}

.icon-btn {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--ndt-muted);
}

.error { color: var(--ndt-red); margin-top: 12px; font-weight: 600; }

/* —— Login —— */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.login-stage {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--ndt-white);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.login-visual {
  position: relative;
  min-height: 520px;
  background: #111;
  overflow: hidden;
}

.login-hero {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.88;
  display: block;
}

.login-spider {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 72px;
  height: auto;
  z-index: 2;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.login-panel {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-logo {
  width: 88px;
  height: auto;
  margin-bottom: 18px;
}

.login-kicker {
  margin: 0 0 8px;
  color: var(--ndt-red);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--ndt-black);
}

.login-sub {
  margin: 0 0 28px;
  color: var(--ndt-muted);
  line-height: 1.4;
}

.login-panel label,
.modal-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ndt-black);
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--ndt-line);
  background: var(--ndt-white);
  outline: none;
  color: var(--ndt-text);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ndt-red);
  box-shadow: 0 0 0 3px rgba(179, 0, 0, 0.12);
}

#login-form .btn-primary {
  width: 100%;
  margin-top: 8px;
}

/* —— App shell —— */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--ndt-soft);
}

.sidebar {
  padding: 22px 16px;
  border-right: 1px solid var(--ndt-line);
  background: var(--ndt-white);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.sidebar-brand img {
  width: 52px;
  height: auto;
}

.sidebar-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--ndt-black);
}

.sidebar-brand small {
  color: var(--ndt-muted);
  font-size: 0.8rem;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--ndt-muted);
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
}

.nav-btn.active,
.nav-btn:hover {
  color: var(--ndt-white);
  background: var(--ndt-red);
}

.logout {
  margin-top: auto;
  border: 1px solid var(--ndt-line);
  border-radius: 999px;
  background: transparent;
  color: var(--ndt-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  cursor: pointer;
}

.logout:hover {
  border-color: var(--ndt-red);
  color: var(--ndt-red);
}

.main { padding: 28px 32px 56px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--ndt-red);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: clamp(1.6rem, 2.5vw, 2.1rem);
  color: var(--ndt-black);
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }
.topbar select { width: auto; min-width: 220px; }

.view-root { display: grid; gap: 18px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--ndt-white);
  border: 1px solid var(--ndt-line);
}

.stat .label {
  color: var(--ndt-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .value {
  font-family: var(--font-accent);
  font-size: 2rem;
  margin-top: 8px;
  color: var(--ndt-red);
  line-height: 1;
}

.panel {
  border: 1px solid var(--ndt-line);
  border-radius: var(--radius);
  background: var(--ndt-white);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ndt-line);
}

.panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ndt-black);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ndt-line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--ndt-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td { background: #faf7f7; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--ndt-soft);
  color: var(--ndt-muted);
}

.badge.ok { background: #e8f6ee; color: #1f7a46; }
.badge.warn { background: #fff4d6; color: #8a6200; }
.badge.danger { background: #fde8e8; color: var(--ndt-red); }
.badge.info { background: #fff7cc; color: #7a5a00; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { padding: 7px 12px; font-size: 0.8rem; }

.empty {
  padding: 28px;
  color: var(--ndt-muted);
  text-align: center;
}

#modal {
  border: 1px solid var(--ndt-line);
  border-radius: 16px;
  padding: 0;
  background: var(--ndt-white);
  color: var(--ndt-text);
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

#modal::backdrop { background: rgba(17, 17, 17, 0.55); }

.modal-form header,
.modal-form footer,
#modal-body { padding: 16px 18px; }

.modal-form header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--ndt-line);
}

.modal-form header h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ndt-black);
}

.modal-form footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--ndt-line);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hint {
  color: var(--ndt-muted);
  font-size: 0.85rem;
  margin: 0 0 10px;
}

.card-serata {
  padding: 16px;
  border-bottom: 1px solid var(--ndt-line);
}

.card-serata:last-child { border-bottom: 0; }

.card-serata h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  color: var(--ndt-black);
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--ndt-muted);
  font-size: 0.9rem;
}

.mini-stats strong { color: var(--ndt-text); }

.pass-builder {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--ndt-line);
}

.pass-builder h4 {
  margin: 12px 0 8px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ndt-black);
}

.pass-builder h4:first-child { margin-top: 0; }

.pass-fields {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}

.pass-builder input[type="number"] {
  max-width: 120px;
}

.checkin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.checkin-scan {
  padding: 14px 16px 20px;
}

#qr-reader {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 12px;
  background: #111;
}

.checkin-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 520px;
  overflow: auto;
}

.checkin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ndt-line);
  border-radius: 10px;
  background: var(--ndt-soft);
}

.checkin-row.used {
  opacity: 0.65;
}

.checkin-row strong {
  display: block;
  color: var(--ndt-black);
}

.checkin-row small {
  display: block;
  color: var(--ndt-muted);
  margin: 2px 0 6px;
}

.checkin-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--ndt-line);
}

.checkin-result.ok {
  background: #e8f6ee;
  border-color: #b7e0c5;
}

.checkin-result.ko {
  background: #fde8e8;
  border-color: #f0b8b8;
}

.checkin-result strong {
  display: block;
  margin-bottom: 4px;
}

.checkin-result.ok strong { color: #1f7a46; }
.checkin-result.ko strong { color: var(--ndt-red); }

.live-panel .panel-head {
  align-items: center;
}

.live-dot {
  color: var(--ndt-red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.live-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ndt-red);
  margin-right: 6px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.progress-bar {
  height: 10px;
  margin: 0 16px 12px;
  border-radius: 999px;
  background: var(--ndt-soft);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--ndt-red);
  transition: width 0.4s ease;
}

@media (max-width: 900px) {
  .login-stage { grid-template-columns: 1fr; }
  .login-visual { min-height: 220px; }
  .login-panel { padding: 28px 22px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar nav {
    display: flex;
    overflow-x: auto;
    width: 100%;
    gap: 4px;
  }
  .nav-btn { white-space: nowrap; }
  .logout { margin-top: 0; margin-left: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .checkin-layout { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
