/* Panel de clientes · Asistente IAdriana
   Superficie de trabajo (no de marketing): sobria, densa donde hace falta, con el verde de la marca solo para acciones y estados activos. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #eeece4;       /* barra lateral y paneles secundarios */
  --surface-3: #f1efe8;       /* fondos de campos y filas al pasar el cursor */
  --line: #e3e0d6;
  --line-strong: #cbc7b8;
  --text: #1c2130;
  --muted: #566070;
  --faint: #7a8494;
  --accent: #0b6e53;
  --accent-strong: #095a44;
  --accent-soft: #e0f1ea;
  --accent-text: #ffffff;
  --info: #1f5fbf;
  --ok-fg: #17603a;    --ok-bg: #e1f3e8;
  --warn-fg: #7a4e00;  --warn-bg: #fbefd2;
  --danger-fg: #9c1f17; --danger-bg: #fbe3e0;
  --info-fg: #1a4f9e;  --info-bg: #e3edfb;
  --mute-fg: #4a5362;  --mute-bg: #e9e7df;
  --note-bg: #fbf3d6;  --note-fg: #5c4300;
  --bubble-in: #ffffff;
  --bubble-ia: #e0f1ea;
  --bubble-human: #0b6e53;
  --bubble-human-fg: #ffffff;
  --shadow: 0 1px 2px rgba(28, 33, 48, .06), 0 8px 24px -12px rgba(28, 33, 48, .18);
  --shadow-pop: 0 2px 6px rgba(28, 33, 48, .1), 0 18px 40px -12px rgba(28, 33, 48, .28);
  --radius: 10px;
  --radius-sm: 7px;
  --side-w: 244px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #1a2029;
    --surface-2: #151a21;
    --surface-3: #202733;
    --line: #28303c;
    --line-strong: #3a4454;
    --text: #e9ecf1;
    --muted: #a3acba;
    --faint: #8792a3;
    --accent: #3fc79a;
    --accent-strong: #66d8b3;
    --accent-soft: #14312a;
    --accent-text: #08130f;
    --info: #8db8f5;
    --ok-fg: #7fdca4;    --ok-bg: #17382a;
    --warn-fg: #f0c56b;  --warn-bg: #3a2d10;
    --danger-fg: #ff9d92; --danger-bg: #43201c;
    --info-fg: #8db8f5;  --info-bg: #17284a;
    --mute-fg: #b5bdca;  --mute-bg: #262d38;
    --note-bg: #352c12;  --note-fg: #f0d98d;
    --bubble-in: #232b36;
    --bubble-ia: #14312a;
    --bubble-human: #2a9d78;
    --bubble-human-fg: #06130f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 40px -12px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -.015em; font-weight: 700; }
h2 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -.01em; font-weight: 650; }
h3 { font-size: 1rem; line-height: 1.35; font-weight: 650; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .8667rem; }
.xs { font-size: .8rem; }
.strong { font-weight: 650; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: none; display: inline-block; vertical-align: middle; }
.noscript { padding: 24px; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-weight: 550; white-space: nowrap; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--faint); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }
.btn.danger { color: var(--danger-fg); }
.btn.danger.solid { background: var(--danger-fg); border-color: var(--danger-fg); color: var(--surface); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: .9333rem; }
.btn.block { width: 100%; }
.btn .spin { width: 14px; height: 14px; }
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); transition: background-color .15s var(--ease), color .15s var(--ease);
}
.iconbtn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.iconbtn:disabled { opacity: .45; cursor: default; }

.field { display: block; }
.field > .lbl { display: block; font-size: .8667rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.field > .lbl .opt { font-weight: 400; color: var(--faint); }
.hint { font-size: .8667rem; color: var(--muted); margin-top: 5px; }
.hint.err { color: var(--danger-fg); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); caret-color: var(--accent);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.textarea.tall { min-height: 220px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); }
.input.invalid { border-color: var(--danger-fg); }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.counter { font-size: .8rem; color: var(--faint); text-align: right; margin-top: 4px; }
.counter.over { color: var(--danger-fg); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 40px; height: 24px; flex: none; border-radius: 99px; background: var(--line-strong); position: relative; transition: background-color .2s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- etiquetas, avatares, estados ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--mute-bg); color: var(--mute-fg); }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.danger { background: var(--danger-bg); color: var(--danger-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--accent); }
.dot.warn { background: #d9a21b; }
.dot.danger { background: #d4443a; }
.avatar {
  --h: 160; flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: hsl(var(--h) 38% 88%); color: hsl(var(--h) 55% 22%); font-size: .8667rem; font-weight: 700; letter-spacing: .02em; user-select: none;
}
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 28% 24%); color: hsl(var(--h) 60% 84%); } }
.avatar.sm { width: 24px; height: 24px; font-size: .68rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px; }
.card.flat { box-shadow: none; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .ico-wrap { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-3); color: var(--faint); }
.empty strong { color: var(--text); font-size: 1rem; }
.empty p { max-width: 38ch; }
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 37%, var(--surface-3) 63%); background-size: 400% 100%; border-radius: 6px; animation: shimmer 1.4s ease infinite; min-height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skel, .spin { animation: none; } * { transition-duration: .01ms !important; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; padding: 10px 14px; border: 0; background: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.tab .pill { margin-left: 6px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); font-size: .9rem; font-weight: 550; color: var(--text); }
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .n { font-size: .8rem; opacity: .75; }

/* ---------- toasts, diálogos y panel lateral ---------- */
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-pop); font-size: .9333rem; animation: toast-in .25s var(--ease); }
.toast.error { background: var(--danger-fg); color: var(--surface); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog { padding: 0; border: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow-pop); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(15, 19, 24, .45); }
dialog.drawer { margin: 0 0 0 auto; width: min(480px, 100vw); height: 100dvh; border-radius: 0; display: flex; flex-direction: column; animation: drawer-in .25s var(--ease); }
dialog.drawer:not([open]) { display: none; }
dialog.drawer[open] { display: flex; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
dialog.dlg { margin: auto; width: min(440px, calc(100vw - 32px)); border-radius: var(--radius); padding: 22px; }
dialog.dlg h2 { margin-bottom: 8px; }
dialog.dlg .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- armazón ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--surface-2); border-right: 1px solid var(--line); padding: 16px 12px 12px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.brand .name { font-weight: 700; line-height: 1.2; }
.brand .sub { font-size: .8rem; color: var(--muted); }
.nav { display: grid; gap: 2px; overflow-y: auto; flex: 1; align-content: start; }
.nav-label { padding: 14px 10px 5px; font-size: .75rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 550; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; text-align: center; }
.nav a .count.warn { background: #d9a21b; color: #20180a; }
.side-foot { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.status { display: grid; gap: 6px; padding: 4px 8px; font-size: .8667rem; }
.status div { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status b { margin-left: auto; font-weight: 600; color: var(--text); }
.usercard { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); text-align: left; min-width: 0; }
.usercard:hover { border-color: var(--faint); }
.usercard .who { min-width: 0; flex: 1; line-height: 1.25; }
.menu { position: fixed; z-index: 60; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-pop); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 6px; background: none; text-align: left; }
.menu button:hover { background: var(--surface-3); }
.main { min-width: 0; }
.topbar { display: none; align-items: center; gap: 8px; height: 52px; padding: 0 10px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-weight: 650; }
.scrim { display: none; }
.page { padding: 26px 30px 48px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- ingreso ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 22px; }
.auth-card h1 { font-size: 1.375rem; margin-bottom: 4px; }
.auth-card form { display: grid; gap: 14px; margin-top: 18px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9333rem; background: var(--danger-bg); color: var(--danger-fg); }
.alert.info { background: var(--info-bg); color: var(--info-fg); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }

/* ---------- panel de control ---------- */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 16px 18px 15px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .lbl { font-size: .8667rem; color: var(--muted); font-weight: 550; }
.stat .val { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: .8667rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stat a.foot { color: var(--accent); font-weight: 600; text-decoration: none; }
.stat a.foot:hover { text-decoration: underline; }
.delta { font-weight: 650; }
.delta.up { color: var(--ok-fg); } .delta.down { color: var(--danger-fg); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.list > * + * { border-top: 1px solid var(--line); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; min-width: 0; text-decoration: none; color: inherit; background: none; border: 0; width: 100%; text-align: left; }
a.list-item:hover, button.list-item:hover { background: var(--surface-3); }
.list-item .main-col { flex: 1; min-width: 0; }
.when { flex: none; width: 54px; text-align: center; line-height: 1.15; }
.when b { display: block; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.when span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chart-wrap { position: relative; padding: 8px 14px 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--faint); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.a { stroke: var(--accent); } .chart .line.b { stroke: var(--info); }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .cursor { stroke: var(--faint); stroke-dasharray: 3 3; }
.chart .pt.a { fill: var(--accent); } .chart .pt.b { fill: var(--info); }
.legend { display: flex; gap: 16px; align-items: center; font-size: .8667rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.a { background: var(--accent); } .legend i.b { background: var(--info); }
.tip { position: absolute; z-index: 5; pointer-events: none; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); font-size: .8667rem; line-height: 1.4; white-space: nowrap; transform: translate(-50%, -100%); }

/* ---------- bandeja ---------- */
.inbox { display: grid; grid-template-columns: 350px minmax(0, 1fr) 310px; height: 100dvh; background: var(--surface); }
.convs { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.convs-head { padding: 16px 16px 10px; display: grid; gap: 12px; }
.search { position: relative; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search .input { padding-left: 36px; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 11px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.conv:hover { background: var(--surface-3); }
.conv[aria-current="true"] { background: var(--accent-soft); }
.conv .top { display: flex; align-items: baseline; gap: 8px; }
.conv .nm { font-weight: 650; flex: 1; min-width: 0; }
.conv .tm { font-size: .8rem; color: var(--faint); flex: none; }
.conv.unread .nm { font-weight: 750; } .conv.unread .tm { color: var(--accent); font-weight: 650; }
.conv .pv { color: var(--muted); font-size: .9rem; margin-top: 1px; }
.conv.unread .pv { color: var(--text); }
.conv .tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.conv .tags .pill { font-size: .72rem; padding: 0 7px; }
.conv .unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .who { min-width: 0; flex: 1 1 180px; }
.chat-head .ctrl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assign { display: flex; align-items: center; gap: 6px; font-size: .8667rem; color: var(--muted); }
.assign .select { min-height: 32px; padding: 3px 8px; width: auto; max-width: 170px; }
.ai-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px 0 10px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); font-weight: 600; font-size: .9rem; }
.ai-toggle:hover { background: var(--surface-3); }
.ai-toggle.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); }
.ai-toggle.paused { color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn-fg) 40%, var(--line)); background: var(--warn-bg); }
.timeline { flex: 1; overflow-y: auto; min-height: 0; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.daysep { align-self: center; margin: 10px 0 6px; padding: 2px 12px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: .78rem; font-weight: 600; }
.msg { max-width: min(560px, 82%); padding: 8px 12px 6px; border-radius: 14px; background: var(--bubble-in); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(28, 33, 48, .04); }
.msg.contact { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.ia { align-self: flex-end; background: var(--bubble-ia); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); border-bottom-right-radius: 4px; }
.msg.human { align-self: flex-end; background: var(--bubble-human); border-color: var(--bubble-human); color: var(--bubble-human-fg); border-bottom-right-radius: 4px; }
.msg .by { display: flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 650; margin-bottom: 2px; color: var(--accent); }
.msg.human .by { color: inherit; opacity: .9; }
.msg .at { display: block; text-align: right; font-size: .72rem; margin-top: 2px; opacity: .65; font-variant-numeric: tabular-nums; }
.note { align-self: center; width: min(560px, 92%); padding: 9px 13px; border-radius: 10px; background: var(--note-bg); color: var(--note-fg); font-size: .9333rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .at { display: block; text-align: right; font-size: .72rem; opacity: .7; font-variant-numeric: tabular-nums; }
.note .by { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; margin-bottom: 2px; }
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 16px 14px; }
.composer .modes { display: flex; gap: 4px; margin-bottom: 8px; }
.composer .mode { padding: 5px 11px; border: 1px solid transparent; border-radius: 99px; background: none; color: var(--muted); font-weight: 600; font-size: .9rem; }
.composer .mode:hover { background: var(--surface-3); }
.composer .mode[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.composer.note-mode .mode[aria-pressed="true"] { background: var(--note-bg); color: var(--note-fg); }
.composer .box { display: flex; gap: 10px; align-items: flex-end; }
.composer .textarea { min-height: 44px; max-height: 160px; resize: none; }
.composer.note-mode .textarea { background: var(--note-bg); border-color: transparent; }
.composer .notice { margin-bottom: 8px; }
.info-pane { border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; background: var(--surface); }
.info-sec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.info-sec h3 { display: flex; align-items: center; justify-content: space-between; font-size: .8667rem; margin-bottom: 10px; color: var(--muted); font-weight: 650; }
.profile { display: grid; justify-items: center; gap: 4px; text-align: center; padding-top: 22px; }
.kv { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; font-size: .9333rem; margin-top: 8px; color: var(--muted); }
.kv .ico { margin-top: 2px; }
.mini { padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: 3px; width: 100%; text-align: left; background: var(--surface); }
button.mini:hover { background: var(--surface-3); }
.mini + .mini { margin-top: 8px; }
.inbox .back, .inbox .info-toggle { display: none; }

/* ---------- tablas y contactos ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: .78rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--surface-2); }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-3); }
td.actions, th.actions { text-align: right; white-space: nowrap; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person .nm { font-weight: 650; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.pcard { display: grid; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; width: 100%; }
button.pcard:hover { border-color: var(--faint); background: var(--surface-3); }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 0 1 320px; min-width: 200px; }
.toolbar .chips { flex: 1 1 260px; min-width: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 600; font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* ---------- potenciales ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; scroll-snap-type: x proximity; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; scroll-snap-align: start; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.col.over { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 4px; }
.col-head .t { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.col-head .n { font-size: .8rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.col-sum { padding: 0 14px 8px; font-size: .8667rem; color: var(--muted); }
.col-body { display: grid; gap: 8px; padding: 4px 8px 10px; }
.lead { display: grid; gap: 8px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); text-align: left; width: 100%; cursor: grab; transition: box-shadow .15s var(--ease), border-color .15s var(--ease); }
.lead:hover { border-color: var(--faint); box-shadow: var(--shadow); }
.lead.dragging { opacity: .45; cursor: grabbing; }
.lead .nm { font-weight: 650; }
.lead .val { font-weight: 650; color: var(--ok-fg); font-variant-numeric: tabular-nums; }
.col-empty { padding: 18px 8px; text-align: center; color: var(--faint); font-size: .9rem; }

/* ---------- calendario ---------- */
.cal-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-bar .range { font-size: 1.125rem; font-weight: 650; min-width: 210px; text-transform: capitalize; }
.sched { overflow: hidden; }
.wk { --hour-h: 54px; display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr)); }
.wk-head { display: contents; }
.wk-head > div { padding: 10px 6px; text-align: center; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: .8rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; border-left: 1px solid var(--line); }
.wk-head > div:first-child { border-left: 0; }
.wk-head b { display: grid; place-items: center; width: 30px; height: 30px; margin: 2px auto 0; border-radius: 50%; font-size: 1.0667rem; letter-spacing: 0; color: var(--text); }
.wk-head .today b { background: var(--accent); color: var(--accent-text); }
.wk-hours { position: relative; }
.wk-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: .75rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.wk-col { position: relative; border-left: 1px solid var(--line); height: calc(var(--rows) * var(--hour-h)); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour-h)); cursor: cell; }
.wk-col.off { background-color: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.wk-col.today { background-color: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid #d4443a; z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #d4443a; }
.appt {
  --c: var(--accent); position: absolute; left: calc(var(--lane, 0) * 100% / var(--lanes, 1) + 3px); width: calc(100% / var(--lanes, 1) - 6px); top: calc((var(--start) - var(--from)) * var(--hour-h)); height: calc(var(--dur) * var(--hour-h) - 2px); min-height: 22px;
  overflow: hidden; padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-left: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 6px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); text-align: left; font-size: .8rem; line-height: 1.25; cursor: pointer; z-index: 2;
}
.appt:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.appt.short { display: flex; align-items: baseline; gap: 6px; padding-top: 2px; padding-bottom: 2px; white-space: nowrap; }
.appt.short .s { display: none; }
.appt .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.appt .s { color: var(--muted); }
.appt.s-pendiente { --c: #d9a21b; } .appt.s-confirmada { --c: var(--accent); } .appt.s-atendida { --c: #6d7787; }
.appt.s-no_asistio { --c: #d4443a; } .appt.s-cancelada { --c: #98a1b0; opacity: .7; text-decoration: line-through; }
.appt .ia { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 4px; font-size: .68rem; font-weight: 700; background: var(--accent); color: var(--accent-text); vertical-align: 1px; text-decoration: none; }
.mo { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mo-h { padding: 9px 8px; text-align: center; font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.mo-d { min-height: 104px; padding: 6px; border: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: none; text-align: left; display: grid; align-content: start; gap: 3px; }
.mo-d:nth-child(7n + 1) { border-left: 0; }
.mo-d:hover { background: var(--surface-3); }
.mo-d.out { color: var(--faint); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.mo-d .dn { font-size: .875rem; font-weight: 650; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.mo-d.today .dn { background: var(--accent); color: var(--accent-text); }
.mo-d .ev { font-size: .75rem; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mo-d .more { font-size: .75rem; color: var(--muted); }
.agenda .day { padding: 8px 16px; background: var(--surface-2); font-weight: 650; font-size: .9rem; text-transform: capitalize; border-bottom: 1px solid var(--line); }
.statuses { display: flex; flex-wrap: wrap; gap: 6px; }
.statuses button { min-height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); font-size: .9rem; font-weight: 550; }
.statuses button:hover { background: var(--surface-3); }
.statuses button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }

/* ---------- asistente, equipo y negocio ---------- */
.settings { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 860px; }
.sec-card { padding: 20px 22px; }
.sec-card > h2 + .hint { margin-bottom: 16px; }
.field-list { display: grid; gap: 18px; }
.sched-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sched-row:last-child { border-bottom: 0; }
.sched-row .times { display: flex; align-items: center; gap: 8px; }
.sched-row .times .input { width: 120px; }
.big-switch { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px; }
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin-top: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop); }
.secret { padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--warn-fg) 40%, var(--line)); border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); }
.secret code { display: block; margin: 8px 0; padding: 8px 10px; border-radius: 6px; background: var(--surface); color: var(--text); font: 600 1.0667rem/1.3 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .04em; user-select: all; }

/* ---------- pantallas chicas ---------- */
@media (max-width: 1500px) {
  .inbox { grid-template-columns: 330px minmax(0, 1fr); }
  .info-pane { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(340px, 100vw); box-shadow: var(--shadow-pop); transform: translateX(100%); transition: transform .25s var(--ease); visibility: hidden; }
  .inbox.show-info .info-pane { transform: none; visibility: visible; }
  .inbox .info-toggle { display: inline-grid; }
}
@media (max-width: 1000px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .dash-grid, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-pop); visibility: hidden; }
  .nav-open .side { transform: none; visibility: visible; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(15, 19, 24, .45); }
  .topbar { display: flex; }
  .page { padding: 18px 16px 40px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { justify-content: flex-start; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 52px); }
  .inbox .chat { display: none; }
  .inbox[data-view="chat"] .convs { display: none; }
  .inbox[data-view="chat"] .chat { display: flex; }
  .inbox .back { display: inline-grid; }
  .msg { max-width: 90%; }
  .wk { --hour-h: 48px; }
}
@media (max-width: 560px) {
  .strip { grid-template-columns: minmax(0, 1fr); }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
  .sched-row { grid-template-columns: 1fr; gap: 6px; }
  dialog.drawer { width: 100vw; }
  .toolbar .search { flex-basis: 100%; }
  .hide-sm { display: none; }
}
