:root {
  --bg: #0B1120;
  --panel: #111A2E;
  --panel-alt: #16213A;
  --line: #233049;
  --text: #F3F6FB;
  --muted: #8C9AB5;
  --green: #10B981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --amber: #F59E0B;
  --red: #EF4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  margin: 0;
}

.panel {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.2vh 2.6vw;
  gap: 2vh;
}

/* ---------- Header ---------- */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 1.1vw; }
.brand-logo { height: 4.2vh; width: auto; }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.6rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.95rem; color: var(--muted); }

.header-status { display: flex; align-items: center; gap: 10px; }
.live-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.clock { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

/* ---------- Body ---------- */
.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2.2vh;
  min-height: 0;
}

/* ---------- Barra de filtro de período ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-btn:hover { color: var(--text); border-color: var(--green); }
.filter-btn.is-active {
  color: #0B1120;
  background: var(--green);
  border-color: var(--green);
}

.filter-custom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  color-scheme: dark;
}

.filter-sep { font-size: 0.78rem; color: var(--muted); }

.filter-apply { padding: 6px 14px; }

.filter-range-label {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.3vw;
}

.kpi-card {
  background: linear-gradient(180deg, var(--panel-alt), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.8vh 1.6vw;
  display: flex;
  flex-direction: column;
  gap: 0.6vh;
}

.kpi-label {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  line-height: 1.1;
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.kpi-trend {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
}
.kpi-trend.up { color: var(--green); background: var(--green-soft); }
.kpi-trend.down { color: var(--red); background: rgba(239, 68, 68, 0.15); }
.kpi-trend.flat { color: var(--amber); background: rgba(245, 158, 11, 0.15); }

.kpi-progress {
  margin-top: 4px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.kpi-progress > span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.kpi-placeholder {
  grid-column: 1 / -1;
  padding: 3vh;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}
.kpi-placeholder code { color: var(--green); }

/* ---------- Alertas (atrasados / em produção) ---------- */
/* Importante: [hidden] precisa vencer o display da classe, senão o atributo
   "hidden" não esconde o elemento (regra do autor tem prioridade sobre a
   folha de estilo padrão do navegador). */
.alert-section[hidden] { display: none; }

.alert-section {
  --alert-color: var(--red);
  --alert-bg: rgba(239, 68, 68, 0.08);
  --alert-chip-bg: rgba(239, 68, 68, 0.16);
  --alert-chip-border: rgba(239, 68, 68, 0.4);
  border: 1.5px solid var(--alert-color);
  background: var(--alert-bg);
  border-radius: 14px;
  padding: 1vh 1.4vw;
  display: flex;
  align-items: center;
  gap: 1.2vw;
  animation: alertPulseRed 1.4s ease-in-out infinite;
}

.alert-section.is-amber {
  --alert-color: var(--amber);
  --alert-bg: rgba(245, 158, 11, 0.08);
  --alert-chip-bg: rgba(245, 158, 11, 0.16);
  --alert-chip-border: rgba(245, 158, 11, 0.4);
  animation-name: alertPulseAmber;
}

.alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--alert-color);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.alert-icon { font-size: 1.2rem; }

.alert-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--alert-chip-bg);
  border: 1px solid var(--alert-chip-border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--text);
}
.alert-chip strong { color: var(--alert-color); font-weight: 700; }

@keyframes alertPulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); border-color: var(--red); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); border-color: rgba(239, 68, 68, 0.5); }
}

@keyframes alertPulseAmber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); border-color: var(--amber); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); border-color: rgba(245, 158, 11, 0.5); }
}

/* ---------- Demandas do dia (fila → produção → publicado) ---------- */
.daily-section[hidden] { display: none; }

.daily-section {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-alt), var(--panel));
  border-radius: 16px;
  padding: 1.4vh 1.4vw;
  display: flex;
  flex-direction: column;
  gap: 1.2vh;
}

.daily-section.all-done { border-color: var(--green); }

.daily-head {
  display: flex;
  align-items: center;
  gap: 1.5vw;
}

.daily-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-shrink: 0;
}
.daily-title-wrap h2 { font-size: 1.15rem; }
.daily-progress-label { font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.daily-section.all-done .daily-progress-label { color: var(--green); }

.daily-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.daily-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.daily-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1vw;
}

.daily-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1vh 0.9vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.daily-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.daily-group.is-queue .daily-group-head { color: var(--muted); }
.daily-group.is-prod .daily-group-head { color: var(--amber); }
.daily-group.is-done .daily-group-head { color: var(--green); }

.daily-group-count { font-weight: 400; color: var(--muted); }

.daily-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.daily-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  max-width: 100%;
}
.daily-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daily-item strong { font-weight: 700; flex-shrink: 0; }

.daily-group.is-queue .daily-item strong { color: var(--muted); }
.daily-group.is-prod .daily-item { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.1); }
.daily-group.is-prod .daily-item strong { color: var(--amber); }
.daily-group.is-done .daily-item { border-color: rgba(16, 185, 129, 0.4); background: var(--green-soft); }
.daily-group.is-done .daily-item strong { color: var(--green); }

.daily-group-empty { font-size: 0.78rem; color: var(--muted); }

@media (max-width: 680px) {
  .daily-groups { grid-template-columns: 1fr; }
}

/* ---------- Visão por colaborador ---------- */
.team-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.team-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1vw;
  min-height: 0;
}

.member-card {
  background: linear-gradient(180deg, var(--panel-alt), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.3vh 1vw;
  display: flex;
  flex-direction: column;
  gap: 0.9vh;
  min-height: 0;
  overflow: hidden;
}

.member-card.has-late { border-color: var(--red); animation: alertPulseRed 1.4s ease-in-out infinite; }

.member-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 0.7vh;
  border-bottom: 1px solid var(--line);
}

.member-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0B1120;
  flex-shrink: 0;
}

.member-name-wrap { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.task-pos {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
  flex-shrink: 0;
}
.member-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-counts { font-size: 0.72rem; color: var(--muted); }
.member-counts .num-late { color: var(--red); font-weight: 700; }
.member-counts .num-done { color: var(--green); font-weight: 700; }

/* O corpo do card é um "slot" fixo: os materiais ficam empilhados e o
   JS troca o visível a cada segundo — sem barra de rolagem na TV. */
.member-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 54px;
}

.member-empty { font-size: 0.8rem; color: var(--muted); }

/* ---------- Calendário editorial (reutilizado em outras seções) ---------- */
.calendar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.calendar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1.3vh;
}
.calendar-head h2 { font-size: 1.3rem; }
.calendar-updated { font-size: 0.88rem; color: var(--muted); }

.task-item {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border-left: 3px solid var(--muted);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.task-item.is-active { opacity: 1; transform: none; }

.task-item.is-done { border-left-color: var(--green); }
.task-item.is-late { border-left-color: var(--red); }

.task-status-dot {
  margin-top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.task-item.is-done .task-status-dot { background: var(--green); }
.task-item.is-late .task-status-dot { background: var(--red); }

.task-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-name {
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.task-item.is-done .task-name { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(140,154,181,0.5); }

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.task-due {
  font-size: 0.68rem;
  color: var(--muted);
}

.task-list-tag {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.calendar-placeholder {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

/* ---------- Estados ---------- */
.state-error {
  color: var(--red);
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .alert-section, .member-card.has-late { animation: none; }
  .task-item { transition: none; }
}

/* A grade é pensada pra TV (tela larga); em telas estreitas
   (ex: conferindo no notebook) quebra em menos colunas com rolagem. */
@media (max-width: 1100px) {
  html, body { overflow: auto; }
  .panel { height: auto; min-height: 100vh; }
}
@media (max-width: 680px) {
  .team-grid { grid-template-columns: repeat(2, 1fr); }
}
