:root {
    --v2-primary: #2563eb;
    --v2-primary-dark: #1d4ed8;
    --v2-sidebar: #0f172a;
    --v2-sidebar-muted: #94a3b8;
    --v2-canvas: #f8fafc;
    --v2-surface: #ffffff;
    --v2-border: #e2e8f0;
    --v2-text: #0f172a;
    --v2-muted: #64748b;
    --v2-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: var(--v2-canvas);
    color: var(--v2-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

button, a { font: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.v2-shell {
    display: flex;
    width: 100%;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.v2-sidebar {
    display: flex;
    flex: 0 0 246px;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    padding: 26px 14px 18px;
    background: var(--v2-sidebar);
    color: #fff;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 58px;
    padding: 0 12px 25px;
    border-bottom: 1px solid rgba(148, 163, 184, .18);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: contain;
    background: #fff;
}

.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 15px; letter-spacing: .01em; }
.brand-copy small { color: var(--v2-sidebar-muted); font-size: 11px; }

.sidebar-nav { display: grid; gap: 5px; padding-top: 26px; }
.sidebar-section-label {
    padding: 0 12px 8px;
    color: var(--v2-sidebar-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 9px;
    background: transparent;
    color: var(--v2-sidebar-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-link:hover, .sidebar-link:focus-visible { background: rgba(148, 163, 184, .12); color: #fff; }
.sidebar-link.active { background: rgba(37, 99, 235, .2); color: #fff; }
.sidebar-icon { width: 18px; color: currentColor; font-size: 17px; text-align: center; }
.sidebar-link.logout { margin-top: auto; color: #fda4af; }
.sidebar-link.logout:hover, .sidebar-link.logout:focus-visible { background: rgba(244, 63, 94, .12); color: #fecdd3; }

.sidebar-group { display: grid; gap: 2px; }
.sidebar-toggle {
    width: 100%;
    border: 0;
    cursor: pointer;
    text-align: left;
}
.sidebar-caret {
    margin-left: auto;
    color: var(--v2-sidebar-muted);
    font-size: 10px;
    line-height: 1;
    transition: transform .15s ease;
}
.sidebar-group.is-open .sidebar-caret { transform: rotate(180deg); }
.sidebar-submenu {
    display: none;
    gap: 2px;
    padding-left: 12px;
    border-left: 1px solid rgba(148, 163, 184, .18);
    margin-left: 22px;
}
.sidebar-group.is-open .sidebar-submenu { display: grid; }
.sidebar-sub-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--v2-sidebar-muted);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar-sub-link .sidebar-icon { width: 15px; font-size: 14px; }
.sidebar-sub-link:hover, .sidebar-sub-link:focus-visible { background: rgba(148, 163, 184, .12); color: #fff; }
.sidebar-sub-link.active { background: rgba(37, 99, 235, .2); color: #fff; }

.v2-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.v2-shell.is-loading .v2-content { pointer-events: none; }
#spa-content {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
#spa-content[aria-busy="true"]::before { position: absolute; z-index: 10; inset: 0; background: rgba(248, 250, 252, .58); backdrop-filter: blur(2px); content: ""; pointer-events: none; }
#spa-content[aria-busy="true"]::after { position: absolute; z-index: 11; top: 50%; left: 50%; width: 28px; height: 28px; margin: -17px 0 0 -17px; border: 3px solid #bfdbfe; border-right-color: var(--v2-primary); border-radius: 50%; content: ""; animation: v2-spin .7s linear infinite; }

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 28px;
    min-height: 142px;
    padding: 34px 38px 26px;
    border-bottom: 1px solid var(--v2-border);
    background: var(--v2-surface);
}

.dashboard-heading h1 { margin: 0; font-size: clamp(22px, 2.2vw, 30px); letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--v2-primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; }

.dashboard-meta {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-top: 8px;
    color: var(--v2-muted);
    font-size: 13px;
    white-space: nowrap;
}

.dashboard-meta strong { color: var(--v2-text); font-weight: 700; }
.meta-label { color: var(--v2-muted); }
.meta-divider { width: 1px; height: 22px; margin: 0 3px; background: var(--v2-border); }
.user-avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: #dbeafe; color: var(--v2-primary-dark); font-weight: 800; }

.toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 30px 38px 22px;
}

.toolbar-copy h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.toolbar-copy p { margin: 0; color: var(--v2-muted); font-size: 13px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar-icon { width: 14px; height: 14px; flex: 0 0 14px; }

.v2-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--v2-border);
    border-radius: 8px;
    background: var(--v2-surface);
    color: var(--v2-text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}

.v2-button:hover, .v2-button:focus-visible { border-color: #bfdbfe; background: #eff6ff; color: var(--v2-primary-dark); box-shadow: 0 2px 5px rgba(37, 99, 235, .1); }
.v2-button:disabled { cursor: wait; opacity: .65; }
.button-spinner { display: inline-block; width: 13px; height: 13px; flex: 0 0 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: v2-spin .7s linear infinite; }
.sidebar-link.is-loading { cursor: wait; opacity: .75; pointer-events: none; }
.primary-button { border-color: var(--v2-primary); background: var(--v2-primary); color: #fff; }
.primary-button:hover, .primary-button:focus-visible { border-color: var(--v2-primary-dark); background: var(--v2-primary-dark); color: #fff; }

@keyframes v2-spin { to { transform: rotate(360deg); } }

.table-panel {
    margin: 0 38px;
    overflow: visible;
    border: 1px solid var(--v2-border);
    border-radius: 12px;
    background: var(--v2-surface);
    box-shadow: var(--v2-shadow);
}

.table-scroll { overflow-x: auto; }
.table-scroll--program {
    overflow: visible;
    min-height: 0;
}
.program-table thead th { position: sticky; top: 0; z-index: 3; }
.program-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.program-table--auto { table-layout: auto; }
.program-table--auto .column-header,
.program-table--wrap-header .column-header { white-space: normal; line-height: 1.3; }
.program-table th, .program-table td { padding: 16px 15px; text-align: left; vertical-align: middle; line-height: 1.45; }
.program-table th { border-bottom: 1px solid var(--v2-border); background: #f8fafc; color: var(--v2-muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.program-table th > span { vertical-align: middle; }
.column-sort-button { display: none; margin-left: 5px; padding: 0 2px; border: 0; background: transparent; color: var(--v2-muted); cursor: pointer; font-size: 13px; font-weight: 800; line-height: 1; }
.column-sort-button[aria-pressed="true"] { display: inline; }
.column-sort-button:hover, .column-sort-button:focus-visible { color: var(--v2-primary); outline: 0; }
th[data-sortable-column] { cursor: pointer; user-select: none; }
.program-table td { border-bottom: 1px solid #eef2f7; color: #334155; font-size: 13px; }
.table-filter-input { width: 100%; min-width: 0; min-height: 30px; padding: 0.5rem; border: 1px solid var(--v2-border); border-radius: 6px; background: #fff; color: var(--v2-text); font-size: 11px; font-weight: 500; text-transform: none; }
.table-filter-input:focus { border-color: var(--v2-primary); outline: 2px solid #dbeafe; outline-offset: 1px; }
.program-filter-backdrop[hidden] { display: none; }
.program-filter-backdrop { position: fixed; z-index: 1200; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(15, 23, 42, .58); }
.program-filter-modal { width: min(520px, 100%); max-height: 90dvh; overflow: auto; border: 1px solid var(--v2-border); border-radius: 14px; background: var(--v2-surface); box-shadow: 0 24px 60px rgba(15, 23, 42, .25); }
.program-filter-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--v2-border); background: var(--v2-surface); }
.program-filter-header h2 { margin: 4px 0 0; font-size: 20px; }
.program-filter-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 1.5rem 1.5rem 0; }
.program-filter-field { display: grid; gap: 7px; }
.program-filter-field label { color: var(--v2-muted); font-size: 12px; font-weight: 800; }
.program-filter-footer { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--v2-border); background: var(--v2-surface); }
.program-filter-modal .program-table thead th { position: static; }

/* ============================================================================
 * Column header: label + sort + inline filter (popover anchored to the column)
 * ============================================================================ */
.column-header { display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
.column-header-actions { display: inline-flex; align-items: center; gap: 4px; }
.column-filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--v2-muted);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.column-filter-button svg { width: 13px; height: 13px; }
.column-filter-button:hover, .column-filter-button:focus-visible { background: #eef2ff; color: var(--v2-primary); outline: 0; }
.column-filter-button.is-active { background: #dbeafe; border-color: #93c5fd; color: var(--v2-primary); }

.column-filter-popover[hidden] { display: none; }
.column-filter-popover {
    position: fixed;
    z-index: 1300;
    width: 240px;
    border: 1px solid var(--v2-border);
    border-radius: 12px;
    background: var(--v2-surface);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}
.column-filter-arrow {
    position: absolute;
    top: -6px;
    left: 12px;
    width: 12px;
    height: 12px;
    border-left: 1px solid var(--v2-border);
    border-top: 1px solid var(--v2-border);
    background: var(--v2-surface);
    transform: rotate(45deg);
}
.column-filter-popover.flip-above .column-filter-arrow {
    top: auto;
    bottom: -6px;
    border-top: 0;
    border-left: 0;
    border-right: 1px solid var(--v2-border);
    border-bottom: 1px solid var(--v2-border);
}
.column-filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 14px 10px; }
.column-filter-fields label { display: flex; flex-direction: column; gap: 5px; color: var(--v2-muted); font-size: 11px; font-weight: 800; }
.column-filter-fields label.stacked { grid-column: 1 / -1; gap: 6px; }
.column-filter-fields label.stacked input,
.column-filter-fields label.stacked select { margin-top: 0; }
.column-filter-fields .table-filter-input { width: 100%; font-size: 11px; }
.column-filter-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 14px 14px; }
.column-filter-footer .v2-button { padding: 0 12px; min-height: 30px; font-size: 11px; }

.program-table tbody tr:last-child td { border-bottom: 0; }
.program-table tbody tr:hover { background: #fbfdff; }
.program-table td:nth-child(3) { color: var(--v2-text); font-weight: 700; text-align: left; }
.no-column { width: 5%; } .date-column { width: 11%; } .name-column { width: 24%; } .portal-column { width: 8%; } .start-date-column { width: 10%; } .end-date-column { width: 10%; } .status-column { width: 11%; } .actions-column { width: 10%; } .updated-column { width: 11%; }
.row-number-cell { color: var(--v2-muted); font-size: 12px; }
.program-table thead th:nth-child(9), .program-table tbody td:nth-child(9) { padding-right: 8px; padding-left: 8px; text-align: center; }
.program-table tbody td:nth-child(9) .row-actions { gap: 4px; justify-content: center; }

.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-badge::before { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status-badge.active { background: #dcfce7; color: #15803d; }
.status-badge.inactive { background: #f1f5f9; color: #64748b; }
.status-badge.ended { background: #fee2e2; color: #b91c1c; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content:center; }
.row-button { min-height: 30px; padding: 0 9px; border: 1px solid var(--v2-border); border-radius: 6px; background: #fff; color: #334155; cursor: pointer; font-size: 11px; font-weight: 700; }
.row-button:hover, .row-button:focus-visible { border-color: #93c5fd; background: #eff6ff; color: var(--v2-primary-dark); }
.row-button.danger-button:hover, .row-button.danger-button:focus-visible { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* ============================================================================
 * Program list action buttons (Edit / Duplicate / Archive as icon buttons)
 * Revealed on row hover with a clear custom tooltip.
 * ============================================================================ */
.icon-row-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    position: relative;
}
.icon-row-button svg { width: 14px; height: 14px; flex-shrink: 0; }
.icon-row-button:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.icon-row-button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    border-radius: 4px;
    background: #0f172a;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 20;
}
.icon-row-button:hover[data-tooltip]::after,
.icon-row-button:focus-visible[data-tooltip]::after {
    opacity: 1;
}

.program-table tbody tr { transition: background-color .15s ease; }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin: 18px 38px 30px; }
.pagination-summary { color: var(--v2-muted); font-size: 12px; }
.pagination-controls { display: flex; gap: 6px; }
.page-size-control { display: inline-flex; align-items: center; gap: 6px; color: var(--v2-muted); font-size: 12px; white-space: nowrap; }
.page-size-control .table-filter-input { width: auto; min-width: 58px; }
.pagination-button, .page-number { min-width: 34px; min-height: 34px; padding: 0 10px; }
.page-number.current { border-color: var(--v2-primary); background: var(--v2-primary); color: #fff; }

.add-program-page { padding: 30px 38px 32px; }
.add-program-grid { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(480px, 1.1fr); gap: 22px; }
.form-card, .prize-card { min-width: 0; padding: 18px; border: 1px solid var(--v2-border); border-radius: 12px; background: var(--v2-surface); box-shadow: var(--v2-shadow); }
.form-card fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.form-card legend { margin-bottom: 22px; color: var(--v2-text); font-size: 17px; font-weight: 800; }
.form-field { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 4px; margin-bottom: 15px; }
.form-field label, .form-label { color: #334155; font-size: 12px; font-weight: 700; }
.form-field input, .form-field select { width: 100%; min-width: 0; min-height: 38px; padding: 0 8px; border: 1px solid var(--v2-border); border-radius: 7px; background: #fff; color: var(--v2-text); font-size: 12px; }
.form-field input:focus, .form-field select:focus { outline: 3px solid #dbeafe; border-color: #93c5fd; }
.date-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 7px; }
.date-range span { color: var(--v2-muted); font-size: 12px; }
.form-field-prizes { margin-top: 23px; margin-bottom: 0; }
.form-field-prizes .v2-button { justify-self: start; }
.prize-card { display: flex; flex-direction: column; }
.prize-card h2 { margin: 0 0 18px; font-size: 17px; }
.prize-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.prize-table th, .prize-table td { padding: 12px 10px; border: 1px solid var(--v2-border); text-align: left; font-size: 13px; }
.prize-table th { background: #f8fafc; color: var(--v2-muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.prize-table td { color: #334155; }
.prize-table th:nth-child(1) { width: 36%; }
.prize-table th:nth-child(2) { width: 18%; }
.prize-table th:nth-child(3) { width: 26%; }
.prize-table th:nth-child(4) { width: 20%; text-align: center; }
.empty-prize-row { color: var(--v2-muted); text-align: center !important; }
.prize-row.is-saved td { background: #f0fdf4; color: #166534; }
.prize-row.is-saved td:first-child { box-shadow: inset 3px 0 0 #22c55e; }
.prize-row.is-modified td { background: #eff6ff; color: #1e40af; }
.prize-row.is-modified td:first-child { box-shadow: inset 3px 0 0 #3b82f6; }
.prize-row.is-draft td { background: #fffbeb; color: #92400e; }
.prize-row.is-draft td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.prize-source-tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; vertical-align: 1px; }
.prize-source-tag.saved { background: #dcfce7; color: #166534; }
.prize-source-tag.draft { background: #fef3c7; color: #92400e; }
.prize-source-tag.modified { background: #dbeafe; color: #1e40af; }
.prize-source-tag.deleted { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.prize-pagination { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: auto; padding-top: 20px; color: var(--v2-muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-feedback { margin: 12px 0 0; color: #b91c1c; font-size: 13px; font-weight: 700; text-align: right; }

.add-program-page .secondary-button { background: #fff; }

.prize-setting-page { padding: 30px 38px 32px; }
.prize-setting-grid { display: grid; grid-template-columns: minmax(470px, .95fr) minmax(500px, 1.05fr); gap: 22px; }
.setting-card { min-width: 0; margin: 0; padding: 24px; border: 1px solid var(--v2-border); border-radius: 12px; background: var(--v2-surface); box-shadow: var(--v2-shadow); }
.setting-card > h2 { margin: 0 0 22px; color: var(--v2-text); font-size: 17px; font-weight: 800; }
.setting-field { display: grid; grid-template-columns: 124px minmax(0, 1fr); align-items: center; gap: 14px; margin-bottom: 15px; }
.setting-field[hidden] { display: none; }
.setting-field-top { align-items: start; }
.setting-label { color: #334155; font-size: 12px; font-weight: 700; }
.setting-field input[type="text"], .setting-field input[type="number"], .setting-field input[type="date"], .setting-field input[type="time"], .setting-field input[type="file"], .setting-field select { width: 100%; min-width: 0; min-height: 38px; padding: 0 11px; border: 1px solid var(--v2-border); border-radius: 7px; background: #fff; color: var(--v2-text); font-size: 13px; }
.setting-field input:focus, .setting-field select:focus { outline: 3px solid #dbeafe; border-color: #93c5fd; }
.prize-image-preview { margin-top: 9px; text-align: center; }
.prize-image-preview img { display: inline-block; max-width: 100%; max-height: 200px; border: 1px solid var(--v2-border); border-radius: 8px; background: #f8fafc; }
.redeem-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; }
.radio-group { display: flex; flex-wrap: wrap; gap: 16px; color: #334155; font-size: 13px; }
.radio-group label, .day-options label { display: inline-flex; align-items: center; gap: 6px; }
.day-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 12px; border: 1px solid var(--v2-border); border-radius: 8px; background: #f8fafc; color: #334155; font-size: 12px; }
.day-options input { accent-color: var(--v2-primary); }
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 28px; margin-top: 10px; }
.setting-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 27px; padding: 0 8px 0 10px; border: 1px solid #bfdbfe; border-radius: 999px; background: #eff6ff; color: var(--v2-primary-dark); font-size: 11px; font-weight: 800; }
.tier-chip { cursor: grab; }
.tier-chip:active { cursor: grabbing; }
.tier-chip.is-dragging { opacity: .45; }
.tier-sequence { display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--v2-primary); color: #fff; font-size: 10px; }
.setting-chip button { display: grid; width: 17px; height: 17px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: #dbeafe; color: var(--v2-primary-dark); cursor: pointer; line-height: 1; }
.setting-chip button:hover, .setting-chip button:focus-visible { background: #bfdbfe; }
.tier-entry { display: flex; gap: 8px; }
.tier-entry input { max-width: 180px; }
.field-hint { max-width: 390px; margin: 7px 0 0; color: var(--v2-muted); font-size: 11px; line-height: 1.45; }
.date-range.redeem-range { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 7px; }
.redeem-range + .field-hint { grid-column: 2; max-width: none; margin-top: -7px; }

.status-switch { position: relative; display: inline-flex; align-items: center; gap: 9px; width: fit-content; color: #15803d; cursor: pointer; font-size: 13px; font-weight: 800; }
.status-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status-switch-track { position: relative; display: inline-block; width: 42px; height: 24px; border-radius: 999px; background: #bbf7d0; transition: background-color .15s ease; }
.status-switch-track::after { position: absolute; top: 3px; left: 21px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .22); content: ""; transition: left .15s ease; }
.status-switch.is-inactive { color: #b91c1c; }
.status-switch.is-inactive .status-switch-track { background: #fecaca; }
.status-switch.is-inactive .status-switch-track::after { left: 3px; }
.status-switch input:focus-visible + .status-switch-track { outline: 3px solid #dbeafe; outline-offset: 2px; }

body.modal-open { overflow: hidden; }
.reward-modal-backdrop[hidden] { display: none; }
.reward-modal-backdrop { position: fixed; z-index: 1200; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(15, 23, 42, .58); }
.reward-modal { display: flex; width: min(920px, 100%); height: min(720px, calc(100vh - 48px)); max-height: calc(100vh - 48px); flex-direction: column; overflow: hidden; border: 1px solid var(--v2-border); border-radius: 14px; background: var(--v2-surface); box-shadow: 0 24px 60px rgba(15, 23, 42, .25); }
.reward-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--v2-border); }
.reward-modal-header h2 { margin: 4px 0 0; font-size: 20px; }
.modal-close-button { display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 7px; background: #f1f5f9; color: var(--v2-muted); cursor: pointer; font-size: 23px; line-height: 1; }
.modal-close-button:hover, .modal-close-button:focus-visible { background: #e2e8f0; color: var(--v2-text); }
.reward-modal-body { display: flex; min-height: 0; flex: 1 1 auto; flex-direction: column; overflow: hidden; padding: 22px 24px; }
.reward-modal-intro { margin: 0 0 18px; color: var(--v2-muted); font-size: 13px; }
.reward-product-search { display: flex; gap: 9px; margin-bottom: 18px; }
.reward-product-search input { flex: 1; min-height: 38px; padding: 0 11px; border: 1px solid var(--v2-border); border-radius: 7px; font-size: 13px; }
.reward-product-search input:focus { outline: 3px solid #dbeafe; border-color: #93c5fd; }
.reward-modal-body .table-scroll { min-height: 0; flex: 1 1 auto; overflow: auto; }
.reward-product-table { width: 100%; min-width: 680px; border-collapse: collapse; }
.reward-product-table th, .reward-product-table td { padding: 12px 10px; border: 1px solid var(--v2-border); text-align: left; font-size: 12px; }
.reward-product-table th { background: #f8fafc; color: var(--v2-muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.reward-product-state { padding: 30px !important; color: var(--v2-muted); text-align: center !important; }
.reward-pagination { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 16px; color: var(--v2-muted); font-size: 12px; }
.reward-modal-footer { display: flex; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--v2-border); }
.reward-selected { margin: -3px 0 15px 138px; }
.reward-selected[hidden] { display: none; }
.reward-change-button { justify-self: start; min-height: 30px; }

.empty-state {
    display: grid;
    min-height: 360px;
    margin: 0 38px;
    place-content: center;
    justify-items: center;
    border: 1px dashed var(--v2-border);
    border-radius: 12px;
    background: var(--v2-surface);
    color: var(--v2-muted);
    text-align: center;
}

.empty-state-icon { display: grid; width: 42px; height: 42px; margin-bottom: 17px; place-items: center; border-radius: 12px; background: #dbeafe; color: var(--v2-primary); font-size: 20px; }
.empty-state h2 { margin: 7px 0; color: var(--v2-text); font-size: 20px; }
.empty-state p:not(.eyebrow) { margin: 0; font-size: 13px; }
.empty-state-cell { padding: 32px 16px; color: var(--v2-muted); text-align: center; font-size: 13px; }
.error-state { border-color: #fecaca; }

@media (max-width: 900px) {
    .v2-sidebar { flex-basis: 210px; }
    .dashboard-header { padding: 28px 24px 23px; }
    .toolbar { padding-right: 24px; padding-left: 24px; }
    .table-panel { margin-right: 24px; margin-left: 24px; }
    .pagination { margin-right: 24px; margin-left: 24px; }
    .empty-state { margin-right: 24px; margin-left: 24px; }
    .add-program-page { padding: 24px; }
    .add-program-grid { grid-template-columns: 1fr; }
    .prize-setting-page { padding: 24px; }
    .prize-setting-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .v2-shell { display: block; }
    .v2-sidebar { min-height: auto; padding: 12px; }
    .sidebar-heading { padding: 0 8px 12px; }
    .sidebar-nav { display: flex; overflow-x: auto; gap: 5px; padding-top: 12px; }
    .sidebar-group { flex: 0 0 auto; }
    .sidebar-submenu { position: absolute; left: 12px; right: 12px; top: 100%; z-index: 40; padding: 8px 10px; border-left: 0; margin-left: 0; padding-left: 8px; background: #0f172a; border: 1px solid rgba(148, 163, 184, .18); border-radius: 10px; }
    .sidebar-section-label { display: none; }
    .sidebar-link { flex: 0 0 auto; min-height: 38px; white-space: nowrap; }
    .sidebar-link.logout { margin-top: 0; }
    .dashboard-header { flex-direction: column; gap: 16px; min-height: auto; padding: 26px 18px 22px; }
    .dashboard-meta { padding-top: 0; }
    .toolbar { align-items: flex-start; flex-direction: column; padding: 24px 18px 18px; }
    .toolbar-actions { width: 100%; }
    .toolbar-button { flex: 1; }
    .table-panel { margin: 0 12px; }
    .pagination { justify-content: space-between; margin: 16px 12px 24px; }
    .empty-state { min-height: 280px; margin: 0 12px; }
    .add-program-page { padding: 20px 12px 24px; }
    .form-card, .prize-card { padding: 18px; }
    .form-field { grid-template-columns: 1fr; gap: 7px; }
    .form-field-prizes { align-items: start; }
    .prize-pagination { align-items: flex-start; flex-direction: column; }
    .form-actions { justify-content: stretch; }
    .form-actions .v2-button { flex: 1; }
    .prize-setting-page { padding: 20px 12px 24px; }
    .setting-card { padding: 18px; }
    .setting-field { grid-template-columns: 1fr; gap: 7px; }
    .redeem-range + .field-hint { grid-column: auto; margin-top: 0; }
    .day-options { grid-template-columns: 1fr 1fr; }
    .tier-entry input { max-width: none; }
    .reward-selected { margin-left: 0; }
    .reward-modal-backdrop { padding: 12px; }
    .reward-modal-header, .reward-modal-body { padding: 18px; }
    .reward-modal-footer { padding: 14px 18px; }
}

.v2-login-body { background: var(--v2-sidebar); }

.v2-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.v2-login-card {
    width: 100%;
    max-width: 400px;
    padding: 32px 30px 30px;
    border: 1px solid var(--v2-border);
    border-radius: 16px;
    background: var(--v2-surface);
    box-shadow: var(--v2-shadow);
}

.v2-login-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 26px;
}

.v2-login-brand .brand-copy { gap: 1px; }
.v2-login-brand .brand-copy strong { color: var(--v2-text); font-size: 17px; }
.v2-login-brand .brand-copy small { color: var(--v2-muted); font-size: 13px; }

.v2-login-form { display: grid; gap: 18px; }

.v2-login-field { display: grid; gap: 7px; }

.v2-login-label {
    color: var(--v2-text);
    font-size: 13px;
    font-weight: 600;
}

.v2-login-error {
    margin: 0;
    padding: 9px 12px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
}

.v2-login-submit { margin-top: 6px; justify-content: center; }

.prize-setting-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.prize-setting-header h2 { margin: 0; }
.prize-setting-header .eyebrow { margin: 0 0 4px; }

.prize-draft-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 700;
}

.commit-button { background: #16a34a; }
.commit-button:hover, .commit-button:focus-visible { background: #15803d; }

.form-feedback.is-error { color: #b91c1c; }
.form-feedback.is-success { color: #15803d; }

.prize-confirm-text { margin: 0; color: var(--v2-muted); font-size: 14px; line-height: 1.5; }

/* ============================================================================
 * Quiz Management (categories & questions)
 * ============================================================================ */
.quiz-description-column { width: 30%; }
.qty-column { width: 10%; }
.lang-column { width: 8%; }
.seq-column { width: 8%; }
.quiz-question-column { width: 30%; }
.quiz-answers-column { width: 30%; }

.quiz-category-table td:nth-child(5), .quiz-category-table th:nth-child(5) { text-align: center; }
.quiz-category-table th:last-child, .quiz-category-table td:last-child,
.quiz-question-table th:last-child, .quiz-question-table td:last-child {
    padding-right: 12px;
    padding-left: 12px;
    white-space: nowrap;
}
.quiz-category-table .row-actions,
.quiz-question-table .row-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}
.quiz-category-table td:last-child .row-actions { gap: 8px; }
.quiz-category-table td:last-child .row-actions .icon-row-button { margin-left: -3px; }
.quiz-category-table .quiz-category-actions-column { width: 15%; }
.quiz-question-table .quiz-answers-summary { display: flex; flex-wrap: wrap; gap: 5px; }
.quiz-answer-tag {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--v2-border);
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.quiz-back-button { margin-bottom: 14px; }
.quiz-textarea {
    min-height: 66px;
    padding: 8px 10px !important;
    resize: vertical;
    line-height: 1.45;
}
.quiz-form-span-2 { grid-column: 1 / -1; }
.col-span-full { grid-column: 1 / -1; }
.quiz-category-status { align-items: center; gap: 10px; }
.quiz-answers-block { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--v2-border); border-radius: 10px; background: #f8fafc; }
.quiz-answers-title { color: #334155; font-size: 12px; font-weight: 700; }
.quiz-answers-list { display: grid; gap: 9px; }
.quiz-answer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 70px 32px;
    align-items: center;
    gap: 9px;
}
.quiz-answer-field { display: grid; gap: 4px; }
.quiz-answer-field > span { color: var(--v2-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.quiz-answer-row .table-filter-input { min-height: 34px; }
.quiz-remove-answer {
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    font-size: 16px;
    line-height: 1;
}
.quiz-add-answer-button { justify-self: start; }

.quiz-question-modal { width: min(720px, 100%); }
.quiz-question-form .program-filter-field { min-width: 0; }
.quiz-question-thumb {
    display: inline-block;
    width: 34px;
    height: 34px;
    margin-right: 8px;
    vertical-align: middle;
    object-fit: cover;
    border: 1px solid var(--v2-border);
    border-radius: 6px;
    background: #f8fafc;
}
.quiz-image-preview { margin-top: 4px; }
.quiz-image-preview img { max-height: 160px; }
.quiz-import-instructions { margin: 0; color: var(--v2-muted); font-size: 13px; line-height: 1.5; }
.quiz-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0 38px 14px;
}
.quiz-filters label.stacked { display: grid; min-width: 220px; gap: 6px; }
.quiz-filters label.stacked > span { color: var(--v2-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.quiz-filters .table-filter-input { min-height: 34px; }

@media (max-width: 680px) {
    .quiz-filters { margin-right: 12px; margin-left: 12px; }
}

@media (max-width: 680px) {
    .quiz-answer-row { grid-template-columns: 1fr 1fr; }
    .quiz-answer-text-field { grid-column: 1 / -1; }
    .quiz-description-column, .quiz-answers-column { display: none; }
}

.detail-list { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; }
.detail-list > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.detail-list dt { color: var(--v2-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.detail-list dd { margin: 0; color: var(--v2-text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.detail-subtitle { margin: 0 0 8px; color: var(--v2-text); font-size: 13px; font-weight: 800; }

.input-prefix-group { display: flex; align-items: stretch; width: 100%; }
.input-prefix { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--v2-border); border-right: 0; border-radius: 7px 0 0 7px; background: #f1f5f9; color: #475569; font-size: 13px; font-weight: 700; white-space: nowrap; }
.input-prefix-group .table-filter-input { border-radius: 0 7px 7px 0; }
.day-checkboxes { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.day-checkboxes label { display: inline-flex; align-items: center; gap: 6px; color: var(--v2-text); font-size: 13px; font-weight: 600; cursor: pointer; }
.extra-token-package-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.extra-token-package-head { margin-bottom: 4px; }
.extra-token-package-head > span { color: var(--v2-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }

.popup-config-card { padding: 20px; }
.popup-config-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.popup-config-header h3 { margin: 0; font-size: 15px; font-weight: 800; color: var(--v2-text); }
.popup-config-body { display: block; }
.popup-config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 16px; }
.popup-config-actions { display: flex; justify-content: flex-end; }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle-switch input:checked + .toggle-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.popup-section { padding: 20px; margin-bottom: 20px; }
.popup-section-title { margin: 0 0 16px; font-size: 16px; font-weight: 800; color: var(--v2-text); }
.popup-push-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.popup-push-header .popup-section-title { margin-bottom: 0; }
.popup-push-body { display: grid; gap: 12px; }
.popup-push-row { display: flex; align-items: center; gap: 12px; }
.popup-push-label { color: var(--v2-muted); font-size: 13px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.popup-push-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.popup-push-tag { display: inline-flex; align-items: center; padding: 4px 12px; border: 1px solid var(--v2-border); border-radius: 6px; background: #f8fafc; color: var(--v2-text); font-size: 13px; font-weight: 600; }
