/* ============================================================================
   FenixL — Sistema de diseño del backend
   ----------------------------------------------------------------------------
   Misma marca que la web pública (tinta, brasa, tres voces tipográficas) pero
   con otra misión: aquí se trabaja. Más densidad, menos espectáculo, cero
   animación gratuita. El panel debe leerse rápido a las ocho de la tarde.

   Reglas heredadas del sistema público:
     · ámbar/brasa = acción y calor (solo botones primarios y estado activo)
     · esmeralda   = prueba / algo resuelto
     · niebla      = estructura (bordes, texto secundario)
     · la monoespaciada es para datos: importes, fechas, identificadores
   ========================================================================== */

:root {
  --ink-900: #07090D;
  --ink-850: #090C12;
  --ink-800: #0B0E14;
  --ink-700: #0F1520;
  --ink-600: #141A26;
  --ink-500: #1A2130;
  --ink-400: #232B3B;

  --ember-500: #FF6B2C;
  --ember-400: #FF8A4C;
  --amber-400: #FFB020;
  --heat: linear-gradient(135deg, var(--ember-500), var(--amber-400));

  --signal-500: #2DD4A7;
  --blue-400:   #58A6FF;
  --purple-400: #A78BFA;
  --red-400:    #FF6B6B;

  --text-hi:  #F4F6FA;
  --text-mid: #C2C9D6;
  --text-low: #9AA3B5;
  --text-dim: #8B95A8;

  --line-soft: rgba(154,163,181,0.09);
  --line:      rgba(154,163,181,0.16);
  --line-hot:  rgba(255,107,44,0.38);

  --sans:    'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', 'Inter', sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, Menlo, monospace;

  --side-w: 248px;
  --top-h: 66px;
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink-800);
  color: var(--text-hi);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amber-400); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
.ic { flex-shrink: 0; }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--amber-400); outline-offset: 2px; border-radius: 4px;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 300; background: var(--ember-500); color: var(--ink-800); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Chasis ─────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.main-col { min-width: 0; display: flex; flex-direction: column; }

.side {
  background: var(--ink-900); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-top { padding: 20px 18px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--text-hi); }
.brand span { background: var(--heat); -webkit-background-clip: text; background-clip: text; color: transparent; }

.role-chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
}
.role-chip--staff  { color: var(--ember-500); border-color: var(--line-hot); background: rgba(255,107,44,.08); }
.role-chip--client { color: var(--signal-500); border-color: rgba(45,212,167,.35); background: rgba(45,212,167,.08); }

.side-nav { flex: 1; padding: 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text-low);
  font-size: 14px; font-weight: 500; transition: background 140ms var(--ease), color 140ms var(--ease);
}
.nav-item:hover { background: rgba(154,163,181,.07); color: var(--text-hi); }
.nav-item.is-active { background: rgba(255,107,44,.12); color: var(--text-hi); }
.nav-item.is-active .ic { color: var(--ember-500); }
.nav-item--quiet { color: var(--text-dim); }
.side-foot { padding: 12px; border-top: 1px solid var(--line-soft); }

/* ── Barra superior ─────────────────────────────────────────────── */
.topbar {
  height: var(--top-h); display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(16px, 2.5vw, 30px); border-bottom: 1px solid var(--line-soft);
  background: rgba(11,14,20,.86); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 40;
}
.crumb { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.crumb-back {
  width: 32px; height: 32px; display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text-low);
}
.crumb-back:hover { color: var(--text-hi); border-color: var(--text-dim); }
.crumb-title { font-size: 17px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-btn {
  position: relative; width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text-low);
}
.icon-btn:hover { color: var(--text-hi); border-color: var(--text-dim); }
.dot {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; background: var(--ember-500); color: var(--ink-800);
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; border-radius: 999px;
}
.who { display: flex; align-items: center; gap: 9px; color: inherit; padding: 4px 8px 4px 4px; border-radius: 999px; }
.who:hover { background: rgba(154,163,181,.07); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--heat); color: var(--ink-800); font-family: var(--display); font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.who-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-txt strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.who-txt small { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.burger { display: none; flex-direction: column; gap: 4px; width: 38px; height: 38px; align-items: center; justify-content: center; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.burger span { width: 17px; height: 1.8px; background: var(--text-hi); border-radius: 2px; transition: transform 200ms var(--ease), opacity 200ms var(--ease); }
body.nav-open .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .burger span:nth-child(2) { opacity: 0; }
body.nav-open .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Contenido ──────────────────────────────────────────────────── */
.main { padding: clamp(18px, 2.6vw, 32px); max-width: 1320px; width: 100%; }
.shell--wide .main { max-width: none; }

.flash {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px;
  border: 1px solid;
}
.flash--ok  { background: rgba(45,212,167,.08); border-color: rgba(45,212,167,.35); color: #7FE7C9; }
.flash--err { background: rgba(255,107,44,.08); border-color: rgba(255,107,44,.35); color: var(--ember-400); }

/* ── Tarjetas y rejillas ────────────────────────────────────────── */
.card {
  background: var(--ink-600); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 22px;
}
.card--pad0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

.grid { display: grid; gap: 18px; }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }

/* Métrica */
.stat { background: var(--ink-600); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; }
.stat-n { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.stat-l { margin-top: 9px; font-size: 13.5px; font-weight: 500; color: var(--text-mid); }
.stat-s { margin-top: 3px; font-family: var(--mono); font-size: 11px; letter-spacing: .05em; color: var(--text-dim); text-transform: uppercase; }
.stat--hot .stat-n { color: var(--ember-500); }
.stat--good .stat-n { color: var(--signal-500); }

/* ── Tablas ─────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 13px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl thead th {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 500; background: rgba(7,9,13,.4); white-space: nowrap;
}
.tbl tbody tr { transition: background 120ms var(--ease); }
.tbl tbody tr:hover { background: rgba(154,163,181,.04); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td a { color: var(--text-hi); font-weight: 500; }
.tbl td a:hover { color: var(--amber-400); }
.num { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.muted { color: var(--text-low); }
.dim { color: var(--text-dim); }

/* ── Etiquetas de estado ────────────────────────────────────────── */
.tag {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
  border: 1px solid; white-space: nowrap;
}
.tag--grey   { color: var(--text-low);    border-color: var(--line);            background: rgba(154,163,181,.07); }
.tag--green  { color: var(--signal-500);  border-color: rgba(45,212,167,.35);   background: rgba(45,212,167,.08); }
.tag--amber  { color: var(--amber-400);   border-color: rgba(255,176,32,.35);   background: rgba(255,176,32,.08); }
.tag--red    { color: var(--red-400);     border-color: rgba(255,107,107,.35);  background: rgba(255,107,107,.08); }
.tag--blue   { color: var(--blue-400);    border-color: rgba(88,166,255,.35);   background: rgba(88,166,255,.08); }
.tag--purple { color: var(--purple-400);  border-color: rgba(167,139,250,.35);  background: rgba(167,139,250,.08); }

/* ── Botones ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--display); font-size: 14px; font-weight: 600;
  padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  background: var(--heat); color: var(--ink-800); cursor: pointer;
  transition: filter 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); color: var(--ink-800); }
.btn--ghost { background: transparent; color: var(--text-low); border-color: var(--line); }
.btn--ghost:hover { background: transparent; color: var(--text-hi); border-color: var(--text-dim); filter: none; }
.btn--danger { background: transparent; color: var(--red-400); border-color: rgba(255,107,107,.4); }
.btn--danger:hover { background: rgba(255,107,107,.1); color: var(--red-400); filter: none; }
.btn--sm { padding: 7px 15px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Formularios ────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label, .lbl {
  display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 7px;
}
.inp, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; background: var(--ink-800); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; color: var(--text-hi);
  font-family: var(--sans); font-size: 14.5px;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.inp:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ember-500); box-shadow: 0 0 0 3px rgba(255,107,44,.12);
}
input::placeholder, textarea::placeholder { color: #5C6575; }
.hint { display: block; font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.chk { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--text-mid); cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--ember-500); margin-top: 2px; flex-shrink: 0; }
.mono-in { font-family: var(--mono); }

/* Barra de filtros */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filters .btn--sm { font-family: var(--sans); font-weight: 500; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.search input { padding-left: 38px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }

/* ── Estado vacío ───────────────────────────────────────────────── */
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 46px 28px; text-align: center; color: var(--text-low);
}
.empty h3 { font-size: 16px; font-weight: 600; color: var(--text-mid); margin-bottom: 8px; }
.empty p { font-size: 14px; max-width: 460px; margin: 0 auto; }
.empty-act { margin-top: 20px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ── Adjuntos ───────────────────────────────────────────────────── */
.att { display: flex; flex-direction: column; gap: 14px; }
.att-list { display: grid; gap: 8px; }
.att-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: var(--ink-700); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.att-thumb {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 7px; overflow: hidden;
  background: var(--ink-500); display: grid; place-items: center; border: 1px solid var(--line-soft);
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-ext { font-family: var(--mono); font-size: 10px; text-transform: uppercase; color: var(--text-dim); letter-spacing: .04em; }
.att-thumb--pdf .att-ext    { color: var(--red-400); }
.att-thumb--sheet .att-ext  { color: var(--signal-500); }
.att-thumb--doc .att-ext    { color: var(--blue-400); }
.att-thumb--design .att-ext { color: var(--purple-400); }
.att-meta { flex: 1; min-width: 0; }
.att-name { display: block; font-size: 14px; font-weight: 500; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-sub { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); margin-top: 3px; }
.att-del button {
  background: none; border: 0; color: var(--text-dim); font-size: 20px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.att-del button:hover { color: var(--red-400); background: rgba(255,107,107,.1); }

.drop {
  display: block; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.drop:hover, .drop.is-over { border-color: var(--ember-500); background: rgba(255,107,44,.05); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-txt { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-low); }
.att-up { display: flex; flex-direction: column; gap: 11px; align-items: flex-start; }
.att-up .drop { width: 100%; }
.att-files { font-family: var(--mono); font-size: 11.5px; color: var(--signal-500); }

/* ── Conversación ───────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; }
.msg-av {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 13px;
  background: var(--ink-500); color: var(--text-mid); border: 1px solid var(--line);
}
.msg--staff .msg-av { background: var(--heat); color: var(--ink-800); border-color: transparent; }
.msg-body { flex: 1; min-width: 0; background: var(--ink-700); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 13px 15px; }
.msg--staff .msg-body { background: rgba(255,107,44,.05); border-color: rgba(255,107,44,.18); }
.msg-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.msg-who { font-size: 13.5px; font-weight: 600; }
.msg-when { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }
.msg-txt { font-size: 14px; color: var(--text-mid); white-space: pre-wrap; word-wrap: break-word; }

/* ── Progreso ───────────────────────────────────────────────────── */
.bar { height: 6px; background: var(--ink-400); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--heat); border-radius: 999px; }
.bar--thin { height: 4px; }

/* ── Línea de tiempo ────────────────────────────────────────────── */
.steps { position: relative; display: grid; gap: 2px; }
.steps::before { content: ''; position: absolute; left: 15px; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
.step { display: flex; gap: 14px; padding: 9px 0; align-items: flex-start; }
.step-dot {
  position: relative; z-index: 1; width: 31px; height: 31px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink-800); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}
.step.is-done .step-dot { background: rgba(45,212,167,.14); border-color: rgba(45,212,167,.4); color: var(--signal-500); }
.step-b { padding-top: 4px; min-width: 0; }
.step-t { font-size: 14px; font-weight: 500; }
.step-s { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

/* ── Login ──────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 28px 20px; background: var(--ink-800); }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .brand { font-size: 28px; }
.auth-brand p { margin-top: 8px; font-size: 13.5px; color: var(--text-dim); }
.auth-box { background: var(--ink-600); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; }
.auth-box h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-box .auth-intro { font-size: 13.5px; color: var(--text-low); margin-bottom: 22px; }
.auth-alt { margin-top: 18px; text-align: center; font-size: 13px; color: var(--text-dim); }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-dim); }
.auth-lang { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.auth-lang a { font-family: var(--mono); font-size: 11px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-dim); }
.auth-lang a[aria-current=true] { background: var(--text-hi); color: var(--ink-800); border-color: transparent; }

/* ── Lightbox de imágenes ───────────────────────────────────────── */
.lb {
  position: fixed; inset: 0; z-index: 200; display: none;
  background: rgba(7,9,13,.94); padding: 32px; place-items: center;
}
.lb.is-on { display: grid; }
.lb img { max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain; border-radius: var(--radius-sm); }
.lb-close {
  position: absolute; top: 20px; right: 24px; background: none; border: 1px solid var(--line);
  color: var(--text-hi); width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 60;
    transform: translateX(-100%); transition: transform 220ms var(--ease);
  }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(7,9,13,.6); z-index: 50; }
  .burger { display: flex; }
  .split { grid-template-columns: 1fr; }
  .who-txt { display: none; }
}
@media (max-width: 560px) {
  .main { padding: 16px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .tbl th, .tbl td { padding: 11px 13px; }
  .crumb-title { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
