/* ═══════════════════════════════════════════════════════════
   DRAM Rodaje — Sistema de registro y seguimiento
   Canal Mega · Area Dramatica
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Mega brand palette */
  --mega-blue: #3F42C3;
  --mega-blue-dark: #2E30A0;
  --mega-blue-light: #5558D6;
  --mega-blue-subtle: rgba(63, 66, 195, 0.08);
  --mega-blue-glow: rgba(63, 66, 195, 0.15);

  /* Functional colors */
  --success: #0D9B6B;
  --success-bg: rgba(13, 155, 107, 0.10);
  --success-border: rgba(13, 155, 107, 0.25);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.10);
  --warning-border: rgba(217, 119, 6, 0.30);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.10);
  --danger-border: rgba(220, 38, 38, 0.25);

  /* Neutrals */
  --bg: #F8F9FC;
  --bg-alt: #FFFFFF;
  --ink: #111827;
  --ink-secondary: #374151;
  --muted: #6B7280;
  --subtle: #9CA3AF;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  /* Spacing */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

/* ─── Reset ─────────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
  overflow: hidden;
}

.bg-glow {
  display: none;
}

/* ─── Topbar ────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  height: 64px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.92);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
a.brand:hover { opacity: 0.8; }

.brand-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.brand-mark {
  display: none;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-app {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.brand-sub {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--ink-secondary);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  border: none;
  background: transparent;
}

.nav-link:hover {
  background: var(--mega-blue-subtle);
  color: var(--mega-blue);
}

.nav-link.active {
  background: var(--mega-blue-subtle);
  color: var(--mega-blue);
  font-weight: 600;
}

.inline-form {
  margin: 0;
}

.nav-link-button {
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}

.nav-link-button:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.nav-user {
  color: var(--muted);
  font-size: 0.825rem;
  cursor: default;
  padding: 8px 10px;
}

/* ─── Layout ────────────────────────────────────────────── */

.container {
  padding: 32px clamp(16px, 4vw, 48px) 64px;
  max-width: 1140px;
  margin: 0 auto;
}

.page-head {
  margin-bottom: 28px;
  animation: fadeUp 0.5s ease;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

h2, h3 {
  margin-top: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.925rem;
}

.hint {
  margin: 6px 0 0;
  color: var(--subtle);
  font-size: 0.825rem;
}

/* ─── Cards ─────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ─── Grid ──────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* ─── Form fields ───────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

input,
select,
textarea {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.925rem;
  font-family: inherit;
  background: var(--bg-alt);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--mega-blue);
  box-shadow: 0 0 0 3px var(--mega-blue-glow);
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

textarea {
  resize: vertical;
}

.helper {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.hidden {
  display: none;
}

/* El atributo `hidden` debe ganarle a clases que fijan display (.grid, .button),
   si no, elementos ocultos por JS (gate del día, botón Guardar) quedan visibles. */
[hidden] {
  display: none !important;
}

/* ─── Segmented control ─────────────────────────────────── */

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border-radius: calc(var(--radius) - 3px);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.segmented input:checked + label {
  background: var(--mega-blue);
  color: #fff;
  box-shadow: 0 1px 3px rgba(63, 66, 195, 0.3);
}

.segmented input:focus-visible + label {
  border-color: var(--mega-blue);
}

/* ─── Actions / Buttons ─────────────────────────────────── */

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.inline-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.inline-links a {
  color: var(--mega-blue);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
}

.inline-links a:hover {
  text-decoration: underline;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--mega-blue);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.button:hover {
  background: var(--mega-blue-dark);
  box-shadow: 0 2px 8px rgba(63, 66, 195, 0.25);
}

.button:active {
  transform: scale(0.98);
}

.button.secondary {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

.button.secondary:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  box-shadow: none;
}

.button.small {
  padding: 6px 14px;
  font-size: 0.825rem;
}

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

.button.danger:hover {
  background: #B91C1C;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

/* ─── Alerts / Notices ──────────────────────────────────── */

.alert {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.notice {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--success);
  font-weight: 500;
}

/* ─── Info sidebar ──────────────────────────────────────── */

.info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.info h3 {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  margin-bottom: 0;
}

.list {
  padding-left: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
}

/* ─── Hero ──────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Record cards (Mis registros) ──────────────────────── */

.record-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.record {
  animation: fadeUp 0.5s ease both;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.record-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.record-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.record-sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

.badge {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.ok {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge.hold {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.record-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.record-meta span {
  display: block;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.record-notes {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.875rem;
  border: 1px solid var(--border);
}

.record-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ─── Icon buttons ──────────────────────────────────────── */

.icon-button {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--ink-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

/* ─── Sheet / Modal ─────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 12px 20px 16px;
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  overflow: auto;
  animation: sheetUp 0.2s ease;
}

@media (min-width: 960px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: 50%;
    width: min(620px, calc(100% - 48px));
    transform: translate(-50%, 50%);
    border-radius: var(--radius-xl);
    max-height: min(78vh, 760px);
  }
  .sheet-handle {
    display: none;
  }
}

.sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 12px;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-context {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.sheet-context-title {
  font-weight: 700;
  font-size: 0.925rem;
}

.sheet-context-sub {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.3;
  font-size: 0.85rem;
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  padding: 14px 0 2px;
  background: linear-gradient(to top, var(--card) 70%, rgba(255, 255, 255, 0.0));
}

@keyframes sheetUp {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Filters (Seguimiento) ─────────────────────────────── */

.filters {
  margin-bottom: 20px;
}

.filters-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.filters-advanced {
  margin-top: 16px;
}

.filters-toggle {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--mega-blue);
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--mega-blue-subtle);
  border: 1px solid transparent;
  list-style: none;
  transition: background 0.15s ease;
}

.filters-toggle:hover {
  background: var(--mega-blue-glow);
}

.filters-toggle::-webkit-details-marker {
  display: none;
}

/* ─── Optional fields (collapsible) ─────────────────────── */

.optional-fields {
  margin-top: 8px;
}

.optional-grid {
  margin-top: 14px;
}

.details-no-summary > summary {
  display: none;
}

/* Sin resumen visible, el bloque de escena se alinea como una fila más
   (sin el margen extra de .optional-fields / .optional-grid). */
.details-no-summary {
  margin-top: 0;
}

.details-no-summary > .form-row:first-of-type {
  margin-top: 0;
}

/* ─── Panel de estado del día (jornada) ─────────────────── */

.jornada-panel {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.jornada-open-title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.jornada-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.jornada-status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.jornada-chip {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink);
  background: var(--bg-alt);
}

.jornada-chip.en-curso {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}

.jornada-chip.cerrada {
  color: var(--muted);
  border-color: var(--border);
  background: var(--bg-alt);
}

.jornada-subpanel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.button.small {
  padding: 7px 14px;
  font-size: 0.85rem;
}

.alert.warn {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.unit-jornada {
  margin: 6px 0 2px;
}

.chip.jornada-mini {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.chip.jornada-mini.en-curso {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}

.chip.jornada-mini.cerrada {
  color: var(--muted);
  background: var(--bg-alt);
}

.chip.jornada-mini.none {
  color: #b45309;
  border-color: #fcd34d;
  background: #fffbeb;
}

@media (prefers-color-scheme: dark) {
  .jornada-chip.en-curso,
  .chip.jornada-mini.en-curso {
    color: #bbf7d0;
    border-color: #166534;
    background: rgba(22, 101, 52, 0.25);
  }
  .chip.jornada-mini.none {
    color: #fcd34d;
    border-color: #b45309;
    background: rgba(180, 83, 9, 0.18);
  }
  .alert.warn {
    background: rgba(154, 52, 18, 0.2);
    border-color: #9a3412;
    color: #fed7aa;
  }
}

/* ─── Filas de campos en línea (Ítem/Capítulo/Escena/Páginas, horarios) ─── */

.form-row {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.form-row.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 560px) {
  .form-row.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ─── Etiqueta con icono de información ──────────────────── */

.label-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
  position: relative;
  user-select: none;
}

.info-tip:hover,
.info-tip:focus,
.info-tip:focus-visible {
  color: var(--mega-blue);
  border-color: var(--mega-blue);
  outline: none;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  white-space: normal;
  text-align: center;
  background: var(--ink);
  color: var(--bg-alt);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 30;
}

.info-tip:hover::after,
.info-tip:focus::after,
.info-tip:focus-visible::after {
  opacity: 1;
}

/* ─── Summary cards (Seguimiento) ────────────────────────── */

.summary-grid {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

.summary-card {
  padding: 20px 24px;
  overflow: hidden;
}

.summary-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--mega-blue);
  transition: all 0.15s ease;
}

.summary-toggle:hover {
  background: var(--mega-blue-subtle);
}

.summary-toggle .toggle-open {
  display: none;
}

.summary-card[open] .summary-toggle .toggle-open {
  display: inline;
}

.summary-card[open] .summary-toggle .toggle-closed {
  display: none;
}

.summary-summary {
  list-style: none;
  cursor: pointer;
  padding: 20px 24px 16px;
}

.summary-summary::-webkit-details-marker {
  display: none;
}

.summary-expanded {
  padding: 0 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.expanded-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 8px;
}

.meta-line {
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 0.875rem;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* ─── Unit cards (Seguimiento resumen) ───────────────────── */

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.unit-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 14px;
}

.unit-card.unit-1 {
  border-left: 3px solid var(--mega-blue);
}

.unit-card.unit-2 {
  border-left: 3px solid var(--warning);
}

.unit-top {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.unit-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.unit-report-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mega-blue);
  text-decoration: none;
}
.unit-report-link:hover { text-decoration: underline; }

.unit-line {
  line-height: 1.35;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

/* ─── Chips / Tags ──────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.chip.muted {
  color: var(--muted);
}

.chip.unit.unit-1 {
  border-color: rgba(63, 66, 195, 0.3);
  background: rgba(63, 66, 195, 0.08);
  color: var(--mega-blue);
}

.chip.unit.unit-2 {
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.10);
  color: var(--warning);
}

.chip.tipo {
  border-color: var(--border);
  background: var(--bg);
  color: var(--ink-secondary);
}

.chip.teleserie {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Timeline (Seguimiento expanded) ────────────────────── */

.timeline {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.timeline-item {
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: none;
}

.summary-expanded .timeline-item {
  box-shadow: none;
  border-radius: var(--radius);
  background: var(--card);
}

.timeline-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 14px 16px;
  align-items: center;
  font-size: 0.9rem;
  transition: background 0.1s ease;
}

.timeline-summary:hover {
  background: rgba(63, 66, 195, 0.03);
}

.timeline-summary::-webkit-details-marker {
  display: none;
}

.timeline-summary .time {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  min-width: 52px;
  color: var(--ink);
}

.timeline-summary .title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.875rem;
}

.timeline-summary .set {
  flex-basis: 100%;
  color: var(--muted);
  white-space: normal;
  font-size: 0.825rem;
}

.timeline-details {
  padding: 0 16px 16px;
}

/* ─── User permission table (Usuarios) ───────────────────── */

.user-card {
  transition: box-shadow 0.2s ease;
}

.user-head {
  margin-bottom: 16px;
}
.user-head .record-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.perm-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
}

.perm-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-secondary);
}

.perm-table tbody tr:last-child td {
  border-bottom: none;
}

.perm-check {
  text-align: center !important;
  width: 60px;
}

.perm-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--mega-blue);
}

/* ─── Empty state ───────────────────────────────────────── */

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 24px;
  font-size: 0.925rem;
}

/* ─── Animations ────────────────────────────────────────── */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ────────────────────────────────────────── */

@media (max-width: 720px) {
  .topbar {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 2px;
  }

  .nav-link {
    padding: 8px 12px;
    font-size: 0.825rem;
    white-space: nowrap;
  }

  .container {
    padding: 20px 16px 48px;
  }

  .page-head {
    margin-top: 0;
    margin-bottom: 20px;
  }

  .card {
    padding: 18px;
    border-radius: var(--radius);
  }

  .summary-card {
    padding: 16px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.35rem;
  }

  .record-meta {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeline-summary {
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  .unit-grid {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .filters-top {
    flex-direction: column;
    align-items: stretch;
  }

  .record-meta {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── Report ─────────────────────────────────────────────── */

.report { display: flex; flex-direction: column; gap: 20px; }

.report-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.report-header { padding: 24px; }
.report-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.report-title-row h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 24px;
}
.report-meta div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.report-meta div span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.report-summary h3,
.report-suspended h3,
.report-obs h3,
.report-detail h3 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.report-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}
.report-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.report-table tbody tr:last-child td { border-bottom: none; }
.report-table tbody tr:has(+ .row-obs) td { border-bottom: none; }

.detail-table { font-size: 0.82rem; }
.detail-table td,
.detail-table th { padding: 6px 10px; }

.row-suspended { background: var(--warning-bg); }

.row-obs td {
  padding-top: 0 !important;
  padding-bottom: 10px !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  font-style: italic;
}
.row-obs + tr td,
.row-suspended + .row-obs td {
  border-top: none;
}
.row-suspended + .row-obs td {
  background: var(--warning-bg);
}
.obs-label {
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
}

.report-obs ul {
  margin: 0;
  padding-left: 20px;
}
.report-obs li {
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ─── Report responsive (mobile card layout) ────────────── */

@media (max-width: 768px) {
  .detail-table thead { display: none; }

  .detail-table,
  .detail-table tbody,
  .detail-table tr,
  .detail-table td {
    display: block;
    width: 100%;
  }

  .detail-table tbody tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .detail-table tbody tr:last-child { border-bottom: none; }

  .detail-table td {
    padding: 3px 0 !important;
    border: none !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
  }

  .detail-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    margin-right: 12px;
  }

  .detail-table .row-obs td {
    display: block;
    padding: 4px 0 12px !important;
  }
  .detail-table .row-obs td::before { display: none; }

  .row-suspended {
    border-radius: var(--radius-sm);
    padding: 12px !important;
  }
  .row-suspended + .row-obs td {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .report-header { padding: 16px; }
  .report-title-row { flex-wrap: wrap; }
  .report-title-row h2 { font-size: 1.1rem; }
  .report-meta { grid-template-columns: 1fr 1fr; }

  .report-actions {
    flex-direction: column;
  }
  .report-actions .button {
    width: 100%;
    text-align: center;
  }
}

/* ─── Print ──────────────────────────────────────────────── */

@media print {
  .no-print { display: none !important; }
  .topbar { display: none !important; }
  .page-head { margin-bottom: 8px; }

  body {
    background: white;
    font-size: 10pt;
    color: black;
  }
  .container { max-width: 100%; padding: 0; }
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  .report { gap: 8px; }
  .report-header { padding: 16px; }
  .report-detail { break-inside: auto; }
  .badge { border: 1px solid currentColor; }
  .chip { border: 1px solid currentColor; }

  /* Undo mobile card layout — restore native table semantics */
  .detail-table { display: table !important; table-layout: fixed !important; width: 100% !important; }
  .detail-table thead { display: table-header-group !important; }
  .detail-table tbody { display: table-row-group !important; }
  .detail-table tr { display: table-row !important; }
  .detail-table th,
  .detail-table td {
    display: table-cell !important;
    padding: 3px 5px !important;
    border-bottom: 1px solid #ddd !important;
    font-size: 8pt;
    vertical-align: top;
  }
  .detail-table th { font-size: 7.5pt; }
  .detail-table td::before { display: none !important; }

  /* Short columns: no wrap for both th and td */
  .detail-table th:nth-child(1), .detail-table td:nth-child(1),
  .detail-table th:nth-child(2), .detail-table td:nth-child(2),
  .detail-table th:nth-child(3), .detail-table td:nth-child(3),
  .detail-table th:nth-child(7), .detail-table td:nth-child(7) { white-space: nowrap; }

  .row-obs td { font-size: 8.5pt; }
  .row-suspended { background: #fff3cd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .row-suspended + .row-obs td { background: #fff3cd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge.ok { background: #d1fae5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge.hold { background: #fee2e2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { font-size: 7.5pt !important; padding: 1px 5px !important; white-space: nowrap; }
}
