:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2f3a;
  --text: #e6e8eb;
  --muted: #9aa2af;
  --accent: #4f8cff;
  --danger: #e5484d;
  --ok: #3ecf8e;
  --warn: #e5a83d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1rem auto;
  max-width: 1100px;
}

.login-card {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, button {
  font: inherit;
}

input[type="text"], input[type="password"], input[type="number"], select {
  background: #0d0f13;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
}

button.danger { background: var(--danger); }

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
  font-size: 0.85rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

main { padding: 0 1rem; }

.inline-form { display: flex; gap: 0.5rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
tr.row-disabled { opacity: 0.5; }

.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.actions form { display: inline; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
}
.badge-live { background: var(--ok); color: #04321f; }
.badge-stale { background: var(--warn); color: #402c04; }
.badge-offline { background: var(--border); color: var(--muted); }
.badge-disabled { background: var(--danger); color: white; }
.badge-rec { background: #b91c1c; color: white; }
.badge-rec-off { background: var(--border); color: var(--warn); }

.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }

.secret-cell code { font-size: 0.8rem; }
.secret-item { display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.secret-item + .secret-item { margin-top: 0.25rem; }
.secret-label { color: var(--muted); font-size: 0.75rem; }

.flash { padding: 0.6rem 1rem; border-radius: 6px; max-width: 1100px; margin: 1rem auto; }
.flash-ok { background: #123524; color: var(--ok); }
.flash-error { background: #3a1418; color: var(--danger); }
.error { color: var(--danger); }
.muted { color: var(--muted); }

a { color: var(--accent); }

.nav { display: flex; gap: 1rem; }
.nav-link { text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.nav-link.nav-active { color: var(--text); font-weight: 600; }

.channel-form { display: flex; flex-direction: column; gap: 1rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row label, .form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.overrides-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.overrides-fieldset legend { color: var(--muted); font-size: 0.85rem; padding: 0 0.4rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.rendition-row {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.key-reveal-card {
  border-color: var(--warn);
}
.key-reveal-card .secret-value {
  word-break: break-all;
  font-size: 0.95rem;
}

/* --- Player modal (live preview en canales + VOD en clips) --- */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-modal[hidden] { display: none; }
.player-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.player-box {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  width: min(960px, 92vw);
}
.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.player-head-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.player-head-controls select { padding: 0.2rem 0.4rem; }
.player-box video {
  width: 100%;
  max-height: 70vh;
  background: black;
  border-radius: 6px;
}

/* --- URL popup (tabla de canales) --- */
.url-box { width: min(720px, 92vw); }
.url-value {
  display: block;
  word-break: break-all;
  background: #0d0f13;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.url-actions { display: flex; gap: 0.75rem; }
.playback-cell { white-space: nowrap; }

/* --- Users page --- */
.platform-checks { border: none; padding: 0; margin: 0.5rem 0; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.platform-checks legend { padding: 0; margin-bottom: 0.25rem; }
.check-inline { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }

/* --- Activity page --- */
.window-picker { font-size: 0.85rem; margin-left: 1rem; }
.window-picker .nav-active { color: var(--accent); font-weight: 600; }
.timeline-grid {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr minmax(140px, max-content);
  gap: 0.4rem 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.timeline-track {
  position: relative;
  height: 18px;
  background: #0d0f13;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.timeline-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--ok);
  border-radius: 2px;
}
.timeline-meta { font-size: 0.8rem; white-space: nowrap; }
.heatmap-scroll { overflow-x: auto; }
.heatmap { border-collapse: collapse; }
.heatmap th { font-weight: 400; font-size: 0.7rem; padding: 0.15rem 0.25rem; }
.heat-cell {
  min-width: 34px;
  text-align: center;
  font-size: 0.7rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  color: #fff;
}

/* --- Branding --- */
.brand h1 { margin: 0; }
.brand-sub { font-size: 0.75rem; margin-top: 0.1rem; }

/* El atributo hidden debe ganar SIEMPRE, también sobre los display:flex de
   los labels del formulario (si no, el campo "oculto" se ve igualmente). */
[hidden] { display: none !important; }
