/* =====================================================================
   QR Invitation System - admin UI
   Modern shell: dark sidebar, soft cards, clean tables.
   ===================================================================== */

:root {
    --bg: #f5f6fb;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --ink: #101828;
    --ink-soft: #475467;
    --muted: #8492a6;
    --line: #e8ebf2;
    --line-strong: #d8dee9;

    --brand: #5b5bf6;
    --brand-2: #8b5cf6;
    --brand-ink: #4343e0;
    --brand-soft: #eeeeff;

    --success: #0f9d58;
    --success-bg: #e8f8ef;
    --warn: #b54708;
    --warn-bg: #fff5e5;
    --danger: #d92d20;
    --danger-bg: #fdeceb;

    --sidebar: #0b1220;
    --sidebar-2: #111a2e;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 12px 28px -12px rgba(16, 24, 40, .16);
    --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .28);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body.admin {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* =====================================================================
   Shell
   ===================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 8px 20px -8px rgba(91, 91, 246, .9);
}
.sidebar-brand .logo svg { width: 21px; height: 21px; color: #fff; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-brand .brand-text strong { font-size: 14.5px; letter-spacing: .01em; }
.sidebar-brand .brand-text small {
    font-size: 11.5px;
    color: #8ba0bf;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px 8px; }
.nav-group { margin-bottom: 18px; }
.nav-label {
    display: block;
    font-size: 10.5px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: #5f7391;
    padding: 0 10px 8px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 11px;
    color: #b6c3d6;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 3px;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active {
    background: linear-gradient(135deg, rgba(91, 91, 246, .95), rgba(139, 92, 246, .95));
    color: #fff;
    box-shadow: 0 10px 22px -14px rgba(91, 91, 246, 1);
}
.nav-icon { display: grid; place-items: center; width: 20px; height: 20px; opacity: .95; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-link-scan { border: 1px dashed rgba(255, 255, 255, .18); }

.sidebar-foot {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    background: rgba(255, 255, 255, .12);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 13px; color: #e6ecf5; }
.user-meta small { font-size: 11px; color: #7d8ea8; }

.sidebar-scrim { display: none; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 26px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.topbar-title h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
}
.chip-muted { background: var(--brand-soft); color: var(--brand-ink); }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--ink-soft);
}
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 26px 60px; }

.footer { border-top: 1px solid var(--line); background: #fff; margin-top: auto; }
.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 26px;
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

/* =====================================================================
   Page header
   ===================================================================== */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; margin: 0 0 5px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--ink-soft); font-size: 14px; max-width: 70ch; }

/* =====================================================================
   Cards & grids
   ===================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
    transition: box-shadow .18s ease, border-color .18s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card h2 { font-size: 15.5px; margin: 0 0 4px; letter-spacing: -.01em; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}
.card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.card-danger { border-color: #f6c9c4; background: linear-gradient(180deg, #fff 0%, #fffafa 100%); }
.card-danger h2 { color: var(--danger); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* =====================================================================
   Stats
   ===================================================================== */
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--brand), var(--brand-2));
    opacity: .9;
}
.stat .label {
    color: var(--muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 600;
}
.stat .value { font-size: 30px; font-weight: 750; margin-top: 8px; letter-spacing: -.02em; line-height: 1.1; }
.stat .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat.success::after { background: linear-gradient(180deg, #12b76a, #0f9d58); }
.stat.success .value { color: var(--success); }
.stat.warn::after { background: linear-gradient(180deg, #f79009, #dc6803); }
.stat.warn .value { color: var(--warn); }
.stat.danger::after { background: linear-gradient(180deg, #f04438, #d92d20); }
.stat.danger .value { color: var(--danger); }

/* =====================================================================
   Forms
   ===================================================================== */
label { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 6px; color: var(--ink-soft); letter-spacing: .01em; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], input[type=date], input[type=file], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14.5px;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #c3ccdb; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(91, 91, 246, .14);
}
input[type=file] { padding: 9px; background: var(--surface-2); }
textarea { min-height: 190px; resize: vertical; font-family: inherit; line-height: 1.6; }

.form-row { margin-bottom: 16px; }
.form-row.tight { margin-bottom: 10px; }
.field-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inline-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields > * { flex: 0 1 auto; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 13.5px; color: var(--ink-soft); }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

/* switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: 500;
}
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.switch-row strong { font-size: 13.5px; color: var(--ink); }
.switch-row em { font-style: normal; font-size: 12.5px; color: var(--muted); }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #d5dbe6;
    transition: background .18s ease;
    position: relative;
}
.switch .knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .28);
    transition: transform .18s cubic-bezier(.4, 0, .2, 1);
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.switch input:checked + .track .knob { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px rgba(91, 91, 246, .2); }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: #eef0f7;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    box-shadow: 0 10px 22px -12px rgba(91, 91, 246, .85);
}
.btn-primary:hover { box-shadow: 0 14px 26px -12px rgba(91, 91, 246, .95); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 10px 22px -14px rgba(217, 45, 32, .9); }
.btn-danger:hover { background: #b42318; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c3ccdb; }
.btn-quiet { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: #d7e0ee; }
.btn-quiet:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.table th {
    background: var(--surface-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fbfcff; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table tr.selected { background: #f3f3ff; }
table.table input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }

.thumb {
    width: 62px;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--line);
    display: block;
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.thumb-missing {
    width: 62px;
    height: 62px;
    border-radius: 8px;
    border: 1px dashed var(--line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
    background: var(--surface-2);
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* =====================================================================
   Badges & day chips
   ===================================================================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: #eef1f7; color: var(--ink-soft); }

.day-dots { display: flex; gap: 4px; margin-top: 6px; justify-content: flex-end; flex-wrap: wrap; }
.day-dot {
    font-size: 10px;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 5px;
    background: #eef1f7;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}
.day-dot.on { background: var(--success-bg); color: var(--success); }
.day-dot.on.multi { box-shadow: inset 0 0 0 1px #9fdcb9; }

/* =====================================================================
   Alerts
   ===================================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
    background: #fff;
}
.alert-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 7px;
    background: currentColor;
}
.alert-success { background: var(--success-bg); border-color: #bfe8d0; color: #0b6b3a; }
.alert-error, .alert-danger { background: var(--danger-bg); border-color: #f5c6c6; color: #8f1d1d; }
.alert-warn { background: var(--warn-bg); border-color: #f6dfb4; color: #7a4200; }
.alert-info { background: var(--brand-soft); border-color: #dcdcff; color: #3730a3; }

/* =====================================================================
   Progress
   ===================================================================== */
.progress { height: 8px; background: #eceff6; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .25s ease; }
.progress-label { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

/* =====================================================================
   Misc
   ===================================================================== */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 9px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

.preview-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.preview-wrap img { display: block; max-width: 100%; height: auto; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.pagination a, .pagination span {
    padding: 7px 12px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 13px;
    color: var(--ink);
}
.pagination a:hover { border-color: var(--brand); color: var(--brand-ink); text-decoration: none; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

.notice-list { margin: 12px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.notice-list li { margin-bottom: 6px; }

.split { display: grid; gap: 22px; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
.scroll-y { max-height: 340px; overflow-y: auto; }

/* =====================================================================
   Login
   ===================================================================== */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(91, 91, 246, .42), transparent 60%),
        radial-gradient(900px 500px at 100% 100%, rgba(139, 92, 246, .34), transparent 55%),
        #0b1220;
}
.login-card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
}
.login-card .login-logo {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 12px 26px -14px rgba(91, 91, 246, 1);
}
.login-card .login-logo svg { width: 24px; height: 24px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1080px) {
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100%;
        transform: translateX(-102%);
        transition: transform .22s cubic-bezier(.4, 0, .2, 1);
        box-shadow: var(--shadow-lg);
        width: 268px;
        flex-basis: 268px;
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 15, 30, .55);
        z-index: 45;
        backdrop-filter: blur(2px);
    }
    .menu-btn { display: grid; }
    .app-topbar { padding: 10px 16px; }
    .topbar-actions .btn-ghost { display: none; }
    .container { padding: 18px 16px 48px; }
    .page-head h1 { font-size: 21px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { font-weight: 650; color: var(--ink-soft); margin-top: 8px; }
    .card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
