/* eComm360 · apps internas — Concepto B (docs/design/mockups/b-*.png)
   Lateral navy, página azul muy claro, tarjetas blancas r16 con borde fino y sombra suave,
   títulos navy en negrita, acento teal para enlaces, activo y foco.
   Fuente: Open Sans · Iconos: Lucide 16–18 px, trazo 1.75 */

:root {
  /* Tinta */
  --navy: #141d3a;       /* títulos, botón primario */
  --text: #2a3340;       /* cuerpo */
  --muted: #5a6677;      /* secundario, iconos */
  --subtle: #8a96a8;     /* metadatos, placeholders */

  /* Superficies */
  --bg: #ffffff;         /* tarjetas, campos */
  --page: #f3f7fb;       /* fondo de página (azul muy claro) */
  --side: #142040;       /* lateral navy */
  --side-text: #dbe3f0;
  --side-muted: #8fa3c7;
  --side-hover: rgba(255, 255, 255, 0.06);
  --side-line: rgba(255, 255, 255, 0.12);
  --side-title: #ffffff;  /* nombre del workspace */
  --side-border: transparent;
  --side-active-bg: #23809a;
  --side-active-text: #ffffff;
  --side-active-icon: #ffffff;
  --hover: #f1f5f9;      /* hover de fila / item */
  --active: #e9eef4;     /* item seleccionado (sobre blanco) */
  --line: #e6ecf2;       /* separadores dentro de tarjetas */
  --tile-line: #e1e8f0;  /* borde de tarjeta */
  --tile-line-hover: #c9d6e3; /* borde de tarjeta clicable al pasar el ratón */
  --cyan-line: #cfe7ec;  /* borde de tarjeta cyan / teal claro */
  --card-shadow: 0 1px 2px rgba(20, 29, 58, 0.04), 0 6px 20px rgba(20, 29, 58, 0.04);

  /* Acento teal */
  --teal: #2a8aa0;       /* enlaces «Ver todas», pestaña activa, foco */
  --teal-strong: #23809a;/* elemento activo del lateral */
  --teal-soft: #e6f4f7;  /* cuadrado de icono, fila seleccionada, chip activo */
  --teal-line: #9fc9d4;  /* borde de botón «Preparar» */

  /* Rellenos de tarjeta */
  --fill-paper: #f4f7fa;
  --fill-cyan: #dcf0f3;  /* tarjeta de IA */
  --fill-teal: #3aabc0;
  --cyan-700: #2a8aa0;
  --column: #edf3f8;     /* fondo de columna del tablero */

  /* Etiquetas: fondo tenue + texto oscuro */
  --tag-gray: #eef1f5;   --tag-gray-t: #4b5563;
  --tag-blue: #e3eefb;   --tag-blue-t: #1f5fa8;
  --tag-purple: #eee8f8; --tag-purple-t: #6b4bb0;
  --tag-green: #e3f3ea;  --tag-green-t: #1f7a4d;
  --tag-amber: #fbf0d9;  --tag-amber-t: #9a6510;
  --tag-red: #fbe6e3;    --tag-red-t: #a83a2f;
  --tag-cyan: #dcf0f3;   --tag-cyan-t: #1d6f82;

  /* Estados (punto) */
  --ok: #2e9b62; --warn: #e0a020; --bad: #c4473a; --idle: #9aa5b4; --info: #2a8aa0;

  /* Colores de etapa (barra superior de columna y punto) */
  --stage-lead: #3aabc0; --stage-qual: #2f7fd8; --stage-prop: #5b9be6; --stage-nego: #f0a63a; --stage-won: #46b07a; --stage-lost: #9aa5b4;

  --r-tile: 16px; --r-card: 12px; --r-ctl: 8px; --r-tag: 999px;
  --gap: 16px;
  --side-w: 256px;
  --font: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.lucide { width: 16px; height: 16px; stroke-width: 1.75; color: var(--muted); flex: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.main { min-width: 0; padding: 0 28px 40px; }
.page { max-width: 1320px; margin: 0 auto; }

/* ---------- Lateral navy ---------- */
.sidebar { background: var(--side); color: var(--side-text); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar svg.lucide, .sidebar-shell svg.lucide { color: var(--side-muted); width: 18px; height: 18px; }
.brand { display: flex; flex-direction: column; padding: 4px 10px 18px; font-size: 26px; line-height: 1.05; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.brand em { font-style: normal; color: var(--fill-teal); }
.nav-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); padding: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--side-text); cursor: pointer; font-size: 15px; }
.nav-item:hover { background: var(--side-hover); }
.nav-item.active { background: var(--side-active-bg); color: var(--side-active-text); font-weight: 600; }
.nav-item.active svg.lucide { color: var(--side-active-icon); }
.nav-item .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--fill-teal); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.side-search { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; border: 1px solid var(--side-line); border-radius: 10px; color: var(--side-muted); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--side-line); }

/* ---------- Barra superior en tarjeta ---------- */
.topbar { display: flex; align-items: center; gap: 12px; min-height: 64px; margin: 14px 0 0; padding: 10px 14px 10px 24px; background: var(--bg); border: 1px solid var(--tile-line); border-radius: var(--r-tile); box-shadow: var(--card-shadow); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.crumbs b { color: var(--navy); font-weight: 600; }
.topbar .spacer { flex: 1; }

/* ---------- Encabezado ---------- */
.page-head { display: flex; align-items: center; gap: 16px; padding: 18px 0 14px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; }
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 2px; }
h1.title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; color: var(--navy); }
.lead { margin: 2px 0 0; font-size: 14px; color: var(--muted); max-width: 70ch; }
.count { color: var(--subtle); font-weight: 400; }
h1.title .count { display: inline-grid; place-items: center; vertical-align: middle; min-width: 28px; height: 24px; padding: 0 9px; margin-left: 6px; border-radius: 999px; background: var(--tag-gray); color: var(--navy); font-size: 13px; font-weight: 600; letter-spacing: 0; }

/* ---------- Bento / tarjetas ---------- */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); grid-auto-flow: dense; }
.tile { grid-column: span 4; background: var(--bg); border: 1px solid var(--tile-line); border-radius: var(--r-tile); box-shadow: var(--card-shadow); padding: 22px 24px; min-width: 0; display: flex; flex-direction: column; }
.s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; } .s6 { grid-column: span 6; }
.s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
.r2 { grid-row: span 2; }
.tile.paper { background: var(--fill-paper); }
.tile.cyan { background: var(--fill-cyan); border-color: var(--cyan-line); }
.tile.teal { background: var(--fill-teal); border-color: transparent; color: var(--navy); }
.tile.navy { background: var(--navy); border-color: transparent; color: #c9d3e6; }
.tile.navy .tile-title, .tile.navy .big, .tile.navy .t, .tile.navy .time { color: #fff; }
.tile.navy .sub { color: #8fa3c7; }
.tile.navy svg.lucide { color: #8fa3c7; }
.tile.flush { padding: 0; overflow: hidden; }

.tile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 30px; }
.tile-head > svg.lucide { width: 22px; height: 22px; color: var(--navy); }
.tile-title { margin: 0; min-width: 0; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; color: var(--navy); }
.tile-title .count { font-weight: 400; }
.tile-head .go { margin-left: auto; }
.tile-foot { margin-top: auto; padding-top: 16px; display: flex; align-items: center; gap: 10px; }

/* «Ver todas →»: enlace teal a la vista completa */
.go { display: inline-flex; align-items: center; gap: 6px; color: var(--teal); font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; }
.go svg.lucide { color: var(--teal); width: 16px; height: 16px; }
.go:hover { text-decoration: underline; text-underline-offset: 3px; }
.tile.navy .go, .tile.navy .go svg.lucide { color: var(--fill-teal); }

/* Cuadrado de icono (KPI, notas, actividad) */
.icon-sq { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--teal-soft); flex: none; }
.icon-sq svg.lucide { width: 22px; height: 22px; color: var(--navy); }
.icon-sq.sm { width: 40px; height: 40px; border-radius: 10px; }
.icon-sq.sm svg.lucide { width: 18px; height: 18px; }
.icon-sq.round { border-radius: 50%; }

/* KPI: una tarjeta por cifra, con icono */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); }
.kpi { display: flex; align-items: center; gap: 14px; padding: 20px 18px; background: var(--bg); border: 1px solid var(--tile-line); border-radius: var(--r-tile); box-shadow: var(--card-shadow); min-width: 0; }
.kpi.on { background: var(--teal-soft); border-color: var(--cyan-line); }
.kpi .k { font-size: 15px; color: var(--muted); }
.kpi .icon-sq { width: 44px; height: 44px; }
.kpi .big { margin-top: 2px; }

/* Cifras */
.big { font-size: 36px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; color: var(--navy); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.metric { padding: 2px 20px; border-left: 1px solid var(--line); }
.metric:first-child { padding-left: 0; border-left: 0; }
.metric .k { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.delta { font-size: 12px; color: var(--ok); margin-left: 6px; letter-spacing: 0; }
.delta.down { color: var(--bad); }

/* ---------- Botones (r8) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-ctl); border: 1px solid var(--tile-line); background: var(--bg); color: var(--navy); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary svg.lucide { color: #fff; }
.btn.primary:hover { background: #222d52; }
.btn.outlined { border-color: var(--teal-line); color: var(--navy); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn.ghost:hover { background: var(--hover); color: var(--navy); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-ctl); background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.link { color: var(--teal); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Pestañas y barra de herramientas ---------- */
.views { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.view { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px; color: var(--muted); font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.view:hover { color: var(--navy); }
.view.on { color: var(--navy); border-color: var(--teal); font-weight: 600; }
.view.on svg.lucide { color: var(--navy); }
.views .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 0; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 10px; height: 40px; min-width: 180px; padding: 0 12px; border: 1px solid var(--tile-line); border-radius: var(--r-ctl); background: var(--bg); color: var(--subtle); }
.search:focus-within { border-color: var(--teal); }
.search input { border: 0; outline: 0; background: transparent; width: 220px; color: var(--text); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; border: 1px solid var(--tile-line); background: var(--bg); }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 12px; white-space: nowrap; border-radius: 8px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--teal-soft); color: var(--teal); font-weight: 600; }

/* ---------- Etiquetas y estados (píldoras) ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: var(--r-tag); font-size: 13px; font-weight: 500; white-space: nowrap; background: var(--tag-gray); color: var(--tag-gray-t); }
.tag.blue { background: var(--tag-blue); color: var(--tag-blue-t); }
.tag.purple { background: var(--tag-purple); color: var(--tag-purple-t); }
.tag.green { background: var(--tag-green); color: var(--tag-green-t); }
.tag.amber { background: var(--tag-amber); color: var(--tag-amber-t); }
.tag.red { background: var(--tag-red); color: var(--tag-red-t); }
.tag.cyan { background: var(--tag-cyan); color: var(--tag-cyan-t); }
.status { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--tag-gray); color: var(--tag-gray-t); font-size: 13px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--idle); flex: none; }
.status.ok { background: var(--tag-green); color: var(--tag-green-t); } .status.ok::before { background: var(--ok); }
.status.warn { background: var(--tag-amber); color: var(--tag-amber-t); } .status.warn::before { background: var(--warn); }
.status.bad { background: var(--tag-red); color: var(--tag-red-t); } .status.bad::before { background: var(--bad); }
.status.info { background: var(--tag-cyan); color: var(--tag-cyan-t); } .status.info::before { background: var(--info); }
.status.plain { background: transparent; padding: 0; height: auto; color: var(--muted); }
.when { color: var(--muted); white-space: nowrap; }
.when.today { color: var(--tag-green-t); font-weight: 600; }
.when.late { color: var(--bad); }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 6px; font-size: 13px; font-weight: 600; background: var(--tag-gray); color: var(--tag-gray-t); }
.chip.today { background: var(--tag-green); color: var(--tag-green-t); }
.chip.soon { background: var(--tag-amber); color: var(--tag-amber-t); }
.chip.late { background: var(--tag-red); color: var(--tag-red-t); }

/* ---------- Personas ---------- */
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--teal-soft); color: var(--navy); font-size: 11px; font-weight: 700; flex: none; }
.avatar.md { width: 36px; height: 36px; font-size: 13px; }
.avatar.lg { width: 76px; height: 76px; border-radius: 14px; font-size: 26px; }
.person { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }

/* ---------- Filas (dentro de tarjetas) ---------- */
.rows { display: flex; flex-direction: column; margin: 0 -10px; }
.row { display: flex; align-items: center; gap: 16px; min-height: 52px; padding: 10px; border-radius: 10px; cursor: pointer; }
.row:hover { background: var(--hover); }
.row + .row { border-top: 1px solid var(--line); border-radius: 0; }
.row .time { width: 64px; color: var(--navy); font-weight: 700; flex: none; font-size: 15px; }
.row .main-t { flex: 1; min-width: 0; }
.row .t { color: var(--navy); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.row.now { background: var(--teal-soft); }
.row.now .time::after { content: "ahora"; display: block; font-size: 11px; font-weight: 600; color: var(--teal); }
.tile.navy .row:hover { background: rgba(255,255,255,.06); }
.tile.navy .row + .row { border-top-color: rgba(255,255,255,.1); }
.check { appearance: none; width: 18px; height: 18px; border: 1.5px solid #b7c1ce; border-radius: 4px; margin: 0; flex: none; cursor: pointer; display: grid; place-items: center; background: var(--bg); }
.check:checked { background: var(--teal); border-color: var(--teal); }
.check:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- Tabla en tarjeta ---------- */
.db-card { background: var(--bg); border: 1px solid var(--tile-line); border-radius: var(--r-tile); box-shadow: var(--card-shadow); overflow: hidden; }
.db { width: 100%; border-collapse: collapse; background: var(--bg); }
.db th { text-align: left; font-weight: 600; font-size: 14px; color: var(--navy); height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.db th svg.lucide { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; color: var(--subtle); }
.db td { height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.db th + th, .db td + td { border-left: 1px solid var(--line); }
.db tbody tr:hover { background: var(--hover); }
.db tr.selected { background: var(--teal-soft); }
.db .name { color: var(--navy); font-weight: 600; }
.db .num { text-align: right; }
.db-foot { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 20px; color: var(--muted); font-size: 14px; background: var(--bg); }
.db-foot .pager { margin-left: auto; display: flex; gap: 6px; }

/* ---------- Tablero ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 320px); gap: 16px; overflow-x: auto; padding: 16px 0; }
.col { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 18px 12px 12px; background: var(--column); border-radius: var(--r-tile); overflow: hidden; }
.col::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--stage, var(--stage-lost)); }
.col-head { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 6px; }
.col-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--stage, var(--stage-lost)); flex: none; }
.col-head .name { color: var(--navy); font-size: 17px; font-weight: 700; }
.col-head .count { font-size: 13px; }
.col-head .icon-btn { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--bg); border: 1px solid var(--tile-line); }
.card { background: var(--bg); border: 1px solid var(--tile-line); border-radius: var(--r-card); box-shadow: var(--card-shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.card:hover { border-color: var(--tile-line-hover); }
.card.focus { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.card .t { color: var(--navy); font-weight: 700; font-size: 15px; }
.card .sub { color: var(--muted); font-size: 14px; }
.card .amount { color: var(--navy); font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 6px 0 2px; }
.card .meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.card .next { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--fill-paper); color: var(--navy); font-size: 14px; }
.card .next.today { background: var(--tag-amber); color: var(--tag-amber-t); }
.card .next.today svg.lucide { color: var(--tag-amber-t); }
.add { display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: var(--r-ctl); color: var(--navy); cursor: pointer; border: 1px solid var(--tile-line); background: var(--bg); font-weight: 500; }
.add:hover { background: var(--hover); }

/* ---------- Propiedades (ficha) ---------- */
.props { display: grid; grid-template-columns: 140px 1fr; row-gap: 4px; margin: 0; }
.props dt { display: flex; align-items: center; gap: 10px; min-height: 36px; color: var(--muted); }
.props dd { margin: 0; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px; border-radius: 8px; color: var(--navy); }
.props dd:hover { background: var(--hover); }
.props.stack { grid-template-columns: 1fr; }
.props.stack dt { min-height: 0; font-size: 13px; }
.props.stack dd { padding: 0; font-size: 15px; margin-bottom: 14px; }

/* ---------- IA ---------- */
.ai-label { font-size: 12px; color: var(--teal); display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: rgba(255,255,255,.6); font-weight: 600; }
.ai-label::before { content: "✦ IA"; font-size: 11px; font-weight: 700; color: var(--teal); }

/* ---------- Varios ---------- */
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.empty { color: var(--subtle); padding: 24px 0; text-align: center; }
.demo-note { margin-top: 24px; color: var(--subtle); font-size: 12px; }

/* ---------- Responsive (al final para ganar en cascada) ---------- */
@media (max-width: 1100px) {
  .s3, .s4, .s5 { grid-column: span 6; }
  .s6, .s7, .s8 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 0 16px 32px; }
  .tile, .s3, .s4, .s5, .s6, .s7, .s8 { grid-column: span 12; }
  h1.title { font-size: 22px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 16px; gap: 12px; }
  .kpi .icon-sq { width: 40px; height: 40px; }
  .big { font-size: 28px; }
  .metric { padding: 12px 0; border-left: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 8px 10px 8px 14px; }
}
