*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Montserrat', sans-serif;
  --white: #ffffff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e8eaed;
  --border-dark: #d0d4db;
  --text: #111318;
  --text-secondary: #6b7280;
  --text-hint: #9ca3af;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-dark: #1d4ed8;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo-mark { width: 36px; height: 36px; background: var(--text); color: var(--white); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: .05em; flex-shrink: 0; }
.logo-name { font-size: 14px; font-weight: 700; color: var(--text); }
.logo-sub  { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }
.sidebar-nav { padding: 10px 8px; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-secondary); text-decoration: none; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }
.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.avatar { width: 32px; height: 32px; background: var(--bg); border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }
.user-details { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-secondary); }
.logout-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; transition: background .12s, color .12s; }
.logout-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Main ── */
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px; min-height: 100vh; min-width: 0; }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub   { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; font-family: var(--font); cursor: pointer; border: 1px solid var(--border-dark); background: var(--white); color: var(--text); text-decoration: none; transition: background .12s; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--text); color: var(--white); border-color: var(--text); }
.btn-primary:hover { background: #2d3340; }
.btn-accent  { background: var(--accent); color: var(--white); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger  { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title  { font-size: 14px; font-weight: 700; }
.card-body   { padding: 20px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-hint); margin-top: 4px; }
.stat-live  { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--success); font-weight: 600; margin-top: 4px; }
.stat-live::before { content:''; width:6px; height:6px; border-radius:50%; background:var(--success); animation:pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.4} }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 0; }
thead th { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; text-align: left; background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.td-secondary { color: var(--text-secondary); font-size: 12px; }

/* ── Mobile cards (replace tables on mobile) ── */
.mobile-list { display: none; padding: 12px; }
.mobile-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.mobile-card:last-child { margin-bottom: 0; }
.mobile-card-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mobile-card-row { display: flex; justify-content: space-between; align-items: flex-start; font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.mobile-card-row:last-of-type { border-bottom: none; }
.mobile-card-row span:first-child { color: var(--text-secondary); flex-shrink: 0; }
.mobile-card-row span:last-child { text-align: right; font-weight: 500; }
.mobile-card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-blue  { background: var(--accent-light); color: var(--accent); border: 1px solid #bfdbfe; }
.badge-gray  { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-red   { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

/* ── Progress ── */
.progress { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 50px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
input[type="text"],input[type="email"],input[type="password"],input[type="number"],
input[type="datetime-local"],select,textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border-dark); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font); color: var(--text); background: var(--white); outline: none; transition: border-color .12s; }
input:focus,select:focus,textarea:focus { border-color: var(--accent); }
.form-hint  { font-size: 11px; color: var(--text-hint); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input[type="checkbox"] { width:16px; height:16px; cursor:pointer; flex-shrink:0; }
.form-check span { font-size: 13px; font-weight: 500; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }

/* ── Event selector ── */
.event-selector { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.event-selector label { margin: 0; white-space: nowrap; }
.event-selector select { flex: 1; max-width: 320px; }

/* ── Chart ── */
.chart-container { position: relative; height: 200px; width: 100%; overflow: hidden; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--white); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.15); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 20px; line-height: 1; padding: 4px; }
.modal-body   { padding: 20px 24px 24px; }

/* ── Scan ── */
.scan-layout { max-width: 480px; margin: 0 auto; }
.scan-mode-toggle { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 16px; }
.scan-mode-btn { flex:1; padding:9px; text-align:center; font-size:13px; font-weight:600; border-radius:var(--radius-sm); cursor:pointer; border:none; background:none; font-family:var(--font); color:var(--text-secondary); transition:all .15s; }
.scan-mode-btn.active { background: var(--white); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.scan-camera-wrap { position: relative; width: 100%; background: #111; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 16px; aspect-ratio: 1/1; max-height: 340px; display: flex; align-items: center; justify-content: center; }
.scan-camera-wrap video { width:100%; height:100%; object-fit:cover; display:block; }
.scan-camera-corners { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; pointer-events:none; }
.scan-camera-corners-inner { width:190px; height:190px; position:relative; }
.corner { position:absolute; width:30px; height:30px; border-color:#fff; border-style:solid; }
.corner-tl { top:0;left:0; border-width:3px 0 0 3px; border-radius:3px 0 0 0; }
.corner-tr { top:0;right:0; border-width:3px 3px 0 0; border-radius:0 3px 0 0; }
.corner-bl { bottom:0;left:0; border-width:0 0 3px 3px; border-radius:0 0 0 3px; }
.corner-br { bottom:0;right:0; border-width:0 3px 3px 0; border-radius:0 0 3px 0; }
.scan-status-bar { position:absolute; bottom:0;left:0;right:0; padding:8px 14px; background:rgba(0,0,0,.6); color:#fff; font-size:12px; font-weight:500; text-align:center; font-family:'Montserrat',sans-serif; }
.scan-result { border-radius:var(--radius-lg); padding:24px 20px; text-align:center; min-height:150px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; }
.scan-result.success { background:var(--success-bg); border:1px solid var(--success-border); }
.scan-result.error   { background:var(--danger-bg);  border:1px solid var(--danger-border); }
.scan-result.idle    { background:var(--bg);          border:1px solid var(--border); }
.scan-result-title   { font-size:16px; font-weight:700; }
.scan-result.success .scan-result-title { color:var(--success); }
.scan-result.error   .scan-result-title { color:var(--danger); }
.scan-result-table { text-align:left; width:100%; font-size:12px; margin-top:6px; }
.scan-result-table td { padding:3px 6px; }
.scan-result-table td:first-child { color:var(--text-secondary); font-weight:500; white-space:nowrap; }

/* ── Login ── */
.login-page  { min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--bg); padding:20px; }
.login-card  { background:var(--white); border:1px solid var(--border); border-radius:var(--radius-lg); padding:36px; width:100%; max-width:380px; box-shadow:var(--shadow); }
.login-logo  { text-align:center; margin-bottom:28px; }
.login-logo .logo-mark { margin:0 auto 10px; }
.login-logo-title { font-size:18px; font-weight:700; }
.login-logo-sub   { font-size:12px; color:var(--text-secondary); }

/* ── Event tabs ── */
.event-tabs { display:flex; gap:0; border-bottom:1px solid var(--border); padding:0 20px; }
.event-tab  { padding:12px 16px; font-size:13px; font-weight:600; color:var(--text-secondary); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; background:none; border-top:none; border-left:none; border-right:none; font-family:var(--font); transition:color .12s; }
.event-tab.active { color:var(--text); border-bottom-color:var(--text); }

/* ── Mobile topbar ── */
.mobile-topbar { display:none; position:fixed; top:0;left:0;right:0; height:var(--topbar-h); background:var(--surface); border-bottom:1px solid var(--border); padding:0 16px; align-items:center; justify-content:space-between; z-index:300; }
.hamburger { display:flex; flex-direction:column; justify-content:center; gap:5px; width:36px; height:36px; background:none; border:none; cursor:pointer; padding:6px; border-radius:var(--radius-sm); }
.hamburger span { display:block; height:2px; background:var(--text); border-radius:2px; transition:transform .2s,opacity .2s; }
.hamburger.open span:nth-child(1) { transform:translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity:0; }
.hamburger.open span:nth-child(3) { transform:translateY(-7px) rotate(-45deg); }
.sidebar-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:250; }
.sidebar-overlay.active { display:block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-topbar { display:flex; }

  .sidebar { top:0; left:0; height:100vh; transform:translateX(-100%); transition:transform .25s ease; z-index:400; }
  .sidebar.open { transform:translateX(0); box-shadow:4px 0 20px rgba(0,0,0,.15); }

  .main-content { margin-left:0 !important; padding:12px !important; padding-top:calc(var(--topbar-h) + 12px) !important; }

  /* 1 oszlopos stat grid mobilon */
  .stats-grid { grid-template-columns: 1fr 1fr; gap:10px; margin-bottom:14px; }
  .stat-value { font-size:22px; }
  .stat-card  { padding:12px 14px; }

  /* Grafikon */
  .chart-container { height:150px; }

  /* Form */
  .form-row, .form-row-3 { grid-template-columns:1fr; gap:0; }

  /* Táblázat elrejtése, kártyás lista megjelenítése */
  .desktop-table { display:none !important; }
  .mobile-list   { display:block; }

  /* Scan */
  .scan-layout { max-width:100%; }
  .scan-camera-wrap { max-height:260px; border-radius:var(--radius); }

  /* Page */
  .page-title { font-size:17px; }
  .page-header { margin-bottom:14px; }
  .card-header { padding:12px 16px; }
  .card-body   { padding:14px; }
  .card { border-radius:var(--radius); }

  /* Event selector */
  .event-selector { flex-direction:column; align-items:stretch; }
  .event-selector select { max-width:100%; }

  /* Modal */
  .modal { max-height:95vh; }
  .modal-body { padding:16px; }
}

/* ── Utility ── */
.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}
.flex{display:flex}.items-center{align-items:center}.gap-2{gap:8px}.gap-3{gap:12px}
.text-secondary{color:var(--text-secondary)}.text-sm{font-size:12px}.font-600{font-weight:600}
.w-full{width:100%}.text-right{text-align:right}
