:root {
    --bg: #071121;
    --panel: #0c1b33;
    --panel-soft: #102444;
    --line: rgba(255, 255, 255, 0.09);
    --text: #f4f8ff;
    --muted: #90a6c8;
    --primary: #29a9ff;
    --primary-strong: #1987e0;
    --success: #3be3a4;
    --warning: #ffc857;
    --danger: #ff6b7b;
    --radius: 18px;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(41, 169, 255, 0.18), transparent 25%),
        linear-gradient(180deg, #040a14 0%, #071121 100%);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    padding: 18px;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(12, 27, 51, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.topbar > div:first-child {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar h1 {
    margin: 0;
    font-size: 1.2rem;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #65f2ff);
    color: #001224;
    font-weight: 700;
    letter-spacing: 1px;
}

.topbar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar-links a,
.sidebar-nav a,
.btn-primary,
.btn-secondary,
.btn-ghost {
    transition: all 0.2s ease;
}

.topbar-links a,
.sidebar-nav a {
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
}

.topbar-links a:hover,
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(41, 169, 255, 0.12);
}

.flash-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.flash {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.flash-success {
    background: rgba(59, 227, 164, 0.12);
    color: #bff9e2;
}

.flash-error {
    background: rgba(255, 107, 123, 0.12);
    color: #ffd8dd;
}

.content-grid,
.dashboard-layout,
.auth-layout {
    display: grid;
    gap: 18px;
}

.hero-card,
.section-card,
.auth-card,
.auth-side,
.sidebar,
.dashboard-content,
.metric-card,
.info-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(12, 27, 51, 0.9);
    box-shadow: var(--shadow);
}

.hero-card {
    display: grid;
    gap: 18px;
    padding: 24px;
}

.hero-card h2,
.auth-card h2,
.section-header h3 {
    margin: 0;
}

.hero-card p,
.auth-card p,
.code-box,
.empty-card,
.raffle-content p {
    color: var(--muted);
}

.hero-actions,
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.hero-side,
.stack-list,
.list-table,
.winner-grid,
.raffle-grid,
.card-grid,
.split-grid {
    display: grid;
    gap: 16px;
}

.stat-panel,
.metric-card,
.table-row,
.empty-card,
.code-box,
.qr-wrapper,
.image-preview {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.stat-panel,
.metric-card,
.empty-card,
.code-box {
    padding: 18px;
}

.stat-panel strong,
.metric-card span,
.table-row small,
.raffle-meta,
.switch-link {
    color: var(--muted);
}

.metric-card strong,
.stat-panel span {
    display: block;
    margin-top: 8px;
    font-size: 1.8rem;
}

.section-card,
.dashboard-content,
.auth-card,
.auth-side,
.sidebar {
    padding: 20px;
}

.section-header,
.inline-between,
.profile-block,
.table-row,
.table-main,
.table-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-header {
    margin-bottom: 16px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    z-index: 9999;
}

.modal-card {
    width: min(520px, 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(12, 27, 51, 0.98);
    box-shadow: var(--shadow);
    padding: 20px;
    display: grid;
    gap: 12px;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.btn-compact {
    padding: 8px 12px;
    font-size: 0.88rem;
    border-radius: 12px;
}

.raffle-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.thumb-button {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.thumb-button img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.table-main-text {
    display: grid;
    gap: 4px;
}

.table-card .table-main {
    justify-content: flex-start;
}

.modal-image {
    width: min(920px, 100%);
    padding: 14px;
}

.modal-image-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-image img {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.modal-raffle {
    width: min(920px, 100%);
    max-height: 85vh;
    overflow: auto;
}

.modal-raffle .image-preview {
    min-height: 180px;
}

.winner-card,
.raffle-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}

.winner-card {
    display: flex;
    align-items: center;
}

.winner-card img {
    width: 92px;
    height: 92px;
    object-fit: cover;
}

.winner-card div {
    padding: 14px;
    display: grid;
    gap: 4px;
}

.raffle-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.raffle-content {
    padding: 18px;
    display: grid;
    gap: 12px;
}

.raffle-content h4 {
    margin: 0;
}

.raffle-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.92rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(41, 169, 255, 0.16);
    color: #bfe6ff;
    font-size: 0.82rem;
}

.badge-muted {
    background: rgba(255, 255, 255, 0.1);
    color: #d0dbef;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #65f2ff);
    color: #00101f;
    font-weight: 700;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn-secondary {
    background: rgba(41, 169, 255, 0.12);
    color: var(--text);
    border-color: rgba(41, 169, 255, 0.24);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.btn-ghost:hover,
.btn-secondary:hover {
    border-color: rgba(41, 169, 255, 0.4);
}

.auth-layout,
.dashboard-layout {
    grid-template-columns: 1fr;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid label {
    display: grid;
    gap: 8px;
}

.form-grid span {
    font-size: 0.92rem;
    color: #d3e3ff;
}

.form-grid input,
.form-grid textarea {
    width: 100%;
    min-height: 50px;
    padding: 14px 16px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
    outline: none;
}

.form-grid textarea {
    min-height: 120px;
    resize: vertical;
}

.form-grid input:focus,
.form-grid textarea:focus {
    border-color: rgba(41, 169, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(41, 169, 255, 0.14);
}

.sidebar {
    align-self: start;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin: 18px 0;
}

.profile-block {
    align-items: center;
}

.avatar-circle,
.avatar-photo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    flex-shrink: 0;
}

.avatar-circle {
    display: grid;
    place-items: center;
    background: rgba(41, 169, 255, 0.18);
    color: #bfe6ff;
    font-size: 1.2rem;
    font-weight: 700;
}

.avatar-photo {
    object-fit: cover;
}

.dashboard-content {
    display: grid;
    gap: 18px;
}

.table-row {
    padding: 14px 16px;
}

.table-card {
    flex-wrap: wrap;
}

.table-main,
.table-side {
    flex: 1;
}

.table-side {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.1);
}

.status-pill.connected {
    background: rgba(59, 227, 164, 0.16);
    color: #bff9e2;
}

.status-pill.disconnected,
.status-pill.close {
    background: rgba(255, 107, 123, 0.16);
    color: #ffd9de;
}

.status-pill.connecting,
.status-pill.qr_ready {
    background: rgba(255, 200, 87, 0.16);
    color: #ffe8b0;
}

.qr-panel {
    margin-top: 16px;
}

.qr-wrapper,
.image-preview {
    min-height: 240px;
    display: grid;
    place-items: center;
    padding: 18px;
}

.qr-wrapper img,
.image-preview img {
    max-height: 280px;
    border-radius: 18px;
}

.switch-link {
    margin-top: 14px;
}

@media (min-width: 768px) {
    .hero-card {
        grid-template-columns: 1.5fr 1fr;
        align-items: start;
    }

    .auth-layout {
        grid-template-columns: minmax(320px, 520px) 1fr;
        align-items: start;
    }

    .dashboard-layout {
        grid-template-columns: 280px minmax(0, 1fr);
        align-items: start;
    }

    .card-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .split-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .split-grid.large-left {
        grid-template-columns: 1.1fr 0.9fr;
    }

    .raffle-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .winner-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .raffle-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
