:root {
  --carbon: #0a0a0c;
  --surface: #121216;
  --surface-2: #17171d;
  --surface-3: #1e1e26;
  --line: #26262e;
  --line-soft: #1d1d24;
  --fire: #ff5b04;
  --green: #22c55e;
  --blue: #3b82f6;
  --yellow: #eab308;
  --red: #ef4444;
  --text: #f4f4f5;
  --muted: #9a9aa5;
  --faint: #6b6b76;
  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --rail: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* los display de abajo le ganan a hidden si no se fuerza */
[hidden] { display: none !important; }

body {
  background: var(--carbon);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- topbar ---------- */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 112%;
  text-transform: uppercase;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px;
  color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 26px; height: 26px;
  background: var(--fire);
  color: #0a0a0c;
  display: grid; place-items: center;
  border-radius: 6px;
  font-size: 13px;
  transform: skewX(-9deg);
}
.pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .18s, border-color .18s, color .18s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #33333d; }
.btn-fire { background: var(--fire); border-color: var(--fire); color: #0a0a0c; }
.btn-fire:hover { background: #ff7a33; border-color: #ff7a33; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,.1); border-color: var(--red); }
.btn svg { width: 15px; height: 15px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: calc(100vh - 56px); }

/* barra de iconos (el patrón de Overskill) */
.rail {
  width: var(--rail);
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  flex-shrink: 0;
}
.rail-btn {
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  transition: color .18s, background .18s, border-color .18s;
}
.rail-btn svg { width: 19px; height: 19px; }
.rail-btn:hover { color: var(--text); background: var(--surface-2); }
.rail-btn.active { color: var(--fire); background: rgba(255,91,4,.1); border-color: rgba(255,91,4,.3); }
.rail-btn .dot {
  position: absolute; top: 7px; right: 7px;
  min-width: 15px; height: 15px;
  background: var(--fire);
  color: #0a0a0c;
  border-radius: 10px;
  font-size: 9px; font-weight: 700;
  display: grid; place-items: center;
  padding: 0 4px;
  font-family: var(--body);
}
.rail-tip {
  position: absolute;
  left: calc(100% + 10px);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transform: translateX(-4px);
  transition: opacity .16s, transform .16s;
  z-index: 60;
}
.rail-btn:hover .rail-tip { opacity: 1; transform: none; }
.rail-sep { width: 26px; height: 1px; background: var(--line); margin: 8px 0; }
.rail-spacer { flex: 1; }

/* contenido */
.main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head { margin-bottom: 26px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.panel-head h1 {
  font-family: var(--display);
  font-weight: 800; font-stretch: 110%;
  text-transform: uppercase;
  font-size: 26px; letter-spacing: -.01em;
}
.panel-head p { color: var(--muted); margin-top: 5px; font-size: 14px; }

/* ---------- tarjetas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 18px;
}
.card-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.card-label svg { width: 14px; height: 14px; }
.card-value {
  font-family: var(--display);
  font-weight: 800; font-stretch: 110%;
  font-size: 32px; line-height: 1.1;
  margin-top: 10px;
}
.card-sub { font-size: 12px; color: var(--faint); margin-top: 4px; }
.card-sub.up { color: var(--green); }
.card-sub.down { color: var(--red); }

.box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  margin-bottom: 18px;
}
.box-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap;
}
.box-head h2 { font-size: 14px; font-weight: 600; }
.box-head p { font-size: 12px; color: var(--faint); margin-top: 2px; }
.box-body { padding: 18px; }

/* ---------- tablas ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); font-weight: 600;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
td { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .strong { font-weight: 600; color: var(--text); }
td .dim { color: var(--faint); font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-nuevo     { color: var(--fire);   background: rgba(255,91,4,.12); }
.badge-contactado{ color: var(--blue);   background: rgba(59,130,246,.12); }
.badge-agendado  { color: var(--yellow); background: rgba(234,179,8,.12); }
.badge-cerrado   { color: var(--green);  background: rgba(34,197,94,.12); }
.badge-perdido   { color: var(--faint);  background: rgba(255,255,255,.05); }
.badge-activa    { color: var(--green);  background: rgba(34,197,94,.12); }
.badge-pausada   { color: var(--faint);  background: rgba(255,255,255,.05); }

.empty { padding: 56px 20px; text-align: center; color: var(--faint); }
.empty svg { width: 34px; height: 34px; margin-bottom: 12px; opacity: .45; }
.empty p { font-size: 13px; }

/* ---------- gráfico de barras ---------- */
.bars { display: flex; align-items: flex-end; gap: 7px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.bar-count { font-size: 11px; color: var(--muted); font-weight: 600; height: 15px; }
.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--fire), rgba(255,91,4,.32));
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: opacity .18s;
  position: relative;
}
.bar-col:hover .bar { opacity: .75; }
.bar-label { font-size: 10px; color: var(--faint); white-space: nowrap; }

/* barra de origen */
.source-row { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.source-name { width: 118px; font-size: 13px; flex-shrink: 0; }
.source-track { flex: 1; height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.source-fill { height: 100%; background: var(--fire); border-radius: 4px; }
.source-val { width: 54px; text-align: right; font-size: 13px; color: var(--muted); flex-shrink: 0; }

/* ---------- formularios ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); font-weight: 600; margin-bottom: 7px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--fire); }
.field textarea { resize: vertical; min-height: 72px; }
.field-hint { font-size: 11px; color: var(--faint); margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.buscador {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 14px;
  margin-bottom: 14px;
  transition: border-color .2s;
}
.buscador:focus-within { border-color: var(--fire); }
.buscador svg { width: 16px; height: 16px; color: var(--faint); flex-shrink: 0; }
.buscador input {
  flex: 1;
  background: none; border: 0;
  padding: 11px 0;
  color: var(--text);
  font-family: var(--body); font-size: 13.5px;
}
.buscador input:focus { outline: none; }
.buscador input::placeholder { color: var(--faint); }
.buscador input::-webkit-search-cancel-button { filter: invert(.6); cursor: pointer; }
.buscador-cuenta { font-size: 12px; color: var(--faint); white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--fire); border-bottom-color: var(--fire); }

/* editor de lista (servicios / galería) */
.item-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.item-row:last-child { border-bottom: 0; }
.item-thumb {
  width: 54px; height: 54px; border-radius: 7px;
  background: var(--surface-3) center/cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.item-main { flex: 1; min-width: 0; }
.item-main h3 { font-size: 14px; font-weight: 600; }
.item-main p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item-actions { display: flex; gap: 7px; flex-shrink: 0; }

.switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.switch span::before {
  content: ''; position: absolute;
  width: 15px; height: 15px; left: 2px; top: 2px;
  background: var(--faint); border-radius: 50%;
  transition: transform .2s, background .2s;
}
.switch input:checked + span { background: rgba(255,91,4,.25); border-color: var(--fire); }
.switch input:checked + span::before { transform: translateX(17px); background: var(--fire); }

.note {
  display: flex; gap: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--fire);
  border-radius: 7px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}
.note svg { width: 16px; height: 16px; color: var(--fire); flex-shrink: 0; margin-top: 2px; }
.note strong { color: var(--text); font-weight: 600; }

/* ---------- ventana de ficha ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 150;
}
.modal.show { display: flex; }
.modal-card {
  width: 100%; max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  margin: auto;
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.modal-head h2 {
  font-family: var(--display); font-weight: 800; font-stretch: 110%;
  text-transform: uppercase; font-size: 17px;
}
.modal-body { padding: 22px; }
.modal-pie {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}

.badge-en_taller { color: var(--blue);   background: rgba(59,130,246,.12); }
.badge-entregado { color: var(--green);  background: rgba(34,197,94,.12); }
.badge-ads       { color: var(--fire);   background: rgba(255,91,4,.12); }
.badge-organico  { color: var(--green);  background: rgba(34,197,94,.12); }
.badge-referido  { color: var(--yellow); background: rgba(234,179,8,.12); }
.badge-directo   { color: var(--faint);  background: rgba(255,255,255,.05); }

.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--surface-3);
  border: 1px solid var(--fire);
  border-radius: 9px;
  padding: 13px 18px;
  font-size: 13px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 200;
}
.toast.show { opacity: 1; transform: none; }

select.inline {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--body);
  cursor: pointer;
}

@media (max-width: 760px) {
  .main { padding: 20px 16px 56px; }
  :root { --rail: 54px; }
  .rail-btn { width: 38px; height: 38px; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .pill { display: none; }
}

/* ---------- medidas de la ventana del diagnóstico ---------- */
.medidas { display: grid; gap: 16px; }
.medida { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.medida label { font-size: 13.5px; color: var(--text); }
.medida output {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12.5px; color: var(--fire);
  min-width: 52px; text-align: right;
}
.medida input[type=range] {
  grid-column: 1 / -1;
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--line); border-radius: 3px; outline: none; cursor: pointer;
}
.medida input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--fire); border: 0; cursor: pointer;
  box-shadow: 0 0 10px rgba(255,91,4,.5);
}
.medida .hint { grid-column: 1 / -1; font-size: 12px; color: var(--faint); margin-top: -2px; }

/* la vista a escala: no es la ventana real, es su proporción */
.vista-previa { margin: 24px 0 20px; }
.vp-fondo {
  background: #08090b; border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 0; display: grid; place-items: center; overflow: hidden;
}
.vp-card {
  background: #121216; border: 1px solid var(--line);
  display: grid; gap: 7px;
  transition: max-width .15s, border-radius .15s, padding .15s;
}
.vp-titulo { height: 11px; width: 58%; border-radius: 3px; background: #3a3a46; margin-bottom: 2px; }
.vp-tarjeta { border: 1px solid var(--line); padding: 9px 10px; display: grid; gap: 5px; transition: border-radius .15s; }
.vp-tarjeta span { height: 5px; border-radius: 2px; background: #2e2e38; }
.vp-tarjeta span:first-child { width: 40%; }
.vp-campo { height: 17px; border-radius: 6px; background: #0d0d11; border: 1px solid #2c2c36; }
.vp-boton { height: 19px; border-radius: 99px; background: #f4f4f5; margin-top: 3px; }
