/* ══════════════════════════════════════
   Control de Inventario — estilos
   ══════════════════════════════════════ */

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

:root {
  --acc:    #e94560;
  --acc3:   #27ae60;
  --bg:     #ffffff;
  --bgs:    #f5f4f0;
  --bgt:    #eeede9;
  --brd:    rgba(0,0,0,0.10);
  --brd2:   rgba(0,0,0,0.18);
  --txt:    #1a1a18;
  --txts:   #6b6a64;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}


body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--txt);
  background: #ffffff;
  min-height: 100vh;
}

/* ── Brand / Logo ── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--txt);
}

/* ── Layout ── */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--brd2);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar h1 span { color: var(--acc); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.tab {
  padding: 6px 16px;
  font-size: 13px;
  border: 1px solid var(--brd2);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--txts);
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover  { background: var(--bgs); color: var(--txt); }
.tab.active {
  background: var(--bg);
  color: var(--txt);
  font-weight: 600;
  border-bottom: 2px solid var(--acc);
}

.main {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Sections ── */
.section { display: none; flex-direction: column; gap: 16px; }
.section.active { display: flex; }

/* ── Card ── */
.card {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--brd);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bgs);
}
.card-body { padding: 16px; overflow-x: auto; }

/* ── Formularios ── */
.row   { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.col   { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 110px; }

label {
  font-size: 11px;
  color: var(--txts);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

input, select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--brd2);
  border-radius: 7px;
  background: var(--bg);
  color: var(--txt);
  font-size: 13px;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--acc); }

/* ── Botones ── */
.btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--brd2);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  background: transparent;
  color: var(--txt);
}
.btn:hover  { background: var(--bgs); }
.btn:active { transform: scale(.98); }
.btn.primary       { background: var(--acc);  color: #fff; border-color: var(--acc); }
.btn.primary:hover { background: #c73550; }
.btn.success       { background: var(--acc3); color: #fff; border-color: var(--acc3); }
.btn.success:hover { background: #1e9651; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* ── Tablas ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--txts);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--brd2);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--brd); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bgs); }
.empty { text-align: center; padding: 32px; color: var(--txts); }

/* ── Métricas ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; }
.metric-card {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.metric-label { font-size: 11px; color: var(--txts); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.metric-val   { font-size: 22px; font-weight: 600; }
.metric-sub   { font-size: 11px; color: var(--txts); }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge.compra { background: #dbeafe; color: #1e40af; }
.badge.venta  { background: #fee2e2; color: #991b1b; }

/* ── Method tabs ── */
.method-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.method-tab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--brd2);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--txts);
  transition: all .15s;
}
.method-tab:hover  { background: var(--bgs); color: var(--txt); }
.method-tab.active { background: var(--acc); color: #fff; border-color: var(--acc); }

/* ── Colores semánticos ── */
.val-pos  { color: #16a34a; }
.val-neg  { color: #dc2626; }
.val-warn { color: #d97706; }
.strong   { font-weight: 600; }

/* ── Alertas ── */
.alert { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 10px; }
.alert.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert.error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert.info    { background: var(--bgs); border: 1px solid var(--brd2); color: var(--txts); }

/* ── Upload / Drop zone ── */
.upload-area {
  border: 2px dashed var(--brd2);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--txts);
}
.upload-area:hover { border-color: var(--acc); background: var(--bgs); }

/* ── Charts ── */
.chart-wrap { position: relative; width: 100%; height: 280px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 680px) { .charts-grid { grid-template-columns: 1fr; } }

/* ── Misc ── */
.select-row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.separator    { height: 1px; background: var(--brd); margin: 8px 0; }
.detail-grid  { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 14px; }
.loading-box  { text-align: center; padding: 32px; color: var(--txts); }

/* ── Pantalla de Login ── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bgs);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  min-width: 380px;
}
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--txt); text-align: center; }
.login-subtitle { font-size: 14px; color: var(--txts); text-align: center; margin-top: 4px; }
.login-names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.login-name-btn {
  padding: 16px 12px;
  border: 2px solid var(--brd2);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
  color: var(--txt);
  cursor: pointer;
  transition: all .18s;
  text-align: center;
}
.login-name-btn:hover {
  border-color: var(--acc);
  background: #fff5f7;
  color: var(--acc);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(233,69,96,0.12);
}

/* ── Pantalla de Bienvenida (Home) ── */
#home-screen {
  display: none;
  min-height: 100vh;
  background: var(--bgs);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.home-header {
  text-align: center;
  margin-bottom: 48px;
}
.home-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px; }
.home-welcome {
  font-size: 28px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 8px;
}
.home-welcome span { color: var(--acc); }
.home-question { font-size: 16px; color: var(--txts); }
.home-modules {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 680px;
  width: 100%;
}
@media (max-width: 640px) {
  .home-modules { grid-template-columns: 1fr; }
}
.module-card {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 14px;
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: var(--shadow);
  text-align: center;
}
.module-card:hover {
  border-color: var(--acc);
  box-shadow: 0 6px 24px rgba(233,69,96,0.13);
  transform: translateY(-3px);
}
.module-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.module-card.disabled:hover {
  transform: none;
  border-color: var(--brd);
  box-shadow: var(--shadow);
}
.module-icon { font-size: 40px; line-height: 1; }
.module-name { font-size: 17px; font-weight: 700; color: var(--txt); }
.module-desc { font-size: 12px; color: var(--txts); }
.module-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--txts);
  background: var(--bgt);
  border-radius: 4px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ══════════════════════════════════════
   Pivot Builder
   ══════════════════════════════════════ */

.pb-layout {
  display: grid;
  grid-template-columns: 200px 1fr 220px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .pb-layout { grid-template-columns: 1fr; }
}

/* Panel de campos */
.pb-panel {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pb-panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--txts);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--brd);
  margin-bottom: 2px;
}

/* Chips */
.pb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  border: 1px solid var(--brd2);
  background: var(--bgs);
  color: var(--txt);
  transition: all .12s;
  white-space: nowrap;
}
.pb-chip:hover       { border-color: var(--acc); background: #fff5f7; color: var(--acc); }
.pb-chip.dragging    { opacity: .45; cursor: grabbing; }
.pb-chip.metric      { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.pb-chip.metric:hover{ background: #dbeafe; border-color: #93c5fd; }

/* Chips dentro de zonas */
.pb-zone-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--acc);
  color: #fff;
  border: 1px solid var(--acc);
  white-space: nowrap;
}
.pb-zone-chip.metric { background: #1d4ed8; border-color: #1d4ed8; }
.pb-zone-chip button {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 0 0 2px;
}
.pb-zone-chip button:hover { color: #fff; }

/* Zona central de construcción */
.pb-builder { display: flex; flex-direction: column; gap: 10px; }

.pb-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) { .pb-zones { grid-template-columns: 1fr; } }

.pb-zone {
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.pb-zone-header {
  padding: 8px 12px;
  background: var(--bgs);
  border-bottom: 1px solid var(--brd);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--txts);
}
.pb-zone-drop {
  min-height: 52px;
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  transition: background .1s;
}
.pb-zone-drop.over      { background: #fff5f7; outline: 2px dashed var(--acc); outline-offset: -3px; border-radius: 0 0 10px 10px; }
.pb-zone-placeholder    { font-size: 11px; color: var(--txts); font-style: italic; pointer-events: none; }

/* Filtro chip con input */
.pb-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--acc);
  font-size: 12px;
}
.pb-filter-chip .label {
  background: var(--acc);
  color: #fff;
  padding: 4px 8px;
  font-weight: 500;
  white-space: nowrap;
}
.pb-filter-chip select {
  height: 28px;
  border: none;
  border-radius: 0;
  border-left: 1px solid rgba(233,69,96,.4);
  font-size: 12px;
  min-width: 90px;
  max-width: 140px;
  padding: 0 6px;
}
.pb-filter-chip .rm {
  background: none;
  border: none;
  border-left: 1px solid rgba(233,69,96,.4);
  color: var(--acc);
  cursor: pointer;
  padding: 0 6px;
  font-size: 14px;
}
.pb-filter-chip .rm:hover { background: #fef2f2; }

/* Fecha row */
.pb-dates {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--brd);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.pb-dates .col { min-width: 130px; max-width: 160px; }

/* Acciones */
.pb-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Panel guardados */
.pb-saved-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.pb-saved-item {
  background: var(--bgs);
  border: 1px solid var(--brd);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .12s;
}
.pb-saved-item:hover { border-color: var(--acc); background: #fff5f7; }
.pb-saved-item .name { font-weight: 600; color: var(--txt); flex: 1; }
.pb-saved-item .date { font-size: 10px; color: var(--txts); }
.pb-saved-item .del  { background: none; border: none; color: var(--txts); cursor: pointer; font-size: 14px; padding: 0 2px; }
.pb-saved-item .del:hover { color: var(--acc); }

/* Resultado pivot */
.pb-result { margin-top: 4px; }
.pivot-tbl-wrap { overflow-x: auto; }
.pivot-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.pivot-tbl th {
  padding: 7px 10px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  color: var(--txts);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--brd2);
  white-space: nowrap;
  background: var(--bgs);
}
.pivot-tbl th.row-hdr { text-align: left; }
.pivot-tbl th.col-grp { text-align: center; border-left: 2px solid var(--brd2); }
.pivot-tbl td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--brd);
  text-align: right;
  white-space: nowrap;
}
.pivot-tbl td.row-key { text-align: left; font-weight: 600; color: var(--txt); }
.pivot-tbl td.total   { font-weight: 700; background: var(--bgs); }
.pivot-tbl tr:last-child td { border-bottom: none; }
.pivot-tbl tr:hover td { background: var(--bgs); }
.pivot-tbl tr.total-row td { font-weight: 700; border-top: 2px solid var(--brd2); background: var(--bgt); }
.pivot-tbl td.neg { color: #dc2626; }

/* ── Usuario en topbar ── */
.topbar-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 13px;
  color: var(--txts);
}
.topbar-user-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-user strong { color: var(--txt); }
.topbar-user button {
  font-size: 11px;
  color: var(--txts);
  background: none;
  border: 1px solid var(--brd2);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
}
.topbar-user button:hover { background: var(--bgs); color: var(--acc); border-color: var(--acc); }
.topbar-datetime {
  font-size: 11px;
  color: var(--txts);
  text-align: right;
}
