/* ==========================================================================
   Estoque Coopginger
   A tela ocupa a largura toda da janela (sem faixas vazias nas laterais);
   só o espaçamento das bordas cresce/diminui com o tamanho da tela.
   ========================================================================== */

:root {
    --green-950: #052e16;
    --green-900: #064e3b;
    --green-800: #065f36;
    --green-700: #047857;
    --green-600: #16a34a;
    --green-100: #dcfce7;
    --soft: #ecfdf5;
    --page: #f3f7f4;
    --surface: #ffffff;
    --ink: #10231c;
    --ink-soft: #55605a;
    --muted: #64748b;
    --line: #e2ebe5;
    --border: #e6e8e4;
    --border-strong: #d4d8d1;
    --amber-100: #fef3c7;
    --amber-500: #f59e0b;
    --amber-700: #92400e;
    --orange-700: #c2410c;
    --red-100: #fee2e2;
    --red-700: #b91c1c;
    --rose-100: #fbdce1;
    --rose-700: #b23a4e;
    --blue-100: #dcebfb;
    --blue-700: #1d5fa8;
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(20, 32, 26, .05);
    --shadow: 0 1px 2px rgba(6, 78, 59, .04), 0 6px 18px rgba(6, 78, 59, .06);
    --shadow-lg: 0 24px 60px rgba(5, 46, 22, .25);
    --gutter: clamp(14px, 2.4vw, 36px);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--page);
    color: var(--ink);
}

.min-w-0 {
    min-width: 0;
}

/* ---- Menu do topo ---- */
.estoque-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--green-950);
    padding: 10px 0;
    box-shadow: 0 2px 12px rgba(5, 46, 22, .25);
}

.estoque-nav .container-fluid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 var(--gutter);
}

.estoque-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-weight: 800;
    font-size: 18px;
    flex-shrink: 0;
}

.estoque-brand i {
    font-size: 20px;
    color: #a3e635;
}

.estoque-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.estoque-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .78);
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}

.estoque-nav-link:hover {
    background: rgba(255, 255, 255, .10);
    color: #ffffff;
}

.estoque-nav-link.is-active {
    background: var(--green-600);
    color: #ffffff;
}

.estoque-nav-link.is-back {
    color: rgba(255, 255, 255, .55);
    font-weight: 600;
}

.estoque-nav-link.is-back:hover {
    color: #ffffff;
}

.estoque-nav-usuario {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .14);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.estoque-nav-usuario i {
    color: #a3e635;
}

.estoque-logout-btn {
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

/* ---- Área da página ---- */
.estoque-content {
    width: 100%;
    padding: 22px var(--gutter) 70px;
}

.estoque-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.estoque-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--green-100);
    color: var(--green-700);
    font-size: 21px;
}

.estoque-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 850;
    color: var(--green-950);
    line-height: 1.15;
}

.estoque-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
}

.estoque-section-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--green-950);
    margin-bottom: 14px;
}

.estoque-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px;
}

.is-negative {
    color: var(--red-700) !important;
}

/* ---- Botões e campos ---- */
.btn-success {
    background: var(--green-600);
    border-color: var(--green-600);
    font-weight: 700;
}

.btn-success:hover,
.btn-success:focus {
    background: var(--green-700);
    border-color: var(--green-700);
}

.btn-outline-success {
    color: var(--green-700);
    border-color: rgba(22, 163, 74, .35);
    font-weight: 700;
}

.btn-outline-success:hover {
    background: var(--soft);
    color: var(--green-700);
    border-color: var(--green-600);
}

.form-label {
    font-weight: 700;
    font-size: 13px;
    color: var(--green-950);
    margin-bottom: 5px;
}

.form-label em {
    color: var(--muted);
    font-style: normal;
    font-weight: 600;
}

.form-control,
.form-select {
    border-color: var(--border-strong);
    border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 .2rem rgba(22, 163, 74, .14);
}

.estoque-field-error {
    display: block;
    margin-top: 4px;
    color: var(--rose-700);
    font-size: 12px;
    font-weight: 700;
}

.estoque-field-error:empty {
    display: none;
}

/* ---- Estados vazios e listas simples ---- */
.estoque-empty {
    background: var(--surface);
    border: 1.5px dashed rgba(22, 163, 74, .30);
    border-radius: var(--radius-lg);
    padding: 56px 24px;
    text-align: center;
    color: var(--muted);
}

.estoque-empty i {
    font-size: 40px;
    color: var(--green-600);
    margin-bottom: 14px;
    display: inline-block;
}

.estoque-empty h5 {
    color: var(--green-950);
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 6px;
}

.estoque-empty p {
    max-width: 460px;
    margin: 0 auto 20px;
    line-height: 1.5;
}

.estoque-list-empty {
    color: var(--muted);
    text-align: center;
    padding: 28px 10px;
    font-size: 14px;
}

.estoque-alert-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 2px;
    border-bottom: 1px solid var(--line);
}

.estoque-alert-row:last-child {
    border-bottom: 0;
}

.estoque-alert-row strong {
    display: block;
    color: var(--green-950);
    font-size: 14px;
}

.estoque-alert-meta {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

/* ---- Painel com cabeçalho ---- */
.estoque-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.estoque-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.estoque-panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.estoque-panel-title-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--soft);
    color: var(--green-700);
    font-size: 19px;
}

.estoque-panel-title-icon.is-warning {
    background: var(--amber-100);
    color: var(--amber-700);
}

.estoque-panel-title-icon.is-danger {
    background: var(--red-100);
    color: var(--red-700);
}

.estoque-panel-title h4 {
    color: #0f172a;
    font-size: 16px;
    font-weight: 900;
    margin: 0 0 2px;
}

.estoque-panel-title small {
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: 12px;
}

.estoque-panel-body {
    padding: 16px 20px;
}

/* ---- Dashboard ---- */
.estoque-hero {
    background: linear-gradient(135deg, rgba(6, 78, 59, .97), rgba(22, 101, 52, .9)), #064e3b;
    color: #ffffff;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    margin-bottom: 20px;
}

.estoque-hero::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, #facc15 0 20%, #38bdf8 20% 42%, #4ade80 42% 100%);
}

.estoque-hero-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px 28px;
    align-items: center;
}

.estoque-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .12);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 900;
    margin-bottom: 10px;
}

.estoque-hero h3 {
    font-size: 26px;
    font-weight: 900;
    margin: 0 0 6px;
}

.estoque-hero p {
    color: rgba(255, 255, 255, .78);
    margin: 0;
    max-width: 640px;
}

.estoque-hero-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(130px, 1fr));
    gap: 10px;
}

.estoque-hero-total {
    display: block;
    color: #ffffff;
    text-decoration: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .18);
    padding: 14px 16px;
    transition: background .15s ease;
}

.estoque-hero-total:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .2);
}

.estoque-hero-total.is-warning {
    border-color: rgba(253, 224, 71, .46);
    background: rgba(161, 98, 7, .3);
}

.estoque-hero-total.is-danger {
    border-color: rgba(252, 165, 165, .5);
    background: rgba(185, 28, 28, .3);
}

.estoque-hero-total span {
    display: block;
    color: rgba(255, 255, 255, .75);
    font-weight: 800;
    font-size: 12px;
}

.estoque-hero-total strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    font-weight: 950;
    margin-top: 6px;
}

.estoque-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.estoque-color-card {
    display: block;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--green-600);
    transition: transform .16s ease, box-shadow .16s ease;
}

.estoque-color-card:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(6, 78, 59, .12);
}

.estoque-color-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.estoque-color-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 16px;
}

.estoque-color-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}

.estoque-color-name {
    font-weight: 800;
    color: var(--green-950);
    margin-bottom: 8px;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.estoque-color-value {
    font-size: 28px;
    font-weight: 850;
    color: var(--green-950);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.estoque-color-value span {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    margin-left: 4px;
}

.estoque-color-progress {
    height: 6px;
    border-radius: 999px;
    background: #e9f2ec;
    overflow: hidden;
}

.estoque-color-card .estoque-color-progress {
    margin-top: 12px;
}

.estoque-color-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--green-600);
    transition: width .3s ease;
}

.estoque-color-min {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
}

.estoque-color-card.estoque-color-card-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 170px;
    color: var(--muted);
    background: transparent;
    border: 1.5px dashed rgba(22, 163, 74, .35);
}

.estoque-color-card-add i {
    font-size: 24px;
    color: var(--green-600);
}

.estoque-color-card-add span {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.estoque-color-card-add:hover {
    background: var(--soft);
    border-color: var(--green-600);
    color: var(--green-700);
}

.estoque-badge-baixo,
.estoque-falta {
    flex-shrink: 0;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--amber-100);
    color: var(--amber-700);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.estoque-dashboard-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

/* ---- Itens: barra de ferramentas ---- */
.estoque-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.estoque-toolbar-info {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.estoque-toolbar-botao {
    margin-left: auto;
}

.estoque-segmento {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.estoque-segmento a {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 8px;
    color: var(--green-700);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.estoque-segmento a.is-active {
    background: var(--green-700);
    color: #ffffff;
}

.estoque-search-box {
    position: relative;
    flex: 0 1 300px;
    min-width: 180px;
}

.estoque-search-box i {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
}

.estoque-search-box input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0 12px 0 34px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
}

.estoque-search-box input:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 .15rem rgba(22, 163, 74, .14);
}

/* ---- Itens: cartões ---- */
.estoque-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}

.estoque-item-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid #cfded4;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow .15s ease, transform .15s ease;
}

.estoque-item-card:hover {
    box-shadow: 0 10px 26px rgba(6, 78, 59, .11);
}

.estoque-item-card.is-ok { border-left-color: var(--green-600); }
.estoque-item-card.is-repor { border-left-color: var(--amber-500); }
.estoque-item-card.is-negativo { border-left-color: var(--red-700); }

.estoque-item-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.estoque-item-titulo {
    flex: 1;
    min-width: 0;
}

.estoque-item-name {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--green-950);
    overflow-wrap: anywhere;
}

.estoque-item-meta {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.estoque-status {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.estoque-status.is-ok { background: var(--green-100); color: #166534; }
.estoque-status.is-repor { background: var(--amber-100); color: var(--amber-700); }
.estoque-status.is-zerado { background: #eef2f0; color: var(--muted); }
.estoque-status.is-negativo { background: var(--red-100); color: var(--red-700); }

.estoque-item-saldo {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.estoque-item-saldo strong {
    font-size: 28px;
    font-weight: 850;
    color: var(--green-950);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.estoque-item-card.is-negativo .estoque-item-saldo strong {
    color: var(--red-700);
}

.estoque-item-card.is-zerado .estoque-item-saldo strong {
    color: #94a3b8;
}

.estoque-item-saldo span {
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
}

.estoque-item-saldo small {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.estoque-item-card.is-repor .estoque-color-progress-fill {
    background: var(--amber-500);
}

.estoque-item-regras {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.estoque-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--green-800);
    font-size: 12px;
    font-weight: 700;
}

.estoque-chip.is-vazio {
    background: #f1f5f3;
    color: var(--muted);
    font-weight: 600;
}

/* caixa da marca preenchida sozinha: destaque para conferir */
.estoque-chip.is-conferir {
    background: #fff3cd;
    color: #7a5200;
    box-shadow: inset 0 0 0 1px #f0c36d;
}

/* "Dividir" da baixa em aberto: o resumo vira botão */
.estoque-dividir > summary {
    list-style: none;
}

.estoque-dividir > summary::-webkit-details-marker {
    display: none;
}

.estoque-item-acoes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.estoque-item-acoes a,
.estoque-item-acoes button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.estoque-item-acoes a:hover,
.estoque-item-acoes button:hover {
    background: var(--soft);
    color: var(--green-700);
}

.estoque-item-acoes .is-principal {
    color: var(--green-700);
    background: var(--soft);
}

.estoque-item-acoes .is-principal:hover {
    background: var(--green-100);
}

.estoque-desativados {
    display: block;
    margin-top: 22px;
}

.estoque-desativados > summary {
    list-style: none;
    cursor: pointer;
    border-bottom: 0;
}

.estoque-desativados[open] > summary {
    border-bottom: 1px solid var(--line);
}

.estoque-desativados > summary::-webkit-details-marker {
    display: none;
}

.estoque-desativados-seta {
    color: var(--muted);
    transition: transform .2s ease;
}

.estoque-desativados[open] .estoque-desativados-seta {
    transform: rotate(180deg);
}

/* ---- Janela (cadastro/edição de item) ---- */
.estoque-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    border: none;
    border-radius: 18px;
    padding: 0;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.estoque-dialog[open] {
    display: flex;
    flex-direction: column;
    animation: estoque-dialog-in .18s ease;
}

.estoque-dialog::backdrop {
    background: rgba(5, 46, 22, .45);
    backdrop-filter: blur(2px);
}

@keyframes estoque-dialog-in {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.estoque-dialog-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.estoque-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, var(--soft), #ffffff 70%);
}

.estoque-dialog-kicker {
    display: block;
    color: var(--green-700);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 2px;
}

.estoque-dialog-head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 850;
    color: var(--green-950);
    overflow-wrap: anywhere;
}

.estoque-dialog-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.estoque-dialog-head p strong {
    color: var(--green-950);
}

.estoque-dialog-close {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
}

.estoque-dialog-close:hover {
    background: rgba(5, 46, 22, .06);
    color: var(--green-800);
}

.estoque-dialog-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.estoque-dialog-secao {
    padding: 20px 24px;
}

.estoque-dialog-secao + .estoque-dialog-secao {
    border-top: 1px solid var(--line);
}

.estoque-dialog-secao h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 850;
    color: var(--green-950);
}

.estoque-dialog-secao h3 i {
    color: var(--green-600);
}

.estoque-dialog-secao h3 + .estoque-ajuda {
    margin-top: -8px;
}

.estoque-ajuda {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}

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

.estoque-campos label {
    display: block;
    min-width: 0;
}

.estoque-campos .form-label {
    display: block;
}

.estoque-campos .is-largo {
    grid-column: 1 / -1;
}

.estoque-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: #fbfdfc;
}

.estoque-dialog-footer .btn-link {
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

/* Regras de consumo em forma de frase */
.estoque-regras {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.estoque-regras:not(:empty) {
    margin-bottom: 10px;
}

.estoque-regra {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--soft);
    border: 1px solid #d1f0dd;
}

.estoque-regra-texto {
    color: var(--green-950);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.estoque-regra .form-control,
.estoque-regra .form-select {
    height: 36px;
    padding-top: 4px;
    padding-bottom: 4px;
    font-size: 14px;
    font-weight: 700;
}

.estoque-regra-num {
    width: 82px;
    text-align: center;
}

.estoque-regra-cor {
    width: auto;
    min-width: 150px;
}

.estoque-regra-remover {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--rose-700);
    cursor: pointer;
}

.estoque-regra-remover:hover {
    background: var(--rose-100);
}

.estoque-regra-removida {
    display: none;
    margin-left: auto;
    color: var(--rose-700);
    font-size: 12px;
    font-weight: 700;
}

.estoque-regra-removida button {
    border: 0;
    background: none;
    padding: 0;
    color: var(--green-700);
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
}

.estoque-regra.is-removida {
    background: #fff5f6;
    border-color: #f5d0d6;
}

.estoque-regra.is-removida > :not(.estoque-regra-removida) {
    opacity: .45;
}

.estoque-regra.is-removida .estoque-regra-remover {
    display: none;
}

.estoque-regra.is-removida .estoque-regra-removida {
    display: inline;
}

.estoque-regra-adicionar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1.5px dashed rgba(22, 163, 74, .45);
    border-radius: 10px;
    background: transparent;
    color: var(--green-700);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.estoque-regra-adicionar:hover {
    background: var(--soft);
    border-color: var(--green-600);
}

/* ---- Lançamento ---- */
.estoque-lancamento {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
    gap: 20px;
    align-items: start;
}

.estoque-tipo-escolha {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.estoque-tipo-escolha label {
    position: relative;
}

.estoque-tipo-escolha input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.estoque-tipo-escolha span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    border: 2px solid var(--border-strong);
    border-radius: 12px;
    color: var(--ink-soft);
    font-weight: 800;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.estoque-tipo-escolha span i {
    font-size: 18px;
}

.estoque-tipo-escolha .is-entrada input:checked + span {
    border-color: var(--green-600);
    background: var(--soft);
    color: var(--green-800);
}

.estoque-tipo-escolha .is-saida input:checked + span {
    border-color: #ea580c;
    background: #fff7ed;
    color: #9a3412;
}

.estoque-tipo-escolha input:focus-visible + span {
    outline: 3px solid rgba(22, 163, 74, .3);
    outline-offset: 2px;
}

.estoque-saldo-previa {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--soft);
    border: 1px solid var(--line);
}

.estoque-saldo-previa span {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
}

.estoque-saldo-previa strong {
    font-size: 18px;
    font-weight: 900;
    color: var(--green-950);
}

.estoque-saldo-previa > div:last-child {
    text-align: right;
}

.estoque-saldo-previa > i {
    color: var(--muted);
}

.estoque-saldo-previa.is-negativo [data-previa-depois] {
    color: var(--red-700);
}

.estoque-aviso-negativo {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--red-100);
    color: #991b1b;
    font-size: 13px;
    font-weight: 700;
}

.estoque-botao-grande {
    min-height: 50px;
    font-size: 16px;
    border-radius: 12px;
}

.estoque-ajuda-card p {
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.55;
}

.estoque-ajuda-card p:last-child {
    margin-bottom: 0;
}

/* ---- Extrato ---- */
.estoque-filtro-extrato {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
    padding: 16px 18px;
}

.estoque-filtro-extrato label {
    min-width: 0;
}

.estoque-filtro-extrato .form-label {
    display: block;
}

.estoque-filtro-botao {
    min-height: 38px;
}

.estoque-extrato-resumo {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.estoque-extrato-resumo > div {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.estoque-extrato-resumo span {
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}

.estoque-extrato-resumo strong {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-950);
    font-variant-numeric: tabular-nums;
}

.estoque-extrato-resumo small {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.estoque-extrato-resumo .is-entrada strong {
    color: var(--green-700);
}

.estoque-extrato-resumo .is-saida strong {
    color: var(--orange-700);
}

.estoque-extrato-resumo .is-final {
    background: var(--green-950);
    border-color: var(--green-950);
}

.estoque-extrato-resumo .is-final span,
.estoque-extrato-resumo .is-final small {
    color: rgba(255, 255, 255, .7);
}

.estoque-extrato-resumo .is-final strong {
    color: #ffffff;
}

.estoque-extrato-resumo .is-final.is-negative strong {
    color: #fca5a5 !important;
}

.estoque-extrato-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.estoque-extrato-tabela {
    padding: 0;
    overflow: hidden;
}

.estoque-extrato-tabela table th {
    padding: 12px 16px;
    background: var(--soft);
    color: var(--green-900);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.estoque-extrato-tabela table td {
    padding: 12px 16px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.estoque-extrato-tabela tbody tr:hover td {
    background: #f8fbf9;
}

.estoque-mov-tipo {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    margin-right: 6px;
}

.estoque-mov-tipo.is-entrada {
    background: var(--green-100);
    color: #166534;
}

.estoque-mov-tipo.is-saida {
    background: #ffedd5;
    color: #9a3412;
}

.estoque-mov-motivo {
    font-weight: 700;
    color: var(--ink);
}

.estoque-mov-auto {
    margin-left: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 10px;
    font-weight: 800;
}

.estoque-mov-qtd {
    font-weight: 900;
}

.estoque-mov-qtd.is-entrada {
    color: var(--green-700);
}

.estoque-mov-qtd.is-saida {
    color: var(--orange-700);
}

.estoque-mov-detalhes {
    max-width: 420px;
    color: var(--muted);
    font-size: 13px !important;
}

/* ---- Aviso rápido (toast) ---- */
.estoque-toast-stack {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 24px));
}

.estoque-toast {
    background: var(--green-900);
    color: #ffffff;
    border-radius: 10px;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 12px 30px rgba(5, 46, 22, .3);
    animation: estoque-toast-in .18s ease;
}

.estoque-toast.is-error {
    background: var(--rose-700);
}

@keyframes estoque-toast-in {
    from { transform: translateY(6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---- Login (mesma receita visual do login do Vendas) ---- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow-x: hidden;
    background: var(--green-950);
}

.login-background,
.login-slide {
    position: fixed;
    inset: 0;
}

.login-background {
    z-index: 0;
    overflow: hidden;
    background: var(--green-950);
}

.login-slide {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    opacity: 0;
    transition: opacity 1100ms ease;
}

.login-slide.is-active {
    opacity: 1;
}

.login-background::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(16, 57, 31, .68), rgba(16, 57, 31, .82));
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .98);
    box-shadow: var(--shadow-lg);
}

.login-accent {
    height: 4px;
    background: linear-gradient(90deg, var(--green-700), var(--green-600));
}

.login-content {
    padding: 34px 32px;
}

.login-logo-frame {
    width: fit-content;
    margin: 0 auto 22px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.login-logo {
    display: block;
    width: 210px;
    max-width: 68vw;
}

.login-kicker {
    display: block;
    margin-bottom: 6px;
    color: var(--green-700);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    text-transform: uppercase;
}

.login-title {
    margin: 0;
    color: var(--green-950);
    font-size: 30px;
    line-height: 1.1;
    font-weight: 700;
    text-align: center;
}

.login-subtitle {
    margin: 8px 0 26px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    text-align: center;
}

.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 13px;
    border: 1px solid #f0cdd3;
    border-radius: var(--radius-sm);
    color: #8f2c3c;
    background: var(--rose-100);
    font-size: 13px;
}

.login-field {
    margin-bottom: 15px;
}

.login-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
}

.login-input {
    position: relative;
}

.login-input i {
    position: absolute;
    top: 50%;
    left: 13px;
    color: var(--muted);
    transform: translateY(-50%);
}

.login-input input {
    width: 100%;
    height: 48px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0 13px 0 40px;
    color: var(--ink);
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
    outline: 0;
}

.login-input input:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(31, 157, 77, .16);
}

.login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    margin-top: 6px;
    border: 0;
    border-radius: var(--radius-sm);
    color: #fff;
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
}

.login-button:hover {
    background: linear-gradient(135deg, var(--green-700), var(--green-800));
    transform: translateY(-1px);
}

.login-button:active {
    transform: translateY(0);
}

.central-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 18px;
    color: var(--green-700);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.central-link:hover {
    color: var(--green-800);
}

/* ==========================================================================
   Telas menores
   ========================================================================== */
@media (max-width: 1100px) {
    .estoque-nav .container-fluid {
        flex-wrap: wrap;
    }

    .estoque-nav-links {
        flex-wrap: nowrap;
        overflow-x: auto;
        width: 100%;
        scrollbar-width: none;
    }

    .estoque-nav-links::-webkit-scrollbar {
        display: none;
    }

    .estoque-nav-usuario {
        margin-left: auto;
    }
}

@media (max-width: 900px) {
    .estoque-dashboard-cols,
    .estoque-lancamento,
    .estoque-hero-content {
        grid-template-columns: 1fr;
    }

    .estoque-extrato-resumo {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .estoque-nav {
        position: static;
        padding: 8px 0;
    }

    .estoque-nav .container-fluid {
        gap: 6px;
    }

    .estoque-nav-link {
        padding: 8px 12px;
    }

    .estoque-nav-usuario {
        display: none;
    }

    .estoque-content {
        padding-top: 14px;
    }

    .estoque-header {
        gap: 10px;
        margin-bottom: 14px;
    }

    .estoque-header-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
        border-radius: 11px;
    }

    .estoque-header h1 {
        font-size: 20px;
    }

    .estoque-header p {
        display: none;
    }

    .estoque-hero {
        padding: 20px 16px;
    }

    .estoque-hero h3 {
        font-size: 21px;
    }

    .estoque-hero-totals {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .estoque-hero-total {
        padding: 12px 10px;
    }

    .estoque-hero-total strong {
        font-size: 26px;
    }

    .estoque-panel-header,
    .estoque-panel-body {
        padding: 14px;
    }

    .estoque-toolbar .estoque-segmento {
        width: 100%;
    }

    .estoque-segmento a {
        flex: 1;
        justify-content: center;
    }

    .estoque-search-box {
        flex: 1 1 100%;
    }

    .estoque-toolbar-botao {
        margin-left: auto;
    }

    .estoque-item-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Janela vira uma "gaveta" que sobe de baixo, do jeito dos apps de celular. */
    .estoque-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 94dvh;
        margin: auto 0 0;
        border-radius: 18px 18px 0 0;
    }

    .estoque-dialog-head,
    .estoque-dialog-secao,
    .estoque-dialog-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .estoque-dialog-footer {
        gap: 8px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .estoque-regra-cor {
        flex: 1 1 140px;
    }

    .estoque-filtro-extrato {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        padding: 14px;
    }

    .estoque-filtro-extrato .form-control,
    .estoque-filtro-extrato .form-select {
        min-width: 0;
        width: 100%;
    }

    .estoque-filtro-item,
    .estoque-filtro-botao {
        grid-column: 1 / -1;
    }

    /* Extrato vira cartões: cada movimentação um bloco, com o rótulo de cada campo. */
    .estoque-extrato-tabela table,
    .estoque-extrato-tabela tbody,
    .estoque-extrato-tabela tr,
    .estoque-extrato-tabela td {
        display: block;
        width: 100%;
    }

    .estoque-extrato-tabela thead {
        display: none;
    }

    .estoque-extrato-tabela tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
    }

    .estoque-extrato-tabela td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 3px 0 !important;
        border: 0;
        text-align: right !important;
    }

    .estoque-extrato-tabela td::before {
        content: attr(data-rotulo);
        flex-shrink: 0;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-align: left;
    }

    .estoque-mov-detalhes {
        max-width: none;
    }

    .estoque-toast-stack {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: none;
    }
}

@media (max-width: 420px) {
    .estoque-campos {
        grid-template-columns: 1fr;
    }

    .login-page {
        padding: 14px;
    }

    .login-content {
        padding: 28px 22px;
    }

    .login-title {
        font-size: 26px;
    }
}

/* Safra */
.estoque-nav-safra { width: auto; max-width: 180px; }
.estoque-veio-anterior { padding: .6rem 1rem; margin-bottom: .75rem; }
.estoque-faixa-safra { margin-bottom: .75rem; }

/* Desfazer lançamento */
.estoque-mov-desfeita td { color: #8a8f87; }
.estoque-mov-desfeita td:not(.estoque-mov-detalhes) { text-decoration: line-through; }
.estoque-mov-desfeito-por { font-size: .78rem; color: #8a5a00; text-decoration: none; }
.estoque-mov-desfazer summary { cursor: pointer; list-style: none; white-space: nowrap; }
.estoque-mov-desfazer summary::-webkit-details-marker { display: none; }
.estoque-mov-desfazer form { margin-top: .4rem; min-width: 210px; }
