/* ==========================================================================
   Rosas Weyh · Layout da aplicação
   ========================================================================== */

/* ---- Shell --------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
}

.app-content {
    flex: 1 1 auto;
    padding: 28px 34px 48px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* ---- Sidebar ------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.sidebar-brand {
    position: relative;
    padding: 26px 24px;
    background: linear-gradient(135deg, #2f6bf0 0%, #1e40af 55%, #172d73 100%);
    color: #fff;
    overflow: hidden;
}
.sidebar-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(115deg, rgba(255,255,255,.14) 0 22%, transparent 22% 40%),
        linear-gradient(200deg, rgba(255,255,255,.10) 0 30%, transparent 30% 55%),
        linear-gradient(300deg, rgba(0,0,0,.14) 0 40%, transparent 40%);
    opacity: .9;
    pointer-events: none;
}
.brand-row { position: relative; display: flex; align-items: center; gap: 13px; z-index: 1; }
.brand-logo {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
    font-weight: 800; font-size: 16px; letter-spacing: .5px;
}
.brand-name { font-size: 18px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; opacity: .82; margin-top: 2px; }

/* Fechar o drawer (só no mobile — display ligado na media query). */
.sidebar-close {
    display: none;
    position: absolute;
    top: 18px; right: 16px;
    z-index: 2;
    width: 36px; height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    transition: background-color .14s ease;
}
.sidebar-close:hover { background: rgba(255, 255, 255, .24); }
.sidebar-close:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .4); }

.sidebar-nav { flex: 1 1 auto; padding: 14px 14px; overflow-y: auto; }
.nav-section-label {
    padding: 14px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--c-text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 14px;
    margin-bottom: 3px;
    border-radius: 10px;
    color: var(--c-text-soft);
    font-size: 14.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background-color .14s ease, color .14s ease;
    cursor: pointer;
}
.nav-item svg { width: 20px; height: 20px; flex: none; color: currentColor; opacity: .9; }
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item.active {
    background: var(--c-brand-soft);
    color: var(--c-brand);
    font-weight: 600;
    border-left-color: var(--c-brand);
}
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--c-brand);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-item.active .nav-badge { background: var(--c-brand); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--c-border); }

/* ---- Topbar (mobile) ----------------------------------------------------- */
.topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .brand-name { color: var(--c-brand-strong); }
.hamburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 8px;
    border: 1px solid var(--c-border); background: var(--c-surface); cursor: pointer; color: var(--c-text-soft);
}
.scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 35;
}

/* ---- Cabeçalho de página ------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-title { font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.page-actions { display: flex; gap: 10px; align-items: center; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--c-text-muted); margin-top: 4px; }
.breadcrumb a { color: var(--c-brand); font-weight: 600; }
.breadcrumb .sep { color: var(--c-border-strong); }

/* ---- Barra de filtros ---------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.toolbar .grow { min-width: 220px; }

/* ---- Stat cards ---------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 18px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-card);
    box-shadow: var(--sh-sm);
}
.stat-icon {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 13px;
    flex: none;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: var(--c-brand-soft); color: var(--c-brand); }
.stat-icon.green { background: var(--c-action-soft); color: var(--c-action); }
.stat-icon.amber { background: var(--c-warning-soft); color: var(--c-warning); }
.stat-icon.slate { background: var(--c-surface-2); color: var(--c-text-soft); }
.stat-label { font-size: 13.5px; color: var(--c-text-muted); }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.stat-value .unit { font-size: 14px; font-weight: 600; color: var(--c-text-muted); margin-left: 5px; }

/* ---- Grids diversos ------------------------------------------------------ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

/* Carrinho/resumo fica "grudado" ao rolar (só quando o .two-col é realmente
   duas colunas lado a lado, ver breakpoint 1080px). No mobile a barra fixa
   (.mobile-bar) já cobre a mesma necessidade de ver o total sempre. */
@media (min-width: 1081px) {
    .reserva-cart-sticky {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
}

/* Card de "produto em preparo" (staging) da busca por autocomplete: mostra
   preço/disponível e o estepper antes de confirmar a adição à reserva. */
.staging-card {
    padding: 16px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-card);
    background: var(--c-surface-2);
}
.split-form { display: grid; grid-template-columns: 1.05fr 1fr; gap: 22px; align-items: start; }
/* Permite que os cartões encolham e o .table-wrap interno role, em vez de
   estourar a largura da tela (gotcha de min-width:auto em grid). */
.two-col > *, .split-form > * { min-width: 0; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }

/* ---- Empty state --------------------------------------------------------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 46px 24px;
    gap: 12px;
    color: var(--c-text-muted);
}
.empty-icon {
    width: 68px; height: 68px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--c-brand-soft);
    color: var(--c-brand);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--c-text-soft); }
.empty-text { font-size: 13.5px; max-width: 340px; }

/* ---- Skeleton ------------------------------------------------------------ */
.skeleton {
    background: linear-gradient(90deg, #edf1f7 25%, #f6f8fc 50%, #edf1f7 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-line { height: 13px; margin: 7px 0; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--c-border); }

/* ---- Spinner inline ------------------------------------------------------ */
.spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex: none;
}
.spinner.dark { border-color: #dbe4f3; border-top-color: var(--c-brand); }

.center-load { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 60px 0; color: var(--c-text-muted); }
.center-load .spinner { width: 30px; height: 30px; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-scrim {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.46);
    display: flex; align-items: center; justify-content: center;
    padding: 22px;
    z-index: 100;
    animation: fade-in .18s ease;
}
.modal {
    background: var(--c-surface);
    border-radius: var(--r-card);
    box-shadow: var(--sh-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in .2s cubic-bezier(.2,.8,.3,1);
}
.modal.lg { max-width: 780px; }
.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; padding: 22px 24px 16px;
}
.modal-head .modal-title { font-size: 18px; font-weight: 700; }
.modal-head .modal-sub { font-size: 13.5px; color: var(--c-text-muted); margin-top: 3px; }
.modal-body { padding: 4px 24px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }
.modal-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px; border: none; background: transparent;
    color: var(--c-text-muted); cursor: pointer; flex: none;
}
.modal-x:hover { background: var(--c-surface-2); color: var(--c-text); }

.confirm-icon {
    width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center; flex: none;
}
.confirm-icon.danger { background: var(--c-danger-soft); color: var(--c-danger); }
.confirm-icon.warning { background: var(--c-warning-soft); color: var(--c-warning); }
.confirm-icon.info { background: var(--c-info-soft); color: var(--c-info); }
.confirm-icon.success { background: var(--c-success-soft); color: var(--c-success); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-host {
    position: fixed;
    top: 20px; right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 200;
    width: 360px;
    max-width: calc(100vw - 40px);
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-text-muted);
    border-radius: 11px;
    box-shadow: var(--sh-lg);
    animation: toast-in .26s cubic-bezier(.2,.8,.3,1);
}
.toast.leaving { animation: toast-out .2s ease forwards; }
.toast-ico { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.toast-body { flex: 1 1 auto; min-width: 0; }
.toast-title { font-size: 14px; font-weight: 700; }
.toast-msg { font-size: 13px; color: var(--c-text-soft); margin-top: 2px; }
.toast-close { border: none; background: transparent; color: var(--c-text-muted); cursor: pointer; padding: 2px; border-radius: 5px; flex: none; }
.toast-close:hover { background: var(--c-surface-2); color: var(--c-text); }
.toast.sucesso { border-left-color: var(--c-success); } .toast.sucesso .toast-ico { color: var(--c-success); }
.toast.erro { border-left-color: var(--c-danger); } .toast.erro .toast-ico { color: var(--c-danger); }
.toast.info { border-left-color: var(--c-info); } .toast.info .toast-ico { color: var(--c-info); }
.toast.aviso { border-left-color: var(--c-warning); } .toast.aviso .toast-ico { color: var(--c-warning); }

@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* ==========================================================================
   Transição de página
   ========================================================================== */
.page-enter { animation: page-in .28s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Diversos de conteúdo
   ========================================================================== */
.result-count { font-size: 13.5px; color: var(--c-text-muted); }
.divider { height: 1px; background: var(--c-border); margin: 4px 0; }

.info-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: var(--c-brand-soft);
    border: 1px solid #d7e5ff;
    border-radius: 10px;
    font-size: 13.5px;
    color: #1c4bb5;
}
.info-note svg { width: 18px; height: 18px; flex: none; }
.info-note.warning { background: var(--c-warning-soft); border-color: #fed7aa; color: #9a3412; }

.list-line {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--c-border);
}
.list-line:last-child { border-bottom: none; }

.summary-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; }
.summary-row + .summary-row { border-top: 1px dashed var(--c-border); }
.summary-total { font-size: 20px; font-weight: 800; color: var(--c-brand); }

.qty-input { width: 84px; text-align: center; }
.money-input { width: 118px; }

/* Rótulo textual que só aparece dentro dos cards de edição no mobile. */
.add-label { display: none; }
.dup-label { display: none; }

/* Botão remover embutido junto ao nome do produto (card mobile). Some no
   desktop: a ação de remover já existe na coluna de Ações. */
.item-remove-inline { display: none; }

/* Utilitário: escondido apenas dentro do breakpoint de cards (<640px). */
.hide-mobile-640 { }

/* Estepper de quantidade (−/+). No desktop os botões ficam ocultos e o campo
   mantém a aparência normal (.qty-input, 84px); no mobile os botões aparecem
   e o campo ocupa a largura toda (ver breakpoint 640px). */
.qty-stepper { display: inline-flex; align-items: center; }
.qty-stepper .qty-btn { display: none; }

/* ==========================================================================
   Autocomplete (busca paginada server-side)
   ========================================================================== */
.autocomplete { position: relative; }
.autocomplete .ac-spin {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    display: inline-flex; pointer-events: none;
}
.autocomplete .ac-spin .spinner { width: 16px; height: 16px; }
.ac-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    z-index: 60;
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--r-control);
    box-shadow: var(--sh-lg);
    max-height: 288px;
    overflow-y: auto;
    padding: 6px;
    animation: fade-in .12s ease;
}
.ac-list { list-style: none; margin: 0; padding: 0; }
.ac-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.3;
}
.ac-item.hi { background: var(--c-brand-soft); }
.ac-item .ac-primary { font-size: 14px; font-weight: 600; color: var(--c-text); }
.ac-item .ac-secondary { font-size: 12px; color: var(--c-text-muted); }
.ac-empty { padding: 14px 12px; font-size: 13.5px; color: var(--c-text-muted); text-align: center; }
/* Tabela editável com autocomplete: não recorta o painel do dropdown. */
.table-wrap.ac-open-host { overflow: visible; }

/* Menu "Exportar" (Excel / PDF) da tela de Relatórios. */
.export-menu { position: relative; display: inline-block; }
.export-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    min-width: 180px;
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--r-control);
    box-shadow: var(--sh-lg);
    padding: 6px;
    animation: fade-in .12s ease;
}
.export-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none; background: none; font: inherit; text-align: left;
    color: var(--c-text);
    border-radius: 8px;
    cursor: pointer;
}
.export-item:hover, .export-item:focus-visible { background: var(--c-brand-soft); }

/* Linha de tabela com problema de validação (ex.: estoque insuficiente). */
.table tbody tr.row-invalid { background: var(--c-danger-soft); }
.table tbody tr.row-invalid:hover { background: #fde8e8; }

.pagination { display: inline-flex; gap: 6px; align-items: center; }
.page-btn {
    min-width: 38px; height: 38px; padding: 0 10px;
    border: 1px solid var(--c-border); border-radius: 9px;
    background: var(--c-surface); color: var(--c-text-soft);
    font-weight: 600; cursor: pointer; font-size: 14px;
}
.page-btn:hover:not(:disabled) { background: var(--c-surface-2); }
.page-btn.active { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}
.login-aside {
    position: relative;
    background: linear-gradient(150deg, #2f6bf0 0%, #1e40af 50%, #14245c 100%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
.login-aside::after {
    content: "";
    position: absolute; inset: 0;
    background:
        linear-gradient(120deg, rgba(255,255,255,.12) 0 24%, transparent 24% 46%),
        linear-gradient(210deg, rgba(255,255,255,.08) 0 32%, transparent 32% 60%),
        linear-gradient(310deg, rgba(0,0,0,.16) 0 38%, transparent 38%);
    pointer-events: none;
}
.login-aside > * { position: relative; z-index: 1; }
.login-brandmark { display: flex; align-items: center; gap: 14px; }
.login-brandmark .brand-logo { width: 50px; height: 50px; font-size: 18px; }
.login-headline { font-size: 34px; font-weight: 800; line-height: 1.18; letter-spacing: -.02em; max-width: 460px; }
.login-lede { font-size: 15.5px; opacity: .9; max-width: 440px; margin-top: 16px; line-height: 1.6; }
.login-flow { display: flex; flex-direction: column; gap: 14px; margin-top: 30px; max-width: 440px; }
.login-flow-step { display: flex; gap: 13px; align-items: flex-start; font-size: 14.5px; opacity: .95; }
.login-flow-step .step-dot {
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.32);
    display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none;
}
.login-foot { font-size: 13px; opacity: .75; }

.login-main { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--c-surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 24px; }
.login-card .sub { color: var(--c-text-muted); margin: 8px 0 26px; font-size: 14.5px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-opt {
    display: flex; flex-direction: column; gap: 3px;
    padding: 13px 14px; border: 1.5px solid var(--c-border-strong); border-radius: 10px;
    cursor: pointer; transition: border-color .14s ease, background-color .14s ease; text-align: left;
    background: var(--c-surface);
}
.role-opt:hover { border-color: var(--c-brand); }
.role-opt.sel { border-color: var(--c-brand); background: var(--c-brand-soft); }
.role-opt .r-name { font-weight: 700; font-size: 14px; }
.role-opt .r-desc { font-size: 11.5px; color: var(--c-text-muted); }

/* User chip no rodapé da sidebar */
.user-chip { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; }
.user-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #2f6bf0, #1e3a8a);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.user-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 12px; color: var(--c-text-muted); }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1080px) {
    .two-col, .split-form { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .login-shell { grid-template-columns: 1fr; }
    .login-aside { display: none; }
}

@media (max-width: 860px) {
    /* Drawer: mais largo, com sombra só quando aberto e alvos de toque maiores. */
    .sidebar {
        width: min(84vw, 320px);
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.open { transform: none; box-shadow: var(--sh-lg); }
    .sidebar-close { display: inline-flex; }
    .nav-item { padding: 13px 14px; font-size: 15px; }
    .app-main { margin-left: 0; }
    .topbar { display: flex; }
    .scrim.show { display: block; }
    .app-content { padding: 20px 18px 40px; }
    .form-grid-3, .form-grid-2 { grid-template-columns: 1fr !important; }
    .page-title { font-size: 23px; }
    .toast-host { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }

    /* Ações e barras de filtro fluem em coluna e ocupam a largura toda. */
    .page-head { gap: 12px; }
    .page-actions { flex-wrap: wrap; }
    .page-actions .btn { flex: 1 1 auto; }
    .toolbar { gap: 10px; }
    /* Só spacers vazios somem; a busca (com conteúdo) ocupa a linha inteira. */
    .toolbar > .grow:empty { display: none; }
    .toolbar > .grow { flex: 1 1 100%; min-width: 0; }
    .toolbar .field { flex: 1 1 46%; }
    .toolbar .field .control { width: 100% !important; }

    /* Rodapé do modal: botões empilham e ocupam a linha. */
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; }
    .card-head { flex-wrap: wrap; }

    /* Utilitário: esconder no mobile (ações que migram para a barra fixa). */
    .hide-mobile { display: none !important; }
}

/* ---- Tabelas em formato de cartão no celular ----------------------------- */
@media (max-width: 640px) {
    .app-content { padding: 16px 14px 40px; }
    .page-title { font-size: 21px; }
    /* Menos padding lateral nos cartões no celular ganha largura útil. */
    .card-pad { padding: 16px 14px; }
    .card-head { padding: 16px 14px; }

    .table-wrap:has(.table-cards) { overflow: visible; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr {
        border: 1px solid var(--c-border);
        border-radius: 12px;
        margin: 10px 12px;
        background: var(--c-surface);
        box-shadow: var(--sh-sm);
        overflow: hidden;
    }
    .table-cards tbody tr:hover { background: var(--c-surface); }
    .table-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 6px 14px !important;
        font-size: 13.5px;
        line-height: 1.35;
        text-align: right;
        border-bottom: 1px solid var(--c-surface-2);
    }
    .table-cards tr td:first-child { padding-top: 10px !important; }
    .table-cards tr td:last-child { border-bottom: none; padding-bottom: 10px !important; }
    .table-cards td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 500;
        color: var(--c-text-muted);
        text-align: left;
        flex: 0 0 auto;
    }
    /* Ações: linha própria e discreta; botões um pouco menores mas ainda tocáveis. */
    .table-cards td.col-actions { justify-content: flex-end; padding: 7px 12px !important; }
    .table-cards td.col-actions::before { content: none; }
    .table-cards td .actions { justify-content: flex-end; gap: 8px; }
    .table-cards td .icon-btn { width: 34px; height: 34px; }
    .table-cards td .icon-btn svg { width: 17px; height: 17px; }

    /* ---- Tabelas EDITÁVEIS: viram cards de edição -----------------------
       Diferente de .table-cards: o rótulo fica ACIMA e o campo ocupa a
       largura toda, para digitar confortavelmente no celular. */
    .table-wrap:has(.table-edit) { overflow: visible; }
    .table-edit thead { display: none; }
    .table-edit, .table-edit tbody, .table-edit tr, .table-edit td { display: block; width: 100%; }
    .table-edit tr {
        border: 1px solid var(--c-border);
        border-radius: var(--r-card);
        margin: 12px 0;
        padding: 8px 6px;
        background: var(--c-surface);
        box-shadow: var(--sh-sm);
    }
    .table-edit tbody tr:hover { background: var(--c-surface); }
    .table-edit td {
        padding: 8px 12px !important;
        border-bottom: none !important;
        text-align: left;
    }
    .table-edit td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-size: 12.5px;
        font-weight: 600;
        color: var(--c-text-soft);
    }
    .table-edit td.no-label::before,
    .table-edit td.col-add::before,
    .table-edit td.col-actions::before { content: none; }
    .table-edit td .control,
    .table-edit td .qty-input,
    .table-edit td .money-input,
    .table-edit td .input-icon,
    .table-edit td .autocomplete { width: 100% !important; }
    .table-edit td.col-actions {
        display: flex;
        gap: 8px;
        justify-content: flex-end;
        padding-top: 2px !important;
    }
    /* Botão que some/aparece por linha (ex.: "+") ganha destaque no celular. */
    .table-edit td.col-add .icon-btn,
    .table-edit td.col-add .btn { width: 100%; gap: 8px; }
    .table-edit td.col-add .icon-btn { height: 44px; }
    .table-edit td.col-add .add-label { display: inline; font-size: 14px; font-weight: 600; }

    .hide-mobile-640 { display: none !important; }

    /* Estepper de quantidade: botões −/+ ladeando o campo, sem setas nativas. */
    .qty-stepper {
        display: flex;
        width: 100%;
        border: 1px solid var(--c-border-strong);
        border-radius: 10px;
        overflow: hidden;
        height: 44px;
    }
    .qty-stepper .qty-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 100%;
        flex: none;
        border: none;
        background: var(--c-surface-2);
        color: var(--c-text-soft);
        cursor: pointer;
    }
    .qty-stepper .qty-btn:active { background: var(--c-border); }
    .qty-stepper .qty-btn:disabled { opacity: .4; cursor: not-allowed; }
    .qty-stepper .qty-btn svg { width: 16px; height: 16px; }
    .qty-stepper .control.qty-input {
        border: none !important;
        border-radius: 0 !important;
        text-align: center;
        font-weight: 700;
        height: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }
    .qty-stepper .control.qty-input:focus { box-shadow: none; }
    .qty-stepper .control.qty-input::-webkit-outer-spin-button,
    .qty-stepper .control.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

    /* ---- Card de produto da Nova Compra: layout em grade 2 colunas -------
       Reduz a altura do card (item mencionado como "exagerado"): Produto
       ocupa a linha toda; Qtd./Valor e Ofertar/Preço Oferta dividem a linha. */
    .compra-items tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px 12px;
        padding: 14px;
    }
    .compra-items td { padding: 0 !important; width: auto; }
    .compra-items td[data-label="Produto"] { grid-column: 1 / -1; }
    .compra-items td[data-label="Qtd."] { grid-column: 1; }
    .compra-items td[data-label="Valor Compra"] { grid-column: 2; }
    .compra-items td[data-label="Ofertar"] { grid-column: 1; }
    /* .switch é inline-flex; como bloco solto vira caixa de linha "fantasma"
       (espaço extra de descendente). Vira bloco para colar exatamente aos 24px. */
    .compra-items td[data-label="Ofertar"] .switch { display: flex; }
    .compra-items td[data-label="Preço Oferta"] { grid-column: 2; }
    .compra-items td.col-actions { grid-column: 1 / -1; padding-top: 2px !important; }

    /* Remover embutido junto ao nome (some a versão da coluna de Ações). */
    .item-remove-inline { display: inline-flex; flex: none; }
    .compra-items td.col-actions .btn-remove-desktop { display: none; }

    /* "Duplicar como Inferior" vira botão largo e legível no card. */
    .compra-items td.col-actions .actions { width: 100%; }
    .compra-items td.col-actions .btn-duplicar {
        width: 100%;
        height: 44px;
        border-radius: 10px;
        gap: 8px;
    }
    .dup-label { display: inline; font-size: 13.5px; font-weight: 600; }

    /* Ações principais da tela (topo e rodapé) ganham alvos de toque maiores. */
    .add-produto-btn { width: 100%; justify-content: center; }
    .compra-footer-actions { flex-direction: column; width: 100%; }
    .compra-footer-actions .btn { width: 100%; justify-content: center; }

    /* ---- Card de produto da Nova Reserva: mesmo tratamento da Nova Compra -
       Produto ocupa a linha toda; Preço/Disponível dividem uma linha; Qtd.
       (estepper) e o botão Adicionar ficam full-width, um por linha. */
    .reserva-items tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px 12px;
        padding: 14px;
    }
    .reserva-items td { padding: 0 !important; width: auto; }
    .reserva-items td[data-label="Produto"] { grid-column: 1 / -1; }
    .reserva-items td[data-label="Preço (Unit.)"] { grid-column: 1; }
    .reserva-items td[data-label="Disponível"] { grid-column: 2; }
    .reserva-items td[data-label="Qtd."] { grid-column: 1 / -1; }
    .reserva-items td.col-add { grid-column: 1 / -1; }

    /* Confirmações e modais ocupam quase toda a tela pequena. */
    .modal-scrim { padding: 12px; }
    .modal { max-height: 92vh; }
}

/* ==========================================================================
   Barra de ação fixa (mobile) — resumo + ação principal sempre à mão
   (ex.: total e "Confirmar" da Nova Reserva). Oculta no desktop.
   ========================================================================== */
.mobile-bar { display: none; }

@media (max-width: 860px) {
    .mobile-bar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 45;
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        background: var(--c-surface);
        border-top: 1px solid var(--c-border);
        box-shadow: 0 -4px 18px rgba(15, 23, 42, .09);
    }
    .mobile-bar .mb-info { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
    .mobile-bar .mb-label { font-size: 12px; color: var(--c-text-muted); }
    .mobile-bar .mb-total { font-size: 19px; font-weight: 800; color: var(--c-brand); }
    .mobile-bar .btn { flex: 1 1 auto; justify-content: center; }
    .mobile-bar .grow { flex: 1 1 auto; }

    /* Reserva espaço para a barra não cobrir o conteúdo/rodapé da página. */
    .has-mobile-bar { padding-bottom: 92px; }
}

/* ==========================================================================
   Impressão (Relatórios)
   ========================================================================== */
@media print {
    .sidebar, .topbar, .scrim, .toast-host, .mobile-bar, .no-print, #blazor-error-ui { display: none !important; }
    .app-shell, .app-main { display: block; margin: 0 !important; }
    .app-content { padding: 0 !important; max-width: none !important; margin: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
    .report-header { display: block !important; margin-bottom: 16px; }
    .report-header h2 { font-size: 20px; }
    .report-header p { color: #333; margin: 4px 0 0; }
    .page-enter { animation: none !important; }

    /* Exportar > PDF: imprime só o bloco selecionado, ocultando os demais.
       O valor de data-print-section é o próprio id da seção (ver rw.printSection). */
    body[data-print-section] .stat-grid { display: none !important; }
    body[data-print-section] .card { display: none !important; }
    body[data-print-section="report-produtos"] #report-produtos,
    body[data-print-section="report-reservas"] #report-reservas,
    body[data-print-section="report-compras"] #report-compras { display: block !important; }
}
