:root {
  /* Grafito y lima: neutros puros + un solo acento lima para acción, selección y "en vivo". */
  --bg: #f7f7f5; --panel: #ffffff; --text: #111111; --muted: #6b6b6b; --line: #e6e6e3; --chip: #efefec;
  --accent: #c6f432; --on-accent: #141a00; --accent-ink: #4a6300; --accent-soft: #f1fbd3; --accent-soft-ink: #3d5200;
  --focus: #4a6300; --chart-strong: #111111;
  --danger: #b42318; --warn: #8a5a00;
  --side-bg: #111111; --side-text: #a3a3a3; --side-hover: #1e1e1e; --side-strong: #ffffff; --side-line: #2a2a2e;
  --bubble-in: #ffffff; --bubble-out: #111111; --bubble-out-ink: #f2f2f2;
  --bubble-human: #f1fbd3; --bubble-human-ink: #3d5200; --bubble-sys: #fbf3d5; --bubble-sys-ink: #5c4300;
  --radius: 10px; font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1); --rail: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0f; --panel: #17171a; --text: #ededed; --muted: #8a8a8f; --line: #26262a; --chip: #202024;
    --accent-ink: #c6f432; --accent-soft: #24300a; --accent-soft-ink: #d6f77a;
    --focus: #c6f432; --chart-strong: #d4d4d4;
    --danger: #ff6b5e; --warn: #f0b44c;
    --side-bg: #070708; --side-text: #8a8a8f; --side-hover: #151517; --side-line: #1f1f22;
    --bubble-in: #1c1c20; --bubble-out: #26262a; --bubble-out-ink: #ededed;
    --bubble-human: #24300a; --bubble-human-ink: #d6f77a; --bubble-sys: #2a2412; --bubble-sys-ink: #f0d58a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 16px; height: 16px; }
.hidden { display: none !important; }
h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); } .error { color: var(--danger); min-height: 1em; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
html { accent-color: var(--accent-ink); scrollbar-color: var(--line) transparent; }

.layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--side-bg); border-right: 1px solid var(--side-line); color: var(--side-text); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; position: sticky; top: 0; height: 100vh; z-index: 5; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; margin-bottom: 10px; flex: none; }
.rail nav { display: flex; flex-direction: column; gap: 4px; }
.rail nav a, .rail-btn, .nav-more { position: relative; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--side-text); text-decoration: none; background: none; border: 0; cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.rail nav a:hover, .rail-btn:hover, .nav-more:hover { background: var(--side-hover); color: var(--side-strong); }
.rail nav a.active { background: var(--accent); color: var(--on-accent); }
.rail-btn { margin-top: auto; }
.nav-more { display: none; }
.nav-label { position: absolute; left: calc(100% + 10px); top: 50%; transform: translate(-4px, -50%); background: var(--side-bg); color: var(--side-strong); border: 1px solid var(--side-line); padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s var(--ease), transform .12s var(--ease); }
.rail nav a:hover .nav-label, .rail nav a:focus-visible .nav-label, .rail-btn:hover .nav-label, .rail-btn:focus-visible .nav-label { opacity: 1; transform: translate(0, -50%); }
.nav-count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: #f0b44c; color: #2a1d00; font-size: 11px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; border: 2px solid var(--side-bg); }
.status-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #6b6b6b; border: 2px solid var(--side-bg); }
.status-dot.on { background: var(--accent); } .status-dot.warn { background: #f0b44c; }
main { padding: 28px 32px 40px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 12px; } .stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); }
.btn:active { transform: scale(.98); } .btn:hover { border-color: var(--muted); }
.btn.primary:hover { filter: brightness(0.96); } .btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); } .btn.ghost { background: transparent; } .btn.small { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; } td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent-soft-ink); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--danger); }

.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 120px); }
.conv-list { overflow-y: auto; padding: 0; }
.conv-item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv-item:hover, .conv-item.active { background: var(--chip); }
.conv-item .top { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; }
.conv-item .preview { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.chat-foot { padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.bubble { max-width: 75%; padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.bubble.cliente { background: var(--bubble-in); align-self: flex-start; border: 1px solid var(--line); }
.bubble.bot { background: var(--bubble-out); color: var(--bubble-out-ink); align-self: flex-end; }
.bubble.humano { background: var(--bubble-human); color: var(--bubble-human-ink); align-self: flex-end; }
.bubble.sistema { background: var(--bubble-sys); color: var(--bubble-sys-ink); align-self: center; font-size: 12px; max-width: 90%; }
.bubble .meta { font-size: 11px; color: inherit; opacity: .7; margin-top: 3px; text-align: right; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .bar-stack { width: 100%; display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.bars .bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .b1 { background: var(--line); } .bars .b2 { background: var(--chart-strong); }
.bars .day { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.qr { width: 260px; height: 260px; background: #fff; padding: 8px; border-radius: 8px; }
.ad-block { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 6px 0; position: relative; }
.ad-block .copy { position: absolute; top: 6px; right: 6px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: 420px; }
.toast.err { background: var(--danger); color: #fff; }

/* Login "Neón centrado": siempre oscuro, sin importar el tema del sistema. */
.auth {
  --bg: #0b0b0c; --panel: #151518; --text: #ededed; --muted: #8f8f95; --line: #2a2a2e; --chip: #202024;
  --accent-ink: #c6f432; --focus: #c6f432; --danger: #ff6b5e;
  position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
  background: var(--bg); color: var(--text); color-scheme: dark;
}
.auth::before { content: ""; position: absolute; z-index: -1; width: min(720px, 140vw); aspect-ratio: 1; left: 50%; top: 50%; transform: translate(-50%, -62%);
  background: radial-gradient(circle, rgba(198, 244, 50, .17) 0%, rgba(198, 244, 50, .06) 35%, rgba(198, 244, 50, 0) 65%); pointer-events: none; }
#authBg { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; }
.auth-card { background: rgba(21, 21, 24, .92); border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px 24px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7), 0 0 0 1px rgba(198, 244, 50, .04); }
.auth-card input { background: #0e0e0f; border-color: #2a2a2e; min-height: 44px; }
.auth-card input:focus { border-color: #c6f432; box-shadow: 0 0 0 3px rgba(198, 244, 50, .15); }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); width: min(720px, 94vw); max-height: 90vh; padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.4); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--side-line); }
  .rail .logo, .rail-btn { display: none; }
  .rail nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; width: 100%; }
  .rail nav a, .nav-more { width: 100%; height: 52px; border-radius: 10px; display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center; }
  .nav-more { display: flex; }
  .nav-label { position: static; opacity: 1; transform: none; background: none; border: 0; padding: 0; color: inherit; font-size: 11px; }
  .rail nav a:hover .nav-label, .rail nav a:focus-visible .nav-label { transform: none; }
  .rail nav .nav-secondary { display: none; }
  .rail nav.open .nav-secondary { display: flex; order: -1; }
  .nav-count { right: calc(50% - 22px); }
  .status-dot { right: calc(50% - 16px); top: 6px; }
  main { padding: 18px 16px 96px; }
  .g2, .g4 { grid-template-columns: 1fr 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; } .conv-list { max-height: 300px; } .chat { height: 70vh; }
  .toast { bottom: 84px; left: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.media-item { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.media-item img, .media-item video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #000; }
.media-item input { padding: 5px 7px; font-size: 12px; }

/* ---------- Centro de mando ---------- */
.cmd-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cmd-head h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.live-line { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-weight: 500; color: var(--text); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #7fb800; box-shadow: 0 0 0 3px rgba(127, 184, 0, .18); }
.pulse.off { background: #f0b44c; box-shadow: 0 0 0 3px rgba(240, 180, 76, .2); } .pulse.dead { background: var(--danger); box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.setup-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bubble-sys); color: var(--bubble-sys-ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.setup-bar a { color: inherit; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .k-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 5px; letter-spacing: 0; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cmd-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.panel-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--chip); color: var(--text); font-variant-numeric: tabular-nums; }
.count.warn { background: var(--bubble-sys); color: var(--bubble-sys-ink); }
.queue { list-style: none; margin: 0; padding: 0 8px 8px; }
.queue li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid var(--line); }
.queue li:first-child { border-top: 0; }
.q-main { flex: 1; min-width: 0; }
.q-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-actions { display: flex; gap: 6px; flex: none; }
.empty { padding: 18px 16px 22px; color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.empty .ic { color: var(--accent-ink); }
.chart14 { padding: 4px 16px 14px; }
.chart14 .bars { height: 120px; }
.bars .b3 { background: var(--accent); }
@media (max-width: 1000px) { .cmd-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi .k-value { font-size: 22px; } .k-unit { display: none; } .q-actions .btn span { display: none; } }

/* ---------- Acceso ---------- */
.auth-logo { width: 104px; height: 104px; margin: -10px auto -4px; display: block; filter: drop-shadow(0 6px 22px rgba(198, 244, 50, .28)); }
.auth-card h1 { text-align: center; letter-spacing: 0.16em; font-weight: 800; font-size: 26px; margin: 0; padding-left: .16em; }
.auth-card > .muted { text-align: center; margin: -4px 0 8px; }
.auth-card label { margin: 6px 0 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 50px; }
.pw-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: #b5b5ba; border-radius: 8px; cursor: pointer; display: grid; place-items: center; transition: color .15s, background-color .15s; }
.pw-toggle:hover { color: #ededed; background: #202024; } .pw-toggle[aria-pressed="true"] { color: #c6f432; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13px; cursor: pointer; margin: 8px 0 4px; }
label.check input { width: 18px; height: 18px; margin: 0; }
.auth-card .btn.primary { min-height: 46px; margin-top: 6px; font-size: 15px; }
.auth-card .btn.primary:hover { filter: none; background: #d4fb52; }
.auth-card .error:empty { display: none; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.rail-logo { width: 40px; height: 40px; margin-bottom: 10px; flex: none; }
@media (max-width: 860px) { .rail-logo { display: none; } }

/* Miniatura en la lista de productos */
.prod-cell { display: flex; gap: 12px; align-items: center; min-width: 220px; }
.prod-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--chip); border: 1px solid var(--line); flex: none; }
.prod-thumb.empty { background: repeating-linear-gradient(45deg, var(--chip), var(--chip) 6px, var(--bg) 6px, var(--bg) 12px); }
