/* ═══════════════════════════════════════════════════════
   BasesAnalysis — CSS
   Estética: Dark Industrial Utility — precisa, densa, funcional
   Fuente: IBM Plex Mono + DM Sans
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── Variables ── */
:root {
  --pri:        #7C3AED;
  --pri-l:      #A78BFA;
  --pri-d:      #5B21B6;
  --pri-bg:     #1E0A3C;
  --pri-sub:    rgba(124,58,237,.12);

  --bg:         #0F0D17;
  --bg2:        #16121F;
  --bg3:        #1E1A2E;
  --bg4:        #252035;

  --card:       #1A1628;
  --card-b:     rgba(124,58,237,.18);

  --text:       #EDE9F5;
  --text-2:     #A89EC8;
  --text-3:     #6B5E8C;

  --border:     rgba(124,58,237,.2);
  --border-2:   rgba(255,255,255,.06);

  --green:      #10B981;
  --amber:      #F59E0B;
  --red:        #EF4444;
  --cyan:       #06B6D4;

  --mono:       'IBM Plex Mono', monospace;
  --sans:       'DM Sans', system-ui, sans-serif;

  --r:          10px;
  --r-sm:       6px;
  --sidebar-w:  256px;
  --topbar-h:   54px;
  --shadow:     0 4px 24px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════
   LAYOUT
══════════════════════════════════════ */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 32px; height: 32px;
  background: var(--pri);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; }
.logo-text {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -.3px;
  color: var(--text);
}

.sidebar-body { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  margin-bottom: 6px;
}
.nav-loading { color: var(--text-3); font-size: 12px; padding: 8px; display: flex; align-items: center; gap: 8px; }

/* Nav items */
.nav-base { border-radius: var(--r-sm); margin-bottom: 1px; }
.nav-base-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; cursor: pointer; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
  transition: all .15s; gap: 6px;
}
.nav-base-hdr:hover { background: var(--bg3); color: var(--text); }
.nav-base-hdr.active { background: var(--pri-sub); color: var(--pri-l); }
.nav-base-icon { font-size: 14px; flex-shrink: 0; }
.nav-base-name { flex: 1; line-height: 1.3; }
.nav-base-tipo {
  font-family: var(--mono); font-size: 8px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0;
}
.tipo-pilotos    { background: rgba(124,58,237,.25); color: var(--pri-l); }
.tipo-sobrecargo { background: rgba(16,185,129,.15); color: #34D399; }
.tipo-uniforme   { background: rgba(245,158,11,.15); color: #FCD34D; }
.nav-chevron { color: var(--text-3); font-size: 10px; transition: transform .2s; flex-shrink: 0; }
.nav-base-hdr.open .nav-chevron { transform: rotate(90deg); }

.nav-sub { display: none; padding: 2px 0 4px 22px; }
.nav-sub.open { display: block; }
.nav-sub-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12px; color: var(--text-3); transition: all .15s;
}
.nav-sub-item:hover { background: var(--bg3); color: var(--text-2); }
.nav-sub-item.active { background: var(--pri-sub); color: var(--pri-l); font-weight: 600; }
.nav-sub-del {
  margin-left: auto; width: 18px; height: 18px; border-radius: 4px;
  background: none; border: none; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  opacity: 0; transition: opacity .15s;
}
.nav-sub-item:hover .nav-sub-del { opacity: 1; }
.nav-sub-del:hover { background: rgba(239,68,68,.2); color: var(--red); }

.nav-upload-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; background: none;
  border: 1px dashed rgba(124,58,237,.35); color: var(--text-2);
  border-radius: var(--r-sm); cursor: pointer; font-size: 12.5px;
  font-family: var(--sans); transition: all .15s; margin-top: 4px;
}
.nav-upload-btn:hover { background: var(--pri-sub); color: var(--pri-l); border-color: var(--pri); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-2);
  font-size: 11.5px;
  color: var(--text-3);
  flex-shrink: 0;
}
.sidebar-footer strong { color: var(--text-2); }

/* ── Main ── */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--bg2); border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.breadcrumb { font-family: var(--mono); font-size: 11px; color: var(--text-3); letter-spacing: .5px; }
.breadcrumb .bc-cur { color: var(--pri-l); font-weight: 600; }

.btn-pdf {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; background: var(--pri); color: #fff;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  font-size: 12px; font-weight: 600; font-family: var(--sans);
  transition: background .15s;
}
.btn-pdf:hover { background: var(--pri-d); }

.page-body { flex: 1; overflow-y: auto; padding: 24px; }
.page-body::-webkit-scrollbar { width: 4px; }
.page-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══════════════════════════════════════
   WELCOME
══════════════════════════════════════ */
.welcome-wrap { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.welcome-inner { max-width: 560px; text-align: center; }
.welcome-icon-wrap { display: flex; justify-content: center; margin-bottom: 24px; }
.welcome-inner h1 { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.welcome-inner h1 span { color: var(--pri-l); }
.welcome-inner p { color: var(--text-2); font-size: 14px; line-height: 1.7; margin-bottom: 24px; }
.btn-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; background: var(--pri); color: #fff;
  border: none; border-radius: var(--r); cursor: pointer; font-size: 14px;
  font-weight: 700; font-family: var(--sans); transition: all .2s;
  margin-bottom: 24px;
}
.btn-cta:hover { background: var(--pri-d); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,58,237,.4); }
.feature-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.feature-chips span {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text-2); font-size: 11.5px; padding: 5px 10px; border-radius: 20px;
}

/* ══════════════════════════════════════
   BASE VIEW
══════════════════════════════════════ */
.base-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.base-hdr-title h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.base-hdr-title .file-name {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3); margin-top: 3px;
}
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-left: 8px;
}
.badge-pilotos    { background: rgba(124,58,237,.25); color: var(--pri-l); }
.badge-sobrecargo { background: rgba(16,185,129,.15); color: #34D399; }
.badge-uniforme   { background: rgba(245,158,11,.15); color: #FCD34D; }

/* Gender tabs */
.gen-tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--r-sm); padding: 4px; width: fit-content; margin-bottom: 20px; }
.gen-tab {
  padding: 7px 18px; border-radius: 5px; border: none; background: none;
  color: var(--text-3); font-size: 12.5px; font-weight: 500; cursor: pointer;
  font-family: var(--sans); transition: all .15s;
}
.gen-tab.active { background: var(--pri); color: #fff; font-weight: 700; }
.gen-tab:not(.active):hover { background: var(--bg4); color: var(--text); }

/* Stat cards */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--card-b);
  border-radius: var(--r); padding: 14px 16px;
}
.stat-lbl { font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--pri-l); line-height: 1; }
.stat-sub { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }

/* Section header */
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 12px; }
.sec-title {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
}
.sec-title::before { content: ''; display: block; width: 3px; height: 14px; background: var(--pri); border-radius: 2px; }

/* Insights row */
.insights-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.insight-card { background: var(--card); border: 1px solid var(--card-b); border-radius: var(--r); padding: 14px; }
.ins-title { font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--pri-l); margin-bottom: 10px; }
.ins-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ins-table td { padding: 5px 0; border-bottom: 1px solid var(--border-2); color: var(--text-2); }
.ins-table tr:last-child td { border-bottom: none; }
.ins-table .ins-val { text-align: right; font-weight: 700; color: var(--pri-l); font-family: var(--mono); }

/* Concentrado grid */
.conc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.prenda-card {
  background: var(--card); border: 1px solid var(--card-b);
  border-radius: var(--r); overflow: hidden;
}
.prenda-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border-2);
  background: linear-gradient(135deg, var(--bg3) 0%, rgba(124,58,237,.1) 100%);
}
.p-name { font-weight: 700; font-size: 13px; color: var(--text); }
.p-total {
  background: var(--pri); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.unitalla-tag {
  background: rgba(245,158,11,.2); color: #FCD34D;
  font-size: 9px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; margin-left: 6px; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: .5px;
}
.talla-table { width: 100%; border-collapse: collapse; }
.talla-table thead th {
  padding: 7px 14px;
  text-align: left;
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--text-3);
  border-bottom: 1px solid var(--border-2); background: var(--bg2);
}
.talla-table thead th:last-child { text-align: right; }
.talla-table tbody td { padding: 7px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border-2); }
.talla-table tbody tr:last-child td { border-bottom: none; }
.talla-table tbody tr:hover td { background: rgba(124,58,237,.06); }
.td-talla { font-family: var(--mono); font-weight: 600; color: var(--text); font-size: 12px; }
.td-bar { width: 100%; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-bg { flex: 1; height: 5px; background: rgba(124,58,237,.15); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--pri); border-radius: 3px; transition: width .4s ease; }
.bar-qty { font-family: var(--mono); font-weight: 700; color: var(--pri-l); font-size: 12px; min-width: 20px; text-align: right; }
.td-pct { text-align: right; font-family: var(--mono); font-size: 10px; color: var(--text-3); }

/* Detail table */
.detail-wrap { overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--r); }
.detail-table { width: 100%; border-collapse: collapse; font-size: 11.5px; white-space: nowrap; }
.detail-table thead th {
  padding: 9px 12px; text-align: left; background: var(--bg2);
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--text-3);
  border-bottom: 1px solid var(--border-2);
}
.detail-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border-2); color: var(--text-2); }
.detail-table tbody tr:last-child td { border-bottom: none; }
.detail-table tbody tr:hover td { background: rgba(124,58,237,.04); color: var(--text); }

/* Warnings */
.warning-box {
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--r-sm); padding: 10px 14px;
  font-size: 12px; color: #FCD34D; margin-bottom: 16px; display: flex; gap: 8px;
}

/* ══════════════════════════════════════
   UPLOAD MODAL
══════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; width: 460px; max-width: 95vw;
  box-shadow: var(--shadow);
}
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border-2);
}
.modal-hdr h3 { font-weight: 700; font-size: 15px; color: var(--text); }
.modal-x {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  width: 28px; height: 28px; border-radius: 6px; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.modal-x:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 22px; }

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r); padding: 36px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--pri); background: var(--pri-sub); }
.uz-icon { display: flex; justify-content: center; margin-bottom: 12px; }
.uz-text { font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
.uz-hint { font-size: 12px; color: var(--text-3); }

.upload-progress { margin-top: 16px; }
.progress-bar { height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: var(--pri); border-radius: 4px; width: 0; transition: width .3s; }
#progressMsg { font-size: 12px; color: var(--text-2); font-family: var(--mono); }

#uploadResult .ok-msg   { color: var(--green); font-size: 13px; margin-top: 12px; display: flex; align-items: center; gap: 8px; }
#uploadResult .err-msg  { color: var(--red);   font-size: 13px; margin-top: 12px; display: flex; align-items: center; gap: 8px; }
#uploadResult .warn-msg { color: var(--amber);  font-size: 12px; margin-top: 8px; }

/* ══════════════════════════════════════
   SPINNERS & MISC
══════════════════════════════════════ */
.spinner-sm {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--pri);
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--pri);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); font-size: 13px; }
.empty-state svg { opacity: .3; margin-bottom: 12px; }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width:768px) {
  :root { --sidebar-w: 220px; }
  .conc-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
}
@media (max-width:540px) {
  .sidebar { display: none; }
  .page-body { padding: 16px; }
}
