*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  background: #f5f0ea;
  color: #2c2218;
  padding: 16px;
}

h1 {
  font-size: 22px;
  color: #5a2412;
  margin-bottom: 6px;
}

.summary {
  color: #7a5c40;
  margin-bottom: 14px;
  font-size: 12px;
}

.stat-nevera { color: #990000; font-weight: 600; }
.stat-balda  { color: #7a5500; font-weight: 600; }

.moves-detail {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
}

.moves-detail summary {
  cursor: pointer;
  color: #5a2412;
  font-weight: 600;
  user-select: none;
}

.moves-detail summary:hover { text-decoration: underline; }

.moves-body {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #d4c5b0;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.moves-section h3 {
  font-size: 12px;
  color: #5a2412;
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.moves-table {
  border-collapse: collapse;
  font-size: 12px;
}

.moves-table th {
  background: #f0e8dc;
  padding: 4px 10px;
  text-align: left;
  font-weight: 600;
  color: #5a2412;
}

.moves-table td {
  padding: 3px 10px;
  border-bottom: 1px solid #ede5d8;
}

.moves-table td.moves-count {
  text-align: center;
  font-weight: 700;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

thead th {
  background: #5a2412;
  color: #fdf0e0;
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.bottle-row td {
  padding: 4px 10px;
  border-bottom: 1px solid #ede5d8;
  vertical-align: middle;
}

.bottle-row:hover td { background: #fdf3e7; }

.bottle-row.group-b td { background: #fafafa; }
.bottle-row.group-b:hover td { background: #f5ede0; }

/* minor separator inside group A */
tr.separator-inner td {
  height: 6px;
  background: #c4a882;
  border: none;
  padding: 0;
}

/* Por llegar */
tr.separator-por-llegar td {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 7px 10px;
  background: #e0eedc;
  color: #1a5c2a;
  border-top: 2px solid #6aad7a;
  border-bottom: 2px solid #6aad7a;
  letter-spacing: 0.04em;
}

.bottle-row.por-llegar-row td { background: #f2faf0; }
.bottle-row.por-llegar-row:hover td { background: #e4f5e0; }

/* separator between Servicio Blanco and Servicio Tinto */
tr.separator-servicio td {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  padding: 5px 10px;
  background: #e8ddd0;
  color: #5a2412;
  border-top: 2px solid #c4a882;
  border-bottom: 2px solid #c4a882;
  letter-spacing: 0.04em;
}

/* major separator between groups */
tr.separator-major td {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 10px;
  background: #3a1408;
  color: #ffd9a0;
  border-top: 3px solid #5a2412;
  border-bottom: 3px solid #5a2412;
  letter-spacing: 0.04em;
}

/* expired bottles */
tr.expired td { color: #990000; font-style: italic; }

/* botella en nevera incorrecta — alta intensidad (especificidad igual a .bottle-row.group-b) */
.bottle-row.wrong-nevera td { background: #ffe0e0; }
.bottle-row.wrong-nevera:hover td { background: #ffc8c8; }

/* botella en nevera correcta pero balda incorrecta — baja intensidad */
.bottle-row.wrong-balda td { background: #fff8d6; }
.bottle-row.wrong-balda:hover td { background: #fff0a0; }

/* column group separators */
th.col-sep {
  border-right: 2px solid rgba(253, 240, 224, 0.25);
}
td.col-sep {
  border-right: 2px solid rgba(90, 36, 18, 0.12);
}

td.num {
  color: #9e7f5a;
  text-align: right;
  min-width: 32px;
  font-size: 11px;
}

td.tipo {
  white-space: nowrap;
  color: #5a4030;
  font-size: 11px;
}

td.name { font-weight: 500; }

td.price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

thead th.vida-col { padding: 7px 5px; }

td.date {
  white-space: nowrap;
  color: #5a4030;
  text-align: center;
}

td.vida { white-space: nowrap; padding: 4px 5px; }
td.vida.warn { color: #b06000; font-weight: 600; }
td.vida.neg  { color: #990000; font-weight: 600; }

td.expected { white-space: nowrap; font-size: 12px; }
td.expected-ok   { color: #8aaa7a; }
td.expected-wrong { font-weight: 700; color: #5a2412; }
td.expected-na   { color: #bbb; }

/* ── Vista móvil: oculta en escritorio ── */
.mobile-view { display: none; }

/* ══════════════════════════════════════════
   MÓVIL  (≤ 640 px)
   ══════════════════════════════════════════ */
@media (max-width: 640px) {

  .desktop-view { display: none; }
  .mobile-view  { display: block; }

  /* Separadores */
  .m-sep {
    padding: 7px 12px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  .m-sep-major {
    background: #3a1408;
    color: #ffd9a0;
    border-top: 3px solid #5a2412;
    border-bottom: 3px solid #5a2412;
    text-align: center;
  }
  .m-sep-por-llegar {
    background: #e0eedc;
    color: #1a5c2a;
    border-top: 2px solid #6aad7a;
    border-bottom: 2px solid #6aad7a;
    text-align: center;
  }
  .m-sep-servicio {
    background: #e8ddd0;
    color: #5a2412;
    border-top: 2px solid #c4a882;
    border-bottom: 2px solid #c4a882;
    text-align: center;
  }
  .m-sep-inner {
    height: 5px;
    background: #c4a882;
  }

  /* Tarjeta de botella */
  .m-bottle {
    border-bottom: 1px solid #ede5d8;
    background: #fff;
  }
  .m-bottle.wrong-nevera { background: #ffe0e0; }
  .m-bottle.wrong-balda  { background: #fff8d6; }
  .m-bottle.expired      { color: #990000; font-style: italic; }

  .m-bottle > summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }
  .m-bottle > summary::-webkit-details-marker { display: none; }

  .m-num {
    flex-shrink: 0;
    min-width: 22px;
    text-align: right;
    font-size: 11px;
    color: #9e7f5a;
  }
  .m-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-move {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: #5a2412;
    white-space: nowrap;
    margin-left: 4px;
  }

  /* Botón + / − al final de cada fila */
  .m-bottle > summary::after {
    content: '+';
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    font-size: 16px;
    font-style: normal;
    color: #9e7f5a;
    border: 1px solid #c4a882;
    border-radius: 3px;
    margin-left: 6px;
  }
  .m-bottle[open] > summary::after { content: '−'; }

  /* Panel de detalle */
  .m-detail {
    padding: 6px 12px 10px 12px;
    background: rgba(0,0,0,0.03);
    border-top: 1px solid #ede5d8;
  }
  .m-detail dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 10px;
    font-size: 12px;
  }
  .m-detail dt {
    color: #9e7f5a;
    font-weight: 600;
    white-space: nowrap;
  }
  .m-detail dd { color: #2c2218; }
}

/* ── Sort toggle ── */
.sort-toggle {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 8px;
  align-items: center;
}
.sort-btn {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #5a2412;
  background: #f0e8dc;
  border: 1px solid #c4a882;
  border-radius: 3px;
  text-decoration: none;
}
.sort-btn:hover { background: #e8d8c0; }
.sort-btn-active {
  background: #5a2412;
  color: #fdf0e0;
  border-color: #5a2412;
  pointer-events: none;
}

/* ── Columna Óptimo ── */
.optimo-col, td.optimo-cell {
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
}
.optimo-est {
  color: #9e7f5a;
  font-size: 10px;
  margin-right: 1px;
}

/* ══════════════════════════════════════════
   NAV PRINCIPAL
   ══════════════════════════════════════════ */
.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #3a1408;
  padding: 0 16px;
  margin: -16px -16px 16px -16px;
  height: 42px;
}

.nav-brand {
  font-weight: 700;
  color: #ffd9a0;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 10px;
  text-decoration: none;
}

.nav-link {
  color: rgba(253, 240, 224, 0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: #fdf0e0; }

.nav-link.nav-active {
  background: rgba(255,255,255,0.15);
  color: #fdf0e0;
  font-weight: 600;
  pointer-events: none;
}

/* ══════════════════════════════════════════
   AUDITORÍA
   ══════════════════════════════════════════ */
th.audit-col {
  width: 26px;
  padding: 0 4px;
}

td.audit-cell {
  text-align: center;
  padding: 0 4px;
  vertical-align: middle;
}

.audit-cb {
  cursor: pointer;
  accent-color: #5a2412;
  width: 14px;
  height: 14px;
}

.bottle-row.verified td { opacity: 0.45; }
.bottle-row.verified td.audit-cell { opacity: 1; }

.audit-bar {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: #5a4030;
}

.audit-bar.audit-bar-active { display: block; }

.audit-reset-btn {
  margin-left: 8px;
  font-size: 11px;
  padding: 1px 8px;
  cursor: pointer;
  background: #f0e8dc;
  border: 1px solid #c4a882;
  border-radius: 3px;
  color: #5a2412;
}
.audit-reset-btn:hover { background: #e8d8c0; }

/* ── Móvil: checkbox de auditoría en summary ── */
.m-audit-cb {
  flex-shrink: 0;
  margin-right: 2px;
  accent-color: #5a2412;
}

.m-bottle.verified { opacity: 0.45; }
.m-bottle.verified > summary .m-audit-cb { opacity: 1; }


/* ══════════════════════════════════════════
   PÁGINAS INTERIORES (común)
   ══════════════════════════════════════════ */
.page-title {
  font-size: 20px;
  color: #5a2412;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 12px;
  color: #9e7f5a;
  margin-bottom: 16px;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  font-size: 13px;
}

.data-table thead th {
  background: #5a2412;
  color: #fdf0e0;
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr td {
  padding: 5px 10px;
  border-bottom: 1px solid #ede5d8;
  vertical-align: middle;
}

.data-table tbody tr:hover td { background: #fdf3e7; }

.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.mono { font-variant-numeric: tabular-nums; }
.col-up   { color: #2a6a2a; font-weight: 600; }
.col-down { color: #990000; font-weight: 600; }

/* ══════════════════════════════════════════
   ESTADÍSTICAS
   ══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid #d4c5b0;
  border-radius: 6px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.stat-card-up   { border-left: 4px solid #4a9a4a; }
.stat-card-down { border-left: 4px solid #cc2222; }

.stat-label {
  font-size: 11px;
  color: #9e7f5a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #2c2218;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 11px;
  color: #9e7f5a;
  margin-top: 2px;
}

.stats-tables {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}

.stats-section-title {
  font-size: 15px;
  color: #5a2412;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #d4c5b0;
}

.stats-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  background: #d4c5b0;
  color: #5a2412;
  margin-left: 8px;
  vertical-align: middle;
}

.stats-collapsible { margin-bottom: 4px; }

.stats-collapsible-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
}
.stats-collapsible-summary::-webkit-details-marker { display: none; }
.stats-collapsible-summary::after {
  content: ' ＋';
  font-size: 13px;
  opacity: 0.5;
  margin-left: 6px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.stats-collapsible[open] > .stats-collapsible-summary::after { content: ' －'; }

.stats-section h2 {
  font-size: 14px;
  color: #5a2412;
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════
   RECOMENDACIONES
   ══════════════════════════════════════════ */
.rec-section {
  margin-bottom: 28px;
}

.rec-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rec-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 11px;
  background: rgba(0,0,0,0.12);
}

.rec-urgente .rec-title  { background: #ffe0e0; color: #7a0000; border-left: 4px solid #cc2222; }
.rec-ahora   .rec-title  { background: #e0f0e0; color: #1a5c2a; border-left: 4px solid #4a9a4a; }
.rec-proximo .rec-title  { background: #e8f4ff; color: #1a3c6a; border-left: 4px solid #4a7acc; }
.rec-breve   .rec-title  { background: #f5f0ea; color: #5a4030; border-left: 4px solid #c4a882; }
.rec-guarda  .rec-title  { background: #ede8f5; color: #3a2860; border-left: 4px solid #7a5aaa; }

.rec-empty {
  color: #9e7f5a;
  font-style: italic;
  padding: 20px 0;
}

details.rec-collapsible > summary.rec-title {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
details.rec-collapsible > summary.rec-title::-webkit-details-marker { display: none; }
details.rec-collapsible > summary.rec-title::after {
  content: ' ＋';
  font-size: 13px;
  opacity: 0.6;
  margin-left: 4px;
}
details.rec-collapsible[open] > summary.rec-title::after { content: ' －'; }

.m-optimo-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #5a2412;
  background: #f0e8dc;
  border: 1px solid #c4a882;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: auto;
  margin-right: 4px;
}

/* ══════════════════════════════════════════
   MOVIMIENTOS
   ══════════════════════════════════════════ */
.mov-bar {
  display: none;
  margin-bottom: 14px;
  font-size: 12px;
  color: #5a4030;
}
.mov-bar.audit-bar-active { display: block; }

th.num-col { width: 32px; }

.mov-row.verified td,
.mov-row.verified > summary .m-name,
.mov-row.verified > summary .m-move,
.mov-row.verified > summary .m-num { opacity: 0.4; }
.mov-row.verified td.audit-cell,
.mov-row.verified > summary .m-audit-cb { opacity: 1; }

.mov-src { white-space: nowrap; color: #5a4030; }
.mov-src.mov-wrong { color: #990000; font-weight: 600; }
.mov-arrow { text-align: center; color: #9e7f5a; padding: 4px 2px; }
.mov-dst { white-space: nowrap; }
.mov-dst.mov-right { font-weight: 700; color: #2a6a2a; }

.mov-title-nevera { background: #ffe0e0; color: #7a0000; border-left: 4px solid #cc2222; }
.mov-title-balda  { background: #fff8d6; color: #5a3800; border-left: 4px solid #c4a000; }

/* ══════════════════════════════════════════
   RESPONSIVE AJUSTES
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
  .main-nav { padding: 0 10px; gap: 0; }
  .nav-brand { font-size: 12px; margin-right: 6px; }
  .nav-link  { font-size: 12px; padding: 5px 8px; }

  .stats-tables { grid-template-columns: 1fr; }

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

  .stats-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .data-table thead th { white-space: nowrap; }
  .data-table tbody tr td { white-space: nowrap; }
}
