:root {
    --font: 'Inter', 'Tajawal', system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --font-display: 'PlusJakartaSans', 'Inter', 'Tajawal', system-ui, sans-serif;

    --bg: #f7f9fc;
    --bg-grad: radial-gradient(1200px 600px at 90% -10%, rgba(79, 70, 229, .14), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(6, 182, 212, .10), transparent 55%), var(--bg);
    --surface: #ffffff;
    --surface-2: #eef3fb;
    --surface-3: #e1eaf7;
    --border: #dbe4f0;
    --text: #101828;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-strong: #4338ca;
    --accent: #0891b2;
    --neon: #06b6d4;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --ok-fg: #14532d;
    --warn: #d97706;
    --warn-bg: #fef3c7;
    --warn-fg: #78350f;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-fg: #7f1d1d;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 34px rgba(30, 58, 138, .10);
    --shadow-sm: 0 2px 10px rgba(30, 58, 138, .07);
    --glow: 0 0 0 1px rgba(34, 211, 238, .16), 0 8px 26px rgba(79, 70, 229, .22);
}

[data-theme="dark"] {
    --bg: #0b0f19;
    --bg-grad: radial-gradient(1200px 600px at 90% -10%, rgba(79, 70, 229, .24), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(6, 182, 212, .13), transparent 55%), var(--bg);
    --surface: #111827;
    --surface-2: #1b2434;
    --surface-3: #243047;
    --border: #28324d;
    --text: #eef2ff;
    --muted: #93a1bb;
    --primary: #6366f1;
    --primary-strong: #818cf8;
    --accent: #22d3ee;
    --neon: #06b6d4;
    --ok: #34d399;
    --ok-bg: rgba(52, 211, 153, .14);
    --ok-fg: #a7f3d0;
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, .14);
    --warn-fg: #fde68a;
    --danger: #fb7185;
    --danger-bg: rgba(251, 113, 133, .14);
    --danger-fg: #fecdd3;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 14px 44px rgba(2, 6, 23, .55);
    --shadow-sm: 0 4px 14px rgba(2, 6, 23, .38);
    --glow: 0 0 0 1px rgba(34, 211, 238, .28), 0 10px 34px rgba(79, 70, 229, .40);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* ===== Design-system utilities (indigo/cyan legend) ===== */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--primary) 55%, transparent); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.glass-card {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.glow-radial {
    background: radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--primary) 20%, transparent) 0%, color-mix(in srgb, var(--accent) 7%, transparent) 48%, transparent 76%);
}

.gradient-text {
    background: linear-gradient(120deg, var(--primary) 0%, var(--accent) 55%, var(--neon) 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    padding-bottom: .08em;
}

.grad-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 45%, var(--accent) 100%);
    color: #fff; border: 0; border-radius: 12px; padding: 12px 20px;
    font-size: 14.5px; font-weight: 700; cursor: pointer; text-decoration: none;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 38%, transparent);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.grad-btn:hover { transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 40%, transparent); }
.grad-btn:active { transform: translateY(0); }
.grad-btn.ghost {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); box-shadow: none;
}
.grad-btn.ghost:hover { background: var(--surface-3); }

.section-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 15px; border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary-strong); border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent);
    font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
}
.section-pill .pulse {
    width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 12px var(--accent); animation: lPulse 1.7s ease-in-out infinite;
}
@keyframes lPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }

.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

body.center-view { display: grid; place-items: center; padding: 24px; }

a { color: var(--primary); }
a.plain { color: var(--primary); text-decoration: none; }
code { background: var(--surface-3); color: var(--primary); padding: 2px 7px; border-radius: 6px; font-size: 12px; font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; word-break: break-all; }
hr.sep { border: 0; border-top: 1px solid var(--border); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---- Topbar ---- */
.topbar {
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 40;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 9px; }
.brand .dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: linear-gradient(135deg, var(--neon), var(--primary));
    box-shadow: 0 0 12px var(--neon);
}
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav form button {
    color: var(--muted); text-decoration: none; font-size: 13.5px;
    padding: 7px 12px; border-radius: 9px; border: 0; background: none; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav form button:hover { color: var(--text); background: var(--surface-2); }
.nav .sep { color: var(--muted); padding: 0 2px; }
.meta-line { font-size: 12px; color: var(--muted); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; border: 0; border-radius: 11px; padding: 11px 18px;
    font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
    box-shadow: 0 6px 18px rgba(109, 40, 217, .32);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(109, 40, 217, .42); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); box-shadow: var(--shadow-sm); }
.btn.danger { background: linear-gradient(135deg, var(--danger), #b91c1c); box-shadow: 0 6px 18px rgba(220, 38, 38, .25); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.dark-mode { background: linear-gradient(135deg, #0f172a, #312e81); }

/* ---- Theme toggle ---- */
.theme-toggle {
    width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
}
.theme-toggle:hover { transform: rotate(18deg); box-shadow: var(--glow); }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
.theme-toggle.fixed { position: fixed; top: 18px; inset-inline-end: 18px; z-index: 60; }

.pwa-install {
    position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 80;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; border: 0; border-radius: 999px; padding: 11px 20px;
    font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
    box-shadow: 0 10px 26px rgba(109, 40, 217, .4);
    transition: transform .15s ease;
}
.pwa-install:hover { transform: translateY(-2px); }
body[data-page] { }

/* ---- Hero ---- */
.hero {
    position: relative; text-align: center; padding: 72px 24px 60px;
    background: radial-gradient(900px 420px at 50% 0%, rgba(139, 92, 246, .25), transparent 70%);
}
.hero h1 { font-size: clamp(30px, 5vw, 48px); font-weight: 800; margin: 0 0 10px;
    background: linear-gradient(120deg, var(--text) 30%, var(--neon) 60%, var(--accent) 90%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { color: var(--muted); font-size: 16px; max-width: 620px; margin: 0 auto; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }
.container.narrow { max-width: 860px; }
.container.wide { max-width: 1320px; }
.container.wide .grid.reg { grid-template-columns: 1.65fr 0.9fr; }
@media (max-width: 1100px) {
    .container.wide .grid.reg { grid-template-columns: 1fr; }
}
.grid { display: grid; gap: 18px; }
.grid.events { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-2 { grid-template-columns: 1fr 1.5fr; gap: 22px; align-items: start; }
.grid.reg { grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }

/* ---- Cards / Panels ---- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card.lift:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.card .cover { height: 152px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; color: #fff; font-size: 34px; font-weight: 800; }
.card .cover img { width: 100%; height: 152px; object-fit: cover; }
.card .body { padding: 16px 18px 20px; }
.card .when { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card h3 { margin: 6px 0 8px; font-size: 17px; }
.card .venue { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.panel h2 { font-size: 15px; color: var(--text); margin: 0 0 14px; }
.panel.sticky { position: sticky; top: 76px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 27px; font-weight: 800; }
.stat .label { color: var(--muted); font-size: 12.5px; }

/* ---- Forms ---- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=datetime-local], textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, .18); }
textarea { min-height: 92px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-top: 16px; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--primary); }
.checkbox-row label { margin: 0; }

/* ---- Chips / Badges / Pills ---- */
.chip { background: var(--surface-2); color: var(--primary-strong); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.pill { border-radius: 999px; padding: 3px 11px; font-size: 11.5px; font-weight: 700; }
.pill.confirmed, .pill.published, .pill.active, .pill.sent, .pill.paid, .pill.completed { background: var(--ok-bg); color: var(--ok-fg); }
.pill.pending, .pill.draft, .pill.queued, .pill.overdue { background: var(--warn-bg); color: var(--warn-fg); }
.pill.cancelled, .pill.failed, .pill.unpaid { background: var(--danger-bg); color: var(--danger-fg); }
.pill.live { background: var(--surface-3); color: var(--primary); }

/* ---- Tables ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.tbl .actions { display: flex; gap: 10px; }
.tbl .actions a { font-size: 12.5px; }
.tbl .actions form { display: inline; }
.tbl .actions button { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 12.5px; padding: 0; font-family: inherit; }

/* ---- Toolbar / filters ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Flash / notices ---- */
.flash { background: var(--ok-bg); border: 1px solid var(--border); color: var(--ok-fg); border-radius: 11px; padding: 12px 16px; margin-bottom: 16px; }
.flash.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice { background: var(--warn-bg); border: 1px solid var(--border); color: var(--warn-fg); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.notice.danger { background: var(--danger-bg); color: var(--danger-fg); }

/* ---- Auth ---- */
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { font-size: 21px; font-weight: 800; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.back-link { display: inline-block; margin-top: 16px; font-size: 13px; color: var(--muted); text-decoration: none; }

/* ---- Ticket ---- */
.ticket { max-width: 470px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.ticket .strip {
    padding: 20px 24px; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--neon));
}
.ticket .strip h1 { margin: 0; font-size: 20px; }
.ticket .strip p { margin: 4px 0 0; font-size: 13px; color: rgba(255, 255, 255, .85); }
.ticket .body { padding: 24px; }
.ticket .event h2 { margin: 0 0 4px; font-size: 22px; }
.qr { border: 2px dashed var(--border); border-radius: 14px; padding: 16px; text-align: center; }
.qr .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.qr img.qr-img { width: 168px; height: 168px; image-rendering: pixelated; }
.ticket-actions { display: flex; gap: 10px; margin-top: 16px; }
.ticket-actions a { flex: 1; text-align: center; }
.ticket-actions a.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; }

/* ---- Empty state ---- */
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: 13px; padding: 38px; text-align: center; color: var(--muted); }

/* ---- Pager ---- */
.pager { margin-top: 16px; display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.pager a { padding: 5px 11px; border-radius: 8px; background: var(--surface-2); text-decoration: none; color: var(--text); }

/* ---- Footer ---- */
.footer { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
.footer a { color: var(--primary); margin: 0 6px; }

/* ---- Error page ---- */
.error-wrap { text-align: center; padding: 24px; }
.error-code { font-size: 74px; font-weight: 800; background: linear-gradient(135deg, var(--danger), var(--neon)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.error-message { font-size: 18px; color: var(--muted); margin-top: 8px; }
.trace { text-align: left; background: #0b0615; color: #c4b5fd; padding: 16px; border-radius: 12px; overflow: auto; max-width: 760px; font-size: 12px; margin: 18px auto 0; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .grid.reg { grid-template-columns: 1fr; }
    .panel.sticky { position: static; }
    .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .topbar { padding: 10px 16px; }
    .container { padding: 20px 14px 44px; }
    .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
}

@media print {
    body { background: #fff; }
    .topbar, .l-nav, .theme-toggle, .ticket-actions, .footer { display: none; }
    .ticket { box-shadow: none; max-width: 100%; }
}