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

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #748096;
    --primary: #5b4de8;
    --primary-light: #8175ff;
    --border: #e8ebf2;
    --success: #16a878;
    --danger: #e05252;
}

html {
    min-height: 100%;
}

body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: radial-gradient(circle at top right, #eceaff 0, #f4f7fb 35%);
    color: var(--text);
    min-height: 100vh;
}

button,
input,
select {
    font-family: inherit;
}

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

.topbar {
    width: 100%;
    max-width: 1250px;
    margin: 0 auto;
    padding: 34px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.eyebrow,
.section-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.8px;
    color: var(--primary);
}

h1 {
    font-size: clamp(28px, 4vw, 44px);
    margin: 6px 0 8px;
    letter-spacing: -1.5px;
}

h2 {
    font-size: 21px;
    margin-top: 5px;
}

p {
    color: var(--muted);
}

.status-pill {
    background: #fff;
    border: 1px solid var(--border);
    padding: 11px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 25px #1d23400b;
    white-space: nowrap;
}

.status-pill span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 7px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card,
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 12px 35px #20274d08;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: #f0efff;
    display: grid;
    place-items: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.stat-card strong {
    display: block;
    font-size: 24px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    padding: 26px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 22px;
}

.lottery-machine {
    min-height: 255px;
    border-radius: 24px;
    background: linear-gradient(135deg, #171b34, #36306d);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 30px;
    text-align: center;
}

.lottery-machine::before,
.lottery-machine::after {
    content: "";
    position: absolute;
    border: 1px solid #ffffff18;
    border-radius: 50%;
    width: 400px;
    height: 400px;
}

.lottery-machine::before {
    transform: translate(-35%, 40%);
}

.lottery-machine::after {
    transform: translate(35%, -40%);
}

.machine-ring {
    position: absolute;
    width: 150px;
    height: 150px;
    border: 1px solid #ffffff20;
    border-radius: 50%;
    animation: spin 12s linear infinite;
}

.display-name {
    position: relative;
    color: #fff;
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 900;
    letter-spacing: -1px;
    z-index: 1;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.display-division {
    position: relative;
    color: #bcb8ff;
    margin-top: 10px;
    font-weight: 600;
    z-index: 1;
}

.draw-button {
    width: 100%;
    border: 0;
    border-radius: 14px;
    margin-top: 18px;
    padding: 17px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 10px 25px #5b4de83d;
    transition: 0.2s;
}

.draw-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px #5b4de855;
}

.draw-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.draw-message {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 12px;
}

.machine-light {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 14px var(--success);
}

form {
    display: grid;
    gap: 15px;
}

label {
    font-size: 13px;
    font-weight: 800;
    color: #46516a;
}

input,
select {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 13px 14px;
    font: inherit;
    outline: none;
    background: #fbfcff;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #5b4de812;
}

.input-percent {
    position: relative;
}

.input-percent input {
    padding-right: 35px;
}

.input-percent span {
    position: absolute;
    right: 14px;
    top: 19px;
    color: var(--muted);
    font-weight: 700;
}

.primary-btn {
    border: 0;
    border-radius: 11px;
    padding: 14px;
    background: var(--text);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.form-note {
    font-size: 12px;
    line-height: 1.6;
    margin-top: 15px;
}

.table-title {
    align-items: center;
}

.total-badge {
    background: #f3f2ff;
    color: var(--primary);
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 13px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
}

th,
td {
    text-align: left;
    padding: 15px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.name-cell {
    font-weight: 800;
}

.division-tag {
    display: inline-block;
    background: #f3f5f9;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #59657a;
}

.weight-cell {
    font-weight: 900;
    color: var(--primary);
}

.action-btn {
    border: 0;
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
}

.delete-btn {
    background: #fff0f0;
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 35px 10px;
    font-size: 14px;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: center;
    padding: 13px 15px;
    background: #fafbfe;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.history-item strong {
    font-size: 14px;
}

.history-item small {
    color: var(--muted);
}

.danger-outline {
    border: 1px solid #f0caca;
    background: #fff;
    color: var(--danger);
    padding: 9px 12px;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: #172033;
    color: #fff;
    padding: 13px 17px;
    border-radius: 12px;
    opacity: 0;
    transform: translateY(15px);
    pointer-events: none;
    transition: 0.3s;
    font-size: 13px;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.winner {
    animation: winnerPulse 0.6s ease 3;
}

.rolling {
    animation: rolling 0.12s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes rolling {
    0% {
        transform: translateY(-3px);
    }
    50% {
        transform: translateY(3px);
    }
    100% {
        transform: translateY(-3px);
    }
}

@keyframes winnerPulse {
    50% {
        transform: scale(1.08);
        text-shadow: 0 0 25px #aaa4ff;
    }
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .status-pill {
        align-self: flex-start;
    }

    .container {
        padding: 0 14px 40px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card strong {
        font-size: 20px;
    }

    .card {
        padding: 18px;
    }

    .table-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-item {
        align-items: flex-start;
        flex-direction: column;
    }
}
