:root {
    --bg: #f4f7fb;
    --bg-alt: #eef3f8;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-strong: #ffffff;
    --border: rgba(17, 24, 39, 0.08);
    --text: #152033;
    --muted: #596579;
    --primary: #ffb703;
    --primary-strong: #ff9f1c;
    --success: #16a34a;
    --danger: #ef4444;
    --shadow: 0 18px 50px rgba(20, 34, 58, 0.1);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background:
    radial-gradient(circle at top left, rgba(255, 183, 3, 0.16), transparent 22%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.site-header,
.site-footer,
.site-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    gap: 16px;
}

.brand {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

.brand__mark {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.brand__text {
    color: var(--muted);
    font-size: 0.9rem;
}

.site-nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.site-nav a {
    color: var(--muted);
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    transition: 0.2s ease;
}

.site-nav a:hover {
    color: var(--text);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.admin-page {
    background:
        radial-gradient(circle at top left, rgba(14, 165, 233, 0.14), transparent 26%),
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 24%),
        linear-gradient(180deg, #f5f7fb 0%, #edf2f9 100%);
}

.admin-page .site-header {
    padding: 14px 18px;
    margin-top: 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

.admin-page .brand__mark {
    font-size: 1.1rem;
}

.admin-page .site-nav a {
    color: #334155;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    font-weight: 600;
}

.admin-page .site-nav a:hover {
    color: #0f172a;
    border-color: rgba(14, 165, 233, 0.4);
    background: rgba(14, 165, 233, 0.08);
}

.site-main {
    padding: 24px 0 56px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.landing-shell {
    display: grid;
    gap: 24px;
}

.landing-page .site-main {
    padding-top: 16px;
}

.landing-intro {
    max-width: 840px;
}

.landing-intro h1 {
    max-width: 14ch;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
    gap: 24px;
    align-items: start;
}

.hero-copy,
.wheel-panel {
    padding: 28px;
}

.eyebrow {
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: var(--primary-strong);
    font-size: 0.78rem;
}

h1 {
    margin: 0;
    font-size: clamp(2.2rem, 4vw, 4.3rem);
    line-height: 0.95;
}

h2 {
    margin: 0;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    line-height: 1.15;
}

.lead {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.7;
    max-width: 60ch;
}

.play-form {
    display: grid;
    gap: 16px;
}

.play-form.is-disabled {
    opacity: 0.55;
    filter: grayscale(0.25);
    pointer-events: none;
}

.form-head {
    display: grid;
    gap: 8px;
    margin-bottom: 6px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.play-form label,
.field-group label {
    display: grid;
    color: var(--text);
    font-weight: 600;
    font-size: 0.96rem;
}

.play-form input[type="text"],
.play-form input[type="email"],
.play-form input[type="tel"] {
    width: 100%;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    border-radius: 16px;
    padding: 15px 16px;
    outline: none;
    transition: 0.2s ease;
}

.play-form input:focus {
    border-color: rgba(255, 159, 28, 0.55);
    box-shadow: 0 0 0 4px rgba(255, 159, 28, 0.12);
}

.play-form label.terms-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.terms-check__text {
    display: inline;
    font-size: 0.72rem;
    line-height: 1.35;
    font-weight: 500;
    color: var(--muted);
}

.terms-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-strong);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border: 0;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.button--full {
    width: 100%;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.button--primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #231500;
}

.wheel-panel {
    display: grid;
    gap: 18px;
    background:
        radial-gradient(circle at 12% 14%, rgba(255, 255, 255, 0.75), transparent 35%),
        radial-gradient(circle at 90% 12%, rgba(255, 183, 3, 0.25), transparent 30%),
        #ffffff;
}

.wheel-stage {
    position: relative;
    display: grid;
    place-items: center;
    padding: 20px 0 10px;
}

.wheel-stage--codepen {
    padding-top: 28px;
}

.wheel-halo {
    position: absolute;
    width: min(74vw, 520px);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(255, 183, 3, 0.22) 0%, rgba(255, 183, 3, 0.08) 45%, transparent 68%),
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.6), transparent 45%);
    filter: blur(1px);
    pointer-events: none;
    z-index: 0;
}

.wheel-pointer {
    position: absolute;
    top: 2px;
    z-index: 4;
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 32px solid #0ea5e9;
    filter: drop-shadow(0 8px 10px rgba(20, 34, 58, 0.22));
}

.wheel {
    --size: min(70vw, 480px);
    width: var(--size);
    height: var(--size);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 14px solid #ffffff;
    box-shadow:
        inset 0 0 0 10px rgba(255, 255, 255, 0.35),
        0 22px 50px rgba(20, 34, 58, 0.2),
        0 0 0 10px rgba(255, 183, 3, 0.18);
    position: relative;
    overflow: hidden;
    background: var(--surface-strong);
    z-index: 2;
}

.wheel--d3 {
    --size: min(88vw, 500px);
    width: min(100%, 500px);
    height: auto;
    aspect-ratio: auto;
    border: 0;
    box-shadow: none;
    background: transparent;
    overflow: visible;
}

.wheel--d3::after {
    display: none;
}

#chart {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    z-index: 1;
}

#chart::before {
    content: "";
    display: block;
    position: absolute;
    width: 102%;
    height: 102%;
    left: -1%;
    top: -1%;
    pointer-events: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    z-index: -1;
}

#chart svg {
    width: 100%;
    height: 100%;
}

.wheel-panel svg text {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    fill: #ffffff;
    pointer-events: none;
}

#question {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 16px auto 0;
    min-height: 56px;
    text-align: center;
}

#question p {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #1e293b;
}

.wheel-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.wheel::after {
    content: '';
    position: absolute;
    inset: 50%;
    width: 22%;
    height: 22%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: linear-gradient(160deg, #ffdd57 0%, #ff9f1c 100%);
    box-shadow:
        inset 0 0 0 6px rgba(255, 255, 255, 0.55),
        0 6px 18px rgba(0, 0, 0, 0.2);
    z-index: 3;
}

.wheel__label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: 0 0;
    color: #ffffff;
    font-size: clamp(0.72rem, 1.1vw, 0.95rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
    pointer-events: none;
}

.wheel__label span {
    display: inline-block;
    transform: translate(-50%, -50%) rotate(90deg);
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(6px);
}

.wheel.is-spinning {
    filter: saturate(1.05) brightness(1.02);
}

.result-box {
    min-height: 64px;
    padding: 16px;
    border-radius: 20px;
    background: #f8fafc;
    border: 1px solid rgba(17, 24, 39, 0.06);
    color: var(--muted);
}

.result-box strong {
    color: var(--text);
}

.flash-success {
    color: #177245;
}

.flash-error {
    color: #b42318;
}

.wheel-note {
    margin: 0;
    color: #334155;
    font-size: 0.95rem;
    text-align: center;
    font-weight: 600;
}

.landing-page .button--primary {
    background: linear-gradient(160deg, #ffdd57 0%, #ff9f1c 45%, #ff6b35 100%);
    color: #2f1800;
    box-shadow: 0 12px 24px rgba(255, 159, 28, 0.35);
}

.landing-page .button--primary:hover {
    transform: translateY(-2px) scale(1.01);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.stat-card,
.table-card,
.form-card {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.admin-page .admin-layout {
    gap: 20px;
}

.admin-hero {
    padding: 6px 2px;
}

.admin-hero .eyebrow {
    margin-bottom: 8px;
    color: #0ea5e9;
    letter-spacing: 0.16em;
}

.admin-hero h1 {
    font-size: clamp(1.8rem, 2.4vw, 2.5rem);
    line-height: 1.1;
}

.admin-hero .lead {
    margin-top: 10px;
    max-width: 70ch;
    font-size: 0.92rem;
}

.admin-page .stat-card,
.admin-page .form-card,
.admin-page .table-card {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    border-radius: 18px;
}

.admin-page .stat-card {
    position: relative;
    overflow: hidden;
}

.admin-page .stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

.admin-page .stat-card p {
    margin: 0;
    color: #64748b;
    font-weight: 600;
}

.stat-card__value {
    margin: 8px 0 0;
    font-size: 2rem;
    font-weight: 800;
    color: #0f172a;
}

.admin-layout {
    display: grid;
    gap: 24px;
}

.admin-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.admin-section__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.admin-section__head h2 {
    font-size: 1.18rem;
    line-height: 1.2;
}

.admin-section__head p {
    margin: 0;
    color: #64748b;
    font-size: 0.88rem;
}

.admin-filters label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
}

.admin-filters input,
.admin-filters select {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #ffffff;
    color: var(--text);
    border-radius: 12px;
    padding: 10px 12px;
}

.admin-filters input:focus,
.admin-filters select:focus {
    outline: none;
    border-color: rgba(14, 165, 233, 0.45);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.13);
}

.admin-filters__actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-filters__actions .button {
    min-height: 42px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}

.admin-filters__actions .button--primary {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(2, 132, 199, 0.28);
}

.admin-filters__actions .button--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(2, 132, 199, 0.33);
}

.admin-filters__actions .action-link {
    min-height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.14);
    color: #334155;
    font-weight: 600;
    transition: 0.2s ease;
}

.admin-filters__actions .action-link:hover {
    border-color: rgba(14, 165, 233, 0.45);
    color: #0f172a;
    background: #f0f9ff;
}

.warning-banner,
.success-banner {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid;
    font-size: 0.92rem;
}

.warning-banner {
    background: #fff7ed;
    border-color: #fdba74;
    color: #9a3412;
}

.success-banner {
    background: #ecfdf3;
    border-color: #86efac;
    color: #166534;
}

.color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid rgba(15, 23, 42, 0.15);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
}

.table-pagination {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.table-pagination .action-link {
    min-height: 36px;
    padding: 0 12px;
    background: #ffffff;
    color: #334155;
}

.table-pagination .action-link.is-active {
    background: #0ea5e9;
    color: #ffffff;
    border-color: #0ea5e9;
}

.table-pagination .action-link.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-ellipsis {
    color: #64748b;
    font-weight: 700;
    padding: 0 2px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: top;
}

th {
    color: #475569;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #f8fafc;
}

tbody tr:nth-child(even) {
    background: #fcfdff;
}

tbody tr:hover {
    background: rgba(14, 165, 233, 0.06);
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip,
.action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.chip--on {
    color: #b7f7c2;
}

.chip--off {
    color: #ffd0d0;
}

.admin-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-form .full-width {
    grid-column: 1 / -1;
}

.admin-form label,
.auth-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.admin-form input,
.admin-form textarea,
.admin-form select,
.auth-form input {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(7, 13, 24, 0.9);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}

.brand-form input[type="text"],
.brand-form input[type="url"],
.brand-form input[type="number"],
.brand-form select {
    background: #ffffff;
    color: #111827;
}

.auth-form input {
    background: #ffffff;
    color: #111827;
}

.brands-page {
    gap: 18px;
}

.brands-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.brand-kpi {
    background: linear-gradient(165deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.brand-kpi p {
    margin: 0;
    color: #64748b;
    font-weight: 600;
    font-size: 0.88rem;
}

.brand-kpi strong {
    display: inline-block;
    margin-top: 8px;
    font-size: 1.8rem;
    color: #0f172a;
}

.brand-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.brand-status-badge--on {
    color: #166534;
    background: #ecfdf3;
    border-color: #86efac;
}

.brand-status-badge--off {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.brands-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 16px;
    align-items: start;
}

.brand-preview-card {
    display: grid;
    gap: 14px;
}

.brand-preview-box {
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 16px;
    min-height: 210px;
    display: grid;
    align-content: start;
    gap: 10px;
}

.brand-preview-logo {
    max-height: 46px;
    width: auto;
    object-fit: contain;
}

.brand-preview-box h3 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.3;
    color: #0f172a;
}

.brand-preview-box p {
    margin: 0;
    color: #334155;
    font-weight: 600;
}

.brand-snippet {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 14px;
    background: #f8fafc;
    padding: 12px;
    display: grid;
    gap: 8px;
}

.brand-snippet p {
    margin: 0;
    font-size: 0.84rem;
    color: #475569;
    font-weight: 700;
}

.brand-snippet code {
    display: block;
    white-space: pre-wrap;
    word-break: break-all;
    color: #0f172a;
    font-size: 0.8rem;
    line-height: 1.45;
}

.field-error {
    min-height: 1.1em;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
}

.field-group input:invalid:not(:placeholder-shown) {
    border-color: rgba(180, 35, 24, 0.35);
}

.admin-form textarea {
    min-height: 110px;
    resize: vertical;
}

.auth-shell {
    width: min(520px, calc(100% - 32px));
    margin: 48px auto;
}

.auth-card {
    padding: 32px;
}

.auth-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.site-footer {
    padding: 20px 0 34px;
    color: var(--muted);
    font-size: 0.95rem;
}

.admin-page .site-footer {
    color: #64748b;
}

.wheel-popup-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    z-index: 9999;
}

.wheel-popup {
    width: min(440px, 100%);
    position: relative;
    background: #ffffff;
    color: var(--text);
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(17, 24, 39, 0.08);
}

.wheel-popup__eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.75rem;
    color: #ff9f1c;
    font-weight: 800;
}

.wheel-popup h3 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    line-height: 1.2;
}

.wheel-popup p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.wheel-popup strong {
    color: var(--text);
}

.wheel-popup__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.05);
    color: var(--text);
    font-size: 1.6rem;
    cursor: pointer;
}

@media (max-width: 980px) {
    .hero-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .brands-summary-grid,
    .brands-form-grid {
        grid-template-columns: 1fr;
    }

    .admin-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wheel-halo {
        width: min(92vw, 520px);
    }

    .admin-form {
        grid-template-columns: 1fr;
    }

    .admin-section__head {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .landing-intro h1 {
        max-width: none;
    }

    .hero-copy,
    .wheel-panel,
    .stat-card,
    .table-card,
    .form-card,
    .auth-card {
        padding: 20px;
    }

    .wheel {
        --size: min(82vw, 360px);
    }

    .admin-filters {
        grid-template-columns: 1fr;
    }

    .wheel-stage--codepen {
        padding-top: 16px;
    }
}
