/* ════════════════════════════════════════════════════════════════════════
   PHASE 147 — Episode Links + Season Ledger
   Matches the sr55 Showrunner card language; mobile = full-screen sheet.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Season Ledger card ─────────────────────────────────────────────── */
.p147-kpis { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 14px; }
.p147-kpi {
  background: rgba(103, 76, 46, 0.07);
  border: 1px solid rgba(103, 76, 46, 0.16);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 96px;
}
.p147-kpi strong { display: block; font-size: 1.15rem; color: #3a2718; }
.p147-kpi span { font-size: 0.72rem; color: #74563d; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }

.p147-table { border: 1px solid rgba(103, 76, 46, 0.16); border-radius: 12px; overflow: hidden; }
.p147-grid {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) repeat(6, minmax(52px, 1fr));
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #3a2718;
  border-top: 1px solid rgba(103, 76, 46, 0.1);
  align-items: center;
}
.p147-grid:first-child { border-top: none; }
.p147-gridhead {
  background: rgba(103, 76, 46, 0.08);
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5e432d;
}
.p147-ep { font-weight: 700; }
.p147-un { background: rgba(217, 119, 6, 0.08); color: #92400e; }
.p147-un .p147-ep { color: #92400e; }

/* ── Assignment panel ───────────────────────────────────────────────── */
#p147-panel {
  position: fixed; inset: 0; z-index: 9400;
  background: rgba(20, 14, 8, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.p147-sheet {
  background: #fbf6ec;
  border: 1px solid rgba(103, 76, 46, 0.25);
  border-radius: 18px;
  width: min(680px, 100%);
  max-height: min(80vh, 640px);
  display: flex; flex-direction: column;
  box-shadow: 0 18px 60px rgba(30, 18, 6, 0.35);
}
.p147-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 10px; }
.p147-kicker { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #9a6b3f; }
.p147-head h3 { margin: 2px 0 0; color: #3a2718; font-size: 1.05rem; }
.p147-close {
  border: 1px solid rgba(103, 76, 46, 0.25); background: transparent; color: #5e432d;
  width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 0.9rem;
}
.p147-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 20px 10px; }
.p147-tab {
  border: 1px solid rgba(103, 76, 46, 0.22); background: #fff; color: #5e432d;
  border-radius: 999px; padding: 6px 12px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.p147-tab.active { background: #3a2718; color: #fbf6ec; border-color: #3a2718; }
.p147-body { overflow: auto; padding: 4px 20px; flex: 1; }
.p147-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-top: 1px solid rgba(103, 76, 46, 0.1);
}
.p147-row:first-child { border-top: none; }
.p147-item { font-size: 0.88rem; color: #3a2718; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p147-row select {
  border: 1px solid rgba(103, 76, 46, 0.25); border-radius: 9px; background: #fff;
  color: #3a2718; font-size: 0.82rem; padding: 6px 8px; max-width: 52%;
}
.p147-empty { padding: 26px 4px; color: #74563d; font-size: 0.88rem; }
.p147-foot { padding: 10px 20px 16px; font-size: 0.74rem; color: #9a6b3f; }

/* ── Floating pill on production tabs ───────────────────────────────── */
#p147-pill {
  position: fixed; right: 18px; bottom: 84px; z-index: 8900;
  border: none; border-radius: 999px; cursor: pointer;
  background: #3a2718; color: #fbf6ec;
  font-weight: 800; font-size: 0.82rem; padding: 11px 16px;
  box-shadow: 0 8px 24px rgba(30, 18, 6, 0.35);
}
#p147-pill:hover { transform: translateY(-1px); }

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #p147-panel { padding: 0; align-items: flex-end; }
  .p147-sheet { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .p147-row select { max-width: 46%; }
  #p147-pill { bottom: 132px; right: 12px; }
  /* Ledger table: keep the grid but let it scroll sideways inside the card */
  .p147-table { overflow-x: auto; }
  .p147-grid { grid-template-columns: minmax(120px, 2fr) repeat(6, minmax(44px, 1fr)); min-width: 480px; font-size: 0.78rem; }
  .p147-kpi { min-width: 44%; flex: 1 1 44%; }
}
