/* ------------------------------------------------------------------
   Panel de clan - hoja de estilos unica
   ------------------------------------------------------------------ */

:root {
  --bg: #12151b;
  --bg-2: #191d26;
  --bg-3: #212734;
  --line: #2c3444;
  --txt: #e6e9ef;
  --txt-dim: #96a0b5;
  --accent: #4f8cff;
  --accent-dark: #2f6ede;
  --ok: #2fa84f;
  --ok-soft: #1f6b36;
  --warn: #d9a300;
  --warn-soft: #6d5300;
  --bad: #d33d3d;
  --bad-soft: #7a2323;
  --radius: 10px;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 6px 0; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.muted { color: var(--txt-dim); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mt { margin-top: 12px; }
.warn-text { color: var(--warn); }

/* ---------------- Barra superior ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #0d1016;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { color: var(--txt); font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); margin-right: 6px; }

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--txt-dim);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14.5px;
}
.nav a:hover { background: var(--bg-3); color: var(--txt); text-decoration: none; }
.nav a.on { background: var(--bg-3); color: #fff; }

.pill {
  background: var(--bad);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11.5px;
  font-weight: 700;
  margin-left: 2px;
}

.userbox { display: flex; align-items: center; gap: 10px; }
.who { color: var(--txt); font-size: 14px; }

.wrap { max-width: 1500px; margin: 0 auto; padding: 22px 20px 60px; }
.foot { text-align: center; color: var(--txt-dim); font-size: 12.5px; padding: 20px 0 30px; }

/* ---------------- Bloques ---------------- */

.page-head { margin-bottom: 18px; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card-title { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-dim); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-narrow { max-width: 420px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- Estadisticas ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat.st-ok { border-left-color: var(--ok); }
.stat.st-mid { border-left-color: var(--warn); }
.stat.st-bad { border-left-color: var(--bad); }
.stat-num { display: block; font-size: 24px; font-weight: 700; }
.stat-lbl { display: block; color: var(--txt-dim); font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------------- Formularios ---------------- */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--txt-dim); margin-bottom: 4px; }

input[type=text], input[type=password], input[type=search], input[type=number],
input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, .18);
}
textarea { resize: vertical; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: auto; }

.btn {
  display: inline-block;
  background: var(--bg-3);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #2a3243; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-warn { background: var(--warn-soft); border-color: var(--warn); color: #ffe6a1; }
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: #ffd7d7; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--txt-dim);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { color: var(--txt); border-color: var(--accent); text-decoration: none; }

/* ---------------- Avisos ---------------- */

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.alert-ok { background: rgba(47, 168, 79, .12); border-color: var(--ok); color: #b6f0c4; }
.alert-warn { background: rgba(217, 163, 0, .12); border-color: var(--warn); color: #ffe6a1; }
.alert-danger { background: rgba(211, 61, 61, .12); border-color: var(--bad); color: #ffc9c9; }

/* ---------------- Tabla de miembros ---------------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; min-width: 130px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}

table.roster { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.roster thead th {
  position: sticky;
  top: 56px;
  background: #0d1016;
  color: var(--txt-dim);
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 5;
}
table.roster th a.th-sort { color: inherit; }
table.roster th a.th-sort:hover { color: var(--txt); }
table.roster td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.roster tbody tr:hover { background: rgba(255, 255, 255, .03); }

.col-name { font-weight: 600; min-width: 150px; }
.col-notes { max-width: 260px; min-width: 140px; color: var(--txt-dim); }
.tick { width: 30px; }
.row-actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--txt-dim); padding: 30px !important; }

/* Franja de color por estado, como en la hoja de calculo */
tr.row-active   td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
tr.row-watch    td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.row-inactive td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.row-left     { opacity: .55; }
tr.row-left td:first-child { box-shadow: inset 3px 0 0 #555; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
}
.badge.st-active { background: var(--ok); }
.badge.st-watch { background: var(--warn); color: #241c00; }
.badge.st-inactive { background: var(--bad); }
.badge.st-left { background: #555; }

.inline-select {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  width: auto;
  min-width: 92px;
  cursor: pointer;
}
.inline-select:hover { border-color: var(--line); }
.inline-select.saving { opacity: .5; }

/* El desplegable de estado se colorea como en la captura */
.st-sel { font-weight: 700; color: #fff; }
tr.row-active .st-sel { background: var(--ok); }
tr.row-watch .st-sel { background: var(--warn); color: #241c00; }
tr.row-inactive .st-sel { background: var(--bad); }
tr.row-left .st-sel { background: #555; }

.grade-chip {
  display: inline-block;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--txt-dim);
}

.tag {
  display: inline-block;
  background: var(--bg-3);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11.5px;
  color: var(--txt-dim);
  white-space: nowrap;
}
.tag-ok { background: rgba(47, 168, 79, .2); color: #9fe0b0; }
.tag-bad { background: rgba(211, 61, 61, .2); color: #f2b4b4; }
.tag-warn { background: rgba(217, 163, 0, .2); color: #ffdf94; }
.tag-role { background: rgba(79, 140, 255, .18); color: #b6cffb; }
.resp-yes { background: rgba(47, 168, 79, .2); color: #9fe0b0; }
.resp-no { background: rgba(211, 61, 61, .2); color: #f2b4b4; }
.resp-maybe { background: rgba(217, 163, 0, .18); color: #ffdf94; }

/* Celda en edicion */
td[data-edit] { cursor: text; }
td[data-edit]:hover { background: rgba(79, 140, 255, .08); }
td.editing { padding: 2px 4px !important; }
td.editing input { padding: 5px 6px; font-size: 13px; }
td.saved { animation: flash-ok 1s ease; }
@keyframes flash-ok {
  0% { background: rgba(47, 168, 79, .35); }
  100% { background: transparent; }
}

/* ---------------- Barra de acciones en lote ---------------- */

.bulkbar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.bulkbar select { width: auto; }

/* ---------------- Tablas pequenas y listas ---------------- */

table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.mini tr:last-child td { border-bottom: 0; }
table.mini.wide td { padding: 9px 6px; }
table.attendance td:last-child { text-align: right; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 9px 0 9px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.feed li:last-child { border-bottom: 0; }
.feed li.lvl-warn { border-left-color: var(--warn); }
.feed li.lvl-danger { border-left-color: var(--bad); }
.feed li.lvl-info { border-left-color: var(--accent); }
.feed li.unread { background: rgba(79, 140, 255, .07); }

.bigpct { font-size: 34px; font-weight: 700; line-height: 1.1; }
.bar { background: var(--bg-3); border-radius: 6px; height: 9px; overflow: hidden; margin: 6px 0; }
.bar-fill { background: var(--ok); height: 100%; }

.chip {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--txt-dim);
  border-radius: 20px;
  padding: 3px 11px;
  font-size: 12.5px;
  cursor: pointer;
}
.chip:hover { color: var(--txt); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip.on.ok { background: var(--ok); border-color: var(--ok); }
.chip.on.bad { background: var(--bad); border-color: var(--bad); }
.rsvp, .att-toggle { display: inline-flex; gap: 5px; align-items: center; }

.pager { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 14px; }
.pager a { padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--txt-dim); }
.pager a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.danger-zone { border-color: var(--bad-soft); }

/* ---------------- Modales ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------------- Login / instalador ---------------- */

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.auth-logo { font-size: 34px; text-align: center; color: var(--accent); }
.auth-title { text-align: center; margin: 6px 0 2px; }
.auth-sub { text-align: center; color: var(--txt-dim); font-size: 13px; margin-bottom: 20px; }
.auth-help { text-align: center; color: var(--txt-dim); font-size: 12.5px; margin-top: 14px; }

.install-steps { color: var(--txt-dim); font-size: 14px; padding-left: 20px; }
.install-steps li.good { color: #9fe0b0; }
.install-steps li.bad { color: #f2b4b4; }

/* ---------------- Movil ---------------- */

@media (max-width: 820px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  table.roster thead th { top: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .wrap { padding: 16px 12px 50px; }
  table.roster { font-size: 12.5px; }
}
