* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: rgb(13, 15, 26);
    color: #e6e6e6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

/* ─── Login overlay ─────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(0, 252, 236, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(240, 120, 15, 0.04) 0%, transparent 60%),
        rgb(13, 15, 26);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 200;
}

.login-card {
    width: min(380px, 100%);
    background: linear-gradient(180deg, #1a1f29 0%, #11151c 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-card__title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #f3f3f3;
}

.login-card__sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 6px;
}

.login-card__btn {
    margin-top: 4px;
    width: 100%;
}

.login-card__error {
    min-height: 18px;
    font-size: 12.5px;
    color: #f88;
    text-align: center;
    margin: 0;
}

/* ─── App shell ─────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
}

/* ─── Mobile top bar ────────────────────────────────────── */
.mobile-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #0a0d14;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-bar__title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.mobile-bar__hamburger {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-bar__hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: #f3f3f3;
    border-radius: 1px;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #11151c 0%, #0a0d14 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    height: 100vh;
}

.sidebar__head {
    padding: 22px 22px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #f3f3f3;
}

.sidebar__nav {
    flex: 1;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.62);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: #f3f3f3; }
.nav-item.is-active {
    background: rgba(0, 252, 236, 0.1);
    border-color: rgba(0, 252, 236, 0.25);
    color: #00fcec;
}
.nav-item__icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

.sidebar__foot {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}
.user-pill__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 252, 236, 0.15);
    color: #00fcec;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    flex-shrink: 0;
}
.user-pill__name {
    font-size: 12.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    font-size: 10.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.04em;
    text-align: center;
}
.status-badge.is-ok    { color: #5dd1b5; }
.status-badge.is-error { color: #f88; }

/* ─── Main ──────────────────────────────────────────────── */
.main {
    height: 100vh;
    overflow-y: auto;
    padding: 28px 32px 40px;
}

.view { display: none; }
.view.is-visible { display: block; }

.view__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.view__title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #f3f3f3;
}

.view__sub {
    margin-top: 4px;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.55;
    max-width: 580px;
}

.view__head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.muted { font-size: 12px; color: rgba(255, 255, 255, 0.5); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn--primary {
    background: linear-gradient(180deg, #00fcec 0%, #07c4b6 100%);
    color: #0a0d18;
    box-shadow: 0 4px 12px rgba(0, 252, 236, 0.28);
}
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.14);
}
.btn--ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.04); }
.btn--danger {
    background: rgba(220, 70, 70, 0.12);
    color: #f88;
    border-color: rgba(220, 70, 70, 0.3);
}
.btn--danger:hover { background: rgba(220, 70, 70, 0.2); }
.btn--block { width: 100%; }
.btn--xs { padding: 5px 10px; font-size: 11px; }

/* ─── Config grid: wheel + editor ───────────────────────── */
.config-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
}

.wheel-stage {
    background: linear-gradient(180deg, #14181f 0%, #0d1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wheel-frame {
    position: relative;
    width: min(440px, 60vh);
    aspect-ratio: 1 / 1;
}
.wheel-frame__pointer {
    position: absolute;
    top: -3%;
    left: 50%;
    transform: translateX(-50%);
    width: 11%;
    z-index: 3;
    pointer-events: none;
}
.wheel-frame__rotor { position: relative; width: 100%; height: 100%; }
.wheel-frame__img {
    width: 100%; height: 100%; display: block;
    user-select: none; -webkit-user-drag: none;
}
.wheel-frame__overlay {
    position: absolute; inset: 0; width: 100%; height: 100%;
    overflow: visible;
}

.wheel-hit {
    fill: transparent;
    cursor: pointer;
    transition: fill 0.15s ease, stroke 0.15s ease;
    stroke: transparent;
    stroke-width: 0.5;
}
.wheel-hit:hover {
    fill: rgba(0, 252, 236, 0.08);
    stroke: rgba(0, 252, 236, 0.4);
}
.wheel-hit.is-selected {
    fill: rgba(0, 252, 236, 0.18);
    stroke: rgba(0, 252, 236, 0.6);
}

.wheel-frame__labels-text {
    fill: #c5e7e2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.7);
    stroke-width: 0.4;
}
.wheel-frame__labels-text--bonus { fill: #f0c79a; }
.wheel-frame__labels-text--empty { fill: rgba(255, 255, 255, 0.35); }

/* ─── Editor ────────────────────────────────────────────── */
.editor {
    background: linear-gradient(180deg, #14181f 0%, #0d1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 22px 22px 24px;
    position: sticky;
    top: 28px;
}
.editor__title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 18px;
}
.editor__title #editorIndex { color: #00fcec; font-size: 18px; }
.editor__angle {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.04em;
}
.editor__sep {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 18px 0 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field--row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
}
.field__label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}
.field__hint {
    font-size: 10.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.02em;
    text-transform: none;
}

.input, select.input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 9px 12px;
    color: #f3f3f3;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
}
select.input {
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.4) 50%),
        linear-gradient(-45deg, transparent 50%, rgba(255,255,255,0.4) 50%);
    background-position:
        calc(100% - 16px) 14px,
        calc(100% - 11px) 14px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 30px;
}
.input:focus {
    border-color: rgba(0, 252, 236, 0.5);
    background: rgba(255, 255, 255, 0.06);
}
.field input[type="checkbox"] { accent-color: #00fcec; width: 16px; height: 16px; }

.seg-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.seg-toggle__btn {
    flex: 1;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.seg-toggle__btn:hover { color: #fff; }
.seg-toggle__btn.is-active { background: rgba(0, 252, 236, 0.15); color: #00fcec; }

.kind-only { display: none; }
.editor[data-kind="fs"]    .kind-only--fs    { display: block; }
.editor[data-kind="bonus"] .kind-only--bonus { display: block; }

/* ─── Cards & tables ────────────────────────────────────── */
.card {
    background: linear-gradient(180deg, #14181f 0%, #0d1117 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}
.card--inset { padding: 18px; }

.account-card { display: flex; flex-direction: column; gap: 4px; }
.account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
}

.table-scroll { overflow-x: auto; }

.data-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    vertical-align: middle;
}
.data-table th {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding-top: 12px;
    padding-bottom: 12px;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.empty {
    padding: 36px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}
.has-rows + .empty { display: none; }
table:not(.has-rows) { display: none; }

/* New row flash — drawn briefly when auto-refresh inserts an item */
@keyframes row-flash-in {
    0%   { background: rgba(0, 252, 236, 0.18); }
    100% { background: transparent; }
}
.data-table tbody tr.is-new {
    animation: row-flash-in 1.6s ease-out;
}

/* ─── Pager ────────────────────────────────────────────── */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.pager__btn {
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.78);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.pager__btn:hover:not(:disabled) {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.22);
}
.pager__btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.pager__info {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
    min-width: 110px;
    text-align: center;
}

/* ─── Status / prize pills ──────────────────────────────── */
.prize-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.85);
}
.prize-pill--bonus { color: #f0c79a; border-color: rgba(240, 199, 154, 0.3); }
.prize-pill--jackpot {
    color: #ffd9a3;
    border-color: rgba(255, 217, 163, 0.45);
    background: rgba(240, 120, 15, 0.08);
}

.status-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.7);
}
.status-pill--done       { color: #5dd1b5; border-color: rgba(93, 209, 181, 0.35); }
.status-pill--error      { color: #f88;    border-color: rgba(220, 70, 70, 0.35); }
.status-pill--processing { color: #00fcec; border-color: rgba(0, 252, 236, 0.35); }
.status-pill--mock       { color: #f0c79a; border-color: rgba(240, 199, 154, 0.3); }

/* ─── Grants page ───────────────────────────────────────── */
.grant-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 18px;
}
.grant-form .field { margin-bottom: 0; }

.grants-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.tab {
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, 0.03); }
.tab.is-active {
    background: rgba(0, 252, 236, 0.12);
    color: #00fcec;
    border-color: rgba(0, 252, 236, 0.3);
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.modal[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(5, 7, 14, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal__card {
    position: relative;
    width: min(380px, 92vw);
    background: linear-gradient(180deg, #1a1f29 0%, #0f1219 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 24px 24px 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.22s cubic-bezier(0.18, 0.9, 0.2, 1.05);
}
.modal[aria-hidden="false"] .modal__card {
    transform: translateY(0) scale(1);
}
.modal__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #f3f3f3;
    margin-bottom: 10px;
}
.modal__error {
    min-height: 18px;
    font-size: 12px;
    color: #f88;
    text-align: center;
    margin: 4px 0 0;
}
.modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 20px;
    background: #1a1f2a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #f3f3f3;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 250;
}
.toast.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.is-ok    { border-color: rgba(0, 252, 236, 0.45); }
.toast.is-error { border-color: rgba(220, 70, 70, 0.5); color: #fbb; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1100px) {
    .config-grid { grid-template-columns: 1fr; }
    .editor { position: static; }
}

@media (max-width: 820px) {
    html, body { overflow: auto; }
    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
    }

    .mobile-bar { display: flex; }

    /* Sidebar becomes a slide-in drawer on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 80vw);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
    }
    .sidebar.is-open { transform: translateX(0); }

    /* Backdrop when sidebar is open */
    .sidebar.is-open::after {
        content: "";
        position: fixed;
        inset: 0;
        left: 100%;
        width: 100vw;
        background: rgba(5, 7, 14, 0.55);
        z-index: -1;
    }

    .main {
        height: auto;
        padding: 16px 14px 32px;
    }

    .view__head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .view__title  { font-size: 17px; }
    .view__sub    { font-size: 12px; }

    .grant-form {
        grid-template-columns: 1fr;
    }

    .account-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .wheel-stage  { padding: 16px; }
    .wheel-frame  { width: min(360px, 86vw); }

    .editor       { padding: 16px; }

    .toast {
        left: 12px;
        right: 12px;
        transform: translateY(20px);
        bottom: 16px;
    }
    .toast.is-show { transform: translateY(0); }
}
