/* ==========================================================================
   Prodesco · Plataforma de gestión — sistema visual
   Tema claro (por defecto) y oscuro. Para activar el oscuro:
   <html data-theme="dark">  (o cualquier contenedor con ese atributo)
   Todas las variables llevan prefijo --pd- para no chocar con otros estilos.
   ========================================================================== */


/* ---------- Tokens: tema claro ---------- */
:root,
[data-theme="light"] {
  --pd-bg: #ffffff;          /* fondo base: siempre blanco en claro */
  --pd-card: #ffffff;
  --pd-soft: #f5f8fd;        /* rellenos suaves (buscador) */
  --pd-line: #e3e9f3;
  --pd-ink: #14284b;         /* texto principal (azul marino, no negro) */
  --pd-muted: #5a6b88;       /* texto secundario, 5.4:1 sobre blanco */

  --pd-gold: #b8860b;        /* referencia sutil al logo: marca, detalles */
  --pd-gold-bar: #d4a017;
  --pd-gold-soft: #fbf3dc;
  --pd-gold-ink: #7a5800;    /* texto sobre gold-soft */

  --pd-blue: #2457d6;        /* acción principal y gráficos */
  --pd-on-blue: #ffffff;
  --pd-blue-soft: #e8effe;
  --pd-blue-ink: #1b45b0;
  --pd-bar-dim: #bfd1f8;

  --pd-teal: #0f9f8f;        /* éxito / entregado */
  --pd-teal-soft: #e2f6f3;
  --pd-teal-ink: #0b7064;

  --pd-coral: #e5533d;       /* alerta / incidencia */
  --pd-coral-soft: #fdebe7;
  --pd-coral-ink: #b83420;

  --pd-shadow: 0 1px 2px rgba(20, 40, 75, 0.05), 0 8px 24px rgba(20, 40, 75, 0.06);
}

/* ---------- Tokens: tema oscuro ---------- */
[data-theme="dark"] {
  --pd-bg: #0a101d;
  --pd-card: #121b2e;
  --pd-soft: #172238;
  --pd-line: #25314a;
  --pd-ink: #eef2fa;
  --pd-muted: #9cabc6;

  --pd-gold: #e3b53e;
  --pd-gold-bar: #e3b53e;
  --pd-gold-soft: #2b2411;
  --pd-gold-ink: #f0c95c;

  --pd-blue: #6c9bff;
  --pd-on-blue: #0a101d;
  --pd-blue-soft: #1b2a4d;
  --pd-blue-ink: #9dbbff;
  --pd-bar-dim: #2f4a85;

  --pd-teal: #34d1bf;
  --pd-teal-soft: #12302d;
  --pd-teal-ink: #5fe0cf;

  --pd-coral: #ff7a66;
  --pd-coral-soft: #3a1d1a;
  --pd-coral-ink: #ff9e8f;

  --pd-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- Tipografía y escala ---------- */
:root {
  --pd-font: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pd-font-brand: "Barlow Condensed", "Arial Narrow", sans-serif;
  --pd-radius-lg: 16px;   /* tarjetas */
  --pd-radius-md: 12px;   /* botones, campos, items de menú */
  --pd-radius-pill: 999px;
  --pd-tap: 44px;         /* alto mínimo táctil */
}

/* ---------- Estructura general ---------- */
.pd-app {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  min-height: 100vh;
  box-sizing: border-box;
  background: var(--pd-bg);
  color: var(--pd-ink);
  font-family: var(--pd-font);
  font-size: 14px;
  line-height: 1.45;
}
.pd-app *,
.pd-app *::before,
.pd-app *::after { box-sizing: border-box; }

.pd-sidebar {
  flex: 1 1 248px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  border-right: 1px solid var(--pd-line);
  background: var(--pd-bg);
}
.pd-main {
  flex: 999 1 560px;       /* en móvil el menú pasa arriba */
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 36px 40px;
}

/* ---------- Marca ---------- */
.pd-brand { display: flex; align-items: center; gap: 12px; }
.pd-brand__text { display: flex; flex-direction: column; gap: 4px; }
.pd-brand__name {
  font-family: var(--pd-font-brand);
  font-weight: 600;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.2em;
  color: var(--pd-gold);
}
.pd-brand__sub { font-size: 12px; color: var(--pd-muted); }

/* ---------- Menú ---------- */
.pd-nav { display: flex; flex-direction: column; gap: 4px; }
.pd-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--pd-tap);
  padding: 0 14px;
  border-radius: var(--pd-radius-md);
  color: var(--pd-muted);
  font-weight: 600;
  text-decoration: none;
}
.pd-nav__item:hover { background: var(--pd-soft); color: var(--pd-ink); }
.pd-nav__item--active,
.pd-nav__item--active:hover {
  background: var(--pd-gold-soft);
  color: var(--pd-gold-ink);
  font-weight: 700;
}
.pd-nav__item svg { flex: none; }

.pd-assistant {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: var(--pd-radius-lg);
  background: var(--pd-blue-soft);
}
.pd-assistant__title {
  display: flex; align-items: center; gap: 8px;
  color: var(--pd-blue-ink); font-weight: 800;
}
.pd-assistant p { margin: 0; color: var(--pd-ink); }

/* ---------- Cabecera ---------- */
.pd-topbar {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 16px;
}
.pd-title { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; }
.pd-subtitle { margin: 4px 0 0; color: var(--pd-muted); }
.pd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.pd-search {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; height: var(--pd-tap); padding: 0 14px;
  border: 1px solid var(--pd-line); border-radius: var(--pd-radius-md);
  background: var(--pd-soft); color: var(--pd-muted);
}
.pd-search input {
  width: 100%; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--pd-ink);
}
.pd-search:focus-within { border-color: var(--pd-blue); }

.pd-iconbtn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: var(--pd-tap); height: var(--pd-tap);
  border: 1px solid var(--pd-line); border-radius: var(--pd-radius-md);
  background: var(--pd-card); color: var(--pd-ink); cursor: pointer;
}
.pd-iconbtn__dot {
  position: absolute; top: 10px; right: 11px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--pd-coral); border: 2px solid var(--pd-card);
}
.pd-avatar {
  display: flex; align-items: center; justify-content: center;
  width: var(--pd-tap); height: var(--pd-tap); border-radius: 50%;
  background: var(--pd-gold-soft); color: var(--pd-gold-ink);
  border: 1px solid var(--pd-gold); font-weight: 800;
}

/* ---------- Botones ---------- */
.pd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--pd-tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--pd-radius-md);
  font: inherit; font-weight: 700; cursor: pointer;
}
.pd-btn--primary { background: var(--pd-blue); color: var(--pd-on-blue); }
.pd-btn--primary:hover { filter: brightness(1.06); }
.pd-btn--outline { background: var(--pd-card); color: var(--pd-blue-ink); border-color: var(--pd-blue); }
.pd-btn--block { width: 100%; }
.pd-btn:focus-visible,
.pd-iconbtn:focus-visible,
.pd-nav__item:focus-visible { outline: 2px solid var(--pd-blue); outline-offset: 2px; }

/* ---------- Tarjetas e indicadores ---------- */
.pd-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px;
  background: var(--pd-card); border: 1px solid var(--pd-line);
  border-radius: var(--pd-radius-lg); box-shadow: var(--pd-shadow);
  min-width: 0;
}
.pd-card__title { margin: 0; font-size: 18px; font-weight: 800; }
.pd-card__sub { margin: 2px 0 0; color: var(--pd-muted); }
.pd-card__head {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 8px;
}
.pd-link { color: var(--pd-blue-ink); font-weight: 700; text-decoration: none; }

.pd-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.pd-kpi { padding: 20px; }
.pd-kpi__head { display: flex; align-items: center; gap: 12px; color: var(--pd-muted); font-weight: 600; }
.pd-kpi__icon {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--pd-radius-md);
}
.pd-kpi__value {
  font-size: 30px; line-height: 1.1; font-weight: 800;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}

/* Colores semánticos: úsalos en .pd-kpi__icon y .pd-chip */
.pd-tone-blue  { background: var(--pd-blue-soft);  color: var(--pd-blue-ink); }
.pd-tone-gold  { background: var(--pd-gold-soft);  color: var(--pd-gold-ink); }
.pd-tone-teal  { background: var(--pd-teal-soft);  color: var(--pd-teal-ink); }
.pd-tone-coral { background: var(--pd-coral-soft); color: var(--pd-coral-ink); }

.pd-chip {
  display: inline-block; align-self: flex-start;
  padding: 3px 10px; border-radius: var(--pd-radius-pill);
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}

/* ---------- Gráfico de barras ---------- */
.pd-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.pd-row__wide   { flex: 2 1 420px; min-width: 0; }
.pd-row__narrow { flex: 1 1 300px; min-width: 0; }

.pd-legend { display: flex; align-items: center; gap: 14px; color: var(--pd-muted); font-size: 12.5px; font-weight: 600; }
.pd-legend__item { display: flex; align-items: center; gap: 6px; }
.pd-legend__swatch { width: 10px; height: 10px; border-radius: 3px; }

.pd-bars {
  display: flex; align-items: flex-end; gap: 14px; height: 200px;
  border-bottom: 1px solid var(--pd-line);
  background-image: linear-gradient(var(--pd-line) 1px, transparent 1px);
  background-size: 100% 50px;
}
.pd-bar {
  flex: 1 1 0; min-width: 0;
  height: var(--h, 100px);              /* alto por barra: style="--h:148px" */
  background: var(--pd-bar-dim); border-radius: 8px 8px 0 0;
}
.pd-bar--accent { background: var(--pd-blue); }
.pd-bar--peak   { background: var(--pd-gold-bar); }
.pd-bars-labels {
  display: flex; gap: 14px; text-align: center;
  color: var(--pd-muted); font-size: 12.5px; font-weight: 600;
}
.pd-bars-labels span { flex: 1 1 0; }
.pd-bars-labels .is-peak { color: var(--pd-gold-ink); }

/* ---------- Alertas de stock ---------- */
.pd-alerts { display: flex; flex-direction: column; gap: 12px; }
.pd-alert { display: flex; align-items: center; gap: 12px; }
.pd-alert__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.pd-alert__body { flex: 1 1 auto; min-width: 0; }
.pd-alert__name { font-weight: 700; }
.pd-alert__meta { color: var(--pd-muted); font-size: 12.5px; }
.pd-card__foot { margin-top: auto; }

/* ---------- Tabla ---------- */
.pd-table-scroll { overflow-x: auto; }
.pd-table { min-width: 520px; display: flex; flex-direction: column; }
.pd-tr {
  display: grid; grid-template-columns: 1fr 1.6fr 1fr 1.2fr; gap: 16px;
  align-items: center; padding: 12px 4px;
  border-bottom: 1px solid var(--pd-line);
}
.pd-tr:last-child { border-bottom: 0; }
.pd-tr--head { padding-top: 0; padding-bottom: 10px; color: var(--pd-muted); font-size: 12.5px; font-weight: 700; }
.pd-td-strong { font-weight: 700; }
.pd-td-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pd-tr .pd-chip { justify-self: start; }
