/* ============================================================
   RECETARIO MVP — Estilos Principales
   Autor: Agente de Desarrollo
   Stack: CSS3 Vanilla + Custom Properties
   ============================================================ */

/* ── 1. CUSTOM PROPERTIES ─────────────────────────────────── */
:root {
  /* Paleta */
  --color-bg: #F9F6F1;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F2EDE5;
  --color-border: #E2D9CE;
  --color-border-focus: #7A6A55;

  --color-primary: #5C4A2A;
  --color-primary-h: #7A6A55;
  --color-accent: #C8A96E;
  --color-accent-h: #B8914E;

  --color-success: #4A7C59;
  --color-success-bg: #EAF4EE;
  --color-error: #B04040;
  --color-error-bg: #FAEAEA;
  --color-danger: #B04040;
  --color-danger-h: #8C2F2F;

  --color-text: #2C2418;
  --color-text-muted: #7A6A55;
  --color-text-light: #B5A48E;

  /* Tipografía */
  --font-body: 'Inter', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Espaciado */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Bordes y sombras */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(92, 74, 42, 0.08), 0 1px 2px rgba(92, 74, 42, 0.06);
  --shadow: 0 4px 12px rgba(92, 74, 42, 0.10), 0 2px 4px rgba(92, 74, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(92, 74, 42, 0.12), 0 4px 8px rgba(92, 74, 42, 0.08);

  /* Transiciones */
  --transition: 200ms ease;
  --transition-slow: 350ms ease;
}

/* ── 2. RESET BASE ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

/* ── 3. HEADER ────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.header-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

.header-nav {
  display: flex;
  gap: var(--space-2);
  background: var(--color-surface-alt);
  padding: var(--space-1);
  border-radius: var(--radius);
}

/* Botón hamburguesa: oculto en desktop, visible en móvil via media query */
.nav-mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 7px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.nav-mobile-toggle:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
}

/* Las 3 líneas del hamburguer */
.nav-mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px;
  transition: transform 200ms ease, opacity 200ms ease;
  transform-origin: center;
  pointer-events: none;
}

.nav-mobile-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-mobile-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-mobile-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


.nav-link {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-link:hover {
  color: var(--color-primary);
}

.nav-link.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Separador y botones de sesión dentro del nav ── */
.nav-separator {
  width: 1px;
  align-self: stretch;
  background: var(--color-border);
  margin: 4px 2px;
}

.nav-link-admin {
  color: var(--color-accent-h) !important;
  font-size: var(--text-xs) !important;
  white-space: nowrap;
}

.nav-link-logout {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-link-logout:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

/* Mobile: separator becomes horizontal line, logout is full width */
@media (max-width: 900px) {
  .nav-separator {
    width: 100%;
    height: 1px;
    margin: 4px 0;
  }

  .nav-link-logout,
  .nav-link-admin {
    display: block !important;
    width: 100% !important;
    padding: 12px 16px !important;
    font-size: 1rem !important;
    text-align: left;
  }
}

.recipe-counter {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
}

/* ── 4. MAIN LAYOUT ───────────────────────────────────────── */
.site-main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

/* ── 5. SECTION HEADERS ───────────────────────────────────── */
.section-header {
  margin-bottom: var(--space-6);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ── 6. FORMULARIO ────────────────────────────────────────── */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow);
}

.recipe-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  letter-spacing: 0.01em;
}

.required {
  color: var(--color-accent);
}

.form-input,
.ingredient-input,
.ingredient-select {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.ingredient-input:focus,
.ingredient-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(92, 74, 42, 0.10);
}

.form-input::placeholder,
.ingredient-input::placeholder {
  color: var(--color-text-light);
}

/* ── 7. FILAS DE INGREDIENTES ─────────────────────────────── */
.ingredients-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.ingredient-row,
.ingredients-header {
  display: grid;
  grid-template-columns: 1fr 100px 110px auto;
  gap: var(--space-2);
  align-items: center;
}

.ingredients-header {
  padding-bottom: var(--space-1);
}

.ingredient-row {
  animation: fadeSlideIn var(--transition-slow) both;
}

.ingredient-select {
  padding-right: var(--space-2);
}

.btn-remove-ingredient {
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.btn-remove-ingredient:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error);
}

/* ── 8. BOTONES ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  border: 1.5px solid transparent;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
  text-align: center;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(92, 74, 42, 0.25);
}

.btn-primary:hover {
  background: var(--color-primary-h);
  border-color: var(--color-primary-h);
  box-shadow: 0 4px 14px rgba(92, 74, 42, 0.30);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-border);
}

.btn-outline:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-h);
  border-color: var(--color-danger-h);
}

.btn-add-ingredient {
  align-self: flex-start;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

/* ── 9. ERRORES DE VALIDACIÓN ─────────────────────────────── */
.form-errors {
  background: var(--color-error-bg);
  border: 1px solid rgba(176, 64, 64, 0.25);
  border-left: 3px solid var(--color-error);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-error);
}

.form-errors ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-4);
  list-style: disc;
}

/* ── 10. GRID DE RECETAS ──────────────────────────────────── */
.recipes-section {
  padding-bottom: var(--space-4);
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
}

/* ── 11. TARJETA DE RECETA ────────────────────────────────── */
.recipe-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: fadeSlideIn var(--transition-slow) both;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.recipe-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.recipe-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.recipe-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  margin: 0;
  line-height: 1.2;
}

.recipe-category-badge {
  display: inline-block;
  background-color: var(--color-primary);
  color: white;
  font-size: 0.7rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.recipe-card-badges {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.recipe-cost-badge {
  font-weight: var(--fw-bold);
  color: var(--color-text);
  background-color: #d1fae5;
  /* Verde muy claro */
  color: #065f46;
  /* Verde oscuro */
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  border: 1px solid #10b981;
}

.recipe-dashboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  background: var(--color-bg);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

@media (max-width: 600px) {
  .dashboard-metric {
    flex: 1 1 calc(33% - var(--space-2));
  }
}

@media (max-width: 480px) {
  .dashboard-metric {
    flex: 1 1 calc(50% - var(--space-2));
  }
}

.dashboard-metric {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: var(--fw-bold);
  margin-bottom: 0.2rem;
}

.metric-value {
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--color-text);
}

.status-success {
  background-color: #d1fae5;
  color: #065f46;
}

.status-success .metric-label,
.status-success .metric-value {
  color: #065f46;
}

.status-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.status-warning .metric-label,
.status-warning .metric-value {
  color: #92400e;
}

.status-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.status-danger .metric-label,
.status-danger .metric-value {
  color: #991b1b;
}

.status-profit {
  background-color: var(--color-primary);
}

.status-profit .metric-label,
.status-profit .metric-value {
  color: white;
}

.recipe-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  white-space: nowrap;
}

.btn-delete-recipe {
  background: none;
  border: none;
  color: var(--color-text-light);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.btn-delete-recipe:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

.recipe-divider {
  border: none;
  border-top: 1px solid var(--color-border);
}

.ingredients-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.ingredient-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  border-bottom: 1px dashed var(--color-border);
  gap: var(--space-2);
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-name {
  color: var(--color-text);
}

.ingredient-qty {
  font-weight: var(--fw-semibold);
  color: var(--color-accent-h);
  white-space: nowrap;
}

.recipe-card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ingredient-count-badge {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
}

/* ── 12. ESTADO VACÍO ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  animation: fadeSlideIn var(--transition-slow) both;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-4);
  line-height: 1;
}

.empty-state-text {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.empty-state-hint {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* ── 13. NOTIFICACIÓN TOAST ───────────────────────────────── */
.notification {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  animation: slideInRight var(--transition-slow) both;
}

.notification.success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(74, 124, 89, 0.25);
}

.notification.error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(176, 64, 64, 0.25);
}

.notification.hide {
  animation: slideOutRight var(--transition-slow) both;
}

/* ── 14. MODAL ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 24, 0.45);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--transition) both;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--transition-slow) both;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.modal-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ── 15. FOOTER ───────────────────────────────────────────── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  text-align: center;
}

.footer-text {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

/* ── 16. CATÁLOGO INGREDIENTES Y PRECIOS ────────────────────────────── */
.ingredient-flex {
  flex-direction: row;
  align-items: center;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.catalog-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  animation: fadeSlideIn var(--transition) both;
}

.catalog-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.catalog-item-name {
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  margin-right: var(--space-2);
}

.badge-unit {
  font-size: 0.65rem;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  font-weight: var(--fw-bold);
}

.btn-manage-prices {
  background: none;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  font-size: var(--text-xs);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: var(--space-2);
  transition: all var(--transition);
}

.btn-manage-prices:hover {
  background: var(--color-primary);
  color: white;
}

.catalog-item-prices {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
  width: 100%;
}

.price-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.price-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.price-form {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: var(--space-2);
}

.flex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── 16. ANIMACIONES ──────────────────────────────────────── */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ── 17. RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 640px) {
  .site-main {
    padding: var(--space-6) var(--space-4) var(--space-12);
    gap: var(--space-8);
  }

  .form-section {
    padding: var(--space-6) var(--space-4);
    border-radius: var(--radius-lg);
  }

  .ingredient-flex {
    flex-direction: column;
    align-items: stretch;
  }

  .flex-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .ingredient-row,
  .ingredients-header {
    grid-template-columns: 1fr 80px 90px auto;
    gap: var(--space-1);
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn {
    justify-content: center;
  }

  .recipes-grid {
    grid-template-columns: 1fr;
  }

  .notification {
    top: auto;
    bottom: var(--space-5);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}


@media (max-width: 400px) {
  .ingredient-row {
    grid-template-columns: 1fr;
  }

  .ingredients-header {
    display: none;
  }

  .btn-remove-ingredient {
    width: 100%;
    border-radius: var(--radius);
  }

  .brand-tagline {
    display: none;
  }
}

/* ── HISTORIAL DE COMPRAS ─────────────────────────────────── */
.prices-wrapper {
  padding: var(--space-4);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

/* Formulario de nueva compra: layout en grid */
.price-form-grid {
  display: grid;
  grid-template-columns: 1fr 130px 150px auto;
  gap: var(--space-2);
  align-items: center;
}

.price-form-grid .form-input {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
}

/* Tabla de historial */
.purchase-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.purchase-history-table thead th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: var(--fw-semibold);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.purchase-history-table tbody tr {
  border-bottom: 1px dashed var(--color-border);
  transition: background var(--transition);
}

.purchase-history-table tbody tr:last-child {
  border-bottom: none;
}

.purchase-history-table tbody tr:hover {
  background: var(--color-surface-alt);
}

.purchase-history-table td {
  padding: var(--space-2) var(--space-2);
  color: var(--color-text);
  vertical-align: middle;
}

.purchase-history-table td:last-child {
  text-align: center;
  width: 36px;
}

/* Utilidades de texto */
.text-sm {
  font-size: var(--text-sm);
}

.text-muted {
  color: var(--color-text-muted);
}

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

  .price-form-grid button[type="submit"] {
    grid-column: 1 / -1;
  }
}

/* ── BÚSQUEDA Y TABS DE CATEGORÍA ─────────────────────────── */
.recipes-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-5);
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-base);
  pointer-events: none;
  line-height: 1;
}

.search-input {
  width: 100%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-3) var(--space-3) calc(var(--space-3) + 1.6rem);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(92, 74, 42, 0.10);
}

.search-input::placeholder {
  color: var(--color-text-light);
}

/* Tabs de categoría */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tab-btn {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  padding: var(--space-1) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.tab-btn-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.tab-btn-active:hover {
  background: var(--color-primary-h);
  border-color: var(--color-primary-h);
  color: #fff;
}

/* Header de grupo de categoría en el grid de recetas */
.category-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  margin-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-accent);
  grid-column: 1 / -1;
  width: 100%;
}

.category-group-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
}

.category-group-count {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
}

@media (max-width: 600px) {
  .recipes-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .category-tabs {
    justify-content: flex-start;
  }
}

/* ── PANEL AJUSTE DE PRECIOS POR CATEGORÍA ─────────────────── */
.price-adjust-section {
  padding: 0;
  overflow: hidden;
}

.price-adjust-section details {
  width: 100%;
}

.price-adjust-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-8);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--transition);
  border-radius: var(--radius-xl);
}

.price-adjust-summary::-webkit-details-marker {
  display: none;
}

.price-adjust-summary:hover {
  background: var(--color-surface-alt);
}

details[open] .price-adjust-summary {
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.price-adjust-summary>span:first-child {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.price-adjust-summary>span:first-child::after {
  content: '▾';
  font-size: var(--text-base);
  color: var(--color-accent);
  transition: transform var(--transition);
  display: inline-block;
}

details[open] .price-adjust-summary>span:first-child::after {
  transform: rotate(180deg);
}

.price-adjust-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.price-adjust-body {
  padding: var(--space-6) var(--space-8) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.price-adjust-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 480px;
}

.price-adjust-type-group {
  display: flex;
  gap: var(--space-4);
}

.price-adjust-type-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}

.price-adjust-type-option:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-surface-alt);
  color: var(--color-primary);
}

.price-adjust-type-option input[type="radio"] {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
}

/* Vista Previa */
.price-adjust-preview {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  animation: fadeSlideIn var(--transition-slow) both;
}

.price-adjust-preview-title {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

@media (max-width: 600px) {
  .price-adjust-summary {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-4) var(--space-5);
  }

  .price-adjust-body {
    padding: var(--space-4) var(--space-5);
  }

  .price-adjust-hint {
    display: none;
  }
}

/* ── HISTORIAL DE AJUSTES ──────────────────────────────────── */
.price-adjust-history {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
}

.price-adjust-history-summary {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  cursor: pointer;
  list-style: none;
  padding: var(--space-2) 0;
  user-select: none;
}

.price-adjust-history-summary::-webkit-details-marker {
  display: none;
}

.price-adjust-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  max-height: 280px;
  overflow-y: auto;
}

.history-entry {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
}

.history-entry-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.history-cat {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}

.history-adjust {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  padding: 1px var(--space-2);
  border-radius: 999px;
}

.history-up {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.history-down {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── EXPORTAR / IMPRIMIR (PDF) ────────────────────────────── */
.btn-print {
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-print:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

@media print {

  /* Ocultar todo excepto las recetas */
  .site-header,
  .site-footer,
  #form-section,
  #price-adjust-section,
  .recipes-toolbar,
  .btn-print,
  .btn-edit-recipe,
  .btn-delete-recipe,
  .btn-view-details,
  .btn-manage-prices,
  .btn-edit-price,
  .category-group-header,
  #empty-state {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
  }

  .site-main {
    max-width: 100%;
    padding: 0;
    gap: 0;
  }

  .recipes-section {
    padding: 0;
  }

  /* Grilla de 2 columnas para impresión */
  .recipes-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12pt;
    padding: 8pt;
  }

  .recipe-card {
    break-inside: avoid;
    border: 1pt solid #ccc;
    border-radius: 8pt;
    padding: 10pt;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .recipe-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* Mostrar nombre de categoría como encabezado en impresión */
  .category-group-header {
    display: block !important;
    font-size: 13pt;
    font-weight: bold;
    border-top: 2pt solid #333;
    padding: 6pt 0 3pt;
    margin-top: 12pt;
    break-before: auto;
  }
}

/* ── DASHBOARD ────────────────────────────────────────────── */
/* KPI Grid */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.dash-kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.dash-kpi-card:hover {
  box-shadow: var(--shadow);
}

.dash-kpi-skeleton {
  min-height: 100px;
  background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-surface) 50%, var(--color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.dash-kpi-icon {
  font-size: 1.5rem;
}

.dash-kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  line-height: 1.1;
}

.dash-kpi-good {
  color: var(--color-success);
}

.dash-kpi-warn {
  color: #d97706;
}

.dash-kpi-bad {
  color: var(--color-error);
}

.dash-kpi-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.dash-kpi-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Gráfico barras CSS */
.dash-chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chart-row {
  display: grid;
  grid-template-columns: 160px 1fr 80px;
  align-items: center;
  gap: var(--space-3);
}

.chart-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-track {
  height: 18px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.chart-bar-good {
  background: var(--color-success);
}

.chart-bar-warn {
  background: #d97706;
}

.chart-bar-bad {
  background: var(--color-error);
}

.chart-value {
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  text-align: right;
}

.chart-count {
  color: var(--color-text-muted);
  font-weight: var(--fw-regular);
}

/* Tabla ranking */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dash-table thead tr {
  background: var(--color-surface-alt);
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.dash-table th,
.dash-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.dash-table tbody tr:last-child td {
  border-bottom: none;
}

.dash-row-even {
  background: var(--color-bg);
}

.dash-rank {
  font-weight: var(--fw-bold);
  color: var(--color-text-muted);
  width: 32px;
}

.dash-recipe-name {
  font-weight: var(--fw-semibold);
}

.dash-cat-badge {
  font-size: var(--text-xs);
  background: var(--color-primary);
  color: #fff;
  padding: 2px var(--space-2);
  border-radius: 999px;
  font-weight: var(--fw-bold);
  white-space: nowrap;
}

.dash-fc {
  font-weight: var(--fw-bold);
  padding: 2px var(--space-2);
  border-radius: 999px;
  font-size: var(--text-xs);
}

.fc-good {
  background: #d1fae5;
  color: #065f46;
}

.fc-warn {
  background: #fef3c7;
  color: #92400e;
}

.fc-bad {
  background: #fee2e2;
  color: #991b1b;
}

.dash-profit {
  font-weight: var(--fw-bold);
  color: var(--color-success);
}

@media (max-width: 700px) {
  .chart-row {
    grid-template-columns: 120px 1fr 64px;
  }

  .dash-table th:nth-child(n+6),
  .dash-table td:nth-child(n+6) {
    display: none;
  }
}

/* ── BANNER DE DASHBOARD (pantalla y PDF) ─────────────────── */
#print-header {
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  padding: var(--space-3) var(--space-6);
}

.print-brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

/* La fecha solo se muestra al imprimir, no en pantalla */
.print-date {
  display: none;
}

/* ── ESTILOS DE IMPRESIÓN / PDF ───────────────────────────── */


/* .print-only: oculto en pantalla, visible solo al imprimir */
.print-only {
  display: none;
}

@media print {

  /* Reset general para impresión */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #fff !important;
    font-size: 11pt;
    color: #1a1a1a;
  }

  /* Ocultar al imprimir: nav, botones, filtros */
  .no-print,
  .site-header,
  .site-footer,
  .btn,
  .notification,
  .modal-overlay {
    display: none !important;
  }

  /* Mostrar header de impresión con marca y fecha */
  .print-only,
  .print-date {
    display: block !important;
  }

  #print-header {
    border-bottom: 2px solid #5C4A2A;
    padding-bottom: 10pt;
    margin-bottom: 18pt;
    display: flex !important;
    justify-content: space-between;
    align-items: flex-end;
  }

  .print-brand {
    font-size: 16pt;
    font-weight: 700;
    color: #5C4A2A;
    font-family: Georgia, serif;
  }

  .print-date {
    font-size: 9pt;
    color: #7A6A55;
  }

  /* Layout principal sin margen lateral */
  .site-main {
    max-width: 100% !important;
    padding: 0 !important;
    gap: 18pt !important;
  }

  /* Secciones sin sombra */
  section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* KPI grid: 4 columnas en una fila */
  .dash-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8pt !important;
  }

  .dash-kpi-card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    padding: 8pt !important;
    border-radius: 6pt !important;
  }

  .dash-kpi-value {
    font-size: 14pt !important;
  }

  .dash-kpi-label {
    font-size: 8pt !important;
  }

  /* Gráfico de barras */
  .dash-chart-container {
    display: block !important;
  }

  .chart-bar-good {
    background: #4A7C59 !important;
  }

  .chart-bar-warn {
    background: #C8A96E !important;
  }

  .chart-bar-bad {
    background: #B04040 !important;
  }

  /* Tabla de ranking */
  .dash-table {
    width: 100% !important;
    font-size: 9pt !important;
    border-collapse: collapse !important;
  }

  .dash-table th,
  .dash-table td {
    display: table-cell !important;
    padding: 5pt 6pt !important;
    border: 1px solid #ddd !important;
  }

  .dash-table th {
    background: #F2EDE5 !important;
    color: #5C4A2A !important;
    font-weight: 700;
  }

  .dash-row-even {
    background: #FAFAF8 !important;
  }

  .fc-good {
    color: #4A7C59 !important;
    font-weight: 700;
  }

  .fc-warn {
    color: #92400e !important;
    font-weight: 700;
  }

  .fc-bad {
    color: #B04040 !important;
    font-weight: 700;
  }

  .dash-profit {
    color: #4A7C59 !important;
    font-weight: 700;
  }

  .dash-cat-badge {
    background: #5C4A2A !important;
    color: #fff !important;
    font-size: 7.5pt !important;
    padding: 1pt 4pt !important;
    border-radius: 3pt !important;
  }

  /* Encabezados de sección */
  .section-title {
    font-size: 13pt !important;
    color: #5C4A2A !important;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4pt;
    margin-bottom: 8pt;
  }

  .section-subtitle {
    font-size: 8pt !important;
    color: #7A6A55 !important;
    margin-bottom: 8pt;
  }

  /* Salto de página antes del ranking si hace falta */
  #ranking-title {
    page-break-before: auto;
  }
}

/* ── 18. RESPONSIVE MEJORADO ──────────────────────────────── */


/* ── TABLET Y MÓVIL (≤ 900px) ── */
@media (max-width: 900px) {
  .site-main {
    padding: var(--space-6) var(--space-4) var(--space-12);
  }

  /* Header: brand a la izquierda, hamburger a la derecha */
  .header-inner {
    flex-wrap: nowrap;
    align-items: center;
  }

  .header-brand {
    flex: 1;
    min-width: 0;
  }

  /* Mostrar el hamburger */
  .nav-mobile-toggle {
    display: flex !important;
  }

  /* Menú oculto por defecto en tablet/móvil */
  .header-nav {
    display: none;
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
    gap: var(--space-1);
    box-shadow: var(--shadow);
    z-index: 999;
    border-radius: 0;
  }

  .header-nav.open {
    display: flex;
    animation: fadeSlideIn var(--transition) both;
  }

  .nav-link {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    display: block;
    width: 100%;
  }

  .nav-link.active {
    background: var(--color-surface-alt);
  }

  /* Dashboard KPI: 2 columnas en tablet */
  .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Chart rows más compactas */
  .chart-row {
    grid-template-columns: 110px 1fr 70px;
  }

  /* Formulario price-form-grid */
  .price-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .price-form-grid button[type="submit"] {
    grid-column: 1 / -1;
  }

  /* Tabla ranking: scroll horizontal */
  .dash-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Section header con flex-wrap */
  .section-header.flex-header {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
}

/* ── MÓVIL MEJORADO (≤ 640px) ── */
@media (max-width: 640px) {
  .site-main {
    padding: var(--space-5) var(--space-3) var(--space-10);
    gap: var(--space-8);
  }

  .form-section {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-lg);
  }

  /* KPI en 1 columna */
  .dash-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Chart label más estrecho */
  .chart-row {
    grid-template-columns: 80px 1fr 58px;
    gap: var(--space-2);
  }

  .chart-label {
    font-size: var(--text-xs);
  }

  /* Modal más compacto */
  .modal {
    padding: var(--space-5) var(--space-5);
  }

  /* form-actions ya está en column-reverse, mejorar botones */
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Filas ingredientes: reducir columnas */
  .ingredient-row,
  .ingredients-header {
    grid-template-columns: 1fr 80px 90px auto;
    gap: var(--space-1);
  }


  /* Section subtitle de recetas */
  .section-header.flex-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  /* Tabla dash: ocultar columnas de menor importancia */
  .dash-table th:nth-child(n+6),
  .dash-table td:nth-child(n+6) {
    display: none;
  }

  /* Price form grid: 1 columna */
  .price-form-grid {
    grid-template-columns: 1fr;
  }

  /* Precio-form compacto */
  .price-form {
    grid-template-columns: 1fr 100px auto;
  }

  /* Toolbar de recetas */
  .recipes-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .category-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: var(--space-1);
    -webkit-overflow-scrolling: touch;
  }

  /* Notificación desde abajo */
  .notification {
    top: auto;
    bottom: var(--space-5);
    right: var(--space-3);
    left: var(--space-3);
    max-width: none;
  }

  /* Recetas: 1 columna */
  .recipes-grid {
    grid-template-columns: 1fr;
  }

  /* Ajuste panel de precios */
  .price-adjust-summary {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-4) var(--space-4);
  }

  .price-adjust-hint {
    display: none;
  }

  .price-adjust-body {
    padding: var(--space-4) var(--space-4);
  }

  /* Barra flex-header del header */
  .flex-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  /* Tipo de ajuste de precio */
  .price-adjust-type-group {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ── EXTRA PEQUEÑO (≤ 420px) ── */
@media (max-width: 420px) {
  .brand-name {
    font-size: var(--text-xl);
  }

  .brand-tagline {
    display: none;
  }

  /* KPI: 1 columna total */
  .dash-kpi-grid {
    grid-template-columns: 1fr;
  }

  /* Ingredientes en formulario: 1 columna */
  .ingredient-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-3);
    background: var(--color-bg);
  }

  .ingredients-header {
    display: none;
  }

  .btn-remove-ingredient {
    width: 100%;
    border-radius: var(--radius);
    height: 38px;
    color: var(--color-error);
    border-color: var(--color-error);
  }

  /* Modal: sin bordes redondeados en la base */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-5) var(--space-4);
    width: 100%;
    max-width: 100%;
    animation: slideUpMobile var(--transition-slow) both;
  }

  /* Chart: sólo barra + valor */
  .chart-row {
    grid-template-columns: 1fr 52px;
  }

  .chart-label {
    grid-column: 1 / -1;
    white-space: normal;
  }
}

@keyframes slideUpMobile {
  from {
    opacity: 0;
    transform: translateY(40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}