/* Base: tokens, encabezado, botones, acceso, vista en vivo y primitivos compartidos. */
:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #fff;
  --surface-2: #eef1eb;
  --border: #dce1d9;
  --text: #26352e;
  --muted: #657168;
  --accent: #35634c;
  --accent-strong: #264d3a;
  --danger: #b13d35;
  --page-width: 1180px;
  --page-gutter: 28px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); font-size: 14px; line-height: 1.5; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, summary):focus-visible { outline: 3px solid #6c9378; outline-offset: 4px; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 36px); font-weight: 600; line-height: 1.2; letter-spacing: -.035em; margin-bottom: 10px; }
h2 { font-weight: 600; letter-spacing: -.025em; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 30; padding: 12px 20px; background: var(--surface); border: 1px solid var(--accent); border-radius: 6px; }
.skip-link:focus { top: 12px; }
.app-header { min-height: 76px; padding: 0 max(var(--page-gutter), calc((100% - var(--page-width)) / 2)); display: flex; align-items: center; gap: 54px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; letter-spacing: -.045em; flex-shrink: 0; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: white; }
.brand-mark svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.main-nav { display: flex; gap: 28px; align-self: stretch; }
.main-nav a { display: flex; align-items: center; position: relative; color: var(--muted); font-size: 13px; font-weight: 500; min-height: 44px; }
.main-nav a:hover { color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--accent); }
.main-nav a[aria-current="page"]::after { content: ""; height: 2px; background: var(--accent); position: absolute; bottom: 0; left: 0; right: 0; }
.user-actions { margin-left: auto; display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions form { margin: 0; }
.text-button { min-height: 44px; border: 0; background: transparent; padding: 8px 0; color: var(--muted); }
.text-button:hover, .back-link:hover { color: var(--accent); }
.dashboard-shell, .archive-shell { width: min(var(--page-width), calc(100% - var(--page-gutter) * 2)); margin: 0 auto; padding: 48px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.page-heading p { color: var(--muted); margin-bottom: 0; font-size: 14px; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 12px; }
.secure-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.secure-pill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.section-heading { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.section-heading h2 { font-size: 14px; margin: 0; letter-spacing: 0; }
.count-label { display: grid; place-items: center; background: #e8ece5; min-width: 22px; height: 22px; border-radius: 5px; font-size: 11px; color: var(--muted); }
.camera-card { display: grid; grid-template-columns: 1.35fr 1fr; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.camera-preview { min-height: 320px; position: relative; display: grid; place-items: center; overflow: hidden; background: #e9eee5; }
.entrance-illustration { width: min(90%, 500px); height: 300px; color: #869785; }
.preview-label { position: absolute; left: 22px; top: 20px; color: #52634e; font-size: 11px; letter-spacing: .03em; }
.preview-caption { position: absolute; bottom: 14px; left: 22px; margin: 0; color: #586853; font-size: 11px; }
.camera-meta { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 38px; }
.camera-meta .eyebrow { margin-bottom: 9px; }
.camera-meta h2 { font-size: 25px; line-height: 1.25; margin-bottom: 12px; }
.camera-meta p { color: var(--muted); margin-bottom: 24px; font-size: 13px; max-width: 290px; }
.camera-specs { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-bottom: 30px; }
.camera-specs span + span { border-left: 1px solid var(--border); padding-left: 14px; }
.primary-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; gap: 14px; min-height: 44px; padding: 10px 17px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; font-weight: 550; line-height: 1.4; text-align: center; transition: background .15s, border-color .15s; }
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-strong); }
.secondary-button { border-color: var(--border); background: var(--surface); color: var(--text); }
.secondary-button:hover { background: var(--surface-2); border-color: #b5c1b2; }
.shortcut-icon { width: 42px; height: 42px; display: grid; place-items: center; background: #edf0e9; border-radius: 8px; color: var(--accent); flex-shrink: 0; }
.shortcut-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.shortcut-arrow { margin-left: auto; font-size: 21px; padding: 0 8px; }
.page-note { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 28px; font-size: 11px; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; min-height: 36px; color: var(--muted); font-size: 12px; }
/* Access */
.auth-page { background: var(--bg); }
.auth-page .app-header { border: 0; background: transparent; }
.auth-shell { min-height: calc(100dvh - 76px); width: min(980px, calc(100% - 56px)); margin: auto; display: grid; grid-template-columns: 1fr 400px; align-items: center; gap: 90px; padding: 48px 0 100px; }
.auth-copy h1 { font-size: clamp(34px, 5vw, 48px); line-height: 1.12; max-width: 420px; margin-bottom: 22px; }
.auth-copy p { color: var(--muted); max-width: 320px; line-height: 1.8; font-size: 15px; }
.auth-copy .auth-detail { margin-top: 36px; font-size: 12px; padding-top: 18px; border-top: 1px solid var(--border); }
.auth-card { padding: 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.auth-card h2 { margin-bottom: 6px; font-size: 24px; }
.muted, .privacy-note { color: var(--muted); }
.form-stack { display: grid; gap: 8px; margin-top: 26px; }
.form-stack label { margin-top: 10px; font-size: 12px; font-weight: 550; }
.form-stack input, .archive-filter input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #c7cec4; border-radius: 6px; color: var(--text); background: var(--surface); }
.form-stack .primary-button { margin-top: 16px; }
.privacy-note { margin: 22px 0 0; font-size: 11px; line-height: 1.7; }
.alert { margin-top: 20px; padding: 12px 14px; border: 1px solid #e7bfb9; border-radius: 6px; color: #923f35; background: #fff4f1; font-size: 13px; }
/* Live view: light chrome surrounds the dark video surface. */
.viewer-page { height: 100vh; height: 100dvh; min-height: 360px; display: flex; flex-direction: column; }
.viewer-page .app-header { flex-shrink: 0; min-height: 64px; }
.viewer-page main { display: flex; flex: 1; min-height: 0; }
.viewer-shell { width: min(var(--page-width), calc(100% - var(--page-gutter) * 2)); margin: 0 auto; padding: 20px 0 14px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; min-height: 0; }
.viewer-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.viewer-heading > div:first-child { min-width: 0; }
.viewer-heading h1 { margin: 1px 0 0; font-size: 24px; overflow-wrap: anywhere; }
.viewer-actions { display: flex; align-items: center; gap: 18px; flex-shrink: 0; max-width: 60%; }
.live-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.live-status strong { font-weight: 500; }
.live-status span, .privacy-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: #869186; }
.live-status[data-state="live"] { color: var(--accent); }
.live-status[data-state="live"] span, .privacy-dot { background: var(--accent); }
.live-status[data-state="error"] { color: var(--danger); }
.live-status[data-state="error"] span { background: var(--danger); }
.player-frame { position: relative; min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; border-radius: 8px; border: 1px solid var(--border); background: #151b18; }
.player-stage { position: relative; min-height: 0; overflow: hidden; }
.player-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #101512; }
.player-frame:fullscreen { width: 100%; height: 100%; border: 0; border-radius: 0; }
.player-shade { pointer-events: none; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.4), transparent 25%); opacity: 0; transition: opacity .2s; }
.player-frame[data-state="live"]:is(:hover, :focus-within) .player-shade, .player-frame[data-state="live"]:is(:hover, :focus-within) .player-topline { opacity: 1; }
.connection-state { position: absolute; inset: 0; display: grid; align-content: safe center; justify-items: center; padding: 16px; overflow: auto; text-align: center; background: #19211c; color: #f0f3ee; }
.connection-state h2 { margin: 20px 0 8px; font-size: clamp(18px, 3vw, 24px); font-weight: 500; }
.connection-state p { max-width: 460px; margin-bottom: 0; color: #b2beb2; font-size: 13px; }
.connection-state .secondary-button { margin-top: 20px; }
.spinner { width: 30px; height: 30px; border: 2px solid #3a493e; border-top-color: #b3c6a9; border-radius: 50%; animation: spin 1s linear infinite; }
.player-frame[data-state="error"] .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-topline { position: absolute; top: 18px; left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: center; opacity: 0; transition: opacity .2s; pointer-events: none; color: white; }
.live-badge { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 4px; background: #162019cc; font-size: 10px; font-weight: 650; letter-spacing: .08em; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #f38178; }
.player-topline time { font-size: 12px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 5px #000; }
.player-controls { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-top: 1px solid var(--border); background: var(--surface); }
.control-spacer { flex: 1; }
.control-button, .icon-button { min-height: 44px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; }
.control-button { display: flex; align-items: center; gap: 9px; padding: 0 10px; font-size: 12px; font-weight: 500; }
.icon-button { width: 44px; display: grid; place-items: center; }
.control-button:hover, .icon-button:hover { background: var(--surface-2); }
.control-button svg, .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.viewer-footnote { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; color: var(--muted); font-size: 11px; }
.viewer-footnote span { display: flex; align-items: center; gap: 7px; }
/* Archive */
.archive-notice { padding: 13px 16px; border: 1px solid #e3d7b9; border-radius: 6px; background: #fbf6e9; color: #786027; line-height: 1.6; font-size: 13px; }
.archive-filter span, .archive-help { color: var(--muted); font-size: 12px; line-height: 1.7; }
.archive-help { margin: 20px 0; }
.archive-help summary { cursor: pointer; width: fit-content; }
.archive-help p { max-width: 740px; margin: 10px 0 0; }
@media (hover: none) {
  .player-frame[data-state="live"] .player-shade, .player-frame[data-state="live"] .player-topline { opacity: 1; }
}
@media (max-width: 900px) {
  .app-header { gap: 30px; }
  .main-nav { gap: 22px; }
  .user-name { display: none; }
  .auth-shell { gap: 40px; grid-template-columns: 1fr 360px; }
  .camera-meta { padding: 28px; }
}
@media (max-width: 640px) {
  .app-header { padding: 16px 20px 0; flex-wrap: wrap; gap: 0; min-height: auto; }
  .brand { font-size: 17px; }
  .main-nav { order: 3; width: 100%; gap: 26px; margin-top: 12px; }
  .main-nav a { min-height: 46px; font-size: 12px; }
  .user-actions { margin-left: auto; }
  .dashboard-shell, .archive-shell { width: calc(100% - 40px); padding: 30px 0 40px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
  .page-heading h1 { font-size: 28px; }
  .page-heading p { font-size: 13px; }
  .camera-card { grid-template-columns: 1fr; }
  .camera-preview { min-height: 240px; }
  .entrance-illustration { height: 240px; }
  .camera-meta { padding: 26px; }
  .camera-meta h2 { font-size: 23px; }
  .camera-meta p { margin-bottom: 18px; }
  .camera-specs { margin-bottom: 22px; }
  .camera-meta .primary-button { width: 100%; }
  .auth-page .app-header { padding: 22px; }
  .auth-shell { min-height: calc(100dvh - 76px); grid-template-columns: 1fr; gap: 28px; width: min(100% - 40px, 440px); align-content: center; padding: 30px 0 60px; }
  .auth-copy { display: none; }
  .auth-card { padding: 28px 24px; }
  .viewer-page .app-header { padding-top: 8px; }
  .viewer-page .main-nav { margin-top: 4px; }
  .viewer-page .main-nav a { min-height: 38px; }
  .viewer-shell { width: calc(100% - 24px); padding: 12px 0 max(10px, env(safe-area-inset-bottom)); gap: 10px; }
  .viewer-heading { align-items: flex-start; }
  .viewer-heading h1 { font-size: 18px; }
  .viewer-actions { max-width: 48%; gap: 4px; flex-direction: column-reverse; align-items: flex-end; }
  .viewer-actions .secondary-button { font-size: 11px; min-height: 36px; padding: 7px 10px; }
  .live-status { font-size: 10px; text-align: right; }
  .player-topline { top: 12px; left: 12px; right: 12px; }
  .control-button span { display: none; }
  .control-button { width: 44px; padding: 0; justify-content: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .viewer-page .app-header { min-height: 44px; padding-block: 0; }
  .viewer-page .brand-mark { width: 26px; height: 26px; }
  .viewer-shell { padding-block: 8px; gap: 6px; }
  .viewer-heading > div:first-child { display: flex; align-items: center; gap: 16px; }
  .viewer-heading h1 { margin: 0; font-size: 18px; }
  .viewer-footnote { display: none; }
  .connection-state h2 { margin: 8px 0; font-size: 18px; }
  .connection-state .secondary-button { margin-top: 8px; min-height: 36px; }
  .spinner { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Camera workspace and recording explorer */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:disabled { cursor: default; opacity: .38; }
.camera-workspace .viewer-shell { display: block; width: min(1040px, calc(100% - 48px)); padding: 28px 0 64px; }
.camera-workspace .viewer-heading { margin-bottom: 22px; }
.camera-workspace .viewer-heading h1 { font-size: 25px; }
.camera-workspace .player-frame { width: 100%; border-radius: 10px; }
.camera-workspace .player-stage { height: min(56vw, 510px, calc(100dvh - 290px)); min-height: 220px; }
.camera-workspace .player-frame:fullscreen .player-stage { height: auto; min-height: 0; }
.camera-workspace .viewer-footnote { margin: 10px 0 18px; }
.camera-workspace .viewer-actions > .secondary-button { display: none; }
.camera-workspace .app-header { min-height: 64px; }
.real-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.real-preview .preview-caption { background: #142219cc; color: #fff; padding: 6px 10px; border-radius: 4px; bottom: 16px; }
.preview-open { position: relative; display: grid; place-items: center; width: 54px; height: 54px; border: 1px solid #ffffff88; background: #16271d77; color: #fff; border-radius: 50%; font-size: 28px; padding-left: 3px; transition: background .2s; }
.real-preview:hover .preview-open { background: #35634ce6; }
.day-navigation { display: flex; align-items: center; gap: 4px; }
.day-navigation input { min-height: 40px; border: 1px solid var(--border); border-radius: 5px; padding: 7px 10px; background: #fff; color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; max-width: 160px; }
.day-navigation .icon-button { font-size: 17px; width: 34px; }
.day-navigation .secondary-button { min-height: 40px; padding-inline: 12px; margin-left: 6px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; flex-shrink: 0; border-radius: 2px; background: #e2e6dc; }
.legend-dot.available { background: #75957d; }
.legend-dot.pending { background: #ccb884; }
.recording-duration { position: absolute; bottom: 10px; right: 10px; padding: 2px 6px; background: #112218d9; color: #fff; border-radius: 3px; font-size: 10px; font-variant-numeric: tabular-nums; }
.recording-state { color: #87672c; }
.recording-state.ready { color: var(--accent); }
.empty-clock { color: #8c9f80; font-size: 34px; }
.modal-open { overflow: hidden; }
.recording-modal { width: min(940px, calc(100% - 40px)); max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 24px 100px #15221d40; }
.recording-modal::backdrop { background: #14201bc4; backdrop-filter: blur(4px); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; gap: 16px; }
.modal-heading .eyebrow { margin-bottom: 4px; font-size: 10px; }
.modal-heading h2 { margin: 0; font-size: 20px; font-weight: 550; }
.modal-heading .icon-button { flex-shrink: 0; font-size: 28px; color: var(--muted); }
.modal-stage { position: relative; min-height: 180px; background: #151e18; }
.modal-stage video { display: block; width: 100%; aspect-ratio: 16/9; max-height: calc(100dvh - 250px); object-fit: contain; background: #151e18; }
.modal-stage[data-loading="true"]::after { content: "Cargando grabación…"; pointer-events: none; position: absolute; top: 16px; left: 16px; padding: 7px 12px; border-radius: 5px; background: #142219d9; color: white; font-size: 12px; }
.modal-notice { position: absolute; inset: 0; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 28px; color: #edf2e8; background: #151e18ed; text-align: center; font-size: 13px; }
.modal-notice span { max-width: 400px; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; gap: 20px; }
.modal-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .camera-workspace .viewer-shell { width: calc(100% - 32px); padding-top: 16px; }
  .camera-workspace .viewer-heading { margin-bottom: 16px; }
  .camera-workspace .viewer-heading h1 { font-size: 21px; }
  .camera-workspace .player-stage { height: auto; min-height: 0; aspect-ratio: 16/9; }
  .camera-workspace .live-status { font-size: 11px; }
  .day-navigation { width: 100%; justify-content: space-between; gap: 0; }
  .day-navigation input { flex: 1; width: 120px; min-width: 0; }
  .day-navigation .secondary-button { margin-left: 4px; }
  .recording-modal { width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 8px; }
  .modal-heading { padding: 16px; }
  .modal-heading h2 { font-size: 16px; }
  .modal-heading .eyebrow { font-size: 9px; }
  .modal-footer { padding: 16px; flex-wrap: wrap; gap: 12px; }
  .modal-actions { width: 100%; }
  .modal-actions a { flex: 1; font-size: 12px; }
  .modal-stage video { max-height: calc(100dvh - 260px); min-height: 160px; }
}
/* Agrupaciones desplegables */
.activity-group { margin-bottom: 24px; }
.activity-group summary { cursor: pointer; list-style-position: inside; }
.activity-group summary::-webkit-details-marker { display: none; }
.activity-group summary .activity-hour { display: inline-flex; width: calc(100% - 20px); vertical-align: middle; margin: 10px 0; }
