/* Author: Rafael Silva | Version: 1.14 */

:root {
    --brand: #0034a4;
    --brand-soft: #e8eef8;
    --brand-mid: #1a4db8;
    --secondary: #cccccc;
    --surface: #f5f6f8;
    --panel: #ffffff;
    --ink: #1a1d24;
    --mute: #5c6570;
    --ok: #0d7a45;
    --alert: #b42318;
    --line: #cccccc;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --shell-pad: 1.25rem;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--surface);
    color: var(--ink);
    font-family: Figtree, "Segoe UI", sans-serif;
    padding: 0 0 3rem;
}

/* —— Shell (brand header) —— */

.shell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    padding: 0.85rem var(--shell-pad);
    background: var(--brand);
    color: #fff;
}

.shell-brand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem 1.75rem;
}

.shell-logo {
    display: block;
    line-height: 0;
}

.shell-logo img {
    display: block;
    height: 36px;
    width: auto;
}

.shell-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.site-nav a {
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.site-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.site-nav a.is-active {
    color: var(--brand);
    background: #fff;
}

.site-nav a:focus-visible,
.logout:focus-visible,
.period label:focus-within {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.spot-btn:focus-visible,
.gate-form button:focus-visible,
.gate-form input:focus-visible,
.order-id-input:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.logout {
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
}

.logout:hover {
    color: #fff;
    border-bottom-color: #fff;
}

/* —— Period toolbar —— */

.period {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 0.1rem;
    -webkit-overflow-scrolling: touch;
}

.period label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius);
    padding: 0.4rem 0.65rem;
    background: transparent;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.period label:hover {
    background: rgba(255, 255, 255, 0.1);
}

.period label:has(input:checked) {
    background: #fff;
    color: var(--brand);
    border-color: #fff;
}

.period input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.period-date {
    cursor: default;
}

.period-date span {
    font-family: Chivo, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
}

.period-date input[type="date"] {
    font-family: var(--mono);
    font-size: 0.8rem;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    max-width: 9.5rem;
}

.period label:has(input:checked) .period-date span,
.period label:has(input:checked) input[type="date"] {
    color: var(--brand);
}

/* —— Page content —— */

.page {
    padding: 1.35rem var(--shell-pad) 0;
    max-width: 1400px;
    margin: 0 auto;
    min-width: 0;
}

.page-head {
    margin-bottom: 1rem;
}

.page-head h1 {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-weight: 900;
    font-size: clamp(1.55rem, 3.5vw, 2.1rem);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--ink);
}

.lede {
    margin: 0.35rem 0 0;
    color: var(--mute);
    font-size: 0.95rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.75rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    color: var(--mute);
    font-size: 0.95rem;
    background: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.status.is-loading {
    background: var(--brand-soft);
    border-color: #9bb0d9;
    color: var(--brand);
    font-weight: 600;
}

.status.is-loading::before {
    content: "";
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    border: 2px solid #b8c8e6;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: status-spin 0.7s linear infinite;
}

.status.is-loading {
    animation: status-pulse 1.6s ease-in-out infinite;
}

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

@keyframes status-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 52, 164, 0);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(0, 52, 164, 0.12);
    }
}

@media (prefers-reduced-motion: reduce) {
    .status.is-loading,
    .status.is-loading::before {
        animation: none;
    }
}

.banner {
    background: #f8d7d3;
    color: var(--alert);
    border: 1px solid var(--alert);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    font-weight: 600;
    margin: 0.75rem 0 0;
}

/* —— Hero metric —— */

.till {
    background: var(--brand);
    color: #fff;
    padding: 1.15rem 1.35rem 1.3rem;
    margin: 1rem 0 1.25rem;
    max-width: none;
    width: 100%;
    border-radius: var(--radius);
}

.till-wide {
    max-width: none;
}

.till-tag,
.till-period {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.till-value {
    margin: 0.35rem 0 0.45rem;
    font-family: var(--mono);
    font-size: clamp(1.75rem, 4.5vw, 2.85rem);
    line-height: 1.15;
    color: #fff;
    letter-spacing: 0.02em;
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.metric-tag {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--mute);
}

.metric-value {
    margin: 0.25rem 0 0.4rem;
    font-family: var(--mono);
    font-size: clamp(1.25rem, 3vw, 1.6rem);
    color: var(--ink);
    letter-spacing: 0.02em;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.till-actions {
    margin-top: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

.till .spot-btn {
    background: #fff;
    color: var(--brand);
    border-color: #fff;
}

.till .spot-btn:hover {
    background: var(--brand-soft);
}

.till .spot-btn:focus-visible {
    outline-color: #fff;
}

/* —— KPI tiles (legacy class .lcd kept for JS) —— */

.register {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.lcd {
    background: var(--panel);
    color: var(--ink);
    padding: 0.85rem 0.95rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-height: 5.4rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow: hidden;
}

.lcd span {
    display: block;
    font-family: Chivo, sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--mute);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.lcd strong {
    display: block;
    margin-top: auto;
    font-family: var(--mono);
    font-size: clamp(0.95rem, 2.2vw, 1.15rem);
    font-weight: 500;
    color: var(--ink);
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* —— Panels & tables —— */

.paper,
.receipts article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem 1.2rem;
    min-width: 0;
    overflow-x: auto;
}

.paper {
    margin-bottom: 1.25rem;
}

.receipts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
}

h2 {
    margin: 0 0 0.75rem;
    font-family: Chivo, sans-serif;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

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

th {
    font-family: Chivo, sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mute);
    font-weight: 700;
    background: var(--panel);
}

td:last-child,
th:last-child {
    text-align: right;
    font-family: var(--mono);
}

tbody tr:nth-child(even) {
    background: var(--brand-soft);
}

tbody tr:hover {
    background: #d4dff0;
}

tbody tr {
    transition: background 0.12s ease;
}

.empty {
    color: var(--mute);
    margin: 0;
}

.exception-kind {
    font-family: Chivo, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.order-lookup-label {
    font-family: Figtree, sans-serif;
    font-size: 0.78rem;
    color: var(--mute);
    align-self: center;
}

.order-id-input {
    font-family: var(--mono);
    font-size: 0.95rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    width: 9rem;
    min-height: 2.35rem;
}

.audit-band {
    padding: 0.85rem 0;
    border-top: 1px solid var(--line);
}

.audit-band:first-of-type {
    margin-top: 0.35rem;
}

.audit-band-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem 0.85rem;
    margin-bottom: 0.55rem;
}

.audit-band-title {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}

.audit-band-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--mute);
}

.audit-band-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

.spot-result {
    margin-top: 0.35rem;
}

.batch-results {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.batch-delta {
    margin-bottom: 0.85rem;
}

.batch-exceptions-title {
    margin-top: 0.35rem;
}

.spot-panel {
    margin-bottom: 1.25rem;
}

.spot-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.spot-head h2 {
    margin: 0;
}

.spot-hint {
    margin: 0 0 0.85rem;
}

.spot-btn {
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}

.spot-btn:hover {
    background: var(--brand-mid);
    border-color: var(--brand-mid);
}

.spot-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.spot-btn--ghost {
    background: transparent;
    color: var(--brand);
}

.spot-btn--ghost:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand);
}

.spot-btn--tiny {
    font-size: 0.65rem;
    padding: 0.3rem 0.55rem;
}

.spot-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.95rem 1rem 1.05rem;
    background: var(--panel);
    margin-top: 0.75rem;
}

.spot-card.verdict-ok {
    border-left: 3px solid var(--ok);
}

.spot-card.verdict-amount_mismatch,
.spot-card.verdict-status_not_paid,
.spot-card.verdict-missing_in_asaas {
    border-left: 3px solid var(--alert);
}

.spot-verdict {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.spot-detail {
    margin: 0.4rem 0 0.75rem;
    color: var(--mute);
    font-size: 0.95rem;
}

.spot-facts {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--panel);
}

.spot-fact {
    display: grid;
    grid-template-columns: minmax(7.5rem, 10.5rem) minmax(0, 1fr);
    gap: 0.35rem 0.85rem;
    align-items: baseline;
    padding: 0.55rem 0.75rem;
    background: var(--panel);
    border-radius: 0;
    border-bottom: 1px solid var(--line);
}

.spot-fact:nth-child(even) {
    background: var(--brand-soft);
}

.spot-fact:last-child {
    border-bottom: 0;
}

.spot-fact-label,
.spot-fact span {
    display: block;
    font-family: Chivo, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mute);
    margin: 0;
}

.spot-fact-value,
.spot-fact strong {
    display: block;
    margin: 0;
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 520px) {
    .spot-fact {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
}

.spot-ids {
    margin-top: 0.75rem;
    border-top: 1px solid var(--line);
    padding-top: 0.55rem;
}

.spot-ids summary {
    cursor: pointer;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
    list-style: none;
}

.spot-ids summary::-webkit-details-marker {
    display: none;
}

.spot-ids-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.spot-ids-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.25rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--mute);
    word-break: break-all;
}

.spot-meta {
    margin: 0.45rem 0 0;
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--mute);
}

.verdict-ok .spot-verdict {
    color: var(--ok);
}

.verdict-amount_mismatch .spot-verdict,
.verdict-status_not_paid .spot-verdict,
.verdict-missing_in_asaas .spot-verdict {
    color: var(--alert);
}

.exceptions-wrap {
    overflow-x: auto;
}

.exceptions-wrap table {
    min-width: 36rem;
}

/* —— Login —— */

.gate-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, #1a4db8 0%, transparent 55%),
        var(--brand);
}

.gate {
    width: 100%;
    max-width: 22rem;
    margin: 0;
    color: #fff;
}

.gate-logo {
    display: block;
    height: 40px;
    width: auto;
    margin-bottom: 1.25rem;
}

.gate h1 {
    margin: 0;
    font-family: Chivo, sans-serif;
    font-weight: 900;
    font-size: clamp(1.6rem, 4vw, 2rem);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: #fff;
}

.gate .lede {
    color: rgba(255, 255, 255, 0.75);
}

.gate .banner {
    margin-top: 1rem;
}

.gate-form {
    display: grid;
    gap: 0.75rem;
    margin-top: 1.25rem;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: 1.1rem 1.15rem 1.25rem;
    color: var(--ink);
}

.gate-form label {
    display: grid;
    gap: 0.3rem;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mute);
}

.gate-form input {
    font-family: Figtree, sans-serif;
    font-size: 1rem;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
}

.gate-form button {
    font-family: Chivo, sans-serif;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.75rem 0.8rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}

.gate-form button:hover {
    background: var(--brand-mid);
}

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

@media (max-width: 720px) {
    .shell {
        align-items: flex-start;
    }

    .shell-tools {
        width: 100%;
        justify-content: space-between;
    }

    .period {
        width: 100%;
        order: 2;
    }

    .logout {
        order: 1;
        margin-left: auto;
    }

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

@media (max-width: 420px) {
    .register {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Pedido — modal */

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

.order-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.order-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 29, 36, 0.45);
}

.order-modal-panel {
    position: relative;
    z-index: 1;
    width: min(36rem, 100%);
    max-height: min(90vh, 44rem);
    overflow: auto;
    margin: 0;
    box-shadow: 0 12px 40px rgba(26, 29, 36, 0.18);
}

.order-modal-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.order-modal-head h2 {
    margin: 0;
}

.order-modal-section {
    margin-top: 1rem;
}

.order-modal-section h3 {
    margin: 0 0 0.55rem;
    font-family: Chivo, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mute);
}

#paid-orders table tbody tr {
    cursor: pointer;
}

#paid-orders table tbody tr:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}
