/* Estructura de la aplicación sobre tokens.css + bundle.css del diseño Pati */
html, body { margin: 0; min-height: 100%; }
body { background: var(--shell-bg); }
::selection { background: hsl(213 75% 19% / 0.9); color: #fff; }
a { color: var(--patagonia-700); }
h2, h3 { margin: 0; letter-spacing: -0.02em; }
#app.cp-root { min-height: 100vh; }
[hidden] { display: none !important; }

.skip { position: fixed; top: -6rem; left: 1rem; z-index: 100; background: #fff; color: var(--patagonia-900); padding: 1rem; border-radius: 0.75rem; }
.skip:focus { top: 1rem; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.shell__side { position: fixed; inset: 0 auto 0 0; z-index: 40; }
.shell__body { flex: 1; min-width: 0; margin-left: var(--sidebar-width); }
.shell__main { padding: 32px 24px 64px; }
.shell__main > div { max-width: var(--content-max-width); margin-inline: auto; display: grid; gap: 24px; }
.shell__scrim { display: none; }
.menu-btn { display: none; }
.cp-sidebar__workspace strong { font-size: 16px; }
.cp-sidebar__footer .who { padding: 4px 12px 8px; color: rgb(255 255 255 / 0.55); font-size: 12px; line-height: 16px; }
.cp-sidebar__footer .who strong { display: block; color: #fff; font-weight: 500; font-size: 13px; }
@media (max-width: 1023px) {
  .shell__body { margin-left: 0; }
  .shell__side { transform: translateX(-100%); transition: transform 150ms ease-out; }
  .shell--open .shell__side { transform: none; }
  .shell--open .shell__scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 0.6); }
  .menu-btn { display: inline-flex; }
}
@media (max-width: 639px) {
  .shell__main { padding: 20px 16px 48px; }
}

/* Utilidades */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.grid-stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 1023px) { .grid-2 { grid-template-columns: 1fr; } }
.cp-stat__value--sm { font-size: 28px; }
.small { font-size: 12px; line-height: 16px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.eyebrow { font-size: 12px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 600; }
.link { color: var(--patagonia-700); font-weight: 500; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.cp-card__content--flush { padding: 0; }
.cp-card__header--row { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 0 24px 16px; }
.filters .cp-field { min-width: 160px; }
.cp-table td.cp-num, .cp-table th.cp-num { text-align: right; }
.cp-table th button { all: unset; cursor: pointer; }
.cp-table th button:focus-visible { outline: 3px solid var(--focus-outline); }
textarea.cp-input { height: auto; min-height: 72px; padding: 8px 12px; resize: vertical; }
.cp-input[type='file'] { height: auto; padding: 8px; }
.hint { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.form-error { border-radius: var(--radius-md); background: var(--danger-muted); color: var(--danger-muted-foreground); padding: 8px 12px; font-size: 14px; }
.alert { display: flex; gap: 8px; align-items: flex-start; border-radius: var(--radius-lg); padding: 12px 16px; font-size: 14px; }
.alert--warning { background: var(--warning-muted); color: var(--warning-muted-foreground); }
.alert--danger { background: var(--danger-muted); color: var(--danger-muted-foreground); }
.alert--info { background: var(--info-muted); color: var(--info-muted-foreground); }
.medal { font-size: 18px; }

/* Progreso */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--muted); overflow: hidden; min-width: 80px; }
.progress > i { display: block; height: 100%; background: var(--patagonia-500); border-radius: inherit; }
.progress--done > i { background: var(--success); }

/* Gráfico por día */
.chart { width: 100%; height: 180px; display: block; }
.chart text { font-size: 10px; fill: var(--muted-foreground); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted-foreground); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Evidencias */
.thumb { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); background: var(--muted); cursor: zoom-in; display: block; }
.thumb-btn { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--radius-sm); }
.evidence-full { max-width: 100%; max-height: 60vh; border-radius: var(--radius-lg); border: 1px solid var(--border); display: block; margin-inline: auto; }
.upload-list { display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.upload-item { display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.upload-item img { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); }
.upload-item__info { flex: 1; min-width: 0; font-size: 13px; }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
@media (max-width: 639px) { .timeline li { grid-template-columns: 1fr; gap: 4px; } }

/* Diálogos */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-2xl); box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--foreground); }
dialog.modal--wide { width: min(900px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgb(12 42 82 / 0.55); }
.modal__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 24px 0; }
.modal__body { padding: 16px 24px; display: grid; gap: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 24px 24px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 639px) { .form-grid { grid-template-columns: 1fr; } }

/* Avisos */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--patagonia-900), var(--patagonia-800)); }
.login__card { width: min(400px, 100%); }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 24px; color: #fff; text-align: center; }
.login__brand img { height: 44px; }
.login__brand span { color: var(--sidebar-eyebrow); font-size: 12px; letter-spacing: 0.13em; text-transform: uppercase; }

/* Informe imprimible */
.report { background: #fff; border-radius: var(--radius-2xl); border: 1px solid var(--hairline); padding: 32px; display: grid; gap: 24px; }
.report__banner { background: var(--patagonia-900); color: #fff; border-radius: var(--radius-lg); padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.report__banner img { height: 32px; }
.report h3 { font-size: 16px; margin-bottom: 8px; }
.report .cp-table { font-size: 12px; }
.report .cp-table td, .report .cp-table th { padding: 6px 8px; height: auto; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kv div { border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 10px 12px; }
.kv dt { font-size: 12px; color: var(--muted-foreground); }
.kv dd { margin: 2px 0 0; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--patagonia-900); }

@media print {
  @page { size: A4; margin: 12mm; }
  body, .shell__main { background: #fff !important; padding: 0 !important; }
  .shell__side, .cp-topbar, .no-print, .toasts { display: none !important; }
  .shell__body { margin: 0 !important; }
  .report { border: 0; padding: 0; border-radius: 0; }
  .report__banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report section { break-inside: avoid; }
  .cp-table tr { break-inside: avoid; }
}

.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; }
.cp-table tfoot td { padding: 10px 12px; border-top: 1px solid var(--border); }
.cp-page-header__actions { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }
a.cp-tab, a.cp-btn { text-decoration: none; }
.cp-tabs { max-width: 100%; overflow-x: auto; }
.shell__main > div > *, .grid-2 > *, #tab { min-width: 0; }

/* Manual de uso */
.manual { max-width: 860px; }
.manual p, .manual li, .manual dd { line-height: 1.6; }
.manual ol, .manual ul { padding-left: 20px; display: grid; gap: 6px; margin: 8px 0 12px; }
.manual ul ul { margin-top: 6px; }
.manual p { margin: 0 0 12px; }
.manual .cp-badge { vertical-align: 1px; }
.manual-toc ol { columns: 2 220px; padding-left: 40px; margin: 0; }
.manual-toc li { padding: 3px 0; }
.faq dt { font-weight: 600; margin-top: 14px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 4px 0 0; color: var(--muted-foreground); }
[id^='manual-'] { scroll-margin-top: calc(var(--topbar-height) + 16px); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 8px 12px; border: 1px solid var(--input); border-radius: var(--radius-lg); background: var(--surface-soft); }
.check input { width: 18px; height: 18px; }
