:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #233244;
    --muted: #6b7a90;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0f766e;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #16a34a;
    --border: #dbe3ef;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container { width: min(1100px, 92vw); margin: 0 auto; }
.topbar {
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 1rem 0;
}
.nav-wrap { display: flex; justify-content: space-between; align-items: center; }
.brand { color: white; text-decoration: none; font-size: 1.2rem; font-weight: 600; }
.nav-links a { color: white; text-decoration: none; margin-left: 1rem; }
main { padding: 1.5rem 0 3rem; }
.section-spacing { display: grid; gap: 1.2rem; }
.page-title-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.page-title-row h1 { margin: 0 0 0.2rem; }
.page-title-row p { margin: 0; color: var(--muted); }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    padding: 1rem 1.2rem;
}
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.stat-card { text-align: center; }
.stat-card.warning { border-left: 6px solid var(--warning); }
.stat-card.danger { border-left: 6px solid var(--danger); }
.stat-value { font-size: 2rem; margin: 0.25rem 0 0; font-weight: 700; }
.search-form { display: flex; gap: 0.7rem; margin-top: 0.5rem; }
.search-form input, .form-grid input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.btn {
    display: inline-block;
    border: 0;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-small { padding: 0.5rem 0.7rem; font-size: 0.9rem; margin-right: 0.35rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
.badge { display: inline-block; padding: 0.35rem 0.6rem; border-radius: 999px; font-size: 0.85rem; }
.badge-vigente { background: #dcfce7; color: #166534; }
.badge-proximo { background: #fef3c7; color: #92400e; }
.badge-vencido { background: #fee2e2; color: #991b1b; }
.empty-state { text-align: center; color: var(--muted); }
.form-card { max-width: 700px; }
.form-grid { display: grid; gap: 1rem; }
.checkbox-field { display: flex; gap: 0.6rem; align-items: center; }
.checkbox-field input { width: auto; }
.form-actions { margin-top: 1rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.alert {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.card { overflow-x: hidden; }
.card table { width: 100%; min-width: 640px; }
.alert-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.alert-modal-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}
.alert-modal {
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
    max-width: 440px;
    width: 100%;
    padding: 1.5rem;
    text-align: center;
    transform: translateY(-10px) scale(0.96);
    transition: transform 0.2s ease;
}
.alert-modal-backdrop.is-visible .alert-modal {
    transform: translateY(0) scale(1);
}
.alert-modal-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 1.6rem;
    background: #fef3c7;
    color: var(--warning);
    margin-bottom: 0.8rem;
}
.alert-modal h2 {
    margin: 0 0 0.4rem;
    font-size: 1.3rem;
}
.alert-modal p {
    margin: 0;
    color: var(--muted);
}
.alert-modal-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    display: grid;
    gap: 0.6rem;
}
.alert-modal-list li {
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text);
    font-weight: 600;
}
.alert-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.page-title-actions {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}
.productos-hoy-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.64);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.productos-hoy-modal-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}
.productos-hoy-modal {
    position: relative;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.21);
    width: min(760px, 100%);
    max-height: min(90vh, 800px);
    overflow: auto;
    padding: 1.35rem;
    transform: translateY(-12px) scale(0.97);
    transition: transform 0.25s ease;
}
.productos-hoy-modal-backdrop.is-visible .productos-hoy-modal {
    transform: translateY(0) scale(1);
}
.productos-hoy-modal-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    border: 0;
    background: #f1f5f9;
    color: var(--text);
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.15rem;
}
.productos-hoy-modal-header h2 {
    margin: 0 0 0.4rem;
    font-size: 1.25rem;
}
.productos-hoy-modal-header p {
    margin: 0;
    color: var(--muted);
}
.productos-hoy-modal-body {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}
.productos-hoy-section {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    background: #fbfdff;
}
.productos-hoy-section h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}
.productos-hoy-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.7rem;
}
.productos-hoy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    background: white;
    border: 1px solid #e2e8f0;
}
.productos-hoy-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.productos-hoy-item-main span,
.productos-hoy-date,
.productos-hoy-badge {
    color: var(--muted);
    font-size: 0.92rem;
}
.productos-hoy-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}
.productos-hoy-badge {
    font-weight: 700;
    color: var(--warning);
}
.productos-hoy-empty,
.productos-hoy-loading {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
    text-align: center;
}
.productos-hoy-success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    border-radius: 14px;
    padding: 1rem;
    text-align: center;
}
.productos-hoy-success-icon {
    font-size: 1.6rem;
    margin-bottom: 0.4rem;
}
.productos-hoy-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}
@media (max-width: 980px) {
    .container { width: min(1000px, 96vw); }
    .nav-wrap { gap: 0.75rem; }
    .nav-links { display: flex; flex-wrap: wrap; gap: 0.75rem; }
    .nav-links a { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .page-title-row, .nav-wrap { align-items: stretch; }
    .page-title-row { gap: 1rem; }
    .page-title-row > div { width: 100%; }
    .search-form { flex-direction: column; }
    .search-form button { width: 100%; }
    .form-actions button, .form-actions a { width: 100%; }
    .form-actions a { text-align: center; }
}
@media (max-width: 780px) {
    .stats-grid { grid-template-columns: 1fr; }
    .alert-modal-actions { flex-direction: column-reverse; }
    .alert-modal-actions .btn { width: 100%; }
    .page-title-row, .nav-wrap { flex-direction: column; align-items: flex-start; }
    .search-form { flex-direction: column; }
    .nav-links { width: 100%; }
    .nav-links a { display: block; width: 100%; padding: 0.4rem 0; border-top: 1px solid rgba(255,255,255,0.15); }
    .page-title-row { width: 100%; }
    .card { overflow-x: auto; }
    .card table { min-width: 100%; }
    th, td { padding: 0.8rem 0.6rem; }
}
