:root {
  --ink: #1b1b1f;
  --muted: #7a7a85;
  --line: #e6e6ea;
  --bg: #f2f2f4;

  /* Marca Fénix: carbón + ámbar/fuego */
  --carbon: #17171b;
  --carbon-2: #0d0d10;
  --carbon-soft: #26262c;
  --amber: #ff7a00;
  --amber-dark: #e56900;
  --amber-glow: #ffb020;

  --danger: #d0392b;
  --warn: #d68910;
  --info: #2471a3;
  --green: #2c8a5b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
header {
  background: linear-gradient(135deg, var(--carbon) 0%, var(--carbon-2) 100%);
  color: #fff;
  padding: 16px 0;
  box-shadow: 0 2px 14px rgba(0,0,0,.25);
  border-bottom: 2px solid var(--amber);
}
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand .flame { font-size: 1.7rem; line-height: 1; filter: drop-shadow(0 0 6px rgba(255,122,0,.6)); }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 1.1rem; font-weight: 800; letter-spacing: 1.5px; color: #fff; }
.brand-text span { font-size: .72rem; color: var(--amber-glow); letter-spacing: .5px; text-transform: uppercase; }

.header-actions { display: flex; gap: 10px; align-items: center; }
.btn-logout { color: #d8d8dd !important; border-color: #3a3a42 !important; background: transparent !important; }
.btn-logout:hover { background: #26262c !important; color: #fff !important; }

main { padding: 28px 0 60px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 18px; border: none; border-radius: 8px;
  font-size: .92rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); color: #fff; box-shadow: 0 2px 8px rgba(255,122,0,.28); }
.btn-primary:hover { background: var(--amber-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f7f7f9; }
.btn-sm { padding: 5px 8px; font-size: .78rem; }
.btn-icon { padding: 5px 8px; width: 30px; justify-content: center; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f0c8c4; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; padding: 13px; font-size: 1rem; }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-width: 120px; border-left: 3px solid var(--amber); }
.stat .num { font-size: 1.6rem; font-weight: 800; color: var(--carbon); }
.stat .lbl { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { flex: 1; min-width: 180px; }
.search-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; background: #fff; }
.filter-box select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff; min-width: 150px; }

/* ---------- Card / tabla ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; padding: 9px 10px; font-size: .66rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafafb; border-bottom: 2px solid var(--line); white-space: nowrap; }
tbody td { padding: 8px 10px; border-bottom: 1px solid #f2f2f4; font-size: .82rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fffaf4; }

.nombre-cell { font-weight: 600; color: var(--ink); }
.nombre-cell small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 2px; }
a.link { color: var(--info); text-decoration: none; }
a.link:hover { text-decoration: underline; }
.muted { color: var(--muted); font-style: italic; font-size: .85rem; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.badge-nuevo { background: #eceef2; color: #55606f; }
.badge-contactado { background: #fef1e0; color: var(--warn); }
.badge-en_negociacion { background: #e6f0fa; color: var(--info); }
.badge-cliente { background: #e5f4ec; color: var(--green); }
.badge-descartado { background: #fbe9e7; color: var(--danger); }

/* Estado como desplegable editable en la propia fila, con el mismo
   aspecto que el badge de antes */
select.estado-select {
  appearance: none; -webkit-appearance: none;
  border: none; border-radius: 20px; padding: 5px 26px 5px 12px;
  font-size: .74rem; font-weight: 600; cursor: pointer;
  background-repeat: no-repeat; background-position: right 8px center; background-size: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%2355606f' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
}
select.estado-select {
  appearance: none; -webkit-appearance: none;
  border: none; border-radius: 20px; padding: 4px 20px 4px 9px;
  font-size: .68rem; font-weight: 600; cursor: pointer;
  background-repeat: no-repeat; background-position: right 7px center; background-size: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%2355606f' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
}
select.estado-select.badge-nuevo { background-color: #eceef2; color: #55606f; }
select.estado-select.badge-contactado { background-color: #fef1e0; color: var(--warn); }
select.estado-select.badge-en_negociacion { background-color: #e6f0fa; color: var(--info); }
select.estado-select.badge-cliente { background-color: #e5f4ec; color: var(--green); }
select.estado-select.badge-descartado { background-color: #fbe9e7; color: var(--danger); }

.actividades-cell { max-width: 130px; }
.tag {
  display: inline-block; padding: 1px 6px; margin: 1px 2px 1px 0; border-radius: 6px;
  font-size: .62rem; font-weight: 600; background: #fdf0e2; color: #a85a00;
  border: 1px solid #f6ddb8;
}

/* Checkbox de catálogo enviado */
.catalogo-cell { text-align: center; }
.checkbox-wrap { display: inline-flex; align-items: center; justify-content: center; }
.checkbox-wrap input { width: 18px; height: 18px; accent-color: var(--amber); cursor: pointer; }
.fecha-envio { display: block; font-size: .68rem; color: var(--muted); margin-top: 3px; white-space: nowrap; }

/* Checkboxes de actividad en el formulario */
.checkbox-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafafb;
}
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 400; cursor: pointer; }
.checkbox-item input { width: 16px; height: 16px; accent-color: var(--amber); cursor: pointer; }
.muted-inline { color: var(--muted); font-weight: 400; font-size: .78rem; }

.flash-error { background: #fbeae8; color: #c0392b; border: 1px solid #f2c9c4; }

.actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
/* ---------- Formulario ---------- */
.form-card { max-width: 640px; margin: 0 auto; }
.form-card .card-head { padding: 20px 26px; border-bottom: 1px solid var(--line); border-top: 3px solid var(--amber); }
.form-card .card-head h2 { font-size: 1.2rem; }
.form-body { padding: 26px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; font-family: inherit; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,122,0,.14); }
.field textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 12px; padding-top: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .icon { font-size: 3rem; margin-bottom: 10px; }

.flash { padding: 13px 18px; border-radius: 8px; margin-bottom: 20px; font-size: .92rem; font-weight: 500; }
.flash-ok { background: #e5f4ec; color: #1f6b45; border: 1px solid #b8e0c9; }

footer { text-align: center; padding: 24px; color: var(--muted); font-size: .82rem; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255,122,0,.18), transparent 60%),
    linear-gradient(160deg, #0d0d10 0%, #17171b 100%);
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: #1e1e24;
  border: 1px solid #2c2c34;
  border-top: 3px solid var(--amber);
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 26px; }
.login-brand .flame { font-size: 2rem; filter: drop-shadow(0 0 10px rgba(255,122,0,.7)); }
.login-brand .brand-text { align-items: flex-start; }
.login-brand strong { color: #fff; font-size: 1.25rem; font-weight: 800; letter-spacing: 2px; }
.login-brand span { color: var(--amber-glow); font-size: .72rem; letter-spacing: 1px; }

.login-form .field label { color: #b8b8c0; }
.login-form .field input {
  background: #26262d; border: 1px solid #34343d; color: #fff;
}
.login-form .field input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,122,0,.2); }
.login-error { background: #3a1d1a; color: #ff9d8f; border: 1px solid #5a2a24; padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; font-size: .88rem; text-align: center; }
.login-foot { text-align: center; color: #55555f; font-size: .78rem; margin-top: 18px; letter-spacing: .5px; }

@media (max-width: 720px) {
  .hide-mobile { display: none; }
  thead th, tbody td { padding: 10px 12px; }
  .brand-text span { display: none; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .actividades-cell { max-width: 120px; }
}
