/* Muñiz Automations — Internal CRM
   Spotify-style layout, Muñiz brand palette (from the public site's dark theme).
   Brand: blue #69b6ef primary accent, orange #f1865d secondary. No third-party assets. */
:root {
  --bg: #0e141b;
  --surface: #151e28;
  --surface-2: #1d2935;
  --surface-3: #243344;
  --line: #314252;
  --ink: #edf5fb;
  --muted: #b2c2d1;
  --faint: #7d93a6;
  --brand: #69b6ef;        /* primary accent — Muñiz blue */
  --brand-deep: #3d9be9;
  --brand-soft: #15334a;   /* blue tint for soft fills */
  --accent: #f1865d;       /* secondary accent — Muñiz orange */
  --accent-soft: #3a2417;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --font-body: "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --font-head: "Manrope", "DM Sans", -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  min-width: 320px;
}
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.03em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::placeholder { color: var(--faint); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 248px; flex: 0 0 auto; position: sticky; top: 0; height: 100vh;
  background: #0b1118; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.side-mark {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #08131d; font-family: var(--font-head); font-weight: 800; font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
}
.side-name { font-family: var(--font-head); font-weight: 800; font-size: .98rem; letter-spacing: -.02em; }
.side-sub { color: var(--faint); font-size: .78rem; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 11px 12px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: background .15s, color .15s; text-align: left;
}
.nav-item svg { width: 21px; height: 21px; flex: 0 0 auto; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); }
.nav-item.active svg { color: var(--brand); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 4px; }
.user-badge {
  font-size: .8rem; color: var(--faint); padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3.5vw, 44px) 80px; max-width: 1280px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.view-sub { color: var(--muted); margin: 6px 0 0; }

/* ---------- buttons / inputs ---------- */
.btn-accent {
  background: var(--brand); color: #08131d; border: 0; border-radius: 999px;
  padding: 10px 20px; font-weight: 700; cursor: pointer; transition: filter .15s, transform .15s;
  white-space: nowrap;
}
.btn-accent:hover { filter: brightness(1.12); transform: scale(1.02); }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
.icon-btn {
  background: var(--surface-2); border: 0; color: var(--muted); width: 34px; height: 34px;
  border-radius: 50%; font-size: 1.2rem; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-3); }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 9px; color: var(--ink); cursor: pointer; }
label.check input { width: auto; }
.form { display: flex; flex-direction: column; gap: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 1.05rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  transition: transform .15s;
}
.kpi:hover { transform: translateY(-2px); }
.kpi .v { font-family: var(--font-head); font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.kpi .l { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.kpi.hot .v { color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chip {
  font-size: .74rem; font-weight: 600; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.muted { color: var(--muted); }
.hint { color: var(--faint); font-size: .82rem; }
.empty { color: var(--faint); padding: 18px 4px; font-size: .92rem; }

/* ---------- funnel ---------- */
.funnel-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.funnel-row .name { width: 108px; flex: 0 0 auto; font-size: .88rem; color: var(--muted); }
.funnel-track { flex: 1; height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand-deep), var(--brand)); transition: width .4s ease; }
.funnel-row.closed .funnel-bar { background: var(--faint); }
.funnel-row .n { width: 34px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- A/B test ---------- */
.ab-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ab-row:last-of-type { border-bottom: 0; }
.ab-subj { font-weight: 600; }
.ab-subj .tag { display: inline-block; font-size: .72rem; font-weight: 800; border-radius: 6px; padding: 2px 8px; margin-right: 8px; vertical-align: 1px; }
.tag.a { background: var(--brand-soft); color: var(--brand); }
.tag.b { background: var(--accent-soft); color: var(--accent); }
.ab-stats { display: flex; gap: 18px; text-align: right; }
.ab-stats .big { font-family: var(--font-head); font-size: 1.5rem; font-weight: 800; }
.ab-stats .cap { font-size: .74rem; color: var(--faint); }
.ab-note { margin-top: 10px; }

/* ---------- touch types ---------- */
.tt-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.tt-row .name { width: 130px; flex: 0 0 auto; font-size: .88rem; color: var(--muted); text-transform: capitalize; }
.tt-row .n { width: 30px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- track-list table ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 240px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.toolbar .search input { padding-left: 36px; }
.toolbar select { width: auto; flex: 0 1 170px; }
.table-card { padding: 8px; overflow-x: auto; }
table.tracks { width: 100%; border-collapse: collapse; min-width: 860px; }
.tracks th {
  text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tracks th.sortable { cursor: pointer; user-select: none; }
.tracks th.sortable:hover { color: var(--brand); }
.tracks th .sort-ind { font-size: .7rem; }
.tracks td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tracks tbody tr { transition: background .12s; cursor: pointer; }
.tracks tbody tr:hover { background: var(--surface-2); }
.tracks tbody tr:last-child td { border-bottom: 0; }
.tracks td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tracks th.num { text-align: right; }
.biz-name { font-weight: 700; }
.biz-sub { font-size: .8rem; color: var(--faint); }
.stage-pill {
  display: inline-block; font-size: .76rem; font-weight: 700; border-radius: 999px;
  padding: 3px 11px; white-space: nowrap; border: 1px solid transparent;
}
.st-draft { background: var(--surface-3); color: var(--muted); }
.st-approved { background: var(--brand-soft); color: var(--brand); }
.st-sent { background: var(--brand); color: #08131d; }
.st-replied { background: rgba(105,182,239,.18); color: #8dccfa; border-color: rgba(105,182,239,.4); }
.st-demo-booked { background: var(--accent-soft); color: var(--accent); border-color: rgba(241,134,93,.4); }
.st-customer { background: var(--accent); color: #1d1008; }
.st-unsubscribed, .st-suppressed { background: transparent; color: var(--faint); border-color: var(--line); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(258px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 16px; align-items: start; }
.kcol { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 70vh; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.kcol-head h3 { font-size: .92rem; display: flex; align-items: center; gap: 8px; }
.kcol-head .count { background: var(--surface-3); border-radius: 999px; font-size: .76rem; font-weight: 700; padding: 1px 9px; color: var(--muted); }
.kcol-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; min-height: 80px; }
.kcol.drag-over .kcol-body { background: var(--brand-soft); border-radius: 0 0 var(--radius) var(--radius); }
.kcard {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  cursor: grab; transition: transform .12s, border-color .12s;
}
.kcard:hover { border-color: var(--brand); transform: translateY(-1px); }
.kcard.dragging { opacity: .45; cursor: grabbing; }
.kcard .t { font-weight: 700; font-size: .93rem; margin-bottom: 6px; }
.kcard .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 2px; }

/* ---------- feed / timeline ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover .feed-biz { color: var(--brand); }
.feed-ic {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--brand); font-weight: 800; font-size: .8rem;
}
.feed-ic.reply, .feed-ic.demo { background: var(--accent-soft); color: var(--accent); }
.feed-biz { font-weight: 700; }
.feed-sum { color: var(--muted); font-size: .9rem; }
.feed-date { color: var(--faint); font-size: .8rem; margin-left: auto; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }

/* ---------- drawer (record detail) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 8, 12, .66); z-index: 50; display: flex; justify-content: flex-end; }
.overlay.hidden { display: none; }
.drawer {
  width: min(560px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 26px 26px 60px; position: relative; animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.drawer-close { position: absolute; top: 16px; right: 16px; }
.rec-head h2 { font-size: 1.45rem; padding-right: 40px; }
.rec-head .sub { color: var(--muted); margin-top: 4px; }
.path { display: flex; gap: 4px; margin: 18px 0 6px; flex-wrap: wrap; }
.path-step {
  flex: 1 1 0; min-width: 70px; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; padding: 8px 6px; font-size: .74rem; font-weight: 700; color: var(--muted);
  cursor: pointer; text-align: center; transition: all .12s;
}
.path-step:hover { border-color: var(--brand); color: var(--ink); }
.path-step.done { background: var(--brand-soft); border-color: var(--brand-deep); color: var(--brand); }
.path-step.current { background: var(--brand); border-color: var(--brand); color: #08131d; }
.path-closed { display: flex; gap: 8px; margin-top: 8px; }
.path-closed .path-step { flex: 0 1 auto; padding: 7px 14px; }
.path-closed .path-step.current { background: var(--surface-3); border-color: var(--faint); color: var(--ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; }
.tab2 { background: none; border: 0; color: var(--muted); font-weight: 700; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab2.active { color: var(--ink); border-bottom-color: var(--brand); }
.tab2:hover { color: var(--ink); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.kv .k { font-size: .76rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-weight: 600; margin-top: 2px; word-break: break-word; }
.hook {
  background: var(--accent-soft); border: 1px solid rgba(241,134,93,.35); border-radius: 10px;
  padding: 14px 16px; margin: 16px 0; font-style: italic;
}
.hook .src { font-style: normal; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.hook-label { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-style: normal; display: block; margin-bottom: 6px; }
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 9px 0; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 14px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); border: 2px solid var(--surface);
}
.tl-item.reply::before, .tl-item.demo::before { background: var(--accent); }
.tl-item .t { font-weight: 700; text-transform: capitalize; }
.tl-item .d { font-size: .8rem; color: var(--faint); }
.note-item { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.note-item .d { font-size: .78rem; color: var(--faint); margin-top: 5px; }
.sec-title { font-size: 1rem; margin: 20px 0 10px; }
.stage-hist { font-size: .85rem; color: var(--muted); }
.stage-hist div { padding: 5px 0; border-bottom: 1px dashed var(--line); }

/* ---------- modal ---------- */
#touchWrap.overlay, #addWrap.overlay { justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: min(480px, 100%); padding: 26px; position: relative; box-shadow: var(--shadow); animation: fade .18s ease; }
.modal h2 { margin-bottom: 16px; padding-right: 36px; }
.modal-close { position: absolute; top: 16px; right: 16px; }

/* ---------- banners / fatal ---------- */
.banner { background: var(--accent-soft); border: 1px solid rgba(241,134,93,.5); color: var(--ink); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: .9rem; }
.banner.hidden { display: none; }
.banner strong { color: var(--accent); }
.fatal {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex;
  align-items: center; justify-content: center; padding: 24px;
}
.fatal.hidden { display: none; }
.fatal-inner { max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 30px; }
.fatal-inner h2 { margin-bottom: 10px; }
.fatal-inner code { display: block; background: var(--surface-2); border-radius: 8px; padding: 12px; margin: 12px 0; font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 40;
    flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side-brand { padding: 0; }
  .side-brand-text { display: none; }
  .side-mark { width: 32px; height: 32px; font-size: 1rem; }
  .side-nav { flex-direction: row; flex: 1; overflow-x: auto; gap: 2px; }
  .nav-item { padding: 9px 10px; font-size: .82rem; gap: 7px; white-space: nowrap; }
  .nav-item svg { width: 18px; height: 18px; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; padding: 0; }
  .side-foot .btn-accent { display: none; }
  .user-badge { max-width: 110px; font-size: .72rem; padding: 6px 8px; }
  .main { padding: 18px 14px 90px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .drawer { width: 100%; }
  .row2 { grid-template-columns: 1fr; }
  .funnel-row .name { width: 88px; font-size: .8rem; }
  .view-head h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
