/* ============================================================
   CRM RSI México — Sistema de diseño
   Identidad: rojo RSI, blanco, tarjetas redondeadas, aire.
   ============================================================ */
:root {
  --rsi-red: #d81f2a;
  --rsi-red-dark: #b3161f;
  --rsi-red-soft: #fdecee;
  --ink: #1e2430;
  --ink-2: #5a6472;
  --ink-3: #6b7480; /* AA 4.6:1 sobre blanco (antes #98a1ad daba 2.6:1) */
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e8eaee;
  --green: #16a34a; --green-soft: #e8f7ee;
  --amber: #d97706; --amber-soft: #fdf3e3;
  --blue: #2563eb;  --blue-soft: #e9f0fe;
  --purple: #7c3aed; --purple-soft: #f1ebfd;
  --gray-soft: #eef0f3;
  --radius: 18px;
  --shadow: 0 1px 3px rgba(20, 26, 40, .06), 0 8px 24px -12px rgba(20, 26, 40, .12);
  --shadow-lg: 0 24px 48px -16px rgba(20, 26, 40, .22);
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 14.5px; line-height: 1.5; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0;
  z-index: 40; transition: transform .25s ease;
}
.main { flex: 1; margin-left: 232px; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px 28px 90px; max-width: 1440px; width: 100%; margin: 0 auto; }

.brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px;
}
.brand-logo {
  background: var(--rsi-red); color: #fff; font-weight: 800; font-style: italic;
  border-radius: 10px; padding: 7px 13px; font-size: 19px; letter-spacing: .5px;
  box-shadow: 0 6px 14px -6px rgba(216, 31, 42, .6);
}
.brand small { display: block; color: var(--ink-3); font-size: 10.5px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; }
.brand strong { font-size: 14px; }

.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); margin: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 500; font-size: 13.5px; margin-bottom: 2px;
  transition: all .15s;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: var(--gray-soft); color: var(--ink); }
.nav a.active { background: var(--rsi-red-soft); color: var(--rsi-red); font-weight: 600; }
.nav a .pill { margin-left: auto; }

.sidebar-user {
  border-top: 1px solid var(--line); padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--rsi-red);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.avatar.gray { background: var(--ink-3); }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { font-size: 11.5px; color: var(--ink-3); }
.sidebar-user > a svg { width: 18px; height: 18px; display: block; }

/* topbar */
.topbar {
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 12px 28px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; background: var(--gray-soft);
  border: 1px solid transparent; border-radius: 11px; padding: 6px 12px;
  color: var(--ink-3); font-size: 12.5px; min-width: 170px;
}
.search-trigger svg { width: 15px; height: 15px; flex-shrink: 0; }
.search-trigger:hover { border-color: var(--line); background: #fff; }
.search-trigger kbd {
  margin-left: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; font-size: 10.5px; font-family: inherit; color: var(--ink-3);
}
.hamburger { display: none; background: none; border: 0; padding: 6px; }
.hamburger svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------- componentes */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid rgba(232,234,238,.6);
}
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 svg { width: 17px; height: 17px; color: var(--rsi-red); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 12px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; transition: all .15s;
  background: var(--gray-soft); color: var(--ink);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { filter: brightness(.96); transform: translateY(-1px); }
.btn-red { background: var(--rsi-red); color: #fff; box-shadow: 0 6px 16px -6px rgba(216,31,42,.55); }
.btn-red:hover { background: var(--rsi-red-dark); }
.btn-outline { background: #fff; border: 1.5px solid var(--line); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-wa { background: #22c55e; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 99px;
  padding: 3px 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill-gray  { background: var(--gray-soft); color: var(--ink-2); }
.pill-red   { background: var(--rsi-red-soft); color: var(--rsi-red); }
.pill-green { background: var(--green-soft); color: #15733a; } /* texto AA sobre fondo soft */
.pill-amber { background: var(--amber-soft); color: #92500a; }
.pill-blue  { background: var(--blue-soft); color: var(--blue); }
.pill-purple{ background: var(--purple-soft); color: var(--purple); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* formularios */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 9px 12px;
  background: #fff; color: var(--ink); transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--rsi-red);
  box-shadow: 0 0 0 3px rgba(216,31,42,.1);
}
.field textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }

/* tablas */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; background: var(--card); }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #fafbfc; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* flashes */
.flashes { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.flash {
  background: var(--ink); color: #fff; border-radius: 13px; padding: 12px 18px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: slideIn .3s ease;
  display: flex; gap: 9px; align-items: flex-start;
}
.flash.ok { background: var(--green); }
.flash.error { background: var(--rsi-red); }
.flash.warning { background: var(--amber); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* page header */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 700; }
.page-head .spacer { flex: 1; }
.page-head p.sub { width: 100%; color: var(--ink-2); font-size: 13px; margin-top: -6px; }

/* filtros */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input, .filters select {
  border: 1.5px solid var(--line); border-radius: 11px; padding: 8px 12px; background: #fff;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--rsi-red); }

/* ---------------------------------------------------------- dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  border: 1px solid rgba(232,234,238,.6);
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--rsi-red));
}
.kpi .kpi-label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .8px; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .kpi-foot { font-size: 12px; color: var(--ink-2); }
.kpi.red { --accent: var(--rsi-red); }
.kpi.green { --accent: var(--green); }
.kpi.blue { --accent: var(--blue); }
.kpi.amber { --accent: var(--amber); }
.kpi.purple { --accent: var(--purple); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.chart-box { position: relative; height: 240px; }

.insight {
  display: flex; gap: 12px; padding: 12px 14px; border-radius: 13px; background: var(--bg);
  margin-bottom: 9px; align-items: flex-start; transition: all .15s; border: 1px solid transparent;
}
.insight:hover { border-color: var(--line); background: #fff; box-shadow: var(--shadow); }
.insight .ico {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 15px;
}
.insight p { font-size: 12.8px; color: var(--ink-2); }
.insight.hot .ico { background: var(--rsi-red-soft); }
.insight.win .ico { background: var(--green-soft); }
.insight.warn .ico { background: var(--amber-soft); }
.insight.mail .ico { background: var(--blue-soft); }
.insight.clock .ico { background: var(--purple-soft); }

.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px;
  font-size: 13px; transition: background .12s;
}
.mini-item:hover { background: var(--bg); }
.mini-item .grow { flex: 1; min-width: 0; }
.mini-item .grow b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .grow span { font-size: 11.5px; color: var(--ink-3); }
.mini-item .when { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

/* ---------------------------------------------------------- kanban */
.kanban {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px;
  align-items: flex-start; scroll-snap-type: x proximity;
}
.kcol {
  min-width: 264px; width: 264px; flex-shrink: 0; background: var(--gray-soft);
  border-radius: var(--radius); padding: 12px; scroll-snap-align: start;
}
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 2px 6px 10px; }
.kcol-head b { font-size: 13px; }
.kcol-head .count { margin-left: auto; }
.kcol-head .sum { font-size: 11px; color: var(--ink-3); display: block; }
.kcol-body { min-height: 60px; display: flex; flex-direction: column; gap: 9px; }
.kcol.drag-over { outline: 2px dashed var(--rsi-red); outline-offset: -4px; background: var(--rsi-red-soft); }
.kcard {
  background: #fff; border-radius: 13px; padding: 12px 13px; box-shadow: var(--shadow);
  cursor: grab; transition: transform .12s, box-shadow .12s; border: 1px solid rgba(232,234,238,.6);
}
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kcard.dragging { opacity: .45; transform: rotate(2deg); }
.kcard b { font-size: 13px; display: block; margin-bottom: 3px; line-height: 1.35; }
.kmove {
  background: #fff; border: 1.5px solid var(--line); border-radius: 8px;
  width: 28px; height: 26px; color: var(--ink-2); font-size: 13px; line-height: 1;
  flex-shrink: 0; padding: 0;
}
.kmove:hover { border-color: var(--rsi-red); color: var(--rsi-red); }
.move-list { display: grid; gap: 8px; }
.kcard .kmeta { font-size: 11.5px; color: var(--ink-3); display: block; margin-bottom: 8px; }
.kcard .kfoot { display: flex; align-items: center; gap: 7px; }
.kcard .kamount { font-weight: 700; font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
.prob-bar { height: 4px; border-radius: 4px; background: var(--gray-soft); margin-top: 9px; overflow: hidden; }
.prob-bar i { display: block; height: 100%; border-radius: 4px; background: var(--rsi-red); }

/* ---------------------------------------------------------- contacto 360 */
.profile-head {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
}
.avatar-xl { width: 62px; height: 62px; font-size: 21px; border-radius: 18px; }
.profile-head .info { flex: 1; min-width: 200px; }
.profile-head .info h2 { font-size: 20px; }
.profile-head .info p { color: var(--ink-2); font-size: 13px; }
.profile-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-360 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin-top: 16px; }
.datalist { display: grid; gap: 9px; }
.datalist .row { display: flex; gap: 10px; font-size: 13px; }
.datalist .row b { color: var(--ink-3); font-weight: 600; min-width: 110px; font-size: 12px; }
.datalist .row span { word-break: break-word; }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ""; position: absolute; left: -24px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 3px solid var(--rsi-red);
}
.tl-item.email::before { border-color: var(--blue); }
.tl-item.event::before { border-color: var(--purple); }
.tl-item .tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 3px; }
.tl-item .tl-head b { font-size: 13px; }
.tl-item .tl-head time { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.tl-item p { font-size: 12.8px; color: var(--ink-2); white-space: pre-line; }
.tl-item .next { margin-top: 6px; font-size: 12px; background: var(--amber-soft); color: var(--amber); border-radius: 8px; padding: 4px 10px; display: inline-block; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-3); border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--rsi-red); border-color: var(--rsi-red); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

/* ---------------------------------------------------------- cotizador */
.q-items { width: 100%; }
.q-items th { font-size: 10.5px; }
.q-items td { padding: 7px 6px; }
.q-items input { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.q-items input:focus { outline: none; border-color: var(--rsi-red); }
.q-items .num-in { width: 84px; text-align: right; }
.totals { margin-left: auto; width: 280px; display: grid; gap: 6px; font-size: 13.5px; }
.totals .trow { display: flex; justify-content: space-between; }
.totals .trow.grand { font-size: 17px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 4px; }
.autocomplete { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; max-height: 260px; overflow-y: auto;
}
.ac-item { padding: 9px 13px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.ac-item:hover, .ac-item.sel { background: var(--rsi-red-soft); }
.ac-item .grow { flex: 1; min-width: 0; }
.ac-item b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item span { font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------------------------------------- inbox */
.mail-row { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); align-items: center; transition: background .12s; }
.mail-row:hover { background: #fafbfc; }
.mail-row.unread { background: #fff; }
.mail-row.unread .subj { font-weight: 700; }
.mail-row .grow { flex: 1; min-width: 0; }
.mail-row .subj { font-size: 13.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row .snippet { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.mail-row time { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.ai-badge {
  background: linear-gradient(135deg, var(--rsi-red), #f97316); color: #fff;
  border-radius: 99px; padding: 3px 10px; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px; box-shadow: 0 4px 10px -4px rgba(216,31,42,.5);
}
.mail-body { white-space: pre-line; font-size: 13.8px; color: var(--ink); line-height: 1.65; }

/* ---------------------------------------------------------- calendario */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--ink-3); text-align: center; padding: 6px 0; }
.cal-day {
  background: var(--card); border-radius: 12px; min-height: 96px; padding: 7px;
  border: 1px solid var(--line); font-size: 12px;
}
.cal-day.other { opacity: .38; }
.cal-day.today { border-color: var(--rsi-red); border-width: 2px; }
.cal-day .dnum { font-weight: 700; font-size: 12px; margin-bottom: 4px; display: inline-block; }
.cal-day.today .dnum { background: var(--rsi-red); color: #fff; border-radius: 7px; padding: 1px 7px; }
.cal-ev {
  display: block; background: var(--rsi-red-soft); color: var(--rsi-red); border-radius: 7px;
  padding: 3px 7px; margin-bottom: 3px; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-ev.google { background: var(--blue-soft); color: var(--blue); }
.cal-ev.task { background: var(--amber-soft); color: #92500a; }   /* tareas con vencimiento */
.cal-ev.task.overdue { background: var(--rsi-red-soft); color: var(--rsi-red); }
.cal-ev.done { opacity: .6; text-decoration: line-through; }

/* Safari: normalizar la apariencia de los <select> nativos para que el desplegable
   no quede "estorbando" y respete el estilo del CRM (appearance + flecha propia). */
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%235a6472' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 26px;
}

/* ---------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(216,31,42,.16), transparent),
              radial-gradient(900px 500px at -10% 110%, rgba(216,31,42,.12), transparent), var(--bg);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 26px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 880px; display: grid; grid-template-columns: 1.1fr 1fr; overflow: hidden;
}
.login-hero {
  background: linear-gradient(160deg, var(--rsi-red) 0%, #a01018 100%);
  color: #fff; padding: 44px 40px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%;
  border: 50px solid rgba(255,255,255,.08); right: -120px; bottom: -120px;
}
.login-hero h1 { font-size: 27px; line-height: 1.25; margin: 18px 0 10px; }
.login-hero p { opacity: .85; font-size: 13.5px; }
.login-hero ul { list-style: none; margin-top: 22px; display: grid; gap: 10px; font-size: 13px; z-index: 1; }
.login-hero li { display: flex; gap: 9px; align-items: center; }
.login-form { padding: 44px 38px; }
.login-form h2 { font-size: 20px; margin-bottom: 4px; }
.login-form > p { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.demo-users { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; display: grid; gap: 7px; }
.demo-users button {
  display: flex; gap: 9px; align-items: center; background: var(--bg); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 12px; font-size: 12.5px; text-align: left; width: 100%;
}
.demo-users button:hover { border-color: var(--rsi-red); background: var(--rsi-red-soft); }
.demo-users b { font-size: 12.5px; display: block; }
.demo-users span { color: var(--ink-3); font-size: 11px; }

/* ---------------------------------------------------------- command palette */
.palette-overlay {
  position: fixed; inset: 0; background: rgba(20,26,40,.45); backdrop-filter: blur(3px);
  z-index: 90; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 0;
}
.palette-overlay.open { display: flex; }
.palette {
  background: #fff; border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: popIn .18s ease;
}
@keyframes popIn { from { transform: scale(.97) translateY(-8px); opacity: 0; } }
.palette input {
  width: 100%; border: 0; padding: 17px 20px; font-size: 15.5px; border-bottom: 1px solid var(--line);
}
.palette input:focus { outline: none; }
.palette .results { max-height: 340px; overflow-y: auto; padding: 8px; }
.palette .hint { padding: 14px 20px; font-size: 12.5px; color: var(--ink-3); }

/* ---------------------------------------------------------- modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,26,40,.45); z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); width: 100%;
  max-width: 480px; padding: 24px; max-height: 90vh; overflow-y: auto; animation: popIn .18s;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }

/* ---------------------------------------------------------- misc */
a:focus-visible, button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--rsi-red); outline-offset: 2px;
}
/* celda de precio con candado visible (precio bloqueado para el comercial) */
.price-cell { position: relative; display: flex; align-items: center; }
.price-lock { position: absolute; right: 6px; font-size: 12px; pointer-events: none; opacity: .8; }
.price-cell input[readonly] { padding-right: 22px; background: var(--gray-soft); cursor: not-allowed; }
.cal-agenda { display: none; }
.task-check { width: 26px; height: 26px; border-radius: 8px; position: relative; flex-shrink: 0; padding: 0; }
.task-check::after { content: ""; position: absolute; inset: -10px; } /* hit-area táctil ~46px */
/* renglón propuesto por el asistente de cotización */
.q-items tr.proposed { background: var(--rsi-red-soft); }
.q-items tr.proposed .desc { border-color: var(--rsi-red); }
/* selects tipo pill (cambio de etapa en línea) */
.pill-select { border: 1.5px solid var(--line); border-radius: 99px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 600; background: #fff; color: var(--ink-2); }
.pill-select:focus-visible { outline: 2px solid var(--rsi-red); outline-offset: 2px; border-color: var(--rsi-red); }
.empty {
  text-align: center; padding: 44px 20px; color: var(--ink-3);
}
.empty svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: .5; }
.sap-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-ring { font-variant-numeric: tabular-nums; }

/* bottom nav móvil */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line); z-index: 50; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 600; color: var(--ink-3); padding: 4px 0; border-radius: 10px;
}
.bottom-nav a svg { width: 21px; height: 21px; }
.bottom-nav a.active { color: var(--rsi-red); }
.fab {
  position: fixed; right: 18px; bottom: 76px; width: 54px; height: 54px; border-radius: 18px;
  background: var(--rsi-red); color: #fff; display: none; align-items: center; justify-content: center;
  box-shadow: 0 12px 24px -8px rgba(216,31,42,.6); z-index: 49;
}
.fab svg { width: 24px; height: 24px; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .dash-grid, .grid-360 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .search-trigger { min-width: 0; flex: 0 0 auto; }
  .search-trigger .label, .search-trigger kbd { display: none; }
  .content { padding: 16px 14px 110px; }
  .topbar { padding: 10px 14px; }
  .bottom-nav { display: flex; }
  .fab { display: flex; }
  .login-card { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .kpi .kpi-value { font-size: 22px; }
  .totals { width: 100%; }
  /* iOS zoomea inputs <16px al enfocar */
  input, select, textarea, .q-items input, .palette input { font-size: 16px; }
  .cal-grid, .cal-legend { display: none; }
  .cal-agenda { display: block; }

  /* Cotizador móvil (RF-023): cada renglón se apila como tarjeta en vez de
     tabla con scroll horizontal. Descripción full-width; el resto en 2 columnas. */
  .q-items, .q-items tbody, .q-items tr, .q-items td { display: block; width: 100%; }
  .q-items thead { display: none; }
  .q-items tr {
    border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 10px;
    margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  }
  .q-items td { padding: 0; }
  .q-items td[data-label="Descripción"] { grid-column: 1 / -1; }
  .q-items td[data-label]::before {
    content: attr(data-label); display: block; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); margin-bottom: 2px;
  }
  .q-items td[data-label="Descripción"]::before,
  .q-items td[data-label=""]::before { content: none; }
  .q-items .num-in { width: 100%; }
  .q-items td[data-label=""] { grid-column: 1 / -1; text-align: right; }

  /* Tablas-lista como tarjetas en móvil (socios, etc.): cada fila se apila
     con su etiqueta de columna, sin scroll horizontal ni truncado. */
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards thead { display: none; }
  .tbl-cards tr {
    border-bottom: 1px solid var(--line); padding: 12px 14px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: start;
  }
  .tbl-cards td { padding: 0; border: 0; }
  .tbl-cards td.cell-title { grid-column: 1 / -1; }
  .tbl-cards td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); margin-bottom: 2px;
  }
}

/* print — cotización PDF-ready */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-sheet { box-shadow: none !important; border: 0 !important; }
}
