@font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/plus-jakarta-sans-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #fafafa;
    --surface: #fff;
    --border: #e5e5e5;
    --text: #0a0a0a;
    --muted: #737373;
    --accent: #f5f5f5;
    --primary: #171717;
    --primary-fg: #fafafa;
    --brand: #0f766e;
    --brand-fg: #fff;
    --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-brand: "Plus Jakarta Sans", var(--font-sans);
    --sidebar-w: 256px;
    --topbar-h: 68px;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .08);
    /* Gráficos: mesmas cores dos selos de situação (finalizado, em aberto, cancelado) */
    --chart-completed: #15803d;
    --chart-pending: #2563eb;
    --chart-canceled: #dc2626;
    --tone-warning: #b45309;
    --tone-danger: #b91c1c;
}

:root[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: #111;
    --border: #262626;
    --text: #fafafa;
    --muted: #a3a3a3;
    --accent: #1f1f1f;
    --primary: #fafafa;
    --primary-fg: #171717;
    --brand: #2dd4bf;
    --brand-fg: #0a0a0a;
    --brand-soft: color-mix(in srgb, var(--brand) 14%, var(--surface));
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    --chart-completed: #16a34a;
    --chart-pending: #3b82f6;
    --chart-canceled: #ef4444;
    --tone-warning: #fbbf24;
    --tone-danger: #f87171;
}

* { box-sizing: border-box; }

.search-match { padding: .1em .2em; border-radius: 3px; background: var(--brand-soft); color: var(--brand); }

/* Busca global */
.global-search { position: relative; }
.global-search .global-search-toggle,
.global-search .global-search-close { display: none; }

.global-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 320px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
}

.global-search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.global-search-field input { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; }
.global-search-field kbd { white-space: nowrap; }

.global-search-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 40;
    width: min(440px, calc(100vw - 32px));
    max-height: min(560px, calc(100dvh - 90px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.global-search-status { margin: 0; padding: 12px 16px; color: var(--muted); font-size: 12px; }
.global-search-heading { padding: 8px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.global-search-result { display: flex; flex-direction: column; gap: 3px; padding: 10px 16px; overflow-wrap: anywhere; }
.global-search-result strong { font-size: 13px; font-weight: 600; }
.global-search-result small { color: var(--muted); font-size: 12px; }
.global-search-result:hover,
.global-search-result.is-active { background: var(--brand-soft); }
.global-search-footer { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

@media (max-width: 767px) {
    .global-search .global-search-toggle,
    .global-search .global-search-close { display: inline-flex; }
    .global-search-field { display: none; }
    .global-search.is-open .global-search-field { display: flex; position: fixed; top: 12px; left: 16px; right: 16px; z-index: 41; width: auto; height: 44px; }
    .global-search-field input { font-size: 16px; }
    .global-search-field kbd { display: none; }
    .global-search-panel { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; max-height: calc(100dvh - 80px); }
    .global-search-footer { display: none; }
}

body {
    margin: 0;
    background: var(--surface);
    color: var(--text);
    font: 14px/1.5 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

/* Identidade da marca (a mesma da landing), ativada pelos layouts do sistema; a vitrine fica neutra */
.theme-brand {
    --primary: var(--brand);
    --primary-fg: var(--brand-fg);
    font-family: var(--font-brand);
}

a { color: inherit; text-decoration: none; }

svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

kbd {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--muted);
    font: 11px/1.6 inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
}

.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--accent); }
.btn-icon { width: 36px; padding: 0; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { opacity: .9; }


.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}

.card:empty { min-height: 160px; }
.card + .card { margin-top: 16px; }

.card-title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
}

/* Formulários */
.field { margin-bottom: 16px; }

.field label,
.field .field-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea.input { height: auto; min-height: 144px; padding: 12px; line-height: 1.5; resize: vertical; }
.image-thumb { display: block; width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--accent); }
.image-thumb-empty { display: grid; place-items: center; color: var(--muted); }
.image-thumb-empty svg { width: 20px; height: 20px; }

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--muted);
    cursor: pointer;
}

.check:hover { color: var(--text); }

.check input[type="checkbox"] {
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid var(--muted);
    border-radius: 5px;
    background: var(--surface);
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}

.check input[type="checkbox"]:hover { border-color: var(--text); }

.check input[type="checkbox"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}

.check input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 1px;
    left: 5px;
    width: 4px;
    height: 9px;
    border: solid var(--primary-fg);
    border-width: 0 2px 2px 0;
    opacity: 0;
    transform: rotate(45deg) scale(.6);
    transition: opacity .12s ease, transform .12s ease;
}

.check input[type="checkbox"]:checked::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.check input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.check input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }

.check input[type="checkbox"]:indeterminate { border-color: var(--primary); background: var(--primary); }
.check input[type="checkbox"]:indeterminate::after {
    top: 7px;
    left: 3px;
    width: 9px;
    height: 0;
    border-width: 0 0 2px;
    opacity: 1;
    transform: none;
}

.check input[type="radio"] {
    appearance: none;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid var(--muted);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.check input[type="radio"]:hover { border-color: var(--text); }
.check input[type="radio"]:checked { border-color: var(--primary); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 9px var(--primary); }
.check input[type="radio"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.check:has(input:checked) { color: var(--text); }

/* Opção logo abaixo de um campo */
.field label.check-inline { margin-top: 10px; font-size: 13px; }

/* `.field label` é mais específico que `.check`; aqui o checkbox volta a ser uma linha com o texto */
.field label.check {
    display: flex;
    margin-bottom: 0;
    font-weight: 400;
}

/* Opção com texto de apoio: a dica fica alinhada ao texto da opção, não ao checkbox */
.field > .check + .field-hint { margin: 2px 0 0 28px; }

/* Envio de arquivo */
.input[type="file"] {
    height: auto;
    min-height: 48px;
    padding: 8px 10px;
    border-style: dashed;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}

.input[type="file"]:hover { border-color: var(--muted); background: var(--accent); }

.input[type="file"]::file-selector-button {
    height: 30px;
    margin-right: 12px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .12s ease;
}

.input[type="file"]::file-selector-button:hover { background: var(--accent); }

.btn-block { width: 100%; }

.alert {
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--accent);
}

.alert-error { color: #b91c1c; }
.alert-success { color: #15803d; }
.alert-warning { color: #b45309; }
.alert-info { color: #1d4ed8; }

:is(.alert-error, .alert-success, .alert-warning, .alert-info) {
    border-color: color-mix(in srgb, currentColor 30%, var(--border));
    background: color-mix(in srgb, currentColor 8%, var(--surface));
}

:root[data-theme="dark"] .alert-error { color: #f87171; }
:root[data-theme="dark"] .alert-success { color: #4ade80; }
:root[data-theme="dark"] .alert-warning { color: #fbbf24; }
:root[data-theme="dark"] .alert-info { color: #60a5fa; }
.alert:has(> svg) { display: flex; align-items: flex-start; gap: 10px; }
.alert > svg { margin-top: 2px; }

/* Modal */
.modal {
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.modal-text { margin: 0 0 20px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Botões */
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-sm.btn-icon { width: 30px; padding: 0; }
.icon-dots { stroke-width: 3; }
.btn-danger { color: #dc2626; }
.btn-danger:hover { border-color: #dc2626; }
.btn-danger-solid { background: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Botão aguardando resposta: o conteúdo some e um indicador gira no lugar */
.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading > * { visibility: hidden; }

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.btn-outline.is-loading::after { border-color: var(--text); border-right-color: transparent; }

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

/* Formulários */
select.input { padding-right: 8px; }
.field-hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

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

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

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.form-actions-start { margin-right: auto; }

/* Campo com ícone à esquerda */
.input-icon { position: relative; }
.input-icon > svg { position: absolute; top: 50%; left: 12px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.input-icon > .input { padding-left: 36px; }

/* Título de um grupo de opções (<legend>) com o mesmo visual dos rótulos */
.field-legend { margin-bottom: 6px; padding: 0; font-weight: 500; }

/* Lista de opções (radio) com título e descrição */
.choices { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }

.field .choice,
.choice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 400;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}

.choice:hover { background: var(--accent); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--accent); }
.choice input { margin: 3px 0 0; accent-color: var(--primary); }
.choice span { display: grid; gap: 1px; }
.choice small { color: var(--muted); font-size: 12px; }

/* Formulário dividido em seções: título à esquerda e campos à direita no desktop */
.form-section + .form-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.form-section-title { margin: 0; font-size: 15px; font-weight: 600; }
.form-section-title:has(> svg) { display: flex; align-items: center; gap: 8px; }
.form-section-title > svg { color: var(--muted); }
.form-section-text { margin: 2px 0 16px; color: var(--muted); font-size: 13px; }
.form-section .field:last-child { margin-bottom: 0; }

@media (min-width: 1024px) {
    .form-section { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; }
    .form-section-text { margin-bottom: 0; }
}

/* Interruptor (checkbox liga/desliga) */
.switch {
    appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 36px;
    height: 20px;
    margin: 0;
    border-radius: 999px;
    background: var(--border);
    cursor: pointer;
    transition: background-color .15s ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}

.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(16px); background: var(--primary-fg); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* Lista de opções liga/desliga com título e descrição */
.toggle-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background-color .12s ease;
}

.toggle-row + input + .toggle-row,
.toggle-row + .toggle-row { border-top: 1px solid var(--border); }
.toggle-row:hover { background: var(--accent); }
.toggle-row-text { display: grid; gap: 2px; }
.toggle-row-text small { color: var(--muted); font-size: 13px; }

/* Card com ícone no título e texto de apoio */
.card-title:has(> svg) { display: flex; align-items: center; gap: 8px; }
.card-title > svg { color: var(--muted); }
.card-text { margin: -6px 0 16px; color: var(--muted); font-size: 13px; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--accent);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Fundo tingido com a própria cor do texto, como os status da landing */
.badge-success { color: #15803d; }
.badge-warning { color: #b45309; }
.badge-danger { color: #b91c1c; }
.badge-info { color: #1d4ed8; }
:is(.badge-success, .badge-warning, .badge-danger, .badge-info) { background: color-mix(in srgb, currentColor 13%, transparent); }

:root[data-theme="dark"] .badge-success { color: #4ade80; }
:root[data-theme="dark"] .badge-warning { color: #fbbf24; }
:root[data-theme="dark"] .badge-danger { color: #f87171; }
:root[data-theme="dark"] .badge-info { color: #60a5fa; }

/* Filtros das listas */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.filters .field { margin-bottom: 0; }
.filters .field-grow { flex: 1; min-width: 220px; }

/* Tabelas */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th { color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .nowrap { white-space: nowrap; }
.table-sub { display: block; color: var(--muted); }

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.empty { margin: 0; padding: 32px 0; color: var(--muted); text-align: center; }

/* Estado vazio com ícone, texto e ação */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 40px 16px;
    text-align: center;
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: var(--accent);
    color: var(--muted);
}

.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title { margin: 0; font-size: 15px; font-weight: 600; }
.empty-state-text { max-width: 420px; margin: 0; color: var(--muted); font-size: 13px; }
.empty-state .btn { margin-top: 16px; }

/* Espera por um processamento em segundo plano (partials/components/loading_state) */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px 16px;
    text-align: center;
}

.loading-state-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
}

.loading-state-icon svg { width: 26px; height: 26px; animation: loading-pulse 1.6s ease-in-out infinite; }

.loading-state-ring {
    position: absolute;
    inset: -4px;
    border: 3px solid transparent;
    border-top-color: var(--brand);
    border-right-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-state-title { margin: 0; font-size: 15px; font-weight: 600; }
.loading-state-text { max-width: 440px; margin: 0; color: var(--muted); font-size: 13px; }
.loading-state-status { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 600; }

.loading-state-bar {
    position: relative;
    overflow: hidden;
    width: min(280px, 100%);
    height: 4px;
    margin-top: 14px;
    border-radius: 999px;
    background: var(--accent);
}

.loading-state-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    border-radius: inherit;
    background: var(--brand);
    animation: loading-slide 1.4s ease-in-out infinite;
}

@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes loading-pulse { 50% { transform: scale(.88); opacity: .7; } }

/* Célula com miniatura (ou ícone) seguida de título e subtítulo */
.media-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.media-cell-body { min-width: 0; }
.media-cell-body strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-thumb-sm { width: 40px; height: 40px; border-radius: 8px; }
.image-thumb-sm svg { width: 18px; height: 18px; }

/* Selos logo abaixo do título de uma célula */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Cabeçalho de card com título e informação à direita */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.card-header .card-title { margin: 0; }

.meta-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.meta-inline svg { width: 14px; height: 14px; }

/* Abas de navegação entre páginas irmãs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: -1px;
    padding: 10px 12px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.is-active { border-bottom-color: var(--primary); color: var(--text); }

.tab-count {
    min-width: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

/* Linhas selecionáveis e barra de ação em lote (components/bulk-select.js) */
.table tr.is-selected td { background: var(--accent); }
[data-bulk-row] { cursor: pointer; }

.bulk-bar {
    position: sticky;
    bottom: 16px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.bulk-bar[hidden] { display: none; }
.bulk-bar-count { margin-right: auto; font-weight: 600; }

/* Paginação */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
}

.pagination-link:hover { background: var(--accent); }
.pagination-link.is-active { border: 1px solid var(--border); font-weight: 500; }


/* Botão grande (ações principais em telas de toque) */
.btn-lg { height: 48px; padding: 0 20px; border-radius: 12px; font-size: 15px; }

.form-error { margin: 0 0 12px; color: #dc2626; font-size: 13px; }

/* Ícones SVG compartilhados por <use href="#i-...">: o sprite fica no corpo da página, sem ocupar espaço */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Carregamento */
.skeleton {
    background: linear-gradient(90deg, var(--accent) 25%, var(--border) 37%, var(--accent) 63%);
    background-size: 400% 100%;
    border-radius: 8px;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Painel sobreposto (<dialog>): folha inferior no celular, modal no computador */
html.is-locked { overflow: hidden; }

.sheet {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    overflow: hidden;
}

.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgba(0, 0, 0, .5); animation: fade-in .18s ease both; }

.sheet-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1) both;
}

.sheet-body { display: flex; flex: 1; flex-direction: column; min-height: 0; }

.sheet-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    cursor: pointer;
}

.sheet-close:hover { background: var(--accent); }
.sheet-close svg { width: 18px; height: 18px; }

/* Gaveta lateral (carrinho): ocupa a altura toda, em tela cheia no celular */
.sheet-cart .sheet-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(440px, 100vw);
    height: 100dvh;
    max-height: none;
    padding-bottom: 0;
    border-width: 0 0 0 1px;
    border-radius: 0;
    transform: none;
    animation: drawer-in .26s cubic-bezier(.2, .8, .2, 1) both;
}

@media (min-width: 840px) {
    .sheet-panel {
        top: 50%;
        right: auto;
        bottom: auto;
        left: 50%;
        width: min(920px, calc(100vw - 48px));
        height: min(640px, calc(100dvh - 48px));
        max-height: none;
        padding-bottom: 0;
        border-bottom: 1px solid var(--border);
        border-radius: 16px;
        transform: translate(-50%, -50%);
        animation: sheet-pop .2s ease both;
    }
}

/* Galeria de fotos da empresa (partial `image_gallery`) */
.gallery { display: grid; gap: 12px; min-width: 0; }
.gallery-search { position: relative; }
.gallery-search svg { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.gallery-search .input { padding-left: 38px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.gallery-grid:empty { display: none; }
.gallery-item { position: relative; display: grid; gap: 4px; padding: 4px; border: 2px solid transparent; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.gallery-item:hover { border-color: var(--border); }
.gallery-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.gallery-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--accent); }
.gallery-item-name { overflow: hidden; font-size: 12px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.gallery-item.is-selected { border-color: var(--primary); }
.gallery-item.is-selected::after { content: "\2713"; position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: var(--primary-fg); font-size: 13px; font-weight: 700; box-shadow: 0 0 0 2px var(--surface); }
.gallery-status { margin: 0; color: var(--muted); font-size: 13px; }
.gallery-status:empty, .gallery-status[hidden] { display: none; }
.gallery-more { justify-self: center; }
.gallery-more[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(32px); opacity: .6; } }
@keyframes sheet-pop { from { transform: translate(-50%, calc(-50% + 12px)) scale(.98); opacity: 0; } }
@keyframes drawer-in { from { transform: translateX(32px); opacity: .6; } }

/* Seletor de quantidade */
.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
}

.stepper:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }

.stepper-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.stepper-btn:hover { background: var(--accent); }
.stepper-btn:active { background: var(--border); }

.stepper-input {
    width: 52px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;
}

.stepper-input:focus { outline: none; }
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

/* Avisos rápidos: ficam na camada superior (popover) para aparecer acima dos painéis abertos */
.toasts {
    position: fixed;
    inset: auto auto calc(16px + env(safe-area-inset-bottom)) 50%;
    display: grid;
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    box-shadow: var(--shadow);
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in .2s ease both;
}

.toast-error { background: #b91c1c; color: #fff; }

.toast-action {
    flex-shrink: 0;
    margin-left: auto;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .sheet-panel, .sheet::backdrop, .toast, .skeleton, .loading-state-icon svg, .loading-state-bar span { animation: none; }
    .loading-state-ring { animation-duration: 3s; }
}

@media (max-width: 767px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* Painéis (início do gerente e do vendedor) */
/* Seletor de período (partials/components/period_filter) */
.segmented {
    display: inline-flex;
    flex-shrink: 0;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.segmented-item {
    padding: 6px 12px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
}

.segmented-item:hover { background: var(--accent); color: var(--text); }
.segmented-item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* Indicadores (partials/components/stat_tile) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

a.stat-tile { transition: border-color .12s ease; }
a.stat-tile:hover { border-color: var(--muted); }

.stat-tile-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-tile-info { display: inline-flex; margin-left: auto; cursor: help; }
.stat-tile-info svg { width: 14px; height: 14px; }
.stat-tile-value { font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -.025em; overflow-wrap: anywhere; }
.stat-tile-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.stat-tile-hint { color: var(--muted); font-size: 13px; }

.stat-tile-warning { border-color: color-mix(in srgb, var(--tone-warning) 40%, var(--border)); }
.stat-tile-warning .stat-tile-hint { color: var(--tone-warning); font-weight: 600; }

/* Grade de cards dos painéis */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
    margin-bottom: 16px;
}

.dash-grid-wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-block { margin-bottom: 16px; }
.dash-grid > .card + .card { margin-top: 0; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Gráfico de colunas empilhadas (partials/components/stacked_chart) */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0 0 12px;
    padding: 0;
    color: var(--muted);
    font-size: 13px;
    list-style: none;
}

.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }

.chart-swatch { display: inline-block; flex-shrink: 0; width: 10px; height: 10px; border-radius: 3px; }
.chart-swatch-completed { background: var(--chart-completed); }
.chart-swatch-pending { background: var(--chart-pending); }
.chart-swatch-canceled { background: var(--chart-canceled); }

.chart-frame { position: relative; height: 280px; }

.chart-table { margin-top: 12px; font-size: 13px; }
.chart-table summary { color: var(--muted); cursor: pointer; }
.chart-table summary:hover { color: var(--text); }
.chart-table .table-wrap { max-height: 320px; margin-top: 8px; overflow: auto; }
.chart-table .table th, .chart-table .table td { padding: 8px 12px; }

/* Barras horizontais (rankings) */
.bar-track { display: block; height: 8px; border-radius: 999px; background: var(--accent); overflow: hidden; }
.bar-fill { display: block; min-width: 4px; height: 100%; border-radius: 999px; background: var(--brand); }

.bar-cell { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.bar-cell .bar-track { flex: 1; }

.bar-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.bar-list-item { display: grid; gap: 6px; }
.bar-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bar-list-name { min-width: 0; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.bar-list-value { font-size: 13px; white-space: nowrap; }
.bar-list-sub { color: var(--muted); font-size: 12px; }

/* Lista ordenada com nome, detalhe e valor */
.rank-list { margin: 0; padding: 0; list-style: none; }
.rank-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank-list li:last-child { border-bottom: 0; }
.rank-list-name { display: grid; min-width: 0; }
.rank-list-name strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.rank-list-name small { color: var(--muted); font-size: 12px; }
.rank-list-name:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.rank-list-value { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Lista de avisos com ícone ("Precisa de atenção", "Saúde da operação") */
.attention-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.attention-item { display: flex; gap: 12px; }

.attention-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--muted);
}

.attention-icon-danger { color: var(--tone-danger); }
.attention-icon-warning { color: var(--tone-warning); }
:is(.attention-icon-danger, .attention-icon-warning) { background: color-mix(in srgb, currentColor 13%, transparent); }

.attention-body { display: grid; flex: 1; gap: 4px; min-width: 0; }
.attention-link { justify-self: start; color: var(--brand); font-size: 13px; font-weight: 600; }
.attention-sublist { display: grid; gap: 6px; margin: 2px 0 0; padding: 0; font-size: 13px; list-style: none; }
.attention-sublist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.attention-sublist a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attention-sublist a:hover,
.attention-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.attention-more { color: var(--muted); }

.empty-state-compact { padding: 24px 8px; }

@media (max-width: 1199px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid-wide { grid-template-columns: minmax(0, 1fr); }
}

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

@media (max-width: 767px) {
    .page-header:has(.segmented) { flex-direction: column; }
    .stat-grid { gap: 12px; }
    .stat-tile { padding: 16px; }
    .stat-tile-value { font-size: 22px; }
    .chart-frame { height: 240px; }
    .dash-block .card-header { flex-wrap: wrap; }
    .dash-block .meta-inline { white-space: normal; }
}

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

/* Recurso fora do plano (componente plan_lock e aviso do preço por catálogo) */
.btn.is-plan-locked { color: var(--muted); }
.btn .plan-lock-icon { width: 14px; height: 14px; }
.price-lock { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.price-lock svg { width: 12px; height: 12px; }

/* Aviso da assinatura no topo do painel */
.subscription-notice .alert-link { margin-left: auto; font-weight: 600; color: inherit; text-decoration: underline; white-space: nowrap; }
