:root {
    --hk-primary: #2f6f4f;
    --hk-primary-dark: #234f39;
    --hk-accent: #f2a541;
    --hk-bg: #f4f6f5;
    --hk-card: #ffffff;
    --hk-text: #1f2a24;
    --hk-muted: #6b7a72;
    --hk-border: #e3e8e5;
    --hk-radius: 14px;
    --hk-ok: #2f9e5c;
    --hk-atencao: #d9a412;
    --hk-urgente: #e2762f;
    --hk-vencido: #d64545;
    --hk-neutro: #8a978f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--hk-bg);
    color: var(--hk-text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(135deg, var(--hk-primary) 0%, var(--hk-primary-dark) 100%);
    color: #fff;
    padding: 1rem 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.app-logo { font-size: 2rem; line-height: 1; }

.app-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.3px;
}

.app-subtitle {
    font-size: 0.8rem;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
}

.btn-sair,
.btn-instalar {
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    padding: 0.4rem 1.1rem;
}
.btn-sair:hover,
.btn-instalar:hover { background: rgba(255, 255, 255, 0.15); border-color: #fff; }
.btn-instalar .icon { margin-right: 0.15rem; }

.app-main {
    max-width: 1200px;
    padding: 1.5rem 1rem 3rem;
    margin: 0 auto;
}

.toolbar { margin-bottom: 1rem; }
.toolbar-actions { flex-wrap: wrap; }

.summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--hk-muted);
}
.summary-chips .chip {
    background: var(--hk-card);
    border: 1px solid var(--hk-border);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    font-weight: 600;
}

.btn-incluir {
    background: var(--hk-primary);
    border-color: var(--hk-primary);
    border-radius: 999px;
    font-weight: 600;
    padding: 0.55rem 1.3rem;
    box-shadow: 0 4px 12px rgba(47, 111, 79, 0.25);
}
.btn-incluir:hover { background: var(--hk-primary-dark); border-color: var(--hk-primary-dark); }
.btn-incluir .icon { font-weight: 800; margin-right: 0.15rem; }

.grid-card {
    background: var(--hk-card);
    border-radius: var(--hk-radius);
    border: 1px solid var(--hk-border);
    box-shadow: 0 6px 24px rgba(20, 30, 25, 0.05);
    overflow: hidden;
}

.table-grid { margin: 0; }
.table-grid thead th {
    background: #f8faf9;
    color: var(--hk-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    border-bottom: 1px solid var(--hk-border);
    padding: 0.9rem 1rem;
}
.table-grid tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--hk-border);
    vertical-align: middle;
}
.table-grid tbody tr:last-child td { border-bottom: none; }
.table-grid tbody tr:hover { background: #fafcfb; }

.produto-nome { font-weight: 600; }
.produto-tipo-badge {
    display: inline-block;
    background: #eef3f0;
    color: var(--hk-primary-dark);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
}
.status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.status-ok { color: var(--hk-ok); background: rgba(47, 158, 92, 0.12); }
.status-atencao { color: var(--hk-atencao); background: rgba(217, 164, 18, 0.14); }
.status-urgente { color: var(--hk-urgente); background: rgba(226, 118, 47, 0.14); }
.status-vencido { color: var(--hk-vencido); background: rgba(214, 69, 69, 0.14); }
.status-neutro { color: var(--hk-neutro); background: rgba(138, 151, 143, 0.14); }

.btn-acao {
    border: none;
    background: transparent;
    color: var(--hk-muted);
    font-size: 1rem;
    padding: 0.3rem 0.5rem;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}
.btn-acao:hover { background: #eef3f0; color: var(--hk-primary-dark); }
.btn-incrementar {
    margin-left: 0.4rem;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1;
    padding: 0;
    border: 1px solid var(--hk-border);
    border-radius: 50%;
    background: #fff;
    color: var(--hk-primary-dark);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.btn-incrementar:hover:not(:disabled) { background: var(--hk-primary-dark); color: #fff; }
.btn-incrementar:disabled { opacity: 0.5; cursor: default; }

.btn-acao.excluir:hover { background: rgba(214, 69, 69, 0.1); color: var(--hk-vencido); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--hk-muted);
}
.empty-state p:first-child { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* Mobile card list */
.card-list { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.produto-card {
    border: 1px solid var(--hk-border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    background: #fff;
}
.produto-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.produto-card-header .produto-nome { font-size: 1.02rem; }
.produto-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.75rem;
    font-size: 0.85rem;
}
.produto-card-body .label { color: var(--hk-muted); display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.3px; }
.produto-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.25rem;
    margin-top: 0.6rem;
    border-top: 1px solid var(--hk-border);
    padding-top: 0.5rem;
}

@media (max-width: 767.98px) {
    .app-title { font-size: 1.15rem; }
    .app-subtitle { display: none; }
    .toolbar { flex-direction: column; align-items: stretch !important; }
    .summary-chips { justify-content: center; }

    .toolbar-actions { justify-content: center; gap: 0.4rem; }
    .btn-tipos,
    .btn-incluir {
        padding: 0.35rem 0.65rem;
        font-size: 0.78rem;
    }
}

.modal-dialog-scrollable .modal-content {
    height: calc(100vh - 1rem);
    height: calc(100dvh - 1rem);
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
}
.modal-dialog-scrollable .modal-body {
    flex-basis: 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

@media (min-width: 576px) {
    .modal-dialog-scrollable .modal-content {
        height: calc(100vh - 3.5rem);
        height: calc(100dvh - 3.5rem);
        max-height: calc(100vh - 3.5rem);
        max-height: calc(100dvh - 3.5rem);
    }
}

#toastMensagem {
    background: var(--hk-primary-dark);
    color: #fff;
}
#toastMensagem.bg-danger { background: var(--hk-vencido) !important; }

.btn-tipos {
    border-radius: 999px;
    font-weight: 600;
    padding: 0.55rem 1.1rem;
}

.tipos-lista { max-height: 260px; overflow-y: auto; }
.tipos-lista .list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.tipos-lista .tipo-acoes { display: flex; gap: 0.25rem; }

/* Scanner de código de barras */
.scanner-container {
    margin-top: 0.6rem;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    padding: 0.5rem;
    text-align: center;
}
.scanner-container video {
    width: 100%;
    max-height: 260px;
    border-radius: 6px;
    background: #000;
}

/* Campos de medida do produto (quantidade, datas, tempo estimado) */
.campos-medidas { align-items: flex-start; }
.input-numero-curto { width: 4.5rem; flex: 0 0 auto; }
.input-data-curta { width: 9.5rem; flex: 0 0 auto; }
.input-group .input-numero-curto { width: 4.5rem; flex: 0 0 auto; }

/* Imagem do produto */
.imagem-produto-box {
    width: 120px;
    height: 120px;
    border: 1px dashed var(--hk-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8faf9;
    overflow: hidden;
}
.imagem-produto-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.imagem-placeholder-icone { font-size: 2rem; opacity: 0.5; }

/* QR Code */
.qrcode-preview-box {
    width: 150px;
    height: 150px;
    border: 1px dashed var(--hk-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8faf9;
    padding: 0.5rem;
    text-align: center;
}
.qrcode-preview-box canvas, .qrcode-preview-box img { max-width: 100%; max-height: 100%; }

/* Miniatura na grade */
.produto-thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 0.5rem;
    vertical-align: middle;
    border: 1px solid var(--hk-border);
}
.produto-thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    margin-right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f0f3f1;
    color: var(--hk-muted);
    font-size: 1rem;
    vertical-align: middle;
}

.alerta-icone {
    margin-left: 0.35rem;
    font-size: 0.85rem;
    cursor: help;
}
