:root {
    --app-bg: #f6f7fb;
    --app-border: #dee4ee;
    --app-text: #172033;
    --app-muted: #657084;
    --app-sidebar: #111827;
    --app-accent: #0d6efd;
    --app-success: #198754;
}

* {
    letter-spacing: 0;
}

html {
    overflow-x: hidden;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

img,
video,
canvas {
    max-width: 100%;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px 1fr;
}

.sidebar {
    background: var(--app-sidebar);
    color: #fff;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    min-height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 8px 10px 22px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #0d6efd;
}

.sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 500;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.main {
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.content {
    padding: 24px;
}

.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0;
}

.panel {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 18px;
}

.logo-upload-panel {
    display: flex;
    align-items: center;
    gap: 18px;
    border: 1px dashed var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 16px;
}

.logo-preview {
    width: 136px;
    min-width: 136px;
    height: 96px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 10px;
}

.logo-placeholder {
    color: var(--app-muted);
    display: grid;
    justify-items: center;
    gap: 6px;
    font-size: .86rem;
    font-weight: 600;
}

.logo-placeholder svg {
    width: 24px;
    height: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 18px;
    min-height: 116px;
}

.stat-label {
    color: var(--app-muted);
    font-size: .84rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 750;
}

.table thead th {
    color: var(--app-muted);
    font-size: .78rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.table a {
    word-break: break-word;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon svg,
.sidebar svg,
.topbar svg {
    width: 18px;
    height: 18px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .78rem;
    font-weight: 700;
}

.status-DISPONIVEL {
    background: #e7f5ff;
    color: #075985;
}

.status-UTILIZADO {
    background: #eaf7ef;
    color: #146c43;
}

.status-EXPIRADO,
.status-CANCELADO {
    background: #fff1f2;
    color: #be123c;
}

.auth-page,
.public-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card,
.public-card {
    width: min(100%, 520px);
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 28px;
}

.promo-shell {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 18px;
    align-items: start;
}

.promo-panel {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 24px;
}

.promo-brand-highlight {
    width: fit-content;
    max-width: 100%;
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--promo-primary) 28%, var(--app-border));
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .13);
    padding: 14px 18px;
    margin-bottom: 18px;
}

.promo-logo {
    display: block;
    max-height: 86px;
    max-width: 220px;
    object-fit: contain;
}

.qr-preview {
    width: min(100%, 280px);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.chart-box {
    height: 300px;
}

@media (max-width: 992px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        position: sticky;
        top: 0;
        z-index: 20;
        padding: 12px;
    }

    .brand {
        padding: 4px 4px 10px;
    }

    .sidebar .nav {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        padding: 0 0 4px;
        scrollbar-width: none;
    }

    .sidebar .nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar .nav-link {
        flex: 0 0 auto;
        padding: 9px 11px;
        white-space: nowrap;
    }

    .topbar {
        position: static;
    }

    .content {
        padding: 18px;
    }

    .promo-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    body {
        font-size: .95rem;
    }

    .brand {
        font-size: 1rem;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 14px;
    }

    .topbar form,
    .topbar .btn {
        width: 100%;
    }

    .content {
        padding: 14px;
    }

    .content > .d-flex.flex-wrap.justify-content-between,
    .content > .d-flex.justify-content-between {
        align-items: stretch !important;
        gap: 12px !important;
    }

    .content > .d-flex.flex-wrap.justify-content-between > .btn,
    .content > .d-flex.justify-content-between > .btn,
    .content > .d-flex.flex-wrap.justify-content-between > .d-flex,
    .content > .d-flex.justify-content-between > .d-flex,
    .content > .d-flex.flex-wrap.justify-content-between > form,
    .content > .d-flex.justify-content-between > form {
        width: 100%;
    }

    .content > .d-flex .btn {
        min-height: 42px;
    }

    .content > .d-flex > .d-flex .btn {
        flex: 1 1 0;
    }

    .content > .d-flex > form {
        flex-wrap: wrap;
    }

    .content > .d-flex > form .form-select,
    .content > .d-flex > form .btn {
        width: 100%;
    }

    .page-title {
        font-size: 1.28rem;
    }

    .panel,
    .stat-card {
        padding: 14px;
    }

    .stat-card {
        min-height: 94px;
    }

    .stat-value {
        font-size: 1.55rem;
    }

    .chart-box {
        height: 240px;
    }

    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }

    form.panel > .d-flex.justify-content-end {
        align-items: stretch;
        flex-direction: column;
    }

    form.panel > .d-flex.justify-content-end .btn {
        width: 100%;
    }

    .input-group {
        align-items: stretch;
        flex-direction: column;
    }

    .input-group > .input-group-text,
    .input-group > .form-control {
        border-radius: 8px !important;
        width: 100%;
    }

    .input-group > .input-group-text {
        border-bottom: 0;
        font-size: .82rem;
        overflow-wrap: anywhere;
    }

    .auth-card,
    .public-card,
    .promo-panel {
        padding: 18px;
    }

    .logo-upload-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .logo-preview {
        width: 100%;
        min-width: 0;
    }

    .promo-brand-highlight {
        width: 100%;
    }

    .promo-logo {
        margin: 0 auto;
    }

    .auth-page,
    .public-page {
        align-items: start;
        min-height: 100dvh;
        padding: 12px;
        place-items: start center;
    }

    .auth-card,
    .public-card {
        margin-top: 20px;
    }

    .promo-shell {
        gap: 12px;
        width: 100%;
    }

    .promo-panel .display-6 {
        font-size: 1.72rem;
        line-height: 1.08;
    }

    .promo-panel .lead {
        font-size: 1rem;
    }

    .qr-preview {
        width: min(100%, 240px);
    }
}

@media (max-width: 700px) {
    .table-responsive {
        overflow: visible;
    }

    .table {
        display: block;
        margin-bottom: 0;
    }

    .table thead {
        display: none;
    }

    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tbody {
        display: grid;
        gap: 12px;
    }

    .table tr {
        border: 1px solid var(--app-border);
        border-radius: 8px;
        background: #fff;
        padding: 10px 12px;
    }

    .table td {
        border: 0;
        padding: 7px 0;
    }

    .table td[data-label] {
        align-items: flex-start;
        display: flex;
        gap: 16px;
        justify-content: space-between;
    }

    .table td[data-label]::before {
        color: var(--app-muted);
        content: attr(data-label);
        flex: 0 0 38%;
        font-size: .78rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .table td[data-label] > * {
        min-width: 0;
    }

    .table td[data-label].fw-semibold {
        display: block;
        font-size: 1rem;
        padding-bottom: 9px;
    }

    .table td[data-label].fw-semibold::before {
        display: block;
        margin-bottom: 2px;
    }

    .table td.text-end {
        text-align: left !important;
    }

    .table td[data-label].text-end {
        align-items: center;
        display: flex;
        gap: 8px;
    }

    .table td[data-label].text-end form {
        display: inline-flex !important;
    }

    .table td[colspan] {
        padding: 8px 0;
    }
}
