:root {
    --bg: #eef0f3;
    --panel: #ffffff;
    --ink: #1c2230;
    --muted: #6b7280;
    --line: #e2e5ea;

    --available: #1f9d55;
    --available-bg: #e8f7ee;
    --reserved: #b7791f;
    --reserved-bg: #fdf3df;
    --sold: #c0392b;
    --sold-bg: #fbeae8;
    --mine: #2563eb;
    --mine-bg: #eaf1ff;

    --header: #161b26;

    --font-display: -apple-system, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-display);
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

a { color: var(--mine); }

.topbar {
    background: var(--header);
    color: #f4f5f7;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar-title h1 { margin: 4px 0 0; font-size: 1.35rem; font-weight: 600; }
.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: #8b93a7;
    text-transform: uppercase;
}
.stats { font-family: var(--font-mono); font-size: 0.85rem; color: #d7dae2; }
.stats strong { font-weight: 700; }

main { padding: 24px; max-width: 1140px; margin: 0 auto; }

.buyer-bar {
    background: var(--panel);
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 1px 2px rgba(20, 25, 40, 0.06);
}
.buyer-bar input {
    padding: 7px 10px;
    border: 1px solid #cfd3da;
    border-radius: 6px;
    font-family: var(--font-display);
}
.buyer-bar input:focus-visible { outline: 2px solid var(--mine); outline-offset: 1px; }
.hint { color: var(--muted); font-size: 0.88rem; }

/* --- Jegyrács / "ticket stub" kártyák --- */
.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
}

.ticket {
    background: var(--panel);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(20, 25, 40, 0.08);
    border-left: 5px solid var(--line);
    overflow: hidden;
}
.ticket-available { border-left-color: var(--available); }
.ticket-reserved   { border-left-color: var(--reserved); }
.ticket-sold        { border-left-color: var(--sold); }
.ticket-mine { box-shadow: 0 0 0 2px var(--mine) inset, 0 1px 3px rgba(20,25,40,0.08); }

.ticket-top { padding: 14px 14px 10px; text-align: center; }
.seat {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
}
.badge-available { background: var(--available-bg); color: var(--available); }
.badge-reserved   { background: var(--reserved-bg);  color: var(--reserved); }
.badge-sold        { background: var(--sold-bg);       color: var(--sold); }

.price { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* perforáció a jegy "letörhető" törzse felett */
.perf {
    position: relative;
    border-top: 2px dashed var(--line);
    margin: 0 10px;
}
.perf::before, .perf::after {
    content: "";
    position: absolute;
    top: -7px;
    width: 14px; height: 14px;
    background: var(--bg);
    border-radius: 50%;
}
.perf::before { left: -17px; }
.perf::after  { right: -17px; }

.ticket-bottom { padding: 10px 14px 14px; text-align: center; }
.ticket button {
    width: 100%;
    padding: 8px;
    margin-top: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}
.ticket button:focus-visible { outline: 2px solid var(--mine); outline-offset: 2px; }
.btn-reserve { background: var(--available); color: #fff; }
.btn-pay { background: var(--mine); color: #fff; }
.btn-cancel { background: #e5e7eb; color: #374151; }
.countdown { font-family: var(--font-mono); font-size: 0.8rem; color: var(--reserved); margin-bottom: 2px; }
.sold-by { font-size: 0.8rem; color: var(--muted); }

.c-available { color: var(--available); }
.c-reserved { color: var(--reserved); }
.c-sold { color: var(--sold); }

/* --- Jegytípus-kártyák (Early Entry / Elővételes / Normál) --- */
section.section { margin-bottom: 26px; }
section.section > h2 {
    font-size: 1rem;
    margin: 0 0 12px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
section.section > h2 .muted { font-weight: 400; }

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.type-card {
    background: var(--panel);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(20, 25, 40, 0.08);
    border-top: 5px solid var(--available);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.type-card.sold-out { border-top-color: var(--sold); opacity: 0.85; }
.type-card h3 { margin: 0; font-size: 1.15rem; }
.type-price { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; }
.availability-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}
.availability-fill { height: 100%; background: var(--available); transition: width 0.3s; }
.type-card.sold-out .availability-fill { background: var(--sold); }
.availability-label { font-size: 0.82rem; color: var(--muted); font-family: var(--font-mono); }
.type-card button.btn-buy {
    margin-top: auto;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: var(--available);
    color: #fff;
}
.type-card button.btn-buy:disabled { background: #cbd1db; cursor: not-allowed; color: #6b7280; }
.type-card button:focus-visible { outline: 2px solid var(--mine); outline-offset: 2px; }
.sold-out-tag {
    align-self: flex-start;
    background: var(--sold-bg);
    color: var(--sold);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 9px;
    border-radius: 999px;
}
.sold-out-msg {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 10px 0;
}

/* Zárolt típus-kártya (olcsóbb elérhető, vagy foglalás blokkolja a sort) */
.type-card.locked {
    opacity: 0.55;
    filter: grayscale(30%);
    border-top-color: var(--line);
}
.type-card.sold-out {
    opacity: 0.55;
    filter: grayscale(50%);
    border-top-color: var(--sold);
}
.lock-msg {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    padding: 10px 4px;
    line-height: 1.4;
}

/* --- Checkout / fizetési összefoglaló panel --- */
.checkout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(22, 27, 38, 0.55);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.checkout-box {
    background: var(--panel);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.28);
    width: 100%;
    max-width: 480px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.checkout-box .checkout-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-size: 1.2rem;
}
.checkout-box .checkout-title .countdown-badge {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--reserved-bg);
    color: var(--reserved);
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
}
.checkout-box .checkout-title .countdown-badge.urgent {
    background: var(--sold-bg);
    color: var(--sold);
    animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

.checkout-items {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}
.checkout-items li {
    padding: 11px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}
.checkout-items li:last-child { border-bottom: none; }
.checkout-items .item-seat { font-family: var(--font-mono); font-weight: 700; }
.checkout-items .item-type { color: var(--muted); font-size: 0.8rem; }
.checkout-items .item-price { font-weight: 600; }

.checkout-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0 4px;
}
.checkout-total .total-label { color: var(--muted); font-weight: 400; }

.checkout-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.checkout-actions .btn-pay-all {
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--mine);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.01em;
}
.checkout-actions .btn-pay-all:hover { background: #1d4ed8; }
.checkout-actions .btn-cancel-all {
    padding: 13px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    color: #374151;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.checkout-actions .btn-cancel-all:hover { background: #f9fafb; }

.checkout-note {
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}
.qty-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.qty-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #cfd3da;
    background: #fff;
    font-size: 1.2rem;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    color: var(--ink);
}
.qty-btn:hover:not(:disabled) { background: #f1f2f5; }
.qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-btn:focus-visible { outline: 2px solid var(--mine); outline-offset: 2px; }
.qty-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
}

/* --- Saját jegyeim lista (foglalt / megvásárolt jegyek erre a session-re) --- */
.my-tickets-empty {
    color: var(--muted);
    font-size: 0.9rem;
    background: var(--panel);
    border-radius: 10px;
    padding: 16px;
}
.my-tickets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    padding: 12px 18px;
    border-radius: 8px;
    color: #fff;
    background: #333;
    transition: opacity 0.25s;
    max-width: 320px;
    font-size: 0.9rem;
}
.toast.success { background: var(--available); }
.toast.error { background: var(--sold); color: white; }
.toast.hidden { opacity: 0; pointer-events: none; }

footer { text-align: center; padding: 18px; color: var(--muted); font-size: 0.9rem; }

/* --- Admin --- */
.admin-page main { max-width: 1300px; }
.logout {
    color: #f4f5f7;
    text-decoration: none;
    background: #2a3142;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.settings-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.settings-panel form {
    background: var(--panel);
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(20,25,40,0.06);
}
.settings-panel h2 { margin: 0 0 10px; font-size: 0.95rem; }
.settings-panel label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 10px;
}
.settings-panel input {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 7px 9px;
    border: 1px solid #cfd3da;
    border-radius: 6px;
    font-family: var(--font-display);
}
.settings-panel button {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: var(--mine);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.btn-danger { background: var(--sold) !important; }

.type-manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.type-manage-card {
    background: var(--panel);
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(20,25,40,0.06);
}
.type-manage-card h3 { margin: 0 0 4px; font-size: 1rem; }
.type-manage-card .counts {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 10px;
}
.type-manage-card label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 8px;
}
.type-manage-card input {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 6px 9px;
    border: 1px solid #cfd3da;
    border-radius: 6px;
}
.type-manage-card .row-buttons { display: flex; gap: 6px; }
.type-manage-card button {
    flex: 1;
    padding: 7px;
    border: none;
    border-radius: 6px;
    background: var(--mine);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.82rem;
}

.table-panel, .log-panel {
    background: var(--panel);
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(20,25,40,0.06);
}
.table-panel h2, .log-panel h2 { margin-top: 0; font-size: 1rem; }
.muted { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
td:nth-child(1), td:nth-child(2), td:nth-child(6) { font-family: var(--font-mono); }
.row-available { background: var(--available-bg); }
.row-reserved   { background: var(--reserved-bg); }
.row-sold        { background: var(--sold-bg); }

.actions { display: flex; gap: 4px; flex-wrap: wrap; }
.actions button {
    padding: 5px 8px;
    border: 1px solid #d7dae2;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 0.78rem;
}
.actions button:hover { background: #f1f2f5; }
.actions .btn-danger { color: #fff; border: none; }

.log-panel ul { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow-y: auto; }
.log-panel li {
    padding: 6px 0;
    border-bottom: 1px solid #f1f2f4;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: #444;
}

/* --- Login --- */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--header); }
.login-form {
    background: var(--panel);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 280px;
}
.login-form h2 { margin: 2px 0 6px; }
.login-form input {
    padding: 9px 10px;
    border: 1px solid #cfd3da;
    border-radius: 6px;
}
.login-form button {
    padding: 9px;
    background: var(--mine);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.login-form p { font-size: 0.85rem; text-align: center; margin: 0; }
.error { color: var(--sold); font-size: 0.85rem; }

@media (max-width: 560px) {
    main { padding: 16px; }
    .topbar { padding: 14px 18px; }
}
