/* Archivo: historial, línea de tiempo, calendario y tarjetas de grabación. */
.archive-shortcut { display: flex; align-items: center; gap: 16px; padding: 24px 0; border-bottom: 1px solid var(--border); }
.archive-shortcut h2 { margin: 0 0 3px; font-size: 14px; }
.archive-shortcut p { margin: 0; font-size: 12px; color: var(--muted); }
.archive-shortcut:hover h2 { color: var(--accent); }
.archive-shell > .back-link { margin: -16px 0 20px; }
.archive-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 24px 0; }
.archive-filter label { font-size: 12px; font-weight: 550; }
.archive-filter input { width: auto; max-width: 100%; font-variant-numeric: tabular-nums; }
.archive-filter span { margin-left: auto; }
.hour-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.hour-card { padding: 18px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fafbf8; min-height: 108px; }
.hour-card h2 { margin: 0 0 12px; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.hour-card.has-recordings { background: var(--surface); box-shadow: inset 3px 0 #8ea687; }
.hour-card.has-recordings h2 { color: var(--accent); font-weight: 650; }
.hour-empty { color: #778074; font-size: 11px; margin: 0; }
.recording-active { color: var(--accent); font-size: 12px; }
.recording-link { display: block; padding: 10px 0; border-top: 1px solid var(--border); font-size: 12px; }
.recording-link:hover strong { color: var(--accent); text-decoration: underline; }
.recording-link span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.archive-player { display: block; width: 100%; max-height: 70vh; aspect-ratio: 16 / 9; background: #101512; border-radius: 8px; }
.archive-protect { display: inline-block; margin: 12px 0 12px 12px; }
.archive-settings { max-width: 840px; padding: 28px; margin: 24px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); line-height: 1.7; }
.archive-settings h2 { font-size: 18px; margin-bottom: 12px; }
.archive-settings p { color: var(--muted); }
.archive-settings .archive-notice { color: #786027; }
.archive-settings details { font-size: 12px; }
.archive-settings summary { cursor: pointer; }
.callback-url { overflow-wrap: anywhere; }
.archive-filter input[type="number"] { width: 100px; }
@media (max-width: 900px) {
  .hour-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .archive-shortcut { gap: 12px; }
  .archive-shortcut p { max-width: 235px; }
  .hour-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hour-card { padding: 14px; }
  .archive-filter { gap: 10px; }
  .archive-filter span { margin-left: 0; width: 100%; }
  .archive-settings { padding: 20px; }
  .archive-protect { margin-left: 0; }
}
.history { min-width: 0; }
.timeline-panel { padding: 22px 24px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.timeline-heading, .history-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.timeline-heading h2, .history-heading h2 { font-size: 17px; margin-bottom: 3px; }
.timeline-heading p, .history-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.timeline-scroll { padding: 24px 0 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
/* El zoom solo estira el ancho: los segmentos siguen en porcentaje y no se recalculan. */
.timeline-zoomer { width: calc(var(--timeline-zoom, 1) * 100%); min-width: 100%; }
.timeline-zoom { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.timeline-zoom span { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; font-size: 11px; }
.timeline-zoom .icon-button { width: 28px; min-height: 28px; border: 1px solid var(--border); border-radius: 5px; font-size: 15px; line-height: 1; color: var(--muted); }
.timeline-zoom .icon-button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.timeline-zoom .icon-button:disabled { opacity: .4; cursor: default; }
.timeline-track { position: relative; height: var(--timeline-row, 32px); background: repeating-linear-gradient(to right, #eff1ec 0, #eff1ec calc(4.16667% - 1px), #dce1d9 calc(4.16667% - 1px), #dce1d9 4.16667%); border-radius: 4px; }
.timeline-segment { position: absolute; top: 0; height: 32px; min-width: 3px; border: 0; border-right: 2px solid white; border-radius: 3px; background: #75957d; padding: 0; }
.timeline-segment.pending { background: #ccb884; }
.timeline-segment:hover, .timeline-segment:focus-visible { background: var(--accent); z-index: 1; }
.timeline-segment:focus-visible { outline-offset: 3px; }
.timeline-no-data { display: block; text-align: center; font-size: 11px; line-height: 32px; color: var(--muted); }
.timeline-ticks { display: flex; justify-content: space-between; margin-top: 9px; font-size: 10px; font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; color: var(--muted); font-size: 10px; }
.timeline-legend > span, .calendar-note { display: flex; align-items: center; gap: 5px; }
.history-timezone { margin-left: auto; }
.history-heading { margin: 32px 0 20px; }
.history-heading p::first-letter, .calendar-heading h3::first-letter { text-transform: uppercase; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: #eef1e9; }
.view-switch button { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; }
.view-switch button[aria-pressed="true"] { border-color: #dde3d7; background: #fff; color: var(--text); box-shadow: 0 1px 2px #26352e0a; }
.view-switch svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.history-browser[data-view="calendar"] { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; align-items: start; }
.calendar-panel { padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.calendar-heading h3 { font-weight: 550; font-size: 13px; margin: 0; }
.calendar-heading .icon-button { width: 30px; min-height: 36px; font-size: 16px; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.calendar-weekdays { margin: 12px 0 6px; text-align: center; font-size: 10px; color: var(--muted); }
.calendar-day { position: relative; height: 36px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; background: transparent; }
.calendar-day:hover:not(:disabled) { background: var(--surface-2); }
.calendar-day.outside-month { color: #8a9589; }
.calendar-day.is-today { border-color: #bac8b3; }
.calendar-day[aria-pressed="true"], .calendar-day[aria-pressed="true"]:hover { background: var(--accent); color: #fff; }
.calendar-day.has-video::after { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); position: absolute; bottom: 3px; left: calc(50% - 1.5px); }
.calendar-day.has-video[aria-pressed="true"]::after { background: white; }
.calendar-note { margin: 16px 0 0; font-size: 10px; color: var(--muted); padding-top: 14px; border-top: 1px solid var(--border); }
.recording-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.history-browser[data-view="calendar"] .recording-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recording-card { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.recording-open { display: block; color: inherit; }
.recording-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.recording-card:hover { border-color: #9aae93; box-shadow: 0 3px 10px #26352e08; }
.recording-cover { position: relative; aspect-ratio: 16 / 9; background: #e9eee5; overflow: hidden; }
.recording-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.recording-play { position: absolute; inset: 0; display: grid; place-items: center; color: white; background: #14211912; font-size: 32px; text-shadow: 0 1px 7px #172219; opacity: 0; transition: opacity .15s; }
.recording-card:hover .recording-play, .recording-open:focus-visible .recording-play { opacity: 1; }
.recording-card-body { padding: 14px; }
.recording-card h3 { font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.recording-card-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 10px; }
.history-empty { text-align: center; padding: 46px 24px; background: #f0f3ec; border-radius: 8px; }
.history-empty h3 { font-size: 16px; font-weight: 550; margin: 12px 0 7px; }
.history-empty p { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.load-recordings { display: flex; margin: 24px auto 0; }
.history[aria-busy="true"] .history-browser, .history[aria-busy="true"] .timeline-scroll { opacity: .55; pointer-events: none; }
@media (max-width: 900px) {
  .history-browser[data-view="calendar"] { grid-template-columns: 260px minmax(0, 1fr); gap: 16px; }
  .recording-grid { gap: 12px; }
  .history-browser[data-view="calendar"] .recording-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .timeline-panel { padding: 16px; }
  .timeline-heading { flex-direction: column; align-items: flex-start; gap: 14px; }
  .timeline-heading h2, .history-heading h2 { font-size: 16px; }
  .timeline-ticks { font-size: 9px; }
  .timeline-ticks span:nth-child(even) { visibility: hidden; }
  .history-timezone { margin-left: 0; width: 100%; }
  .history-heading { flex-wrap: wrap; gap: 16px; margin-top: 28px; }
  .history-heading p { font-size: 11px; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; justify-content: center; min-height: 40px; }
  .history-browser[data-view="calendar"] { grid-template-columns: 1fr; }
  .calendar-panel { max-width: 100%; }
  .calendar-day { height: 42px; }
  .recording-grid, .history-browser[data-view="calendar"] .recording-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .recording-card-body { padding: 11px; }
  .recording-card h3 { font-size: 11px; }
  .recording-card-meta { font-size: 9px; }
}
@media (max-width: 380px) {
  .recording-grid, .history-browser[data-view="calendar"] .recording-grid { grid-template-columns: 1fr; }
  .recording-card h3 { font-size: 13px; }
}
.accordion-list { display: flex; flex-direction: column; gap: 12px; }
.hour-card { border-radius: 8px; border: 1px solid var(--border); overflow: hidden; background: #fafbf8; padding: 0; }
.hour-card.has-recordings { background: var(--surface); box-shadow: inset 3px 0 #8ea687; }
.hour-card summary { cursor: pointer; padding: 12px 16px; outline: none; background: var(--surface-2); font-size: 14px; font-weight: 600; list-style-position: inside; margin: 0; }
.hour-card summary h2 { display: inline; margin: 0; font-size: 14px; }
.hour-card .hour-items { padding: 12px 16px; }
.recording-link { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.recording-link:last-child { border-bottom: none; }

/* Rango de fechas: una fila de 24 h por día, todas en el mismo contenedor, de
   modo que el acercamiento y el desplazamiento quedan sincronizados solos. */
.timeline-rows { display: grid; gap: 6px; }
.timeline-row { display: grid; grid-template-columns: 1fr; align-items: center; }
.timeline-rows[data-density="comfortable"] { --timeline-row: 26px; }
/* Con muchos días las filas adelgazan y el conjunto se lee como densidad. */
.timeline-rows[data-density="compact"] { --timeline-row: 7px; gap: 3px; }
.timeline-rows[data-density="compact"] .timeline-no-data { display: none; }
.timeline-day { position: sticky; left: 0; z-index: 2; width: max-content; padding: 0 6px 2px 0; background: var(--surface); color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.timeline-rows[data-density="compact"] .timeline-day { font-size: 9px; padding-bottom: 0; }

.range-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.range-presets { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.range-presets button { min-height: 38px; padding: 0 13px; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.range-presets button:last-child { border-right: 0; }
.range-presets button:hover { color: var(--text); background: var(--surface-2); }
.range-presets button[aria-pressed="true"] { background: var(--accent); color: white; }
.range-presets button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.range-dash { color: var(--muted); }

.history-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.history-sort { min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font-size: 12.5px; }
.history-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* El rango vigente se resalta entero; el extremo a medio elegir, con borde. */
.calendar-day.in-range:not([aria-pressed="true"]) { background: #e4ebe0; }
.calendar-day.is-anchor { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 640px) {
  .range-bar { width: 100%; }
  .range-presets { flex: 1; }
  .range-presets button { flex: 1; padding: 0 8px; }
  .day-navigation { flex-wrap: wrap; }
  .timeline-rows[data-density="comfortable"] { --timeline-row: 22px; }
}

/* Filtros de la lista */
.history-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 18px; }
.history-filters .filter-chip { cursor: pointer; }
.history-filters .filter-chip[aria-pressed="true"] { color: white; background: var(--accent); border-color: var(--accent); }
.filter-divider { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.recording-events { position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: #0f1a13c4; color: white; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; backdrop-filter: blur(3px); }

/* Vista de lista: una fila por grabación, con la miniatura reducida. Caben
   unas cuatro veces más elementos en la misma pantalla. */
.history-browser[data-view="list"] .recording-grid { grid-template-columns: 1fr; gap: 6px; }
.history-browser[data-view="list"] .recording-card { border-radius: 6px; }
.history-browser[data-view="list"] .recording-open { display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 14px; }
.history-browser[data-view="list"] .recording-cover { aspect-ratio: 16 / 9; border-radius: 6px 0 0 6px; }
.history-browser[data-view="list"] .recording-play { font-size: 20px; }
.history-browser[data-view="list"] .recording-info { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 14px 0 0; }
.history-browser[data-view="list"] .recording-events { position: static; margin-left: auto; background: var(--surface-2); color: var(--muted); }
.history-browser[data-view="list"] .select-box { top: 50%; left: 8px; translate: 0 -50%; }
@media (max-width: 640px) {
  .history-browser[data-view="list"] .recording-open { grid-template-columns: 84px 1fr; gap: 10px; }
  .history-filters { gap: 5px; }
}
