:root {
    --bg: #101713;
    --panel: #ffffff;
    --text: #17211f;
    --muted: #66736f;
    --line: #dfe7e4;
    --primary: #16a34a;
    --primary-dark: #0f7a37;
    --accent: #f8d34a;
    --danger: #b42318;
    --warning: #9a6700;
    --success: #067647;
    --shadow: 0 18px 45px rgba(4, 9, 7, .16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Rubik, Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 20% 0%, rgba(34, 197, 94, .18), transparent 28%),
        linear-gradient(135deg, #101713 0%, #16231c 42%, #0a100d 100%);
}

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

code,
pre {
    font-family: Consolas, Monaco, monospace;
}

pre {
    overflow: auto;
    padding: 16px;
    background: #101828;
    color: #f9fafb;
    border-radius: 8px;
}

.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #07100c 0%, #102019 100%);
    color: #e9f4f2;
    padding: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #22c55e);
    color: #101713;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #aac4bf;
    margin-top: 2px;
}

.nav {
    display: grid;
    gap: 18px;
    margin-top: 22px;
}

.nav-group {
    display: grid;
    gap: 5px;
}

.nav-title {
    display: block;
    padding: 0 10px 4px;
    color: #82a49e;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #cfe3df;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 18px;
    font-size: 20px;
    line-height: 1;
}

.nav a.active,
.nav a:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.main {
    min-width: 0;
    padding: 22px;
    background: #f4f7f1;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.topbar strong,
.topbar span {
    display: block;
}

.topbar span {
    color: var(--muted);
    font-size: 13px;
}

.topbar form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel,
.metric,
.login-card,
.scratch-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel h1,
.panel h2,
.metric strong,
.topbar strong,
.scratch-hero h1,
.scratch-result h2 {
    font-family: Rajdhani, Rubik, Arial, sans-serif;
    letter-spacing: 0;
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

.panel h1,
.panel h2 {
    margin: 0 0 14px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-head h2 {
    margin: 0;
}

.narrow {
    max-width: 760px;
}

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

.metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric {
    padding: 16px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.form label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd9d6;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: white;
}

input[type="checkbox"] {
    width: auto;
}

textarea {
    resize: vertical;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.stack {
    display: grid;
    gap: 14px;
}

.full {
    grid-column: 1 / -1;
}

.filter-panel .filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.ajax-results {
    transition: opacity .16s ease;
}

.ajax-results.ajax-loading {
    opacity: .55;
    pointer-events: none;
}

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

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #22c55e);
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-light {
    background: #edf7df;
    color: #102019;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #7a271a;
}

.btn-small {
    min-height: 30px;
    padding: 6px 10px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    background: #99aaa6;
    cursor: not-allowed;
}

.status,
.tag,
.user-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #ecfccb;
    color: #365314;
    font-size: 12px;
    font-weight: 800;
}

.status-gerada {
    background: #f1f5f9;
    color: #334155;
}

.status-enviada {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-erro-envio,
.status-cancelado {
    background: #fee2e2;
    color: #b91c1c;
}

.status-aberta {
    background: #ccfbf1;
    color: #0f766e;
}

.status-raspada {
    background: #ede9fe;
    color: #6d28d9;
}

.status-premiada {
    background: #fef3c7;
    color: #b45309;
}

.status-nao-premiada {
    background: #e2e8f0;
    color: #475569;
}

.status-premio-retirado,
.status-retirado {
    background: #dcfce7;
    color: #15803d;
}

.status-pendente {
    background: #ffedd5;
    color: #c2410c;
}

.status-expirada {
    background: #f3f4f6;
    color: #6b7280;
}

.status-ativo {
    background: #dcfce7;
    color: #15803d;
}

.status-inativo {
    background: #f3f4f6;
    color: #6b7280;
}

.winner-photo-thumb {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.inline-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 2px;
}

.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.qr-preview img {
    width: 120px;
    max-height: 120px;
    object-fit: contain;
}

.qr-preview {
    display: grid;
    gap: 8px;
    justify-items: start;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(7, 16, 12, .72);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-box {
    width: min(680px, calc(100vw - 28px));
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 18px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .32);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-head h2 {
    margin: 0;
}

.qr-modal-content {
    display: grid;
    place-items: center;
    min-height: 420px;
    padding: 14px;
    border-radius: 8px;
    background: #f7faf8;
}

.qr-modal-content img {
    width: min(540px, 88vw);
    height: auto;
    image-rendering: pixelated;
}

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

.danger-text {
    color: var(--danger);
}

.leaflet-map {
    width: 100%;
    min-height: 320px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin: 14px 0 8px;
}

.client-location-map {
    min-height: 520px;
}

.location-page {
    width: min(980px, calc(100vw - 28px));
    margin: 0 auto;
    padding: 24px 0;
}

.layout-preview {
    overflow: hidden;
}

.scratch-preview {
    min-height: 280px;
    display: grid;
    align-content: end;
    gap: 12px;
    padding: 28px;
    color: #fff;
    border-radius: 8px;
    background:
        radial-gradient(circle at 80% 0%, rgba(248, 211, 74, .28), transparent 26%),
        linear-gradient(140deg, var(--preview-theme), #101713);
    background-size: cover;
    background-position: center;
}

.scratch-preview h3 {
    margin: 0;
    font-family: Rajdhani, Rubik, Arial, sans-serif;
    font-size: 42px;
}

.scratch-preview p {
    margin: 0;
    max-width: 520px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: white;
}

.alert-success {
    color: var(--success);
    border-color: #abefc6;
}

.alert-danger {
    color: var(--danger);
    border-color: #fecdca;
}

.alert-warning {
    color: var(--warning);
    border-color: #fedf89;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #0b1f1d;
}

.login-card {
    width: min(420px, calc(100vw - 28px));
    padding: 28px;
}

.login-brand {
    margin-bottom: 22px;
}

.login-separator {
    height: 1px;
    margin: 22px 0;
    background: var(--line);
}

.recovery-form strong {
    font-family: Rajdhani, Rubik, Arial, sans-serif;
    font-size: 1.1rem;
}

.floating-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

.public-page {
    min-height: 100vh;
    background: #eef5f3;
}

.scratch-public {
    width: min(760px, calc(100vw - 24px));
    margin: 0 auto;
    padding: 10px 0 26px;
}

.scratch-hero {
    min-height: 176px;
    border-radius: 0 0 14px 14px;
    padding: 16px 18px;
    color: white;
    background:
        radial-gradient(circle at 82% 18%, rgba(250, 204, 21, .36), transparent 24%),
        linear-gradient(135deg, var(--campaign-color), #101713);
    background-size: cover;
    background-position: center;
    display: grid;
    align-content: end;
}

.scratch-hero h1 {
    margin: 18px 0 4px;
    font-size: clamp(28px, 5vw, 44px);
    line-height: .98;
}

.scratch-hero p {
    margin: 4px 0;
}

.public-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: start;
    font-weight: 800;
}

.public-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
}

.scratch-box {
    padding: 14px;
    margin-top: 12px;
}

.scratch-play {
    border: 2px solid rgba(250, 204, 21, .85);
    background:
        linear-gradient(180deg, rgba(255, 248, 214, .92), rgba(255, 255, 255, .96)),
        var(--panel);
    box-shadow: 0 18px 45px rgba(16, 23, 19, .18);
}

.scratch-play-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: #2f3c37;
    font-weight: 800;
}

.scratch-play-head span {
    font-family: Rajdhani, Rubik, Arial, sans-serif;
    font-size: 24px;
}

.scratch-play-head strong {
    padding: 6px 10px;
    border-radius: 8px;
    background: #101713;
    color: var(--campaign-accent);
    font-size: 13px;
    letter-spacing: 0;
}

.scratch-card {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 292px;
    overflow: hidden;
    border-radius: 10px;
    border: 2px dashed rgba(16, 23, 19, .28);
    background:
        radial-gradient(circle at 20% 10%, rgba(250, 204, 21, .34), transparent 24%),
        linear-gradient(135deg, #ffffff, #eef8f5);
}

.scratch-result {
    text-align: center;
    padding: 20px;
}

.scratch-result h2 {
    margin: 0 0 6px;
    font-size: 40px;
    color: #101713;
}

.scratch-location h2 {
    margin: 0 0 6px;
}

.scratch-location p {
    margin: 6px 0;
}

.scratch-location .leaflet-map {
    min-height: 230px;
    margin: 10px 0 6px;
}

#scratchCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

.prize-img {
    max-width: 220px;
    max-height: 160px;
    object-fit: contain;
    margin-top: 12px;
}

.winner-box {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.withdrawal-qr {
    display: block;
    width: min(260px, 100%);
    height: auto;
    margin: 0 auto 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.qr-reader {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fbf8;
}

.qr-reader video {
    width: 100%;
    max-height: 360px;
    border-radius: 8px;
    background: #101713;
    object-fit: cover;
}

@media (max-width: 1100px) {
    .metrics,
    .grid-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .two-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        height: auto;
    }
    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .nav-group {
        min-width: 0;
    }
    .main {
        padding: 14px;
    }
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .metrics,
    .grid-form {
        grid-template-columns: 1fr;
    }
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .scratch-public {
        width: min(100vw - 16px, 760px);
        padding-top: 6px;
    }
    .scratch-hero {
        min-height: 150px;
        padding: 14px;
    }
    .scratch-hero h1 {
        font-size: 30px;
    }
    .scratch-box {
        padding: 12px;
        margin-top: 10px;
    }
    .scratch-card {
        min-height: 250px;
    }
    .scratch-result h2 {
        font-size: 32px;
    }
    .scratch-location .leaflet-map {
        min-height: 200px;
    }
}
