/* =====================================================
   Trascend CRM · Internal tool
   Sidebar oscura (marca) + contenido claro
   ===================================================== */
:root {
  /* Brand (heredado de la website) */
  --ink:        #060416;
  --night:      #0a0420;
  --indigo:     #130C49;
  --royal:      #1F137D;
  --violet:     #5C21C3;
  --orchid:     #874AD7;
  --magenta:    #9303C5;
  --lilac:      #C9A8F2;
  --orchid-bright:  #B98CEC;
  --magenta-bright: #DC78F2;

  /* Light surface system */
  --bg:         #F4F1FA;
  --surface:    #FFFFFF;
  --surface-2:  #FAF8FE;
  --line:       rgba(26, 14, 62, 0.10);
  --line-soft:  rgba(26, 14, 62, 0.06);

  --text:       #1A0E3E;
  --text-soft:  #4B3B7A;
  --text-dim:   #8678AC;

  /* Sidebar dark tokens */
  --sb-bg:      #0a0420;
  --sb-text:    #D4CCEC;
  --sb-dim:     #8678AC;
  --sb-line:    rgba(255,255,255,0.08);

  /* Semantic */
  --ok:         #1B8A5A;
  --ok-bg:      #E3F5EC;
  --warn:       #9A6700;
  --warn-bg:    #FBF0DA;
  --danger:     #C03540;
  --danger-bg:  #FBE5E7;
  --info:       #2F5FC4;
  --info-bg:    #E5ECFB;
  --violet-bg:  #EFE7FB;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;

  --shadow-card: 0 1px 2px rgba(26,14,62,0.05), 0 8px 24px -16px rgba(26,14,62,0.18);
  --shadow-pop:  0 24px 60px -24px rgba(11,4,36,0.45);

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--violet); color: #fff; }

/* =====================================================
   Shell
   ===================================================== */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }

.sidebar {
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
}
.sb-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
}
.sb-logo img { width: 30px; height: 30px; }
.sb-logo b {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.02rem; color: #F4F0FC; letter-spacing: -0.01em;
  display: block; line-height: 1.1;
}
.sb-logo em {
  font-style: normal; font-family: var(--font-mono);
  font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--lilac);
}
.sb-section {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--sb-dim);
  padding: 16px 18px 6px;
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--sb-text); font-size: 0.86rem; font-weight: 500;
  border: none; background: transparent; text-align: left; width: 100%;
  transition: background 0.15s, color 0.15s;
}
.sb-item svg { width: 17px; height: 17px; flex: none; opacity: 0.75; }
.sb-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sb-item.is-active {
  background: linear-gradient(96deg, rgba(92,33,195,0.45), rgba(147,3,197,0.30));
  color: #fff; box-shadow: 0 0 0 1px rgba(201,168,242,0.22) inset;
}
.sb-item.is-active svg { opacity: 1; }
.sb-item .sb-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.66rem;
  color: var(--lilac); background: rgba(201,168,242,0.12);
  padding: 1px 7px; border-radius: 99px;
}
.sb-footer { margin-top: auto; padding: 12px 10px 14px; border-top: 1px solid var(--sb-line); }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); width: 100%;
  background: transparent; border: none; text-align: left;
}
.sb-user:hover { background: rgba(255,255,255,0.05); }
.sb-user .avatar { width: 30px; height: 30px; font-size: 0.7rem; }
.sb-user b { display: block; color: #F4F0FC; font-size: 0.82rem; font-weight: 600; line-height: 1.2; }
.sb-user span { display: block; color: var(--sb-dim); font-size: 0.7rem; }

.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar h1 {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }
.content-narrow { max-width: 1100px; }

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: 99px;
  font-weight: 600; font-size: 0.84rem;
  border: 1px solid transparent;
  background: var(--surface); color: var(--text);
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: linear-gradient(96deg, var(--violet) 0%, var(--magenta) 100%);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset, 0 10px 22px -12px rgba(92,33,195,0.55);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(255,255,255,0.25) inset, 0 14px 26px -12px rgba(92,33,195,0.7); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-soft); }
.btn-ghost:hover { border-color: rgba(26,14,62,0.25); background: var(--surface); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-icon { padding: 7px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* =====================================================
   Cards, badges, misc
   ===================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.card-head h3 {
  font-family: var(--font-display); font-size: 0.98rem; font-weight: 700;
  letter-spacing: -0.01em;
}
.card-head .spacer { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.64rem; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--violet);
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 9px; border-radius: 99px;
  background: var(--violet-bg); color: var(--violet);
  white-space: nowrap;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok     { background: var(--ok-bg); color: var(--ok); }
.badge-warn   { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info   { background: var(--info-bg); color: var(--info); }
.badge-dim    { background: rgba(26,14,62,0.07); color: var(--text-soft); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff; font-weight: 700; font-size: 0.74rem; flex: none;
  letter-spacing: 0.02em;
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.62rem; }

.mono { font-family: var(--font-mono); }
.dim { color: var(--text-dim); }
.soft { color: var(--text-soft); }
.tnum { font-variant-numeric: tabular-nums; }

/* =====================================================
   Forms
   ===================================================== */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.74rem; font-weight: 600; color: var(--text-soft); }
.input, .select, .textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--orchid);
  box-shadow: 0 0 0 3px rgba(135,74,215,0.16);
}
.textarea { resize: vertical; min-height: 76px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%234B3B7A' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 99px; padding: 7px 14px; min-width: 230px;
}
.search input { border: none; background: transparent; outline: none; font: inherit; color: var(--text); width: 100%; }
.search svg { width: 14px; height: 14px; color: var(--text-dim); flex: none; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* =====================================================
   Tables
   ===================================================== */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.tbl th {
  text-align: left; font-family: var(--font-mono); font-weight: 500;
  font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.is-click { cursor: pointer; }
.tbl .t-right { text-align: right; }

/* =====================================================
   Tabs / segmented
   ===================================================== */
.tabs { display: flex; gap: 2px; background: rgba(26,14,62,0.06); border-radius: 99px; padding: 3px; width: max-content; }
.tabs button {
  border: none; background: transparent; border-radius: 99px;
  padding: 6px 14px; font-size: 0.8rem; font-weight: 600; color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.tabs button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

.pagetabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.pagetabs button {
  border: none; background: none; padding: 8px 2px 10px;
  font-size: 0.86rem; font-weight: 600; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pagetabs button.is-active { color: var(--violet); border-bottom-color: var(--violet); }

/* =====================================================
   KPI cards
   ===================================================== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; }
.kpi .kpi-label { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.kpi .kpi-value {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 700;
  letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-foot { margin-top: 6px; font-size: 0.74rem; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }

/* =====================================================
   Kanban
   ===================================================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 264px; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: start; }
.kcol { background: rgba(26,14,62,0.04); border-radius: var(--radius-lg); padding: 10px; border: 1px solid var(--line-soft); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.kcol-head b { font-size: 0.8rem; font-weight: 700; }
.kcol-head .kcount { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-dim); }
.kcol-head .ksum { margin-left: auto; font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-soft); }
.kcol-cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.kcard {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 12px; cursor: grab;
  box-shadow: var(--shadow-card); transition: box-shadow 0.15s, transform 0.12s;
}
.kcard:hover { transform: translateY(-1px); }
.kcard.is-dragging { opacity: 0.4; }
.kcard b { font-size: 0.84rem; display: block; line-height: 1.3; }
.kcard .kclient { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }
.kcard-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.kcard-foot .kval { font-family: var(--font-mono); font-size: 0.72rem; color: var(--violet); font-weight: 600; }
.kcard-foot .avatar-sm { margin-left: auto; }
.kcol.is-over { background: var(--violet-bg); border-color: var(--orchid); }

/* =====================================================
   Calendar
   ===================================================== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.cal-dow {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-dim); padding: 8px 10px; background: var(--surface-2);
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.cal-day {
  min-height: 108px; padding: 6px; background: var(--surface);
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 4px;
}
.cal-day.is-out { background: var(--surface-2); }
.cal-day .dnum { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-dim); padding: 2px 4px; }
.cal-day.is-today .dnum { background: var(--violet); color: #fff; border-radius: 6px; width: max-content; }
.cal-post {
  font-size: 0.68rem; font-weight: 600; padding: 3px 7px; border-radius: 7px;
  background: var(--violet-bg); color: var(--violet);
  cursor: pointer; display: flex; gap: 5px; align-items: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: none; text-align: left; width: 100%;
}
.cal-post .net { font-family: var(--font-mono); font-size: 0.58rem; opacity: 0.8; flex: none; }

/* =====================================================
   Inbox / chat
   ===================================================== */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 0; height: calc(100vh - 140px); min-height: 480px; }
/* Bandeja full-bleed: rompe el padding del content y ocupa todo el ancho
   del área principal (menos la sidebar). Se ve como un cliente de mail
   real, sin whitespace desperdiciado a la derecha. */
.inbox.inbox-full {
  margin: -24px -28px -48px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  height: calc(100vh - 88px);
  height: calc(100dvh - 88px);
  max-width: none;
}
@media (max-width: 980px) {
  .inbox.inbox-full { margin: -18px -16px -40px; height: calc(100vh - 80px); height: calc(100dvh - 80px); }
}
.threads { border-right: 1px solid var(--line-soft); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thread {
  display: flex; gap: 10px; padding: 12px 14px; width: 100%; text-align: left;
  border: none; background: none; border-bottom: 1px solid var(--line-soft);
  transition: background 0.12s; align-items: flex-start;
}
.thread:hover { background: var(--surface-2); }
.thread.is-active { background: var(--violet-bg); }
.thread b { font-size: 0.82rem; display: block; }
.thread .tprev { font-size: 0.74rem; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.thread .tmeta { margin-left: auto; text-align: right; flex: none; }
.thread .ttime { font-family: var(--font-mono); font-size: 0.62rem; color: var(--text-dim); }
.thread .tunread { display: inline-block; min-width: 17px; padding: 1px 5px; border-radius: 99px; background: var(--magenta); color: #fff; font-size: 0.62rem; font-weight: 700; text-align: center; margin-top: 4px; }

.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-back { display: none; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); place-items: center; flex: none; }
.chat-back:hover { border-color: var(--violet); color: var(--violet); }
.chat-back svg { width: 18px; height: 18px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.chat-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { max-width: min(72%, 780px); padding: 9px 13px; border-radius: 14px; font-size: 0.84rem; line-height: 1.45; }
/* Mails HTML: casi todo el ancho, sin fondo ni padding (el iframe pinta su
   propio fondo blanco). Chat de WhatsApp mantiene burbujas chicas. */
.msg.msg-html { max-width: min(96%, 1100px); padding: 0; background: transparent !important; border: 0; box-shadow: none; }
.msg.msg-html.msg-out { background: transparent !important; color: inherit; }
.msg.msg-html .mtime { padding-left: 4px; }
.msg .mtime { display: block; font-family: var(--font-mono); font-size: 0.58rem; opacity: 0.6; margin-top: 4px; }
.msg-in  { align-self: flex-start; background: var(--surface); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: linear-gradient(96deg, var(--violet), var(--magenta)); color: #fff; border-bottom-right-radius: 4px; }
.chat-input { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line-soft); background: var(--surface); }
.chat-input input { flex: 1; }

/* =====================================================
   Modal
   ===================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6,4,22,0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 20px 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); width: 100%; max-width: 560px;
  display: flex; flex-direction: column; max-height: 86vh;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 0; flex: none; }
.modal-head h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-close { margin-left: auto; border: none; background: rgba(26,14,62,0.06); border-radius: 8px; width: 28px; height: 28px; color: var(--text-soft); font-size: 1rem; line-height: 1; cursor: pointer; flex: none; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; flex: none; border-top: 1px solid var(--line-soft); }

/* =====================================================
   Charts (SVG helpers)
   ===================================================== */
.chart-wrap { width: 100%; }
.chart-legend { display: flex; gap: 16px; font-size: 0.72rem; color: var(--text-soft); flex-wrap: wrap; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* =====================================================
   Login
   ===================================================== */
.login-screen {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(92,33,195,0.35), transparent 60%),
    radial-gradient(700px 480px at 8% 110%, rgba(147,3,197,0.22), transparent 60%),
    var(--ink);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 22px; padding: 36px 34px;
  backdrop-filter: blur(12px);
  color: #F4F0FC;
  box-shadow: 0 40px 90px -40px rgba(0,0,0,0.8);
}
.login-card .sb-logo { padding: 0 0 22px; }
.login-card h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.login-card .login-sub { color: #B5ABD6; font-size: 0.84rem; margin-top: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.login-form label { font-size: 0.74rem; font-weight: 600; color: #D4CCEC; }
.login-form .input {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14); color: #F4F0FC;
}
.login-form .input::placeholder { color: #6E5F99; }
.login-form .input:focus { border-color: var(--orchid-bright); box-shadow: 0 0 0 3px rgba(185,140,236,0.2); }
.login-error {
  background: rgba(192,53,64,0.18); border: 1px solid rgba(192,53,64,0.4);
  color: #FFB9BF; font-size: 0.78rem; padding: 9px 13px; border-radius: 10px;
}
.login-hint { margin-top: 18px; font-family: var(--font-mono); font-size: 0.64rem; color: #6E5F99; line-height: 1.7; }
.login-hint code { color: var(--lilac); }

/* =====================================================
   Analítica web · mapa de calor y barras
   ===================================================== */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; flex: none; }
.segmented button { padding: 7px 13px; border-radius: 7px; font-size: 0.8rem; font-weight: 500; color: var(--text-dim); white-space: nowrap; transition: background .2s, color .2s; }
.segmented button:hover { color: var(--text); }
.segmented button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.an-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.an-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--violet), var(--magenta)); }
.an-map { position: relative; padding: 12px; }
.an-map-inner { position: relative; transform-origin: top left; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.an-map-spacer { pointer-events: none; }
.an-blobs { position: absolute; inset: 0; mix-blend-mode: screen; }
.an-blob { position: absolute; width: 82px; height: 82px; margin: -41px 0 0 -41px; border-radius: 50%; background: radial-gradient(circle, rgba(255,64,96,0.5) 0%, rgba(255,180,0,0.34) 34%, rgba(80,120,255,0.16) 62%, transparent 74%); }

/* =====================================================
   Misc layout
   ===================================================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--text-dim);
  font-size: 0.86rem;
}
.empty b { display: block; font-family: var(--font-display); font-size: 1.05rem; color: var(--text-soft); margin-bottom: 4px; }

/* banner global de error de API (falla al guardar) — ver ui.jsx ApiErrorHost */
.api-error-banner {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 9000; max-width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px;
  background: var(--danger); color: #fff;
  padding: 11px 15px; border-radius: 12px;
  box-shadow: 0 18px 44px -12px rgba(0,0,0,.5);
  font-size: 0.84rem; font-weight: 600; line-height: 1.42;
  animation: apiErrDrop .22s ease;
}
.api-error-banner svg { width: 18px; height: 18px; flex: none; stroke: #fff; }
.api-error-banner button {
  margin-left: 2px; background: rgba(255,255,255,.2); color: #fff; border: 0;
  width: 22px; height: 22px; border-radius: 6px; font-size: 15px; line-height: 1; cursor: pointer; flex: none;
}
@keyframes apiErrDrop { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* pantalla de carga de módulos (post-login) */
.app-boot {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: #B5ABD6; font-size: 0.9rem; font-weight: 500;
}
.app-boot-spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(201,168,242,0.25); border-top-color: var(--lilac);
  animation: bootSpin 0.7s linear infinite;
}
@keyframes bootSpin { to { transform: rotate(360deg); } }

.net-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.64rem; font-weight: 500;
  padding: 2px 9px; border-radius: 99px; letter-spacing: 0.04em;
  background: rgba(26,14,62,0.07); color: var(--text-soft);
}
.net-chip i { width: 7px; height: 7px; border-radius: 50%; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #F4F0FC; font-size: 0.82rem; font-weight: 600;
  padding: 11px 22px; border-radius: 99px; z-index: 80;
  box-shadow: var(--shadow-pop); animation: modalIn 0.2s ease-out;
  border: 1px solid rgba(201,168,242,0.25);
}

/* =====================================================
   Growth: atribución, automatización, integraciones, informes
   ===================================================== */
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(282px, 1fr)); gap: 14px; }

.pbar { height: 7px; border-radius: 99px; background: rgba(26,14,62,0.08); overflow: hidden; }
.pbar span { display: block; height: 100%; border-radius: 99px; transition: width 0.45s ease; }

.chan-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.64rem; font-weight: 500;
  padding: 2px 9px; border-radius: 99px; letter-spacing: 0.04em;
  background: rgba(26,14,62,0.07); color: var(--text-soft);
}
.chan-chip i { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.score-num { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* timeline de trazabilidad digital */
.tl { position: relative; padding-left: 28px; }
.tl::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -28px; top: -1px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--violet-bg); color: var(--violet); display: grid; place-items: center;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.tl-dot svg { width: 11px; height: 11px; }
.tl-item b { font-size: 0.82rem; display: block; line-height: 1.3; }
.tl-item .tl-meta { font-size: 0.68rem; color: var(--text-dim); font-family: var(--font-mono); }

/* tarjeta de integración */
.intg { display: flex; gap: 13px; align-items: flex-start; padding: 16px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.intg .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-family: var(--font-display); font-size: 0.95rem; }
.intg.is-off { background: var(--surface-2); }
.intg.is-off .ico { filter: grayscale(0.55); opacity: 0.7; }
.intg-name { font-weight: 700; font-size: 0.9rem; }
.intg-desc { font-size: 0.74rem; color: var(--text-dim); margin-top: 1px; }

/* switch on/off */
.switch { width: 38px; height: 22px; border-radius: 99px; background: rgba(26,14,62,0.18); position: relative; border: none; padding: 0; flex: none; transition: background 0.15s; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left 0.15s; }
.switch.on { background: linear-gradient(96deg, var(--violet), var(--magenta)); }
.switch.on::after { left: 18px; }

/* tarjeta de KPI con meta */
.kpit { padding: 15px 17px; display: flex; flex-direction: column; gap: 9px; }
.kpit .kpit-head { display: flex; align-items: center; gap: 8px; }
.kpit .kpit-foot { display: flex; align-items: center; justify-content: space-between; font-size: 0.72rem; color: var(--text-dim); }

/* =====================================================
   Admin / permisos / seguridad / conexiones
   ===================================================== */
.card-head h3 svg { width: 17px; height: 17px; flex: none; vertical-align: -3px; }
.card-head h3 .row { display: inline-flex; align-items: center; }

/* confirmación global "¿estás seguro?" */
.confirm-backdrop { z-index: 120; }
.confirm {
  width: min(420px, calc(100vw - 40px)); background: var(--surface); border-radius: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg, 0 24px 60px rgba(20,8,50,0.28));
  padding: 26px 24px 20px; text-align: center;
}
.confirm-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; margin: 0 auto 14px; }
.confirm-ico svg { width: 24px; height: 24px; }
.confirm-ico.is-danger { background: var(--danger-bg); color: var(--danger); }
.confirm-ico.is-info { background: var(--info-bg); color: var(--info); }
.confirm h3 { font-family: var(--font-display); font-size: 1.12rem; letter-spacing: -0.01em; margin: 0 0 6px; }
.confirm-msg { color: var(--text-soft); font-size: 0.88rem; margin: 0 auto; max-width: 34ch; }
.confirm-type { margin-top: 16px; text-align: left; }
.confirm-type label { font-size: 0.78rem; color: var(--text-soft); display: block; margin-bottom: 6px; }
.confirm-type b { color: var(--danger); font-family: var(--font-mono); }
.confirm-foot { display: flex; gap: 10px; margin-top: 20px; }
.confirm-foot .btn { flex: 1; justify-content: center; }
.btn-danger-solid { background: var(--danger); color: #fff; border: 1px solid var(--danger); }
.btn-danger-solid:hover { filter: brightness(1.05); }
.btn-danger-solid:disabled { opacity: 0.5; cursor: not-allowed; }

.switch.is-disabled { opacity: 0.45; cursor: not-allowed; }

/* medidor de fuerza de contraseña */
.pwd-meter { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pwd-bars { display: flex; gap: 4px; flex: none; }
.pwd-bars span { width: 26px; height: 5px; border-radius: 99px; transition: background 0.2s; }
.pwd-label { font-size: 0.72rem; }

/* tabs de administración (con iconos, ajustables) */
.admin-tabs { width: 100%; flex-wrap: wrap; box-sizing: border-box; }
.admin-tabs .tab {
  display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent;
  border-radius: 99px; padding: 7px 14px; font-size: 0.8rem; font-weight: 600; color: var(--text-soft);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.admin-tabs .tab svg { opacity: 0.7; }
.admin-tabs .tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.admin-tabs .tab.is-active svg { opacity: 1; color: var(--violet); }

/* matriz de permisos */
.role-presets { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.perm-matrix { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.perm-tbl { width: 100%; }
.perm-tbl th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); padding: 9px 12px; background: var(--surface-2); }
.perm-tbl td { padding: 8px 12px; border-top: 1px solid var(--line-soft); }
.perm-tbl .t-center { text-align: center; } .perm-tbl .t-right { text-align: right; }
.perm-sec td { background: var(--surface-2); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); font-weight: 700; padding: 6px 12px; }
.perm-cb { width: 17px; height: 17px; accent-color: var(--violet); cursor: pointer; }
.perm-cb:disabled { opacity: 0.3; cursor: not-allowed; }
.chipbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 3px 8px; font-size: 0.68rem; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.chipbtn:hover { border-color: var(--violet); color: var(--violet); }

/* flags finos */
.flag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flag-row { display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); cursor: default; }

/* tarjetas de rol */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.role-card { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface); }
.role-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(140deg, var(--violet), var(--magenta)); color: #fff; flex: none; }
.role-ico svg { width: 18px; height: 18px; }

/* conexiones (mail / whatsapp) */
.conn-card { display: flex; flex-direction: column; gap: 11px; border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface); transition: opacity 0.15s; }
.conn-card.is-off { opacity: 0.62; }
.conn-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.conn-note { display: flex; align-items: flex-start; gap: 9px; background: var(--info-bg); color: var(--info); border-radius: 10px; padding: 11px 13px; font-size: 0.78rem; margin-top: 14px; }
.conn-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.conn-note code { background: rgba(47,95,196,0.12); }
.assigned-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chip-user { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 99px; padding: 3px 9px 3px 3px; font-size: 0.72rem; font-weight: 600; color: var(--text-soft); }
.assign-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 220px; overflow: auto; }
.assign-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.assign-row.is-on { border-color: var(--violet); background: rgba(124,58,237,0.05); }
.assign-row input { accent-color: var(--violet); }

/* seguridad */
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 18px; }
.sec-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

/* auditoría */
.audit-scroll { max-height: 560px; overflow: auto; }
.audit-scroll table { width: 100%; }
.audit-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* cuentas conectadas en la bandeja */
.inbox-accounts { display: flex; flex-wrap: wrap; gap: 6px; padding: 11px 14px 0; }
.acct-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 600; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 99px; padding: 4px 10px; }
.acct-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* =====================================================
   Botón (i) + popover de sección
   ===================================================== */
.info-wrap { position: relative; display: inline-flex; }
.info-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text-dim);
  font-family: var(--font-display); font-style: italic; font-weight: 700;
  font-size: 0.78rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: border-color .15s, color .15s, background .15s; flex: none;
}
.info-btn:hover, .info-btn.is-open { border-color: var(--violet); color: var(--violet); background: rgba(92,33,195,.08); }
.info-pop {
  position: absolute; top: 30px; left: 0; z-index: 45; width: 330px; max-width: 80vw;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-pop); padding: 14px 16px; animation: modalIn .14s ease;
}
.info-pop-title { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; margin-bottom: 6px; }
.info-pop-body p { font-size: 0.8rem; line-height: 1.5; color: var(--text-soft); margin: 0 0 8px; }
.info-pop-body p:last-child { margin-bottom: 0; }
.info-pop-body .info-tag { font-size: 0.75rem; color: var(--text-dim); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; }
.info-pop-body .info-tag b { color: var(--violet); }

/* hamburguesa (solo móvil/tablet) */
.topbar-burger {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; place-items: center; flex: none;
}
.topbar-burger svg { width: 20px; height: 20px; }

/* overlay del drawer */
.sb-overlay { display: none; }

/* =====================================================
   2FA (alta por el usuario / login)
   ===================================================== */
.twofa-code { display: flex; align-items: center; gap: 10px; background: var(--sb-bg); color: #fff; border-radius: 12px; padding: 12px 16px; }
.twofa-code .dim { color: rgba(255,255,255,.6); font-size: 0.74rem; flex: 1; }
.twofa-code b { font-size: 1.5rem; letter-spacing: 0.18em; }
.twofa-count { font-size: 0.72rem; color: var(--orchid-bright); font-family: var(--font-mono); }
.twofa-key { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.twofa-demo { margin-top: 8px; font-size: 0.78rem; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; color: var(--text-soft); text-align: center; }
.twofa-demo b { font-size: 1.05rem; letter-spacing: 0.15em; color: var(--violet); }
.twofa-qr { display: flex; align-items: center; gap: 16px; }
.twofa-qr-box { width: 140px; height: 140px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 6px; display: grid; place-items: center; }
.twofa-qr-box img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.twofa-qr-fallback { color: var(--text-dim); }
.twofa-qr-fallback svg { width: 40px; height: 40px; }
.twofa-manual > summary { cursor: pointer; color: var(--violet); font-weight: 600; font-size: 0.78rem; list-style: none; }
.twofa-manual > summary::-webkit-details-marker { display: none; }
.twofa-manual > summary::before { content: '+ '; font-weight: 700; }
.twofa-manual[open] > summary::before { content: '– '; }

/* =====================================================
   Responsive · tablet y celular
   ===================================================== */
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* --- Tablet: la barra lateral pasa a cajón deslizable --- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 256px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 60;
    box-shadow: 0 0 70px rgba(0,0,0,.45);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.is-open { transform: none; }
  .sb-overlay {
    display: block; position: fixed; inset: 0; background: rgba(6,4,22,.5); z-index: 55;
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .sb-overlay.is-open { opacity: 1; pointer-events: auto; }
  .topbar-burger { display: grid; }
  .main { width: 100%; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .flag-grid, .sec-grid, .assign-list { grid-template-columns: 1fr; }
  .perm-tbl .chipbtn { display: none; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .card-pad, .audit-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 540px; }
  .sb-item { padding: 11px 12px; }      /* área táctil mayor */
  .pagetabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .pagetabs button { white-space: nowrap; }
}

/* --- Celular: bandeja de un solo panel (lista <-> chat) --- */
@media (max-width: 760px) {
  .inbox {
    grid-template-columns: 1fr;
    height: calc(100dvh - 120px); min-height: 0;
  }
  .inbox .threads { border-right: none; }
  .inbox.show-chat .threads { display: none; }
  .inbox.show-list .chat,
  .inbox.show-list .inbox-empty { display: none; }
  .chat-back { display: grid; }
  .chat-head .badge { display: none; }   /* el canal ya se ve por contexto */
  .chat-input { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .inbox-accounts { padding-top: 12px; }
}

/* --- Celular chico: ajustes finos + hojas (sheets) --- */
@media (max-width: 560px) {
  .topbar h1 { font-size: 1.02rem; }
  .topbar-actions .badge { display: none; }
  .grid-auto { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .card-head .spacer { margin-left: 0; width: 100%; }
  .twofa-code b { font-size: 1.25rem; }
  .btn { padding: 9px 16px; }            /* objetivos táctiles >= 40px */
  .btn-sm { padding: 7px 13px; }
  /* Modales como hoja inferior, ancho completo */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; width: 100%; max-height: 92dvh;
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  }
  .modal-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
}

/* AGE · bandeja de conversaciones del closer */
.age-conv-grid{display:grid;grid-template-columns:minmax(260px,340px) 1fr;gap:16px;align-items:start}
@media(max-width:900px){.age-conv-grid{grid-template-columns:1fr}}
.age-conv-list{max-height:520px;overflow:auto;display:flex;flex-direction:column}
.age-conv-item{display:flex;flex-direction:column;gap:6px;text-align:left;padding:12px 16px;background:none;border:0;border-top:1px solid var(--line);color:inherit;cursor:pointer;font:inherit}
.age-conv-item:hover{background:var(--surface-2)}
.age-conv-item.on{background:var(--info-bg)}
.age-chat-log{display:flex;flex-direction:column;gap:10px;padding:8px 16px 16px;max-height:420px;overflow:auto}
.age-bubble{max-width:82%;padding:10px 13px;border-radius:14px;border:1px solid var(--line)}
.age-bubble p{margin:0;white-space:pre-wrap;font-size:0.9rem}
.age-bubble span{display:block;margin-top:5px;font-size:0.7rem}
.age-bubble.in{align-self:flex-start;background:var(--surface-2)}
.age-bubble.out{align-self:flex-end;background:var(--info-bg);border-color:rgba(47,95,196,0.22)}
.age-chat-send{display:flex;gap:10px;align-items:flex-end;padding:0 16px 16px;margin-top:auto}
.age-chat-send textarea{flex:1;resize:vertical}

/* Primeros pasos (onboarding) */
.ob-card{border-color:rgba(47,95,196,0.28)}
.ob-bar{height:6px;border-radius:99px;background:var(--surface-2);overflow:hidden;margin-bottom:8px}
.ob-bar span{display:block;height:100%;background:linear-gradient(90deg,var(--magenta,#c0399f),var(--lilac,#9b6be0));transition:width .3s}
.ob-list{display:flex;flex-direction:column;gap:2px;margin-top:14px}
.ob-step{display:flex;align-items:center;gap:12px;padding:11px 0;border-top:1px solid var(--line)}
.ob-step:first-child{border-top:0}
.ob-step .col{flex:1}
.ob-step.done b{opacity:.65}
.ob-tick{width:22px;height:22px;flex:none;border-radius:50%;border:1.5px solid var(--line);display:grid;place-items:center;font-size:0.72rem;font-weight:700}
.ob-step.done .ob-tick{background:var(--ok-bg);color:var(--ok);border-color:transparent}
.ob-reopen{align-self:flex-start;background:var(--info-bg);color:var(--info);border:0;border-radius:99px;padding:7px 14px;font:inherit;font-size:0.78rem;font-weight:600;cursor:pointer}
.ob-reopen:hover{filter:brightness(1.05)}


/* =====================================================================
   DOCUMENTACIÓN · lector interno (módulo documentos.jsx)
   ===================================================================== */
.docu-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }

.docu-list { padding: 8px; max-height: calc(100vh - 210px); overflow-y: auto; }
.docu-group + .docu-group { margin-top: 6px; }
.docu-sec {
  display: block; font-family: var(--font-mono); font-size: 0.62rem; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim);
  padding: 12px 12px 6px;
}
.docu-item {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  padding: 11px 12px; border: 1px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; transition: background .18s, border-color .18s;
}
.docu-item:hover { background: rgba(255,255,255,0.04); }
.docu-item b { font-size: 0.86rem; font-weight: 600; color: var(--text); line-height: 1.25; }
.docu-item span { font-size: 0.74rem; color: var(--text-dim); line-height: 1.45; }
.docu-item.is-active {
  background: linear-gradient(135deg, rgba(92,33,195,0.24), rgba(147,3,197,0.12));
  border-color: rgba(201,168,242,0.32);
}
.docu-item.is-active b { color: #fff; }
.docu-item.is-active span { color: var(--text-soft); }

.docu-view { display: flex; flex-direction: column; overflow: hidden; }
.docu-frame { position: relative; flex: 1; min-height: 0; background: #EEE9F6; }
.docu-frame iframe { display: block; width: 100%; height: calc(100vh - 268px); min-height: 480px; border: 0; }
.docu-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; background: #EEE9F6; z-index: 2;
}

@media (max-width: 1080px) {
  .docu-layout { grid-template-columns: 1fr; }
  .docu-list { max-height: 260px; }
  .docu-frame iframe { height: 70vh; }
}

/* =====================================================================
   MOBILE / iOS · endurecimiento
   ---------------------------------------------------------------------
   Fixes universales para que el CRM se comporte bien en iPhone, iPad,
   Android y también Mac (Safari usa la misma capa WebKit).
   - 100vh no funciona en iOS con la barra de dirección: se usa 100dvh
     (dynamic viewport) con fallback.
   - Inputs con font-size < 16px hacen zoom automático en iOS al focus:
     se fuerzan a 16px en pantallas táctiles.
   - -webkit-tap-highlight-color y touch-action quitan lag y sombras
     azules del tap.
   - env(safe-area-inset-*) respeta el notch/dynamic island.
   ===================================================================== */

/* 1 · Altura de viewport que respeta la barra de dirección iOS. */
.shell { height: 100vh; height: 100dvh; }
.inbox { height: calc(100vh - 140px); height: calc(100dvh - 140px); }
.docu-list { max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); }
.docu-frame iframe { height: calc(100vh - 268px); height: calc(100dvh - 268px); }

/* 2 · Sin lag ni resaltado azul al tocar botones/enlaces en iOS. */
a, button, .btn, .thread, .kcard, .acct-chip, .tab, .chip-user, .docu-item, .conn-card {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 3 · Evita zoom automático de iOS al enfocar inputs: fuerza 16px en
   pantallas táctiles. En desktop se mantiene el tipografía menor. */
@media (max-width: 900px), (pointer: coarse) {
  .input, .select, .textarea, input[type=text], input[type=email], input[type=password],
  input[type=tel], input[type=number], input[type=search], input[type=date],
  input[type=time], input[type=datetime-local], input[type=url], textarea, select {
    font-size: 16px !important;
  }
}

/* 4 · Aspecto consistente de inputs en iOS (sin sombras internas, sin
   redondeo automático). */
input, select, textarea, button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
input[type=checkbox], input[type=radio] { -webkit-appearance: checkbox; appearance: checkbox; }
input[type=radio] { -webkit-appearance: radio; appearance: radio; }

/* 5 · Safe area — respeta el notch en iPhones modernos. */
.topbar { padding-top: max(12px, env(safe-area-inset-top)); }
.sidebar { padding-top: max(22px, env(safe-area-inset-top)); }
.modal-foot { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.chat-input { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

/* 6 · Área táctil mínima recomendada 44x44 (Apple HIG). */
@media (pointer: coarse) {
  .btn-icon { min-width: 40px; min-height: 40px; }
  .thread { min-height: 56px; padding: 10px 14px; }
  .sb-item { min-height: 44px; }
  .tabs button { min-height: 40px; }
}

/* 7 · Overflow horizontal accidental (fuente común en mobile). */
html, body { overflow-x: hidden; }
.card, .card-pad { max-width: 100%; }

/* 8 · Kanban del pipeline: en mobile, columnas más chicas y scroll
   con snap para que sea navegable con el pulgar. */
@media (max-width: 760px) {
  .kanban {
    grid-auto-columns: 82vw;
    scroll-snap-type: x mandatory;
    padding-inline: 2px;
    padding-bottom: 12px;
  }
  .kcol { scroll-snap-align: start; }
}

/* 9 · Firma digital (canvas): evita que el scroll interfiera con el
   trazo en iOS. */
canvas { touch-action: none; }

/* 10 · Iframes: en iOS necesitan `-webkit-overflow-scrolling: touch`
   dentro del wrapper, no sobre el iframe, para el scroll natural. */
.docu-frame, .an-map { -webkit-overflow-scrolling: touch; }

/* 11 · Dropdown de notificaciones: en pantallas muy chicas se pega
   al borde derecho y ocupa 92vw. */
@media (max-width: 480px) {
  .topbar-actions > div > div[style*="position: absolute"] {
    right: -8px !important;
    width: 92vw !important;
    max-width: 360px !important;
  }
}

/* 12 · Bandeja del mail — el HTML del cuerpo puede tener anchos fijos
   que rompan en mobile. El iframe ya está en 100% pero conviene forzar
   que su contenedor no crezca más allá del msg. */
.msg iframe { max-width: 100%; }

/* 13 · Modales — ya se convierten en bottom sheet abajo de 560px.
   Refuerzo el scroll interno del body del modal en iOS y uso dvh en la
   altura máxima para que respete la barra dinámica. */
.modal-body { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal { max-height: 86vh; max-height: 86dvh; }
.modal-backdrop { padding: max(7vh, env(safe-area-inset-top)) 20px 20px; }
@media (max-width: 560px) {
  .modal { max-height: 92vh; max-height: 92dvh; }
}

/* 14 · Tablas responsivas — en móvil se scrollean horizontalmente
   dentro de su contenedor. */
@media (max-width: 760px) {
  .card > .tbl, .card-pad > .tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}

