/* ===========================================================
   JorSegui — Panel Backstagge (glass)
   Design tokens portados desde backstagge-sistema
   =========================================================== */

:root {
  --cream: #fff0e0;
  --cream-2: #fff7ec;
  --ink: #33281b;
  --ink-soft: #5a4a37;
  --ink-soft-2: #7a664e;
  --red: #d12123;
  --red-l: #e6494c;
  --red-d: #a91a1c;
  --brown: #765f42;
  --brown-l: #8e7554;
  --sage: #9fbfa0;
  --line: rgba(51, 40, 27, 0.10);
  --line-soft: rgba(51, 40, 27, 0.06);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-brd: rgba(51, 40, 27, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 8px 24px -14px rgba(51, 40, 27, 0.35);
  --shadow-2: 0 22px 44px -22px rgba(51, 40, 27, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 100% 0%, #ffe6c8 0%, transparent 55%),
    radial-gradient(1000px 700px at 0% 100%, #ffd6c0 0%, transparent 60%),
    var(--cream);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* -----------------------------------------------------------
   Glass primitive
   ----------------------------------------------------------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

/* -----------------------------------------------------------
   App shell
   ----------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-strong);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-right: 1px solid var(--glass-brd);
  z-index: 20;
}

.sidebar-head {
  padding: 1.4rem 1.4rem 1.1rem;
}

.wordmark {
  font-family: 'Sacramento', 'Brush Script MT', cursive;
  font-size: 2.1rem;
  line-height: 1;
  color: var(--red);
  letter-spacing: 0.5px;
}

.brand-sub {
  margin-top: 0.35rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--ink-soft-2);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.4rem 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.section-label {
  padding: 1.1rem 0.8rem 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brown);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
}
.nav-link svg { flex-shrink: 0; opacity: 0.8; }
.nav-link[data-active] {
  background: linear-gradient(180deg, var(--red-l), var(--red) 60%, var(--red-d));
  color: #fff5ee;
  box-shadow: 0 12px 26px -14px rgba(209, 33, 35, 0.6);
}
.nav-link[data-active] svg { opacity: 1; }

.sidebar-foot {
  padding: 0.8rem 1rem 1rem;
  border-top: 1px solid var(--line-soft);
}
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(209, 33, 35, 0.08); color: var(--red-d); border-color: var(--red-l); }

/* -----------------------------------------------------------
   Main content
   ----------------------------------------------------------- */
.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.6rem;
  background: rgba(255, 240, 224, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-brd);
}
.page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.topbar-status { display: flex; align-items: center; gap: 0.7rem; }

.app-content {
  padding: 1.4rem 1.6rem 2.5rem;
  max-width: 1280px;
  width: 100%;
}

/* -----------------------------------------------------------
   Mobile burger + off-canvas
   ----------------------------------------------------------- */
.burger {
  display: none;
  position: fixed;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  color: var(--ink);
  cursor: pointer;
}
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(51, 40, 27, 0.35);
  backdrop-filter: blur(4px);
  z-index: 25;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    z-index: 30;
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  .burger { display: grid; place-items: center; }
  .mobile-overlay[style*="display: block"],
  .mobile-overlay[style*="display:block"] { display: block !important; }
  .app-topbar { padding-left: 4rem; }
  .app-content { padding: 1rem 1rem 2rem; }
}

/* -----------------------------------------------------------
   Card / grid / kpi
   ----------------------------------------------------------- */
.card {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-1);
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.kpi { padding: 1rem 1.1rem; }
.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brown);
}
.kpi-value {
  margin-top: 0.35rem;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.kpi-sub {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--ink-soft-2);
}

/* -----------------------------------------------------------
   Pills, badges, buttons
   ----------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill-ok { background: rgba(159, 191, 160, 0.28); color: #3e6b40; border: 1px solid rgba(63, 107, 65, 0.25); }
.pill-warn { background: rgba(255, 199, 122, 0.28); color: #8a5a1b; border: 1px solid rgba(150, 100, 30, 0.25); }
.pill-err { background: rgba(209, 33, 35, 0.15); color: var(--red-d); border: 1px solid rgba(209, 33, 35, 0.25); }
.pill-muted { background: rgba(51, 40, 27, 0.08); color: var(--ink-soft); border: 1px solid var(--line); }

.badge-hot { background: linear-gradient(180deg, #ff7549, #d12123); color: #fff; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-warm { background: linear-gradient(180deg, #ffb26b, #e6884a); color: #fff; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-cold { background: #a9b8b0; color: #fff; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-dead { background: #786d5f; color: #fff; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

.stage-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(51, 40, 27, 0.08);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn, button:not(.btn-logout):not(.btn-primary):not(.burger) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.15s;
}
.btn:hover, button:not(.btn-logout):not(.btn-primary):not(.burger):hover { box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(180deg, var(--red-l), var(--red) 60%, var(--red-d));
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.05s, filter 0.15s;
  box-shadow: 0 12px 24px -14px rgba(209, 33, 35, 0.55);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }

/* -----------------------------------------------------------
   Forms
   ----------------------------------------------------------- */
label { display: block; margin-bottom: 0.6rem; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
label > span { display: block; margin-bottom: 0.3rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], textarea, select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--red-l);
  box-shadow: 0 0 0 3px rgba(209, 33, 35, 0.15);
}
textarea { min-height: 90px; resize: vertical; }

/* -----------------------------------------------------------
   Tables
   ----------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
th, td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { font-weight: 700; color: var(--brown); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.08em; }
tr:hover td { background: rgba(255, 255, 255, 0.4); }

/* -----------------------------------------------------------
   Priority / Insights / Conversation
   ----------------------------------------------------------- */
.priority-list { display: flex; flex-direction: column; gap: 0.9rem; }
.priority-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 1.1rem;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.priority-score {
  display: grid;
  place-items: center;
  padding: 0.7rem 0.4rem;
  background: linear-gradient(180deg, var(--red-l), var(--red-d));
  color: #fff;
  border-radius: var(--radius-sm);
  min-height: 68px;
}
.priority-score .n { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.priority-score .lbl { font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 0.2rem; opacity: 0.9; }
.priority-body h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.priority-signal { padding: 0.55rem 0.75rem; margin-top: 0.55rem; border-radius: var(--radius-sm); background: rgba(209, 33, 35, 0.08); border: 1px solid rgba(209, 33, 35, 0.18); font-size: 0.85rem; color: var(--red-d); }

.insight-card { padding: 1rem 1.2rem; }
.insight-title { font-weight: 700; color: var(--ink); }
.insight-desc { color: var(--ink-soft); margin-top: 0.25rem; font-size: 0.9rem; }

.conv-list { display: flex; flex-direction: column; gap: 0.5rem; }
.conv-msg { padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.9rem; max-width: 85%; }
.conv-in { background: rgba(255, 255, 255, 0.7); align-self: flex-start; }
.conv-out { background: linear-gradient(180deg, var(--red-l), var(--red)); color: #fff; align-self: flex-end; }

.last-msg {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--ink-soft);
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  margin-top: 0.4rem;
}

/* -----------------------------------------------------------
   Heatmap / Funnel bars
   ----------------------------------------------------------- */
.heatmap-cell { display: inline-block; width: 22px; height: 22px; border-radius: 4px; margin: 1px; }
.funnel-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0; }
.funnel-bar .label { flex: 0 0 140px; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.funnel-bar .track { flex: 1; height: 10px; background: rgba(51, 40, 27, 0.08); border-radius: 999px; overflow: hidden; }
.funnel-bar .fill { height: 100%; background: linear-gradient(90deg, var(--red-l), var(--red-d)); border-radius: 999px; }
.funnel-bar .val { flex: 0 0 auto; font-weight: 700; color: var(--ink); font-size: 0.85rem; min-width: 40px; text-align: right; }

/* -----------------------------------------------------------
   Auth page (login)
   ----------------------------------------------------------- */
body.auth-page {
  display: grid;
  place-items: center;
  padding: 2rem;
}
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card {
  padding: 2rem 1.8rem 1.6rem;
  text-align: center;
}
.auth-card .wordmark { font-size: 2.6rem; }
.auth-card .brand-sub { margin-bottom: 1.4rem; }
.auth-brand { margin-bottom: 0.4rem; }
.auth-error {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(209, 33, 35, 0.12);
  color: var(--red-d);
  border: 1px solid rgba(209, 33, 35, 0.25);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.auth-form label span { text-align: left; }
.auth-form input { text-align: left; }
.auth-form .btn-primary { width: 100%; margin-top: 0.4rem; }
.auth-foot {
  margin-top: 1.2rem;
  font-size: 0.72rem;
  color: var(--ink-soft-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* -----------------------------------------------------------
   Utilities
   ----------------------------------------------------------- */
.muted { color: var(--ink-soft-2); }
.small { font-size: 0.82rem; }
.mono { font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap-1 { gap: 0.5rem; }
.flex-gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-red { color: var(--red-d); }
.text-brown { color: var(--brown); }

[x-cloak] { display: none !important; }
