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

:root {
  --red:      #C8102E;
  --red-dark: #A00D24;
  --red-deep: #7D0A1B;
  --red-soft: #FCEEF0;
  --red-pale: #FDF5F6;
  --warm:     #FDFCFC;
  --white:    #FFFFFF;
  --ink:      #1A1A1A;
  --muted:    #6B6B6B;
  --line:     #E8D8DA;
  --gold:     #C9922A;
  --shadow:    0 18px 50px rgba(200,16,46,0.10);
  --soft-shadow: 0 10px 26px rgba(200,16,46,0.06);
  --radius:   20px;
  --sidebar:  286px;
}

html { min-height: 100%; scroll-behavior: smooth; background: var(--warm); }

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(252,238,240,0.7) 0, rgba(253,252,252,0.98) 320px),
    var(--warm);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.app {
  min-height: 100svh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0,1fr);
}

/* ── SIDEBAR ── */
.sidebar {
  position: sticky; top: 0; z-index: 20;
  height: 100svh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 28px 22px;
  background: rgba(253,252,252,0.97);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: grid; gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 140px; min-height: 134px;
  display: grid; place-items: center; padding: 4px;
}
.brand-logo img { width: 88px; height: auto; object-fit: contain; }

.brand-identity {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 6px;
  color: var(--red);
  font-family: Poppins, Inter, sans-serif;
}
.brand-identity svg { width: 28px; height: 28px; stroke-width: 1.8; flex-shrink: 0; }
.logo-text { font-size: 0.62rem; font-weight: 900; letter-spacing: 0.08em; text-align: center; line-height: 1.15; }

.brand-kicker, .eyebrow, .section-kicker {
  margin: 0; color: var(--red);
  font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.09em; text-transform: uppercase;
}

.brand-title {
  margin: 0; color: var(--ink);
  font-family: Poppins, Inter, sans-serif;
  font-size: 0.98rem; line-height: 1.35; font-weight: 700;
}

.nav { display: grid; gap: 6px; }
.mobile-menu-toggle { display: none; }

.nav-link {
  min-height: 46px; display: flex; align-items: center;
  gap: 12px; padding: 10px 12px; border-radius: 14px;
  color: var(--muted); font-weight: 700;
  transition: background 190ms ease, color 190ms ease, transform 190ms ease;
}
.nav-link:hover, .nav-link.active {
  background: var(--red-pale); color: var(--red);
  transform: translateX(2px);
}
.nav-link svg, .button svg, .icon-button svg,
.metric-icon svg, .alert-icon svg, .field-icon svg,
.movement-option svg { width: 18px; height: 18px; stroke-width: 2; }

.sidebar-note {
  margin-top: auto; padding: 16px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--red-soft);
  color: var(--red-dark);
  font-family: Poppins, Inter, sans-serif;
  font-size: 0.9rem; line-height: 1.38; font-weight: 700;
}

/* ── MAIN ── */
.main { min-width: 0; padding: 0 clamp(18px,4vw,52px) 48px; }

.announcement {
  min-height: 34px; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  margin: 0 calc(clamp(18px,4vw,52px) * -1) 24px;
  padding: 8px 18px;
  background: var(--red); color: var(--white);
  font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.announcement-mobile { display: none; }

/* ── HERO ── */
.hero {
  position: relative; overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0,1.12fr) minmax(280px,0.68fr);
  gap: clamp(22px,3vw,36px); align-items: center;
  min-height: 488px; padding: clamp(24px,3.6vw,44px);
  margin-bottom: 24px;
  border: 1px solid var(--line); border-radius: 26px;
  background:
    linear-gradient(120deg, rgba(252,238,240,0.85), rgba(255,255,255,0.97)),
    var(--white);
  box-shadow: var(--shadow);
}
.hero::before {
  content: ""; position: absolute; inset: 18px;
  pointer-events: none;
  border: 1px solid rgba(200,16,46,0.13); border-radius: 22px;
}
.hero-copy, .hero-visual { position: relative; z-index: 1; }

.hero-logo-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.hero-logo {
  width: 86px; height: 86px; display: grid; place-items: center; padding: 4px;
}
.hero-logo img { width: 54px; height: auto; object-fit: contain; }

.brand-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--red-soft); color: var(--red);
  font-size: 0.78rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
}

h1, h2, h3, h4, .metric-value {
  font-family: Poppins, Inter, sans-serif; letter-spacing: 0;
}
h1 {
  max-width: 820px; margin: 0; color: var(--ink);
  font-size: clamp(2.2rem,3.8vw,3.6rem);
  line-height: 1.04; font-weight: 900;
}
.hero-description {
  max-width: 680px; margin: 18px 0 24px;
  color: var(--muted); font-size: 1.06rem; line-height: 1.72; font-weight: 550;
}
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.button {
  min-height: 46px; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; padding: 12px 18px;
  border-radius: 999px; border: 1px solid var(--red);
  background: var(--red); color: var(--white);
  font-family: Poppins, Inter, sans-serif; font-weight: 800;
  line-height: 1; white-space: nowrap;
  box-shadow: 0 12px 26px rgba(200,16,46,0.22);
  transition: transform 190ms ease, box-shadow 190ms ease, background 190ms ease, border-color 190ms ease;
}
.button:hover {
  background: var(--red-dark); border-color: var(--red-dark);
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(200,16,46,0.28);
}
.button.secondary {
  background: var(--white); color: var(--red);
  border-color: rgba(200,16,46,0.4); box-shadow: none;
}
.button.secondary:hover {
  background: var(--red-pale); border-color: var(--red); box-shadow: none;
}
.button.ghost {
  min-height: 40px; padding: 10px 14px;
  background: transparent; color: var(--red);
  border-color: var(--line); box-shadow: none;
}
.button:disabled,
.movement-option:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none !important;
  box-shadow: none !important;
}
.reset-demo-button {
  width: 100%;
  margin-top: 12px;
}

/* ── HERO VISUAL ── */
.hero-visual { display: grid; gap: 16px; align-content: center; }

.product-stage {
  position: relative; min-height: 342px; border-radius: 28px;
  background: #FBF0F1; border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--soft-shadow);
  overflow: hidden; display: grid; place-items: center;
}
.product-stage::before {
  content: ""; position: absolute;
  left: 8%; right: 8%; bottom: 46px; height: 18px;
  border-radius: 999px;
  background: rgba(200,16,46,0.09); filter: blur(5px);
}
.stage-logo {
  position: absolute; top: 20px; left: 20px;
  width: 42px; height: auto; opacity: 0.65;
}

/* Product photo treatments */
.product-image-wrapper {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  transform: translateY(0);
  transition: transform 210ms ease;
}
.product-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform:
    translate(var(--image-x, 0), var(--image-y, 0))
    scale(var(--image-scale, 1.18));
  transform-origin: center;
}
.hero-product-image {
  width: 100%;
  height: 100%;
}

.bag-product {
  position: absolute; display: grid; place-items: center;
  filter: drop-shadow(0 14px 20px rgba(120,10,20,0.18));
}
.bag-product.primary { width: 54%; height: 86%; right: 22%; bottom: 18px; z-index: 3; }
.bag-product.left   { width: 43%; height: 72%; left: 2%;  bottom: 54px; z-index: 2; transform: rotate(-6deg); }
.bag-product.right  { width: 43%; height: 72%; right: 2%; bottom: 54px; z-index: 1; transform: rotate(6deg); }

.bag-tag {
  position: absolute; bottom: -6px; left: 50%;
  transform: translateX(-50%);
  background: var(--white); color: var(--red);
  font-family: Poppins, Inter, sans-serif;
  font-size: 0.55em; font-weight: 900; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid rgba(200,16,46,0.25);
}

.hero-mini-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px;
}
.mini-stat {
  padding: 14px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--white); box-shadow: var(--soft-shadow);
}
.mini-stat span { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.mini-stat strong { display: block; margin-top: 5px; color: var(--red); font-family: Poppins, Inter, sans-serif; font-size: 1.05rem; line-height: 1.1; }

/* ── SECTIONS ── */
.section { margin-top: 28px; scroll-margin-top: 18px; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-bottom: 18px;
}
.section-title {
  margin: 6px 0 0; color: var(--ink);
  font-size: clamp(1.5rem,2.4vw,2.2rem); line-height: 1.12; font-weight: 850;
}
.section-copy {
  max-width: 700px; margin: 8px 0 0; color: var(--muted); line-height: 1.6; font-weight: 550;
}

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }

.kpi-card, .finance-card, .panel, .product-card,
.store-card, .category-card, .chart-card, .import-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); box-shadow: var(--soft-shadow);
}
.kpi-card {
  min-height: 192px; display: grid; align-content: space-between;
  gap: 20px; padding: 22px;
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}
.kpi-card:hover, .product-card:hover, .store-card:hover, .category-card:hover {
  transform: translateY(-3px);
  border-color: rgba(200,16,46,0.4);
  box-shadow: var(--shadow);
}
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.metric-icon, .alert-icon, .field-icon {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 14px; background: var(--red-soft); color: var(--red);
  border: 1px solid rgba(200,16,46,0.18);
}
.metric-label { margin: 0; color: var(--muted); font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { display: block; margin-top: 10px; color: var(--ink); font-size: clamp(2rem,3vw,3rem); line-height: 1; font-weight: 850; }
.metric-note { margin: 8px 0 0; color: var(--muted); line-height: 1.45; font-weight: 550; }

.state {
  display: inline-flex; align-items: center; width: fit-content;
  min-height: 28px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(200,16,46,0.2);
  background: var(--red-soft); color: var(--red);
  font-size: 0.74rem; font-weight: 800; white-space: nowrap;
}
.state.warning { background: rgba(201,146,42,0.12); color: #7A5A10; border-color: rgba(201,146,42,0.32); }
.state.orange  { background: rgba(210,90,40,0.12);  color: #9A3A14; border-color: rgba(210,90,40,0.28); }
.state.danger  { background: rgba(140,20,20,0.12);  color: #8C1414; border-color: rgba(140,20,20,0.28); }
.state.info    { background: rgba(60,100,160,0.10);  color: #2A5AA0; border-color: rgba(60,100,160,0.22); }
.state.green   { background: rgba(40,130,60,0.10);   color: #1A6A2A; border-color: rgba(40,130,60,0.22); }

.finance-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-top: 16px; }
.finance-card {
  padding: 18px 20px; display: flex;
  align-items: center; justify-content: space-between; gap: 14px;
}
.finance-card span { display: block; color: var(--muted); font-weight: 760; font-size: 0.82rem; }
.finance-card strong { display: block; margin-top: 4px; color: var(--ink); font-family: Poppins, Inter, sans-serif; font-size: 1.45rem; line-height: 1; }

/* ── ALERTS ── */
.alert-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.alert-card {
  min-height: 164px; padding: 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--white); box-shadow: var(--soft-shadow);
}
.alert-card strong { display: block; margin: 14px 0 8px; font-family: Poppins, Inter, sans-serif; font-size: 1.02rem; line-height: 1.2; }
.alert-card p { margin: 0; color: var(--muted); line-height: 1.48; font-weight: 550; }

/* ── PORTFOLIO / CATEGORIES ── */
.portfolio-grid {
  display: grid; grid-template-columns: repeat(3, minmax(180px,1fr)); gap: 14px;
  overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin;
}
.category-card {
  min-height: 240px; display: grid; grid-template-rows: 128px 1fr;
  overflow: hidden;
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}
.category-art { position: relative; display: grid; place-items: center; background: var(--red-soft); overflow: hidden; }
.category-art > img { width: 84%; height: 118%; object-fit: contain; transform: translateY(10px); }
.presentation-image {
  width: 130px;
  height: 128px;
}
.category-body { padding: 14px; }
.category-body h3 { margin: 0; color: var(--ink); font-size: 1rem; line-height: 1.2; font-weight: 800; }
.category-body p { margin: 6px 0 12px; color: var(--muted); font-size: 0.86rem; font-weight: 650; }
.category-link { color: var(--red); font-size: 0.82rem; font-weight: 850; }

/* ── PRODUCTS ── */
.products-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.product-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-rows: 250px auto; min-height: 540px;
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}
.product-media {
  position: relative; display: grid; place-items: center;
  padding: 18px; background: var(--product-bg, var(--red-soft));
  border-bottom: 1px solid var(--line); overflow: hidden;
}
.stock-product-image {
  width: min(82%, 245px);
  height: 222px;
  filter: drop-shadow(0 16px 18px rgba(120,0,20,0.12));
}
.product-card:hover .stock-product-image { transform: translateY(-2px); }
.flavor-dot {
  position: absolute; top: 16px; right: 16px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent, var(--red));
  box-shadow: 0 0 0 6px rgba(255,255,255,0.72);
}
.product-body { display: grid; gap: 16px; padding: 20px; }
.product-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.product-card h3 { margin: 0; color: var(--ink); font-size: 1.28rem; line-height: 1.12; font-weight: 850; }
.product-category { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; font-weight: 760; }
.product-stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.product-stat { padding: 12px; border-radius: 14px; background: var(--red-pale); border: 1px solid var(--line); }
.product-stat span { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
.product-stat strong { display: block; margin-top: 4px; color: var(--ink); font-family: Poppins, Inter, sans-serif; font-size: 1rem; line-height: 1.15; }

/* ── STORES ── */
.store-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.store-card {
  display: grid; gap: 18px; padding: 20px;
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}
.store-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.store-head > div { min-width: 0; }
.store-card h3 { margin: 0; color: var(--ink); font-size: 1.12rem; line-height: 1.2; font-weight: 820; }
.store-card p { margin: 5px 0 0; color: var(--muted); font-weight: 650; }
.rotation { display: grid; gap: 8px; }
.rotation-line { height: 10px; overflow: hidden; border-radius: 999px; background: var(--red-soft); }
.rotation-line span { display: block; height: 100%; width: var(--rate); border-radius: inherit; background: var(--accent, var(--red)); }
.store-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.store-metric { padding: 11px; border-radius: 14px; background: var(--red-pale); border: 1px solid var(--line); }
.store-metric span { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.store-metric strong { display: block; margin-top: 4px; color: var(--ink); font-family: Poppins, Inter, sans-serif; line-height: 1.12; }
.store-detail { display: grid; gap: 8px; color: var(--muted); font-size: 0.9rem; line-height: 1.42; font-weight: 600; }
.store-detail b { color: var(--ink); }

/* ── CHARTS ── */
.charts-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
.chart-card { min-height: 330px; padding: 22px; }
.chart-card h3 { margin: 0 0 18px; color: var(--ink); font-size: 1.16rem; font-weight: 820; }
.bar-chart, .rotation-chart, .ranking-list { display: grid; gap: 13px; }
.bar-row, .rotation-row {
  display: grid; grid-template-columns: 150px minmax(0,1fr) 54px;
  gap: 12px; align-items: center; color: var(--muted); font-weight: 700;
}
.bar-track, .rotation-track {
  height: 13px; overflow: hidden; border-radius: 999px; background: var(--red-soft);
}
.bar-fill, .rotation-fill {
  display: block; width: var(--value); height: 100%;
  border-radius: inherit; background: var(--accent, var(--red));
}
.ranking-item {
  display: grid; grid-template-columns: 46px minmax(0,1fr) auto;
  gap: 12px; align-items: center; padding: 12px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--red-pale);
}
.ranking-avatar {
  width: 46px; height: 46px; display: grid; place-items: center;
  overflow: hidden; border-radius: 14px;
  background: var(--red-soft); border: 1px solid var(--line);
}
.ranking-product-image {
  width: 42px;
  height: 42px;
}
.ranking-item strong { display: block; color: var(--ink); font-family: Poppins, Inter, sans-serif; line-height: 1.1; }
.ranking-item span { color: var(--muted); font-size: 0.88rem; font-weight: 650; }
.loss-panel { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.loss-card { padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--red-pale); }
.loss-card span { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 800; text-transform: uppercase; }
.loss-card strong { display: block; margin-top: 7px; color: var(--ink); font-family: Poppins, Inter, sans-serif; font-size: 1.36rem; line-height: 1; }

/* ── INVENTORY TABLE ── */
.panel { overflow: hidden; }
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: center;
  padding: 18px; border-bottom: 1px solid var(--line); background: var(--red-pale);
}
.filter-group { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.input, .select {
  min-height: 44px; width: min(100%,280px);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); font-weight: 650; outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.input:focus, .select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(200,16,46,0.12);
}
.field-wide { grid-column: 1 / -1; }
.field-hint,
.field-error {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 700;
}
.field-hint { color: var(--muted); }
.field-error { color: var(--red-dark); }
.input.is-invalid,
.select.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(200,16,46,0.10);
}
.table-wrap { overflow-x: auto; background: var(--white); }
table { width: 100%; min-width: 890px; border-collapse: separate; border-spacing: 0; }
th {
  position: sticky; top: 0; z-index: 1; padding: 15px 18px;
  background: var(--red-soft); color: var(--red);
  font-size: 0.76rem; font-weight: 850; letter-spacing: 0.05em;
  text-align: left; text-transform: uppercase;
}
td { padding: 17px 18px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 650; vertical-align: middle; }
tr { transition: background 170ms ease; }
tbody tr:hover { background: rgba(252,238,240,0.6); }
.product-line { display: flex; align-items: center; gap: 12px; }
.product-thumb {
  width: 44px; height: 44px; display: grid; place-items: center;
  flex: 0 0 auto; overflow: hidden; border-radius: 14px;
  background: var(--red-soft); border: 1px solid var(--line);
}
.thumb-product-image {
  width: 42px;
  height: 42px;
}
.product-line strong { display: block; color: var(--ink); font-family: Poppins, Inter, sans-serif; line-height: 1.15; }
.product-line span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.84rem; }

.movement-history-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.movement-history-card h3 {
  margin: 4px 0 0;
  color: var(--ink);
  font-family: Poppins, Inter, sans-serif;
  font-size: 1.15rem;
  line-height: 1.15;
}
.movement-history {
  display: grid;
  gap: 10px;
}
.history-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--red-pale);
}
.history-row strong {
  display: block;
  color: var(--ink);
  font-family: Poppins, Inter, sans-serif;
  line-height: 1.15;
}
.history-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.history-row em {
  color: var(--red);
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

/* ── IMPORT / EXCEL ── */
.import-card {
  display: grid;
  grid-template-columns: minmax(0,0.95fr) minmax(340px,1.05fr);
  gap: 22px; padding: 22px;
  background: linear-gradient(120deg, rgba(252,238,240,0.85), rgba(255,255,255,0.98)), var(--white);
}
.dropzone {
  min-height: 280px; display: grid; place-items: center;
  padding: 28px; border: 1.5px dashed rgba(200,16,46,0.35);
  border-radius: 22px; background: var(--red-soft);
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}
.dropzone.dragging { border-color: var(--red); background: var(--red-pale); transform: scale(1.01); }
.dropzone .field-icon { width: 58px; height: 58px; margin: 0 auto 14px; background: var(--white); }
.dropzone h3 { margin: 0; color: var(--ink); font-size: 1.28rem; font-weight: 840; }
.dropzone p { max-width: 360px; margin: 9px auto 18px; color: var(--muted); line-height: 1.55; font-weight: 580; }
.preview-card { display: grid; gap: 14px; align-content: start; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); }
.mapping-row {
  display: grid; grid-template-columns: minmax(0,1fr) 32px minmax(0,1fr);
  align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 14px; background: var(--red-pale); border: 1px solid var(--line);
  color: var(--muted); font-size: 0.88rem; font-weight: 700;
}
.mapping-row strong { color: var(--ink); }
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--red-soft); }
.progress span { display: block; width: var(--progress,0%); height: 100%; border-radius: inherit; background: var(--red); transition: width 240ms ease; }

/* ── INVOICE ── */
.invoice-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 20px; align-items: start; }
.invoice-paper {
  width: 100%; max-width: 816px; min-height: 960px;
  margin: 0 auto; padding: 34px;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--white); color: var(--ink); box-shadow: var(--soft-shadow);
}
.invoice-line { height: 8px; margin: -34px -34px 28px; border-radius: 18px 18px 0 0; background: var(--red); }
.invoice-head {
  display: flex; justify-content: space-between; gap: 24px; align-items: flex-start;
  padding-bottom: 24px; border-bottom: 1px solid var(--line);
}
.invoice-brand { display: flex; gap: 16px; align-items: center; }
.invoice-logo { width: 98px; height: 98px; display: grid; place-items: center; }
.invoice-logo img { width: 72px; height: auto; object-fit: contain; }
.invoice-title { margin: 0; color: var(--ink); font-size: 2rem; font-weight: 870; }
.invoice-meta { display: grid; gap: 6px; color: var(--muted); text-align: right; font-weight: 650; }
.invoice-meta strong { color: var(--red); font-family: Poppins, Inter, sans-serif; font-size: 1.1rem; }
.invoice-blocks { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin: 24px 0; }
.invoice-box { min-height: 126px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--red-pale); color: var(--muted); line-height: 1.55; font-weight: 600; }
.invoice-box h4 { margin: 0 0 8px; color: var(--red); font-size: 0.78rem; font-weight: 850; letter-spacing: 0.05em; text-transform: uppercase; }
.invoice-box strong { color: var(--ink); }
.invoice-paper table { min-width: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.invoice-paper th { position: static; }
.invoice-paper td { padding: 14px 16px; }
.invoice-total { max-width: 360px; display: grid; gap: 10px; margin: 26px 0 0 auto; }
.total-line { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-weight: 700; }
.total-line strong { color: var(--ink); font-family: Poppins, Inter, sans-serif; }
.total-line.grand {
  margin-top: 6px; padding: 14px 16px; border-radius: 16px;
  background: var(--red-soft); color: var(--red);
}
.total-line.grand strong { color: var(--red); font-size: 1.42rem; }
.invoice-side { display: grid; gap: 14px; }
.side-note {
  padding: 18px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--red-pale); color: var(--muted); line-height: 1.55; font-weight: 600;
}
.side-note strong { display: block; margin-bottom: 6px; color: var(--ink); font-family: Poppins, Inter, sans-serif; }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
  background: rgba(26,10,10,0.38); backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 190ms ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(100%, 780px); max-height: min(92svh,820px);
  overflow: auto; border-radius: 24px;
  border: 1px solid var(--line); background: var(--white);
  box-shadow: 0 28px 80px rgba(26,10,10,0.22);
  transform: translateY(12px) scale(0.985); transition: transform 210ms ease;
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal.invoice-modal { width: min(100%,920px); background: var(--warm); }
.modal-head, .modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 20px 22px;
  border-bottom: 1px solid var(--line); background: var(--red-pale);
}
.modal-footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; background: var(--white); }
.modal-footer [hidden] { display: none !important; }
.modal-footer:has([data-save-movement]:not([hidden])) {
  flex-wrap: wrap;
  align-items: stretch;
}
.modal-footer [data-save-movement]:not([hidden]) {
  flex: 1 0 100%;
  width: 100%;
}
.modal-title { margin: 0; color: var(--ink); font-size: 1.3rem; font-weight: 850; }
.icon-button {
  width: 42px; height: 42px; display: grid; place-items: center;
  flex: 0 0 auto; border-radius: 50%;
  border: 1px solid var(--line); background: var(--white); color: var(--red);
  transition: background 170ms ease, transform 170ms ease;
}
.icon-button:hover { background: var(--red-soft); transform: translateY(-1px); }
.modal-body { padding: 22px; }

.stepper { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.step-dot {
  min-height: 42px; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 14px;
  background: var(--red-pale); color: var(--muted);
  border: 1px solid var(--line); font-size: 0.82rem; font-weight: 800;
}
.step-dot span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--white); color: var(--red); }
.step-dot.active { background: var(--red); color: var(--white); border-color: var(--red); }
.step-dot.active span { color: var(--red); }

.movement-step { display: none; }
.movement-step.active { display: block; animation: fadeIn 180ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.movement-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.movement-option {
  min-height: 92px; display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--white); color: var(--ink); text-align: left;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.movement-option:hover, .movement-option.active {
  background: var(--red-pale); border-color: rgba(200,16,46,0.4); transform: translateY(-1px);
}
.movement-option span { display: block; color: var(--muted); margin-top: 4px; font-size: 0.86rem; line-height: 1.35; font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--ink); font-size: 0.84rem; font-weight: 800; }

.summary-box, .confirmation-box {
  padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--red-pale);
}
.summary-list { display: grid; gap: 10px; margin-top: 12px; }
.summary-list div { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-weight: 650; }
.summary-list strong { color: var(--ink); text-align: right; }
.confirmation-box { display: none; margin-top: 16px; background: var(--red-soft); color: var(--red-dark); font-family: Poppins, Inter, sans-serif; font-weight: 760; line-height: 1.45; }
.confirmation-box.show { display: block; animation: fadeIn 180ms ease; }

/* ── TOAST ── */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 110;
  max-width: 360px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--white); color: var(--ink); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity 190ms ease, transform 190ms ease; font-weight: 700;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── RESPONSIVE ── */
@media (max-width: 1180px) {
  :root { --sidebar: 252px; }
  .hero { grid-template-columns: 1fr; }
  .hero-visual { max-width: 620px; }
  .kpi-grid, .alert-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .products-grid, .store-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .charts-grid, .import-card, .invoice-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body { background: var(--warm); }
  .app { display: block; }
  .sidebar { position: relative; height: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 14px; }
  .brand-logo { width: 110px; min-height: 100px; }
  .brand-title { max-width: 260px; }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 4px; }
  .nav-link { min-width: max-content; transform: none; }
  .sidebar-note { display: none; }
  .main { padding: 0 14px 36px; }
  .announcement { margin: 0 -14px 16px; text-align: center; }
  .hero { min-height: auto; padding: 22px; border-radius: 22px; }
  .hero::before { inset: 10px; border-radius: 18px; }
  .hero-logo-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .hero-logo { width: 90px; height: 90px; }
  h1 { font-size: clamp(2.2rem,12vw,4rem); }
  .product-stage { min-height: 300px; }
  .hero-mini-grid, .finance-grid, .loss-panel { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .products-grid, .kpi-grid, .alert-grid { grid-template-columns: 1fr; }
  .store-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .product-card { grid-template-rows: 220px auto; min-height: auto; }
  .store-metrics { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .bar-row, .rotation-row { grid-template-columns: 92px minmax(0,1fr) 44px; font-size: 0.84rem; }
  .filter-bar { align-items: stretch; }
  .filter-group, .input, .select { width: 100%; }
  .table-wrap { overflow: visible; padding: 12px; }
  table, thead, tbody, tr, th, td { display: block; }
  table { min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--white); }
  td { display: grid; grid-template-columns: 118px minmax(0,1fr); gap: 12px; padding: 13px 14px; }
  td::before { content: attr(data-label); color: var(--red); font-size: 0.74rem; font-weight: 850; letter-spacing: 0.04em; text-transform: uppercase; }
  .invoice-paper { min-height: auto; padding: 20px; border-radius: 16px; }
  .invoice-line { margin: -20px -20px 20px; }
  .invoice-head, .invoice-brand, .invoice-blocks { display: grid; grid-template-columns: 1fr; }
  .invoice-meta { text-align: left; }
  .invoice-paper table { border: 0; }
  .modal-backdrop { padding: 10px; }
  .modal-head, .modal-footer { padding: 16px; }
  .modal-body { padding: 16px; }
  .movement-options, .form-grid, .stepper { grid-template-columns: 1fr; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .button { flex: 1 1 auto; }
}
@media (max-width: 620px) {
  .store-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .brand { align-items: flex-start; }
  .brand-logo { width: 92px; min-height: 86px; }
  .brand-title { font-size: 0.9rem; }
  .actions .button { width: 100%; }
  .hero { padding: 18px; }
  .product-stage { min-height: 250px; }
  .portfolio-grid { grid-template-columns: repeat(3, 180px); }
  .store-metrics { grid-template-columns: 1fr; }
  td { grid-template-columns: 1fr; gap: 6px; }
  .toast { left: 14px; right: 14px; bottom: 14px; }
}
@media (max-width: 600px) {
  html, body { max-width: 100%; overflow-x: clip; }
  .app { width: 100%; overflow-x: clip; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    padding: max(6px, env(safe-area-inset-top)) 14px 6px;
    gap: 8px;
    background: rgba(253, 252, 252, 0.86);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(232, 216, 218, 0.3);
    box-shadow: none;
    transition: background 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
  }
  .sidebar.is-scrolled {
    background: rgba(253, 252, 252, 0.97);
    border-bottom-color: rgba(232, 216, 218, 0.9);
    box-shadow: 0 1px 14px rgba(26, 10, 10, 0.06);
  }
  .brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 0;
    border-bottom: 0;
  }
  .brand-logo {
    width: 58px;
    min-height: 54px;
    padding: 0;
  }
  .brand-logo img {
    width: 54px;
  }
  .brand > div {
    display: none;
  }
  .mobile-menu-toggle {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--red);
    box-shadow: var(--soft-shadow);
  }
  .mobile-menu-toggle svg {
    width: 21px;
    height: 21px;
    stroke-width: 2.2;
  }
  .nav {
    display: none;
    grid-auto-flow: row;
    grid-auto-columns: initial;
    grid-template-columns: 1fr;
    gap: 6px;
    overflow-x: visible;
    padding: 8px 0 0;
  }
  .nav.mobile-open {
    display: grid;
  }
  .nav:not(.mobile-open) ~ .reset-demo-button {
    display: none;
  }
  .nav.mobile-open ~ .reset-demo-button {
    display: inline-flex;
  }
  .nav-link {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    justify-content: flex-start;
    padding: 9px 10px;
    transform: none;
    white-space: normal;
  }
  .main {
    width: 100%;
    padding: 0 10px 32px;
    overflow-x: clip;
  }
  .announcement {
    min-height: 30px;
    margin: 0 -10px 6px;
    padding: 7px 10px;
    gap: 6px;
    font-size: 0.7rem;
    line-height: 1;
    letter-spacing: 0.035em;
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
  }
  .announcement svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
  }
  .announcement-desktop { display: none; }
  .announcement-mobile { display: inline; min-width: 0; }
  .hero {
    width: 100%;
    gap: 14px;
    padding: 16px;
    margin-bottom: 18px;
    border-radius: 20px;
  }
  .hero::before {
    inset: 8px;
    border-radius: 16px;
  }
  .hero-logo-row {
    margin-bottom: 12px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .hero-logo {
    display: none;
  }
  .brand-pill {
    max-width: 100%;
    padding: 7px 10px;
    font-size: 0.68rem;
    line-height: 1.15;
    letter-spacing: 0.035em;
  }
  h1 {
    max-width: 100%;
    max-inline-size: 100%;
    font-size: clamp(1.56rem, 7.6vw, 2.06rem);
    line-height: 1;
    letter-spacing: -0.035em;
    text-wrap: balance;
    overflow-wrap: normal;
    word-break: normal;
  }
  .hero-description {
    margin: 14px 0 18px;
    font-size: 0.94rem;
    line-height: 1.5;
  }
  .actions {
    gap: 8px;
  }
  .actions .button {
    width: 100%;
    min-height: 44px;
    padding: 11px 14px;
  }
  .actions .button.secondary {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.88rem;
    box-shadow: none;
  }
  .hero-visual {
    gap: 10px;
  }
  .product-stage {
    min-height: 300px;
    padding: 18px 12px 24px;
    border-radius: 20px;
  }
  .stage-logo {
    display: none;
  }
  .hero-product-image {
    --image-scale: 1 !important;
    --image-x: 0 !important;
    --image-y: 0 !important;
  }
  .hero-product-image img {
    object-fit: contain;
    object-position: center;
  }
  .bag-product.primary {
    width: 44%;
    height: 70%;
    right: 28%;
    bottom: 44px;
  }
  .bag-product.left,
  .bag-product.right {
    width: 31%;
    height: 52%;
    bottom: 76px;
  }
  .bag-product.left { left: 7%; }
  .bag-product.right { right: 7%; }
  .bag-tag {
    padding: 5px 9px;
    font-size: 0.68rem;
  }
  .category-card {
    grid-template-rows: 178px 1fr;
  }
  .category-art {
    min-height: 178px;
    padding: 18px 16px;
  }
  .category-card .presentation-image {
    width: min(100%, 178px);
    height: 148px;
    --image-scale: 1 !important;
    --image-x: 0 !important;
    --image-y: 0 !important;
  }
  .category-card .presentation-image img {
    object-fit: contain;
    object-position: center;
  }
  .product-card {
    grid-template-rows: minmax(280px, auto) auto;
  }
  .product-card .product-media {
    min-height: 280px;
    height: auto;
    padding: 22px 16px;
    display: grid;
    place-items: center;
    overflow: hidden;
  }
  .product-card .stock-product-image {
    width: min(100%, 232px);
    height: 242px;
    --image-scale: 1 !important;
    --image-x: 0 !important;
    --image-y: 0 !important;
  }
  .product-card .stock-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
  }
  .hero-mini-grid {
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 8px;
  }
  .mini-stat {
    min-width: 0;
    overflow: hidden;
    min-height: 74px;
    padding: 10px 8px;
    border-radius: 14px;
    font-size: 0.68rem;
    line-height: 1.18;
  }
  .mini-stat strong {
    margin-top: 5px;
    font-size: 0.86rem;
    line-height: 1.08;
  }
  .mini-stat span,
  .mini-stat strong {
    max-width: 100%;
    overflow-wrap: normal;
    word-break: normal;
  }
  .mini-stat span { font-size: 0.6rem; line-height: 1.1; }
  .portfolio-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) and (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
@page { size: letter; margin: 0.45in; }
@media print {
  body.printing-invoice {
    background: #fff !important;
  }
  body.printing-invoice * {
    visibility: hidden !important;
    box-shadow: none !important;
  }
  body.printing-invoice .invoice-paper:not(.print-active) {
    display: none !important;
  }
  body.printing-invoice .modal-backdrop {
    position: static !important;
    display: contents !important;
    background: transparent !important;
    padding: 0 !important;
  }
  body.printing-invoice .modal,
  body.printing-invoice .modal-body {
    display: contents !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
  body.printing-invoice .modal-head,
  body.printing-invoice .modal-footer,
  body.printing-invoice .sidebar,
  body.printing-invoice .announcement,
  body.printing-invoice .invoice-side,
  body.printing-invoice button {
    display: none !important;
  }
  body.printing-invoice .invoice-paper.print-active,
  body.printing-invoice .invoice-paper.print-active * {
    visibility: visible !important;
  }
  body.printing-invoice .invoice-paper.print-active {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff !important;
  }
  body.printing-invoice .invoice-paper.print-active table,
  body.printing-invoice .invoice-paper.print-active tr,
  body.printing-invoice .invoice-paper.print-active .invoice-total,
  body.printing-invoice .invoice-paper.print-active .invoice-blocks {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  /* Evita páginas en blanco en móvil: el documento completo mide ~15000px
     porque todas las secciones están apiladas en el DOM. Colapsarlas con
     display:none las saca del flujo; visibility:hidden las oculta visualmente
     pero NO las colapsa. Solo aplica al path de impresión desde la sección
     #invoice; el modal ya vive fuera de .main. */
  body.printing-invoice .app { min-height: 0 !important; }
  body.printing-invoice .main > :not(#invoice) { display: none !important; }
}
