/* Panel de la asistente: tema oscuro, estilo ejecutivo. */
:root {
  color-scheme: dark;
  --bg: #08080a;
  --panel: #0b0b0e;
  --card: #111114;
  --elevated: #17171b;
  --line: #1f1f24;
  --line-strong: #2b2b32;
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-line: rgba(34, 211, 238, 0.34);
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: radial-gradient(1100px 380px at 60% -220px, rgba(34, 211, 238, 0.07), transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(34, 211, 238, 0.35); }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* --- Estructura --- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 26px;
  padding: 20px 12px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; }
.logo {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: #fafafa; color: #09090b; font-weight: 800; letter-spacing: -0.03em;
}
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-weight: 650; font-size: 0.95rem; }
.brand-sub { color: var(--faint); font-size: 0.74rem; }
#tabs { display: grid; gap: 20px; align-content: start; }
.nav-group { display: grid; gap: 2px; }
.nav-label { padding: 0 10px 6px; color: var(--faint); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-weight: 500; text-align: left; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tab .ico { width: 17px; height: 17px; color: var(--faint); transition: color 0.12s; }
.tab:hover { background: var(--card); color: var(--text-2); }
.tab.active { background: var(--elevated); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab.active .ico { color: var(--accent); }
.logout {
  display: flex; align-items: center; gap: 10px; margin-top: auto;
  padding: 8px 10px; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: none; color: var(--faint); cursor: pointer; text-align: left;
}
.logout:hover { color: var(--text-2); }

.content { min-width: 0; padding: 34px 44px 64px; }
.page-head { max-width: 1120px; margin: 0 auto 26px; display: grid; gap: 4px; }
.page-head p { color: var(--muted); }
.view { max-width: 1120px; margin: 0 auto; display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }

/* --- Tarjetas --- */
.card {
  display: grid; gap: 12px; align-content: start; min-width: 0;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.section-title, .section-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
}
.section-title .ico { width: 15px; height: 15px; }
.section-title.danger .ico { color: var(--danger); }
.toolbar { display: flex; gap: 8px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--danger); }
.empty { color: var(--faint); }

/* Foco del día */
.focus {
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 20px 22px; border-color: var(--accent-line);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.1), rgba(34, 211, 238, 0) 65%), var(--card);
}
.focus-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.focus-icon .ico { width: 21px; height: 21px; }
.eyebrow { color: var(--accent); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.focus h2 { font-size: 1.3rem; margin-top: 2px; }
.focus-date { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

/* Indicadores */
.kpis { display: grid; gap: 10px; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { display: grid; gap: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.card .stat { background: var(--bg); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.stat-top .ico { width: 16px; height: 16px; color: var(--faint); }
.stat-value { font-size: 1.8rem; font-weight: 650; letter-spacing: -0.025em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-note { color: var(--faint); font-size: 0.78rem; }

/* Embudo */
.funnel { display: grid; gap: 11px; }
.funnel-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 30px; align-items: center; gap: 12px; font-size: 0.85rem; }
.funnel-row .label { color: var(--muted); }
.funnel-row .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--elevated); }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar span.ok { background: var(--ok); }
.bar span.danger { background: var(--danger); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.item {
  display: flex; gap: 10px 16px; align-items: flex-start; justify-content: space-between;
  padding: 13px 0; border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.item-main { display: grid; gap: 4px; min-width: 0; flex: 1; }
.item-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-weight: 550; overflow-wrap: anywhere; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 0.83rem; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Estados */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 9px; border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--text-2); font-size: 0.74rem; font-weight: 550; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.badge.ok .dot { background: var(--ok); }
.badge.warn .dot { background: var(--warn); }
.badge.danger .dot { background: var(--danger); }
.badge.off { color: var(--faint); }
.badge.off .dot { background: var(--faint); }

/* Texto exacto de anuncios, correos e historial */
.exact {
  margin-top: 6px; padding: 12px 14px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: 8px;
}
details > summary { width: fit-content; cursor: pointer; list-style: none; color: var(--muted); font-size: 0.85rem; font-weight: 500; }
details > summary:hover { color: var(--text); }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 12px; margin-right: 4px; font-size: 1.05rem; line-height: 1; transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: 12px; }
details .card { padding: 0; border: 0; background: none; }
details.card > summary { color: var(--text-2); }

/* Botones y formularios */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; cursor: pointer;
  padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card); color: var(--text-2); font-size: 0.85rem; font-weight: 500;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--elevated); border-color: #3a3a43; color: var(--text); }
.btn.primary { background: #fafafa; border-color: #fafafa; color: #09090b; font-weight: 600; }
.btn.primary:hover { background: #e4e4e7; border-color: #e4e4e7; }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.08); }
.btn:disabled { opacity: 0.55; cursor: progress; }
form.form { display: grid; gap: 14px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 0.8rem; font-weight: 500; }
label.wide { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.85rem; cursor: pointer; }
input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { padding: 1px 5px; border-radius: 5px; background: var(--elevated); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.86em; }

/* Ingreso */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); gap: 18px; padding: 30px; }
.login-card .logo { width: 40px; height: 40px; border-radius: 10px; font-size: 1.15rem; }
.login-card .btn { width: 100%; padding: 10px; }

/* Conversación */
.chat { gap: 14px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 280px; max-height: 62vh; overflow-y: auto; padding: 2px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.bubble.yo { align-self: flex-end; background: var(--elevated); border: 1px solid var(--line-strong); color: var(--text); }
.bubble.asistente { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); color: var(--text-2); }
.bubble.error { align-self: flex-start; border: 1px solid rgba(248, 113, 113, 0.3); color: var(--danger); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding-top: 14px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; }

/* Avisos */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: flex-start; gap: 10px;
  width: max-content; max-width: min(560px, calc(100% - 32px));
  padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--elevated); color: var(--text); white-space: pre-wrap;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.toast::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--ok); }
.toast.error::before { background: var(--danger); }

/* Celular: la barra lateral pasa arriba */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    z-index: 10; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 12px 14px 10px; border-right: 0; border-bottom: 1px solid var(--line);
    background: rgba(11, 11, 14, 0.94); backdrop-filter: blur(10px);
  }
  .brand { flex: 1; padding: 0; }
  .logout { margin-top: 0; padding: 6px 4px; border-top: 0; }
  .logout span { display: none; }
  /* min-width: 0 deja que el menú se deslice dentro de su franja en vez de ensanchar la página. */
  #tabs { order: 3; flex-basis: 100%; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .tab { flex: none; width: auto; padding: 6px 12px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); }
  .tab.active { box-shadow: inset 0 0 0 1px var(--line-strong); }
  .content { padding: 22px 14px 48px; }
  .page-head { margin-bottom: 18px; }
  h1 { font-size: 1.25rem; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat-value { font-size: 1.5rem; }
  .card { padding: 16px; }
  .focus { grid-template-columns: auto minmax(0, 1fr); }
  .focus-date { grid-column: 1 / -1; }
  .item { flex-direction: column; }
  .actions { justify-content: flex-start; }
}
