/* Reset base (sitio estático) */
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0}
img{max-width:100%}
[hidden]{display:none!important}
:root{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}

/* Mobile-first. Foco en el PRODUCTO: rotación y comportamiento de la última semana vs mín/prom/máx.
   Dos segmentadores anidados: Área (Cocina/Barra) y Categoría de la carta. Producción se lee contra el máximo. */
:root{
  color-scheme: light;
  --bg:#f6f6f3; --surface:#ffffff; --surface-2:#faf9f6; --surface-3:#f1f0ec;
  --fg:#1a1713; --fg-2:#56524b; --muted:#8a867e;
  --border:rgba(22,20,16,.10); --border-2:#e5e2da;
  --brand:#8a3b4a; --brand-soft:#f3e7e9;
  --c-cocina:#eb6834; --c-barra:#17936a;
  --good:#0ca30c; --good-ink:#006300; --warn:#fab219; --serious:#ec835a; --critical:#d03b3b;
  --grid:#e8e6df; --axis:#c9c6bd;
  --shadow:0 1px 2px rgba(22,20,16,.04), 0 2px 10px rgba(22,20,16,.05);
  --r:14px; --r-sm:9px;
  --font-display:"Fraunces", Georgia, "Times New Roman", serif;
  --font-ui:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  color-scheme: dark;
  --bg:#111110; --surface:#1a1a18; --surface-2:#201f1d; --surface-3:#262521;
  --fg:#f0efec; --fg-2:#bebbb3; --muted:#8a877f;
  --border:rgba(255,255,255,.10); --border-2:#2e2d2a;
  --brand:#d08a96; --brand-soft:#2b1e21;
  --c-cocina:#e0672f; --c-barra:#1aa379;
  --good:#1bb81b; --good-ink:#44d144; --warn:#fab219; --serious:#ec835a; --critical:#e65a5a;
  --grid:#2a2926; --axis:#3a3934;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 2px 12px rgba(0,0,0,.35);
}}
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#111110; --surface:#1a1a18; --surface-2:#201f1d; --surface-3:#262521;
  --fg:#f0efec; --fg-2:#bebbb3; --muted:#8a877f;
  --border:rgba(255,255,255,.10); --border-2:#2e2d2a;
  --brand:#d08a96; --brand-soft:#2b1e21;
  --c-cocina:#e0672f; --c-barra:#1aa379;
  --good:#1bb81b; --good-ink:#44d144; --warn:#fab219; --serious:#ec835a; --critical:#e65a5a;
  --grid:#2a2926; --axis:#3a3934;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 2px 12px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
body{background:var(--bg); color:var(--fg); font-family:var(--font-ui); line-height:1.5; -webkit-font-smoothing:antialiased; font-size:15px;}
.wrap{max-width:1100px; margin:0 auto; padding-left:max(16px, env(safe-area-inset-left,0px)); padding-right:max(16px, env(safe-area-inset-right,0px));}
h1,h2,h3{margin:0; font-weight:600; text-wrap:balance;}
.tnum{font-variant-numeric:tabular-nums;}
button{font-family:inherit; cursor:pointer;}

header.top{position:sticky; top:env(safe-area-inset-top,0px); z-index:20; background:color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter:blur(10px); border-bottom:1px solid var(--border);}
body::before{content:""; position:fixed; inset:0 0 auto; height:env(safe-area-inset-top,0px); background:var(--bg); z-index:21;}
.top-in{display:flex; align-items:center; gap:12px; padding-block:13px; flex-wrap:wrap;}
.brand{display:flex; align-items:baseline; gap:9px; margin-right:auto; min-width:0;}
.brand .mark{font-family:var(--font-display); font-size:25px; font-weight:600; letter-spacing:.3px; line-height:1;}
.brand .mark b{color:var(--brand);}
.brand .sub{font-size:12px; color:var(--muted);}
.hdr-actions{display:flex; align-items:center; gap:8px;}
.btn{display:inline-flex; align-items:center; gap:7px; border:1px solid var(--border-2); background:var(--surface); color:var(--fg); padding:8px 12px; border-radius:var(--r-sm); font-size:13px; font-weight:500;}
.btn:hover{background:var(--surface-3);}
.btn.primary{background:var(--brand); color:#fff; border-color:var(--brand);}
.btn svg{width:16px; height:16px;}
.icon-btn{width:38px; height:38px; padding:0; justify-content:center;}

/* filtros */
.controls{display:flex; flex-direction:column; gap:12px; padding-block:16px;}
.ctrlrow{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.ctrlrow .lab{font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); font-weight:700; min-width:64px;}
.pills{display:flex; gap:5px; background:var(--surface-3); padding:4px; border-radius:11px; flex:1; min-width:0;}
.pills button{flex:1; border:0; background:transparent; color:var(--fg-2); padding:9px 10px; border-radius:8px; font-size:13px; font-weight:600; display:inline-flex; align-items:center; justify-content:center; gap:6px; white-space:nowrap;}
.pills button .sw{width:9px; height:9px; border-radius:3px; flex:none;}
.pills button[aria-pressed="true"]{background:var(--surface); color:var(--fg); box-shadow:var(--shadow);}
.select{appearance:none; -webkit-appearance:none; flex:1; min-width:0; background:var(--surface-3); border:1px solid var(--border-2); color:var(--fg); padding:10px 34px 10px 13px; border-radius:9px; font-size:13.5px; font-weight:600; font-family:inherit; cursor:pointer;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a867e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat:no-repeat; background-position:right 11px center;}

section{margin:22px 0;}
.sec-head{display:flex; align-items:baseline; gap:10px; margin-bottom:13px; flex-wrap:wrap;}
.sec-head h2{font-size:17px; letter-spacing:-.01em;}
.sec-head .eyebrow{font-size:10.5px; text-transform:uppercase; letter-spacing:.09em; color:var(--muted); font-weight:700;}
.sec-head .note{font-size:12px; color:var(--muted); margin-left:auto;}
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--r); box-shadow:var(--shadow);}
.card .pad{padding:16px;}

/* resumen mini-tiles */
.summ{display:grid; grid-template-columns:repeat(4,1fr); gap:10px;}
.stile{background:var(--surface); border:1px solid var(--border); border-radius:var(--r-sm); box-shadow:var(--shadow); padding:13px 14px; display:flex; flex-direction:column; gap:2px;}
.stile .n{font-size:26px; font-weight:700; letter-spacing:-.02em; line-height:1;}
.stile .l{font-size:11.5px; color:var(--fg-2); font-weight:600; line-height:1.25;}
.stile.rec .n{color:var(--good-ink);}
.stile.down .n{color:var(--critical);}

/* tarjetas de producto */
.prodgrid{display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:12px;}
.pcard{background:var(--surface); border:1px solid var(--border); border-radius:var(--r); box-shadow:var(--shadow); padding:14px 15px;}
.pcard .ph{display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:9px;}
.pcard .pn{font-weight:600; font-size:15px; display:flex; align-items:center; gap:7px; min-width:0;}
.pcard .pn .sw{width:9px; height:9px; border-radius:3px; flex:none;}
.pcard .pn .nm{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.badge{display:inline-flex; align-items:center; gap:4px; padding:3px 8px; border-radius:20px; font-size:11.5px; font-weight:700; white-space:nowrap; flex:none;}
.b-rec{background:color-mix(in srgb,var(--good) 16%,transparent); color:var(--good-ink);}
.b-over{background:color-mix(in srgb,var(--good) 13%,transparent); color:var(--good-ink);}
.b-under{background:color-mix(in srgb,var(--serious) 20%,transparent); color:#a0472a;}
.b-low{background:color-mix(in srgb,var(--critical) 15%,transparent); color:var(--critical);}
:root[data-theme="dark"] .b-under,:root:not([data-theme="light"]) .b-under{color:#f0a080;}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .b-under{color:#f0a080;}}
.pcard .ult{font-size:13px; color:var(--fg-2); margin-bottom:8px;}
.pcard .ult b{font-size:20px; color:var(--fg); font-weight:700; font-variant-numeric:tabular-nums;}
.pcard .ult .gap{color:var(--muted); font-size:12px; margin-left:6px;}
.pcard .rbar{width:100%; height:26px; margin:2px 0 7px;}
.pcard .marks{display:flex; justify-content:space-between; font-size:11.5px; font-variant-numeric:tabular-nums;}
.pcard .marks span{display:flex; flex-direction:column; gap:1px;}
.pcard .marks .k{font-size:9.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); font-weight:700;}
.pcard .marks .v{font-weight:700; color:var(--fg-2);}
.pcard .marks .v.mx{color:var(--fg);}

/* heatmap */
.heat-wrap{overflow-x:auto;}
.heatt{width:100%; border-collapse:collapse; font-size:13px; min-width:540px;}
.heatt th,.heatt td{padding:7px 6px; text-align:center;}
.heatt thead th{font-size:10px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); font-weight:700; border-bottom:1.5px solid var(--border-2);}
.heatt td:first-child,.heatt th:first-child{text-align:left; font-weight:600; max-width:190px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.heatt tbody tr{border-bottom:1px solid var(--border);}
.heatt .cell{display:inline-block; min-width:28px; padding:3px 0; border-radius:5px; font-weight:600; font-variant-numeric:tabular-nums;}
.heatt .tot{font-weight:700;}
.heatt .off{color:var(--border-2);}
.h-nm-tot{display:none;}

/* subió / cayó */
.updown{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.udcard h3{display:flex; align-items:center; gap:8px; font-size:14px; margin-bottom:11px;}
.udcard h3 .ic{width:24px; height:24px; border-radius:7px; display:grid; place-items:center;}
.udcard h3 .ic svg{width:14px; height:14px;}
.uitem{display:flex; justify-content:space-between; align-items:center; gap:10px; font-size:13.5px; padding:7px 0; border-bottom:1px solid var(--border);}
.uitem:last-child{border-bottom:0;}
.uitem .nm{font-weight:600; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.uitem .r{display:flex; align-items:center; gap:9px; flex:none;}
.uitem .q{font-size:11.5px; color:var(--muted); font-variant-numeric:tabular-nums;}
.uitem .d{font-weight:700; font-size:13px; font-variant-numeric:tabular-nums;}

/* lectura */
.reco{background:linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);}
.reco ul{margin:0; padding:0; list-style:none; display:flex; flex-direction:column; gap:11px;}
.reco li{display:flex; gap:12px; align-items:flex-start; font-size:14px; line-height:1.5;}
.reco li .ic{flex:none; width:28px; height:28px; border-radius:8px; display:grid; place-items:center; margin-top:1px;}
.reco li .ic svg{width:15px; height:15px;}
.reco b{font-weight:600;}

/* fuente de datos */
.tabs{display:flex; gap:6px; margin-bottom:14px;}
.tabs button{border:1px solid var(--border-2); background:var(--surface); color:var(--fg-2); padding:8px 14px; border-radius:var(--r-sm); font-size:13px; font-weight:600;}
.tabs button[aria-pressed="true"]{background:var(--brand); color:#fff; border-color:var(--brand);}
.drop{border:1.5px dashed var(--border-2); border-radius:var(--r); padding:20px; text-align:center; background:var(--surface-2);}
.drop.over{border-color:var(--brand); background:var(--brand-soft);}
.drop h3{font-size:15px; margin-bottom:4px;}
.drop p{font-size:13px; color:var(--muted); margin:0 0 12px;}
#log{margin-top:12px; font-size:12.5px; color:var(--fg-2); text-align:left; max-height:150px; overflow:auto;}
#log div{padding:3px 0; border-bottom:1px solid var(--border);}
.ok{color:var(--good-ink); font-weight:600;} .err{color:var(--critical); font-weight:600;}
.apibox{border:1px solid var(--border-2); border-radius:var(--r); padding:18px; background:var(--surface-2);}
.apibox h3{font-size:15px; margin-bottom:4px;}
.apibox p{font-size:13px; color:var(--muted); margin:0 0 14px;}
.field{display:flex; flex-direction:column; gap:5px; margin-bottom:12px;}
.field label{font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--fg-2);}
.field input{background:var(--surface); border:1px solid var(--border-2); border-radius:var(--r-sm); padding:10px 12px; font-size:13.5px; color:var(--fg); font-family:inherit;}
.field input:focus{outline:2px solid var(--brand); outline-offset:-1px;}
.apinote{display:flex; gap:9px; align-items:flex-start; font-size:12.5px; color:var(--fg-2); background:var(--surface-3); border-radius:var(--r-sm); padding:11px 13px; margin-top:12px; line-height:1.45;}
.apinote svg{width:16px; height:16px; flex:none; margin-top:1px; color:var(--warn);}
#apiStatus{font-size:13px; font-weight:600; margin-top:12px;}

footer{margin:30px 0 50px; padding-top:18px; border-top:1px solid var(--border); color:var(--muted); font-size:12px; line-height:1.6;}
footer b{color:var(--fg-2);}

@media (max-width:760px){ .summ{grid-template-columns:repeat(2,1fr);} .updown{grid-template-columns:1fr;} }
@media (max-width:600px){
  body{font-size:15px;}
  .ctrlrow .lab{min-width:100%;}
  .prodgrid{grid-template-columns:1fr;}
  /* heatmap -> nombre + 7 días en grilla */
  .heat-wrap{overflow:visible;}
  .heatt{min-width:0; display:block;}
  .heatt thead{display:none;}
  .heatt tbody{display:block;}
  .heatt tbody tr{display:grid; grid-template-columns:repeat(7,1fr); gap:4px; padding:14px 0; border-bottom:1px solid var(--border);}
  .heatt td{padding:0;}
  .heatt .h-nm{grid-column:1/-1; max-width:none; font-size:14.5px; font-weight:600; margin-bottom:5px; white-space:normal; display:flex; justify-content:space-between; align-items:baseline; gap:10px;}
  .h-nm-tot{display:inline; color:var(--muted); font-size:12.5px; font-weight:600;}
  .heatt .h-day{text-align:center; min-width:0;}
  .heatt .h-day::before{content:attr(data-d); display:block; font-size:9px; font-weight:700; text-transform:uppercase; color:var(--muted); margin-bottom:3px;}
  .heatt .h-day .cell{display:block; width:100%; padding:6px 0; font-size:12px;}
  .heatt .h-day .off{display:block; padding:6px 0; color:var(--border-2);}
  .heatt .h-tot{display:none;}
}
@media print, (forced-colors:active){*{box-shadow:none!important;}}
