:root {
  --brand:#ff5001; --violet:#5100c9; --ink:#232b32;
  --bg:#f5f6f8; --surface:#fff; --sunken:#eceef2; --text:#232b32; --mute:#5f6b76; --line:#dde1e7;
  --warn:#9d3200; --warnbg:#ffeadf; --ok:#17754a; --later:#8a6100; --lost:#7b8590; --link:#5100c9;
  --shadow:0 1px 2px rgb(35 43 50 / .06), 0 1px 3px rgb(35 43 50 / .08);
  --lift:0 6px 18px rgb(35 43 50 / .14);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#12161a; --surface:#222a31; --sunken:#1a2026; --text:#edf0f3; --mute:#a3aeb8; --line:#353f48;
    --warn:#ffb48f; --warnbg:#4a2313; --ok:#5fd39c; --later:#e8bd52; --lost:#8d98a3; --violet:#a57cff; --link:#bda0ff; color-scheme:dark }
}
* { box-sizing:border-box }
[hidden] { display:none !important }
body { display:flex; flex-direction:column; min-height:100dvh; margin:0; font:14px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif; background:var(--bg); color:var(--text); -webkit-text-size-adjust:100% }
button, input, select, textarea { font:inherit; color:inherit; background:var(--surface); border:1px solid var(--line); border-radius:9px; padding:8px 12px; min-height:38px; max-width:100% }
input[type=checkbox] { min-height:0; width:18px; height:18px; accent-color:var(--brand) }
textarea { resize:vertical }
button { cursor:pointer; font-weight:500 }
button:hover { border-color:var(--mute) }
button:disabled { opacity:.55; cursor:default }
button.danger { color:var(--warn); border-color:color-mix(in srgb, var(--warn) 45%, var(--line)) }
.filters .toggle[aria-pressed=true] { background:var(--text); color:var(--bg); border-color:var(--text) }
.line.off > .grow, .line.off > .avatar { opacity:.6 }
.line .tag { margin-left:8px }
button.primary { background:var(--brand); border-color:var(--brand); color:#1b1410; font-weight:650 }
button.primary:hover { filter:brightness(1.07) }
:focus-visible { outline:2px solid var(--violet); outline-offset:2px }
.mute { color:var(--mute) }

main { flex:1; min-width:0 }
#foot { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 16px; padding:11px 20px calc(11px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:var(--surface); color:var(--mute); font-size:12px }

/* Barra superior */
.bar { background:#232b32; color:#fff; display:flex; align-items:center; gap:12px 18px; flex-wrap:wrap; padding:11px 20px; border-bottom:3px solid var(--brand) }
.brand { display:flex; align-items:center; gap:12px; margin:0 auto 0 0; font-size:13px; font-weight:500 }
.brand img { width:148px; height:16px }
.brand span { border-right:1px solid rgb(255 255 255 / .3); padding-right:12px; font-size:15px; font-weight:600 }
.bar button:not(.primary), .bar select { background:transparent; color:#fff; border-color:rgb(255 255 255 / .22) }
.bar select option { color:#232b32; background:#fff }
.bar .tabs { display:flex; gap:4px }
.bar .tabs button[aria-pressed=true] { background:rgb(255 255 255 / .14); border-color:transparent }

/* Resumen y filtros */
.stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; padding:16px 20px 0 }
.stat { display:flex; flex-direction:column; align-items:flex-start; text-align:left; padding:11px 15px; border-radius:12px; box-shadow:var(--shadow) }
.stat b { font-size:24px; line-height:1.15; font-variant-numeric:tabular-nums }
.stat span { color:var(--mute); font-size:12px; font-weight:400 }
.stat.alert b { color:var(--warn) }
.stat.good b { color:var(--ok) }
.stat[aria-pressed=true] { border-color:var(--brand); box-shadow:0 0 0 1px var(--brand) }
.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:center; padding:12px 20px 0 }
.filters input[type=search] { flex:1 1 240px; max-width:360px }
.filters .push { margin-left:auto }

/* Tablero */
.stagenav { display:none }
.board { display:flex; gap:12px; overflow-x:auto; padding:14px 20px 18px; align-items:stretch; min-height:0; flex:1; scrollbar-width:thin }
.col { --tone:var(--violet); flex:1 0 232px; background:var(--sunken); border-radius:14px; padding:10px; border:2px solid transparent; border-top:3px solid var(--tone) }
.col.new { --tone:var(--brand) } .col.won { --tone:var(--ok) } .col.later { --tone:var(--later) } .col.lost { --tone:var(--lost) }
.col.over { border-color:var(--brand); background:color-mix(in srgb, var(--brand) 9%, var(--sunken)) }
.col h2 { font-size:13px; margin:0 4px 10px; display:flex; justify-content:space-between; align-items:center; gap:8px }
.col h2 .title { flex:1; min-width:0; overflow-wrap:anywhere }
.col h2 .edit { min-height:0; width:28px; height:28px; padding:0; background:transparent; border-color:transparent; color:var(--mute) }
.col h2 .edit:hover { background:var(--surface); border-color:var(--line) }
.addcol { flex:0 0 150px; align-self:flex-start; border-style:dashed; background:transparent; padding:14px }
.count { background:var(--surface); border-radius:99px; min-width:26px; text-align:center; padding:1px 8px; font-size:12px; font-variant-numeric:tabular-nums }
.card { --src:var(--lost); background:var(--surface); border:1px solid var(--line); border-radius:11px; margin-bottom:9px; box-shadow:var(--shadow); transition:box-shadow .15s, transform .15s }
.card:hover { box-shadow:var(--lift); transform:translateY(-1px) }
.card[draggable=true] { cursor:grab }
.card.dragging { opacity:.45 }
.card .open { display:flex; flex-direction:column; align-items:stretch; gap:8px; width:100%; text-align:left; background:none; border:0; padding:12px; border-radius:11px; cursor:inherit; font-weight:400 }
.card strong { font-size:14px; line-height:1.3; overflow-wrap:anywhere }
.next { color:var(--mute); font-size:12px; overflow-wrap:anywhere }
.who { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--mute); min-width:0 }
.who > span:nth-child(2) { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0 }
.who .age { margin-left:auto; flex:none; font-variant-numeric:tabular-nums }
.avatar { flex:none; width:24px; height:24px; border-radius:50%; display:grid; place-items:center; background:#5100c9; color:#fff; font-size:10px; font-weight:700 }
.avatar.none { background:transparent; color:var(--mute); border:1px dashed var(--mute) }
.tags { display:flex; flex-wrap:wrap; gap:5px }
.tag { max-width:100%; overflow-wrap:anywhere; display:inline-flex; align-items:center; gap:5px; padding:2px 8px; border-radius:99px; background:var(--sunken); font-size:11.5px; font-weight:500 }
.tag.src::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--src) }
.web { --src:#ff5001 } .director { --src:#7c3aed } .ventas { --src:#0e8fb3 } .evento { --src:#2e9e63 } .clickup { --src:#7b8590 }
.tag.warn { color:var(--warn); background:var(--warnbg) }
.quick { display:none }
.empty { color:var(--mute); padding:10px 4px; margin:0; font-size:13px }
.col .empty { border:1px dashed var(--line); border-radius:11px; text-align:center; padding:18px 8px }

/* Vista en lista */
.modes { display:flex }
.modes button { border-radius:0 }
.modes button:first-child { border-radius:9px 0 0 9px }
.modes button:last-child { border-radius:0 9px 9px 0; margin-left:-1px }
.modes button[aria-pressed=true] { background:var(--text); border-color:var(--text); color:var(--bg) }
.listwrap { padding:14px 20px 20px; overflow-x:auto }
.list { width:100%; border-collapse:separate; border-spacing:0; background:var(--surface); border:1px solid var(--line); border-radius:13px; box-shadow:var(--shadow) }
.list th, .list td { text-align:left; vertical-align:middle; padding:9px 12px; border-bottom:1px solid var(--line) }
.list tbody tr:last-child td { border-bottom:0 }
.list th button { border:0; background:none; padding:0; min-height:0; font-size:12px; font-weight:650; color:var(--mute); white-space:nowrap }
.list td > div { display:flex; flex-wrap:wrap; gap:6px; align-items:center; overflow-wrap:anywhere }
.list .name { border:0; background:none; padding:0; min-height:0; text-align:left; font-weight:650 }
.list .name:hover { color:var(--link); text-decoration:underline }
.list select { max-width:230px }

/* Ventanas */
dialog { width:min(560px, calc(100vw - 28px)); max-height:min(90dvh, 900px); border:0; border-radius:16px; background:var(--bg); color:var(--text); padding:0; box-shadow:0 24px 70px rgb(0 0 0 / .35); overscroll-behavior:contain }
dialog.large { width:min(960px, calc(100vw - 28px)) }
dialog::backdrop { background:rgb(18 22 26 / .6); backdrop-filter:blur(2px) }
.head { position:sticky; top:0; z-index:1; display:flex; justify-content:space-between; gap:14px; align-items:flex-start; padding:16px 20px; background:var(--surface); border-bottom:1px solid var(--line) }
.head h2 { margin:0 0 5px; font-size:19px; line-height:1.25; overflow-wrap:anywhere }
.head p { margin:0; font-size:12px }
.content { padding:18px 20px 20px }
.detail { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; align-items:start }
.stack { display:flex; flex-direction:column; gap:14px; min-width:0 }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:13px; padding:15px; min-width:0 }
.panel h3 { margin:0 0 11px; font-size:13px }
.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr)); gap:11px }
label { display:flex; flex-direction:column; gap:4px; font-size:12px; font-weight:500; color:var(--mute); min-width:0 }
label > * { font-size:14px; font-weight:400; color:var(--text); width:100% }
.wide { grid-column:1/-1 }
.actions { display:flex; gap:9px; justify-content:flex-end; margin-top:13px }
.error { color:var(--warn); margin:10px 0 0 }
.error:empty { display:none }
.entry { margin:0; padding:9px 0; border-top:1px solid var(--line); overflow-wrap:anywhere; white-space:pre-wrap }
.entry small { display:block; color:var(--mute) }
.panel form + .entry { margin-top:12px }
details summary { cursor:pointer; padding:8px 0 4px; color:var(--link); font-weight:500 }
details form { padding-top:8px }

.login { display:flex; justify-content:center; padding:48px 16px }
.login .panel { width:min(400px,100%) }
.login h2 { margin:0 0 6px }

/* Configuración y referidos */
.page { max-width:980px; margin:0 auto; padding:20px; display:flex; flex-direction:column; gap:16px }
.page h2 { margin:0; font-size:18px }
.page p { margin:0 }
.line { display:flex; gap:8px; align-items:center; padding:9px 0; border-top:1px solid var(--line) }
.line > .grow { flex:1; min-width:0; overflow-wrap:anywhere }
.line input[type=number] { width:110px }
.line .check { flex-direction:row; align-items:center; gap:6px }
.line .check > * { width:18px }
.panel > form:last-child { border-top:1px solid var(--line); padding-top:14px; margin-top:4px }
.referrals { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(290px,100%),1fr)); gap:12px }
.referrals article { display:flex; flex-direction:column; gap:10px }
.referrals h3 { margin:0; font-size:15px; overflow-wrap:anywhere }
.steps { display:flex; gap:3px }
.steps i { flex:1; height:6px; border-radius:99px; background:var(--sunken) }
.steps i.done { background:var(--brand) }
.steps.won i.done { background:var(--ok) }

#toast { position:fixed; bottom:calc(16px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100vw - 24px); z-index:5 }
#toast p { background:#232b32; color:#fff; padding:11px 17px; border-radius:11px; margin:0; box-shadow:var(--lift); border-left:4px solid var(--brand) }

/* En pantallas anchas el tablero ocupa la ventana y cada columna se desplaza sola, con el pie siempre visible */
@media (min-width:721px) {
  body:has(.board) { height:100dvh; min-height:560px }
  main:has(.board) { display:flex; flex-direction:column; min-height:0 }
  .col { overflow-y:auto; scrollbar-width:thin }
  .col h2 { position:sticky; top:-10px; z-index:1; background:var(--sunken); margin:-10px 0 4px; padding:10px 4px 6px }
}

/* Tableta */
@media (max-width:980px) {
  .detail { grid-template-columns:minmax(0,1fr) }
}

/* Teléfono: una etapa a la vez, con selector para mover */
@media (max-width:720px) {
  button, select, input { min-height:44px }
  input, select, textarea, label > * { font-size:16px }
  .bar { padding:10px 14px; gap:10px }
  .brand { flex:1 0 100%; flex-wrap:wrap; gap:7px 10px }
  .brand span { border:0; padding:0; flex:1 0 100% }
  .brand img { width:122px; height:13px }
  .bar .tabs { margin-right:auto }
  .bar select { flex:1 0 100% }
  .stats { gap:7px; padding:12px 14px 0 }
  .stat { padding:8px; align-items:center; text-align:center; min-width:0 }
  .stat b { font-size:20px }
  .stat span { font-size:10.5px; line-height:1.25 }
  .filters { padding:10px 14px 0; gap:8px }
  .filters input[type=search] { flex:1 0 100%; max-width:none }
  .filters select { flex:1 1 0; min-width:0 }
  .filters .push { margin:0; flex:none }
  .filters .toggle { order:1; flex:1 0 100% }
  .filters .long { display:none }
  .stagenav { display:flex; gap:7px; overflow-x:auto; position:sticky; top:0; z-index:2; background:var(--bg); padding:11px 14px; scrollbar-width:none }
  .stagenav button { flex:none; display:flex; align-items:center; gap:7px; border-radius:99px; min-height:40px }
  .stagenav button[aria-pressed=true] { background:var(--text); color:var(--bg); border-color:var(--text) }
  .stagenav .count { background:var(--sunken); color:var(--text) }
  .board { display:block; overflow:visible; padding:0 14px 24px; min-height:0 }
  #foot { justify-content:center; text-align:center; padding-left:14px; padding-right:14px }
  .col { display:none }
  .col.active { display:block }
  .col h2 .edit { width:44px; height:44px }
  .addcol { width:100% }
  .quick { display:block; padding:0 12px 12px }
  .quick select { width:100% }
  .card:hover { transform:none }
  dialog, dialog.large { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; border-radius:0 }
  .head { padding:13px 14px }
  .content { padding:14px 14px calc(24px + env(safe-area-inset-bottom)) }
  .actions button { flex:1 }
  .page { padding:14px }
  .modes { flex:1 0 100% }
  .modes button { flex:1 }
  .listwrap { padding:12px 14px 24px; overflow:visible }
  .list, .list tbody, .list tr, .list td { display:block; width:100% }
  .list { background:none; border:0; box-shadow:none }
  .list thead { display:none }
  .list tr { background:var(--surface); border:1px solid var(--line); border-radius:12px; margin-bottom:10px; padding:6px 0; box-shadow:var(--shadow) }
  .list td { display:grid; grid-template-columns:105px minmax(0,1fr); gap:8px; align-items:center; border:0; padding:5px 12px }
  .list td::before { content:attr(data-label); color:var(--mute); font-size:12px }
  .list select { max-width:100%; width:100% }
  .list .name { min-height:44px; font-size:15px }
  .line { flex-wrap:wrap }
  .line > .grow { flex:1 0 100% }
}
@media (prefers-reduced-motion:reduce) { * { transition:none !important } }
