/* =======================================================================================
   1) DESIGN TOKENS / ROOT
   ======================================================================================= */
:root {
  --bg: #0f1115;
  --panel: #151922;
  --text: #e7e9ee;
  --muted: #a7adbb;

  --accent: #fae053;
  --accent-2: #2d6cdf;
  --danger: #e24a4a;
  --ok: #16a34a;

  --sidebar-w: 72px;
  --subnav-h: 44px;

  --radius: 14px;

  font-synthesis-weight: none;
}

/* =======================================================================================
   2) RESET Y BASE
   ======================================================================================= */
* { box-sizing: border-box; }

html, body, .layout {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial;
}

a { color: inherit; text-decoration: none; }
.icon { display:inline-block; vertical-align:middle; }

[hidden] { display: none !important; }

/* FORM · reset */
form fieldset{ border:0; padding:0; margin:0; }

/* =======================================================================================
   3) LAYOUT PRINCIPAL Y BOTONES
   ======================================================================================= */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.main {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--subnav-h) 1fr;
}

/* === Base botón global === */
.btn {
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 10px;
  padding: .4rem .6rem;
  font: inherit;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { 
  background: rgba(255,255,255,.08); 
}

.btn:focus-visible {
  outline: 0;
  border-color: rgba(250,224,83,.6);
  box-shadow: 0 0 0 3px rgba(250,224,83,.15);
}

.btn[disabled] { 
  opacity:.6; cursor:not-allowed; 
}

.btn[aria-busy="true"] { 
  position:relative; pointer-events:none; 
}

/* === Mod amarillo (accent) === */
.btn-accent { /* alias de compatibilidad si ya lo usas */
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
}

.btn-accent:hover {
  background: rgba(255,255,255,.08);
  color: var(--text);
}

.btn-accent svg { stroke: currentColor; }

/* Variantes sólidas de botón */
.btn-green{
  background: var(--ok);
  border-color: var(--ok);
  color: #000;
}
.btn-red{
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-green:hover,
.btn-red:hover{
  filter: brightness(1.06);
  color:#fff;
}
.btn--reen svg,
.btn-red svg{
  stroke: currentColor;
}

/* Conservar el hover “a amarillo” dentro de diálogos */
.ui-dialog .btn.btn-green:hover,
.ui-dialog .btn.btn-red:hover{
  background: var(--accent);
  color: #000;
  border-color: #000;
}

/* =======================================================================================
   4) SIDEBAR
   ======================================================================================= */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 20;  
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar .nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.sidebar .nav-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.sidebar .nav-btn.active { background: rgba(250,224,83,.12); color: var(--accent); }

.sidebar .nav-btn svg {
  width: 22px; height: 22px; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.sidebar .nav-btn[data-key="home"] svg { fill: currentColor; stroke: none; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg,#444,#222);
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
  border: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}

.nav-btn[data-route="/settings"] { margin-top: 4px; }
.nav-btn[data-route="/help"] { margin-top: 4px; }

/* =======================================================================================
   5) SUBNAV
   ======================================================================================= */
.subnav {
  height: var(--subnav-h);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 0 12px;
  background: rgb(26, 26, 26);
  border-bottom: 1px solid rgba(255,255,255,.06);
  position: sticky; top: 0; z-index: 1;
}
.subnav-left { display:flex; align-items:center; gap:8px; }
.subnav-right { display:flex; align-items:center; gap:16px; }
.subnav-right > * + * { position: relative; padding-left: 14px; }
.subnav-right > * + *::before {
  content: ""; position:absolute; left:0; top:4px; bottom:4px; width:1px;
  background: rgba(255,255,255,.15); border-radius:1px;
}
.subnav a {
  padding: 6px 10px; border-radius: 10px; color: var(--muted);
  border: 1px solid transparent;
}
.subnav a:hover { background: rgba(255,255,255,.06); color: var(--text); }
.subnav a.active {
  background: rgba(250,224,83,.12); color: var(--accent);
  border-color: rgba(250,224,83,.3);
}

/* =======================================================================================
   6) CONTROLES DE FORMULARIO (SELECT GLOBAL)
   ======================================================================================= */
select:not([multiple]):not([size]) {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  height: 28px; min-width: 220px; padding: 2px 28px 2px 10px;
  font-size: 13px; line-height: 24px; color: var(--text);
  background-color: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a7adbb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select:not([multiple]):not([size]):hover { background-color: rgba(255,255,255,.08); }
select:not([multiple]):not([size]):focus {
  outline: 0; border-color: rgba(250,224,83,.6);
  box-shadow: 0 0 0 3px rgba(250,224,83,.15);
}
select:disabled { opacity: .6; cursor: not-allowed; }
select::-ms-expand { display: none; } /* IE/Edge antiguo */
option { color: var(--text); background: var(--panel); }

/* =======================================================================================
   7) CONTENIDO, CARDS, GRID Y FORMS
   ======================================================================================= */
#app { padding: 16px; }

.card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius);
  padding: 16px;
}

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
@media (max-width: 900px) { .grid.cols-2 { grid-template-columns: 1fr; } }

/* Language select (en Settings) */
.lang-select {
  height: 28px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 2px 8px; font-size: 13px;
}
.lang-select:focus { outline: 0; border-color: rgba(250,224,83,.6); }

/* Accesibilidad */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.settings-inline { display:flex; align-items:center; gap:12px; min-height:28px; }
.settings-inline .hint {
  color: var(--muted); font-size: 12.5px; line-height: 1.2;
  opacity: .9; white-space: nowrap;
}

.img-fluid { max-width:100%; height:auto; display:block; border-radius:8px; } /* test */

/* FORM · layout de etiquetas y títulos */
.form-grid label{ display:grid; gap:6px; }
.form-grid label > span{ font-size:13px; color:var(--muted); line-height:1.2; }

/* FORM · campos */
.form-grid .tbl-input,
.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid input[type="number"],
.form-grid input[type="password"],
.form-grid textarea,
.form-grid select{
  width:100%;
  min-width:0;
  max-width:100%;
  border:1px solid rgba(255,255,255,.25);    /* como las .card */
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius:10px;
  padding:.5rem .6rem;
  font: inherit;
  line-height:1.3;
}

/* foco consistente */
.form-grid .tbl-input:focus-visible,
.form-grid select:focus-visible,
.form-grid textarea:focus-visible{
  outline:0;
  border-color: rgba(250,224,83,.6);
  box-shadow: 0 0 0 3px rgba(250,224,83,.15);
}

/* FORM · sin límites artificiales de ancho */
.form-grid .tbl-input,
.form-grid .tbl-select{
  width:100%;
  min-width:0;       /* anula min-width globales */
  max-width:100%;
}

/* los <select> compactos del sistema, a 100% en formularios */
.form-grid select:not([multiple]):not([size]){
  min-width:0;
  width:100%;
}

/* FORM · rejillas */
.form-grid{ display:grid; gap:12px; }
.form-grid.cols-2{ grid-template-columns:repeat(2,minmax(0,1fr)); }
@media (max-width:900px){ .form-grid.cols-2{ grid-template-columns:1fr; } }

/* FORM · tip y acciones */
.form-grid .hint{ color:var(--muted); font-size:12.5px; }
.form-grid .btn-row{ display:flex; gap:8px; margin-top:6px; }

.hint-error {
  color: var(--danger) !important;
}

/* =======================================================================================
   8) TABLE KIT (REUTILIZABLE PARA TODAS LAS TABLAS)
   ======================================================================================= */

/* Contenedor con scroll si desborda */
.tbl-wrap { overflow:auto; }

/* Tabla base */
.tbl { width:100%; border-collapse:collapse; font-size:14px; }
.tbl th, .tbl td {
  padding:.6rem .8rem;
  border-bottom:1px solid rgba(255,255,255,.06);
  text-align:left;
  vertical-align:middle;
}
.tbl thead th { font-weight:600; color:var(--text); cursor:pointer; }
.tbl tbody tr:hover { background: rgba(255,255,255,.03); }

/* Columna de acciones compacta */
.tbl-th-actions { width:1%; white-space:nowrap; }

/* Toolbar arriba de la tabla (misma separación en todas) */
.tbl-toolbar{
  display:flex; gap:.5rem; align-items:center; flex-wrap:wrap;
  margin:.75rem 0;
}
.tbl-toolbar-spacer{ flex:1 1 auto; }

/* Controles coherentes para tablas */
.tbl-input, .tbl-select, .tbl-btn{
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.04);
  color:var(--text);
  border-radius:10px;
  padding:.4rem .6rem;
  font:inherit;
  line-height:1.2;
}
.tbl-input::placeholder{ color:var(--muted); }

/* Botones genéricos y versión XS del paginador */
.tbl-btn{ display:inline-flex; align-items:center; justify-content:center; gap:.35rem; }
.tbl-btn:hover{ background:rgba(255,255,255,.08); }
.tbl-btn--xs{ padding:.2rem .45rem; font-size:12px; border-radius:8px; }

/* Select compacto “filas por página” */
.tbl-select.table-size{ min-width:0; width:auto; }
.tbl-select.table-size:not([multiple]):not([size]){ padding-right:24px; }

/* Badges de estado */
.tbl-badge{
  display:inline-block; padding:.15rem .5rem; border-radius:999px;
  font-size:12px; line-height:1.2; border:1px solid rgba(255,255,255,.12);
}
.tbl-badge--online  { background:rgba(16,185,129,.16); color:#a7f3d0; }
.tbl-badge--offline { background:rgba(226,74,74,.16);  color:var(--danger); }
.tbl-badge--error   { background:rgba(250,224,83,.16); color:var(--accent); }

/* Acciones por fila: iconos perfectamente centrados */
.tbl-actions{ display:flex; flex-wrap:wrap; gap:.25rem; align-items:center; }
.tbl-iconbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:28px; height:28px; border-radius:8px; padding:0;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.02); color:var(--muted);
  box-sizing:border-box;
}
.tbl-iconbtn:hover{ background:rgba(255,255,255,.08); color:var(--text); }
/* Evita desplazamiento por baseline del SVG */
.tbl-iconbtn .tbl-icon, .tbl-iconbtn svg{ display:block; }
.tbl-act--on{ color:#16a34a; }
.tbl-act--off{ color:var(--danger); }

/* Paginador inferior (igual en todas) */
.tbl-pager{
  display:flex; align-items:center; gap:.5rem;
  justify-content:flex-end; margin-top:.5rem;
}
.tbl-pager-info{ font-size:12px; color:var(--muted); }

/* =======================================================================================
   9) UI DIALOG (NO TABLAS) + ACCIONES POWER
   ======================================================================================= */
.ui-dialog::backdrop { background: rgba(0,0,0,.6); }
.ui-dialog {
  border:0; padding:0; background:transparent;
  width:min(96vw,1100px); max-height:90vh;
}
.ui-dialog.ui--sm { width:min(96vw,520px); }
.ui-dialog.ui--md { width:min(96vw,720px); }
.ui-dialog.ui--lg { width:min(96vw,920px); }
.ui-dialog.ui--xl { width:min(96vw,1100px); }

.ui-dialog__panel {
  background:var(--panel); color:var(--text);
  border:1px solid rgba(255,255,255,.08);
  border-radius:var(--radius);
  box-shadow:0 20px 60px rgba(0,0,0,.5);
  max-height:90vh; display:grid; grid-template-rows:auto 1fr; overflow:hidden;
}

.ui-dialog__hdr {
  display:flex; align-items:center; gap:12px;
  padding:12px 14px; border-bottom:1px solid rgba(255,255,255,.08);
}

.ui-dialog__x {
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.04);
  color:var(--muted); border-radius:10px; padding:.2rem .5rem; flex:0 0 auto;
}
.ui-dialog__x:hover { background:rgba(255,255,255,.08); color:var(--text); }

.ui-dialog__titles { display:flex; flex-direction:column; gap:2px; margin-right:auto; }
.ui-dialog__ttl {
  margin:0; font-size:13px; line-height:1.1; font-weight:700;
  text-transform:uppercase; letter-spacing:.02em;
}
.ui-dialog__subttl {
  margin:0; font-size:12px; line-height:1.2; color:var(--muted);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.ui-dialog__body { padding:14px; overflow:auto; }

/* Cabecera local de la card de detalle */
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  gap:8px; margin-bottom:12px;
}

/* =============================================================================
   DETAIL · GRID Y ESPACIADOS REUTILIZABLES
   - Contenedores para pares etiqueta/valor en tarjetas de detalle
   ========================================================================== */
.kv-grid { display:grid; gap:12px; }
.kv-grid--3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.kv-grid--2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
@media (max-width: 900px){
  .kv-grid--3, .kv-grid--2 { grid-template-columns:1fr; }
}

/* Filas separadas entre grupos (p.ej., fila ID/Nombre/Cliente vs Res/Orientación) */
.kv-row-gap { row-gap:16px; }

/* =============================================================================
   DETAIL · ETIQUETA Y VALOR
   - Etiquetas discretas y valores que destacan
   ========================================================================== */
.kv-item { min-width:0; }                /* evita desbordes en celdas */
.kv-label { font-size:13px; color:var(--muted); line-height:1.2; }
.kv-label--caps { font-variant:small-caps; letter-spacing:.02em; } /* opcional */
.kv-value { color:var(--text); margin-top:4px; word-break:break-word; }

/* =============================================================================
   DETAIL · SEPARADORES SUAVES ENTRE BLOQUES
   ========================================================================== */
.section-sep { margin-top:16px; padding-top:12px; border-top:1px solid rgba(255,255,255,.06); }

/* =============================================================================
   DETAIL · FILA DE BOTONES
   - Espaciado coherente para Edit/Save/Cancel u otros
   ========================================================================== */
.btn-row { display:flex; align-items:center; gap:8px; }
.btn-row .hint { margin-left:4px; }

/* Estados de botones genéricos */
.pl-btn[disabled] { opacity:.6; cursor:not-allowed; }
.pl-btn[aria-busy="true"] { position:relative; pointer-events:none; }

/* =============================================================================
   DETAIL · TRANSICIONES SUAVES (OPCIONAL)
   - Aplica .fade-switch al contenedor y .kv-view / .kv-edit a cada valor/editor
   - Si alternas visibilidad con clases, se animará la opacidad
   ========================================================================== */
.fade-switch .kv-view,
.fade-switch .kv-edit { transition: opacity .15s ease; }
.fade-switch .kv-view[hidden],
.fade-switch .kv-edit[hidden] { display:block; opacity:0; height:0; overflow:hidden; padding:0; margin:0; }
.fade-switch .kv-view:not([hidden]),
.fade-switch .kv-edit:not([hidden]) { opacity:1; height:auto; }

/* =============================================================================
   DETAIL · ACCESIBILIDAD FOCUS
   - Coherente con el resto del sistema
   ========================================================================== */
.sidebar .btn:focus-visible,
.subnav a:focus-visible,
.tbl-iconbtn:focus-visible,
.pl-btn:focus-visible,
.tbl-select:focus-visible,
.tbl-input:focus-visible {
  outline:0;
  border-color: rgba(250,224,83,.6);
  box-shadow: 0 0 0 3px rgba(250,224,83,.15);
}

/* =============================================================================
   DETAIL · UTILIDADES TIPOGRÁFICAS REUTILIZABLES
   ========================================================================== */
.text-muted { color:var(--muted); }
.text-right { text-align:right; }
.nowrap { white-space:nowrap; }
.ellipsis { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.max-w-sm { max-width:700px; }  /* para centrar bloques de lectura si lo necesitas */

/* ==== DETAIL · Ajustes de layout específicos y reutilizables ==== */
.d-label.is-today { color: var(--accent); }

/* Fila 1: ID estrecho, Nombre amplio, Cliente medio */
.kv-cols-3-balanced {
  display:grid;
  grid-template-columns:
    minmax(96px, .5fr)   /* ID */
    minmax(320px, 2fr)   /* Nombre */
    minmax(220px, 1.2fr) /* Cliente */
  ;
  column-gap: 16px;
  row-gap: 8px;
}

/* Fila 2: dos columnas más juntas */
.kv-cols-2-tight {
  display:grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 8px;
}

/* Responsive */
@media (max-width: 900px){
  .kv-cols-3-balanced,
  .kv-cols-2-tight { grid-template-columns: 1fr; }
}

/* DETAIL · selects con ancho automático dentro de player_detail */
#player-detail .kv-item .tbl-select:not([multiple]):not([size]) {
  min-width: 0;   /* anula el 220px global */
  width: auto;    /* se ajusta al contenido */
  max-width: 100%;/* evita desbordes en grid */
  display: inline-block;
  white-space: nowrap;
  padding-right: 28px; /* deja espacio para la flecha */
}

/* Fila 1: 75/25 */
.grid.cols-2-75 { grid-template-columns: 3fr 1fr; }
@media (max-width: 900px){ .grid.cols-2-75 { grid-template-columns:1fr; } }

/* Pila derecha (Estado + Acciones) */
.side-stack { display:grid; gap:12px; align-content:start; }

/* Acciones rápidas compactas */
#quick-actions .tbl-actions { gap:.35rem; }
#quick-actions .tbl-iconbtn { width:30px; height:30px; }

/* Badge ON/OFF (si no lo tienes ya) */
.state-badge{display:inline-block;padding:.2rem .6rem;border-radius:999px;font-weight:600;border:1px solid rgba(255,255,255,.12)}
.state-badge.on{background:rgba(16,185,129,.16);color:#a7f3d0}
.state-badge.off{background:rgba(226,74,74,.16);color:var(--danger)}

/* Utilidad global: select auto-width */
.tbl-select--auto:not([multiple]):not([size]) { min-width:0; width:auto; max-width:100%; white-space:nowrap; padding-right:28px; }

#player-detail #sched .tbl-select:not([multiple]):not([size]) {
  min-width: 0; width: auto; max-width: 100%; padding-right: 28px;
}
#player-detail #waker-box .tbl-select:not([multiple]):not([size]) {
  min-width: 0; width: auto; max-width: 100%; padding-right: 28px;
}

/* Estilo de diálogos consistente con el panel */
.nds-dialog { border: 0; padding: 0; background: transparent; }
.nds-dialog::backdrop { background: rgba(0,0,0,.55); }

.dlg-panel {
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  min-width: 520px;
  max-width: 90vw;
}
.dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.dlg-title { margin: 0; font-size: 16px; }
.dlg-body { padding: 16px; display: grid; gap: 12px; }
.dlg-body label { display: grid; gap: 6px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }

/* Power Calendar */
.pc-wrap { display:flex; flex-direction:column; gap:12px; }

.pc-head{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  /* Fila 1: Add | Título | Waker  · Fila 2: vacío | Nav | vacío */
  grid-template-areas:
    "sp  title sp2"
    "add   nav   waker";
  align-items:end;
  gap:8px;
  text-align:center;
}

.pc-title{ grid-area:title; font-weight:600; font-size:1.1rem; }
.pc-nav{ grid-area:nav; display:flex; justify-content:center; gap:8px; }

.pc-add{ grid-area:add; display:flex; justify-content:start; }   /* <- izquierda */
.pc-waker{ grid-area:waker; display:flex; justify-content:end; opacity:.85; }

.pc-sp{ grid-area:sp; }      /* placeholders de la segunda fila */
.pc-sp2{ grid-area:sp2; }

.pc-grid{ display:grid; gap:8px; }
.pc-ghead{ display:grid; grid-template-columns:repeat(7,1fr); gap:4px; }
.pc-gdow{ text-align:center; opacity:.7; font-size:.9rem; }
.pc-gbody{ display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }

.pc-day{ border:1px solid var(--border, rgba(255,255,255,.12)); border-radius:12px; padding:8px; min-height:110px; display:flex; flex-direction:column; }
.pc-day:hover{ outline:1px solid rgba(255,255,255,.18); cursor:pointer; }
.pc-empty{ visibility:hidden; }
.pc-daynum{ font-weight:600; opacity:.8; margin-bottom:6px; }
.pc-evs{ display:flex; flex-wrap:wrap; gap:6px; }

.pc-ev{ font:inherit; border:0; border-radius:999px; padding:4px 8px; line-height:1; }
.pc-ev.on{ background: var(--ok, #39d98a1a); color: var(--ok-fg, #39d98a); }
.pc-ev.off{ background: var(--warn, #ff63631a); color: var(--warn-fg, #ff6363); }

.pc-legend{ display:flex; align-items:center; gap:8px; opacity:.8; font-size:.9rem; }
.pc-dot{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:4px; vertical-align:middle; }
.pc-on{ background: var(--ok, #39d98a); }
.pc-off{ background: var(--warn, #ff6363); }
.pc-gap{ width:12px; }

.pc-form label,.pc-wd-box { display:flex; flex-direction:column; gap:6px; }
.pc-form .tbl-input,.pc-form .tbl-select{ width:100%; }
.pc-form .pc-row{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
@media (max-width:900px){ .pc-form .pc-row{ grid-template-columns:1fr; } }

/* Responsive */
@media (max-width:700px){
  .pc-head{
    grid-template-columns: 1fr;
    grid-template-areas:
      "add"
      "title"
      "nav"
      "waker";
    text-align:left;
  }
  .pc-add, .pc-waker{ justify-content:start; }
}

/* Día actual */
.pc-day.is-today{
  --border: var(--accent);
  box-shadow: 0 0 0 1px rgba(250,224,83,.25) inset;
}
.pc-day.is-today .pc-daynum{
  color: var(--accent);
  opacity: 1;
}

.pc-wd-list{ display:flex; gap:6px; flex-wrap:wrap; }
.pc-wd-pill{
  height:28px;
  display:inline-grid; place-items:center;
  border:1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-radius:8px; font-weight:600; letter-spacing:.02em;
  cursor:pointer; user-select:none;
}
.pc-wd-pill.is-on{
  background: var(--accent);
  border-color: var(--accent);
  color:#111;
}
.pc-wd-pill:focus-visible{
  outline:0;
  border-color: rgba(250,224,83,.6);
  box-shadow:0 0 0 3px rgba(250,224,83,.15);
}

/* ==== FIXES GENERALES PARA EVITAR DESBORDES ==== */
.grid > * { min-width: 0; }                 /* hijos de grid pueden encoger */
/* Cards fluidas dentro de los detalles */
#player-detail .card,
#user-detail .card,
#org-detail .card {
  min-width: 0;
  margin-bottom: 20px;
}

html, body { overflow-x: hidden; }          /* cinturón de seguridad */

/* =================== Programación =================== */
#schedule-card { min-width:0; }

.sched-head{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-bottom:8px;
}
.sched-ctrls{ display:flex; gap:8px; align-items:center; }
.sched-date{ min-width:0; width:auto; }

/* El scroll horizontal vive aquí, nunca en la página */
.timeline-wrap{
  --hourW: 36px;                 /* fallback; el JS la sobreescribe */
  width:100%;
  max-width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  overscroll-behavior-inline: contain;
  border:1px solid rgba(255,255,255,.06);
  border-radius:12px;
  contain: inline-size paint;    /* aísla layout para evitar expansión */
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* IE/Edge */
}

/* La tira interna puede ser muy ancha, pero no expande al padre */
.timeline{
  position:relative;
  min-height:230px;
  display:block;
  width:max-content;             /* se adapta al contenido */
  min-width:100%;                /* nunca menor que el contenedor */
}

/* Cabecera: días + rejilla de 24h */
.sched-dates{
  position:relative;
  height:60px;
  white-space:nowrap;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.sched-day{
  position:relative;
  display:inline-block;
  height:100%;
  border-right:1px solid rgba(255,255,255,.06);
}
.sched-day .d-label{
  font-size:12px; padding:4px 6px 0; font-weight:600; opacity:.85;
}
.sched-day .h-grid{ height:calc(100% - 20px); display:flex; }
.sched-day .h-grid span{
  flex:1; min-width:var(--hourW); text-align:center; font-size:10px;
  color:rgba(255,255,255,.35); border-left:1px solid rgba(255,255,255,.05);
}
.sched-day .h-grid span:first-child{ border-left:none; }

/* Pistas */
.sched-row{
  position:relative; white-space:nowrap;
  border-top:1px solid rgba(255,255,255,.06);
  min-height:140px;
}
.sched-row--ads{ min-height:90px; }

/* Líneas verticales en pistas, alineadas con horas */
.sched-row::before{
  content:""; position:absolute; inset:0;
  background:
    repeating-linear-gradient(to right,
      rgba(255,255,255,.04) 0,
      rgba(255,255,255,.04) 1px,
      transparent 1px,
      transparent var(--hourW)
    );
  pointer-events:none;
}

/* Leyenda */
.sched-legend{ display:flex; gap:16px; align-items:center; margin-top:10px; opacity:.9; }
.dot{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:-1px; }
.dot-img{ background:#2d6cdf; }   /* azul */
.dot-vid{ background:#39d98a; }   /* verde */
.dot-pri{ background:#e24a4a; }   /* rojo */
.dot-adv{ background:#fae053; }   /* amarillo */

/* =============================================================================
   DASHBOARD HOME
   ============================================================================= */

/* Columna principal del dashboard */
.dash-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Filas internas del dashboard */
.dash-row {
  display: grid;
  gap: 16px;
}

/* Dos donuts principales lado a lado */
.dash-row--donuts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .dash-row--donuts {
    grid-template-columns: 1fr;
  }
}

/* Tarjeta KPI interna */
.dash-kpi-card {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.dash-kpi-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.dash-kpi-header p {
  margin: 2px 0 0;
  font-size: 0.9rem;
}

/* Cuerpo KPI: donut + leyenda */
.dash-kpi-body {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Donut circular genérico */
.dash-donut {
  position: relative;
  width: 120px;
  max-width: 40vw;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
}

.dash-donut__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.dash-donut__bg,
.dash-donut__value {
  fill: none;
  stroke-width: 3;
}

.dash-donut__bg {
  stroke: rgba(255, 255, 255, 0.08);
}

.dash-donut__value {
  stroke: var(--accent); /* valor por defecto */
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.35s ease;
}

/* Colores por tipo de donut */
.dash-donut[data-chart="orgs"] .dash-donut__value {
  stroke: var(--ok); /* organizaciones activas: coincide con dot verde */
}

.dash-donut[data-chart="users"] .dash-donut__value {
  stroke: var(--accent-2);
}

.dash-donut[data-chart="players"] .dash-donut__value {
  stroke: var(--ok);
}

.dash-donut[data-chart="wakers"] .dash-donut__value {
  stroke: var(--danger);
}

/* Ajuste de colores para el donut de organizaciones */
.dash-donut[data-chart="orgs"] .dash-donut__value--active {
  stroke: var(--ok);      /* verde, mismo que dash-dot--on */
}

.dash-donut[data-chart="orgs"] .dash-donut__value--inactive {
  stroke: var(--danger);  /* rojo, mismo que dash-dot--off */
}

/* Contenido centrado en el donut */
.dash-donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dash-donut__big {
  font-size: 1.4rem;
  font-weight: 600;
}

.dash-donut__label {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Leyenda de los donuts */
.dash-kpi-legend {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

/* Dots de estado */
.dash-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
}

.dash-dot--on {
  background: var(--ok);
}

.dash-dot--off {
  background: var(--danger);
}

/* Tiles secundarios (players, wakers, etc.) */
.dash-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 900px) {
  .dash-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.dash-tile {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-tile-label {
  font-size: 12px;
  color: var(--muted);
}

.dash-tile-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.dash-tile-tag {
  font-size: 11px;
}

/* Columna lateral del dashboard */
.dash-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-side-block h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

/* Medidor lineal para cuota */
.dash-linear-meter {
  display: grid;
  gap: 6px;
}

.dash-linear-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dash-linear-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.35s ease;
}

.dash-linear-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

/* Lista de alertas */
.dash-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.dash-list li + li {
  margin-top: 4px;
}

/* Planes contratados */
.dash-plans {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.dash-plan-count {
  font-weight: 600;
  color: var(--accent);
}