/* relojchecador — sistema visual.
   Una familia para la interfaz (Inter), una serif itálica de acento
   (Instrument Serif), un solo acento de color, y el color reservado para lo
   que significa algo: ordinario, doble, triple.
   El movimiento solo confirma una acción o muestra de dónde viene una capa. */

/* Fuentes alojadas en el propio sitio (la política de seguridad no admite
   otros dominios). Subconjunto latino: cubre el español. Licencia SIL Open
   Font License 1.1; los textos están en /fonts/. Origen: paquetes de npm
   @fontsource-variable/inter 5.3.0 y @fontsource/instrument-serif 5.3.0. */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-opsz-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-opsz-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: rgba(0, 0, 0, 0.1);
  --fill: rgba(0, 0, 0, 0.05);
  --fill-press: rgba(0, 0, 0, 0.1);
  --accent: #0071e3;
  --accent-text: #0066cc;
  --on-accent: #ffffff;
  --ok: #248a3d;
  --double: #b25000;
  --double-fill: #f5a623;
  --triple: #d70015;
  /* Semánticos con nombre propio y sus fondos suaves. --warn y --danger son
     los mismos tonos que --double y --triple, que además significan horas. */
  --warn: var(--double);
  --danger: var(--triple);
  --info: #0066cc;
  --ok-soft: color-mix(in srgb, var(--ok) 13%, var(--surface));
  --warn-soft: color-mix(in srgb, var(--warn) 12%, var(--surface));
  --danger-soft: color-mix(in srgb, var(--danger) 10%, var(--surface));
  --info-soft: color-mix(in srgb, var(--info) 10%, var(--surface));
  --line-soft: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.45);
  --chrome: rgba(255, 255, 255, 0.72);
  --scrim: rgba(0, 0, 0, 0.32);
  --shadow-sheet: 0 24px 80px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);

  --radius: 18px;
  --radius-s: 12px;

  /* Familias. --display y --sans son Inter (con eje óptico: el corte de
     titulares entra solo al crecer el cuerpo). --serif es solo un acento en
     itálica. --mono, solo para cifras en columna e identificadores. */
  --sans: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: var(--sans);
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* Curvas y tiempos. Fuente: skills animate y apple-design. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --t-press: 120ms;
  --t-ui: 200ms;
  --t-sheet: 380ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --line: rgba(255, 255, 255, 0.14);
    --fill: rgba(255, 255, 255, 0.08);
    --fill-press: rgba(255, 255, 255, 0.16);
    --accent: #0a84ff;
    --accent-text: #2997ff;
    --ok: #30d158;
    --double: #ff9f0a;
    --double-fill: #ff9f0a;
    --triple: #ff453a;
    --info: #4da3ff;
    --line-soft: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.5);
    --chrome: rgba(22, 22, 23, 0.72);
    --scrim: rgba(0, 0, 0, 0.56);
    --shadow-sheet: 0 24px 80px rgba(0, 0, 0, 0.6);
  }
}

@media (prefers-contrast: more) {
  :root { --line: currentColor; --text-2: var(--text); --text-3: var(--text); }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font: 100%/1.5 var(--sans);
  font-optical-sizing: auto;
  font-synthesis-weight: none;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
}

body { margin: 0; min-height: 100dvh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-text); text-decoration: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

/* ── Tipografía. Escala única: el tracking baja y el interlineado se
      aprieta al crecer el cuerpo; el texto corrido queda en 0. La jerarquía
      sale de peso + tamaño + interlineado, nunca de mayúsculas.
      cuerpo        tamaño                       interl.  tracking  peso
      .display      clamp(2.5rem, 6vw, 4.5rem)   1.02     -0.04em   600
      .title        clamp(1.625rem, 3vw, 2.25rem) 1.12    -0.028em  600
      .headline     1.25rem                      1.25     -0.018em  600
      .lead         clamp(1.0625rem, 1.5vw, 1.25rem) 1.5  -0.011em  400
      texto         1rem                         1.5      0         400
      .caption      0.8125rem                    1.45     0         400
      .eyebrow      0.875rem                     1.4      0         500  ── */
.display { font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: 1.02; letter-spacing: -0.04em; font-weight: 600; text-wrap: balance; }
.title { font-size: clamp(1.625rem, 3vw, 2.25rem); line-height: 1.12; letter-spacing: -0.028em; font-weight: 600; text-wrap: balance; }
.headline { font-size: 1.25rem; line-height: 1.25; letter-spacing: -0.018em; font-weight: 600; }
.lead { font-size: clamp(1.0625rem, 1.5vw, 1.25rem); line-height: 1.5; letter-spacing: -0.011em; color: var(--text-2); text-wrap: pretty; }
.caption { font-size: 0.8125rem; line-height: 1.45; letter-spacing: 0; color: var(--text-2); }
/* Rótulo sobre un título: texto normal. Como mucho uno por pantalla y solo
   si aporta un dato (una fecha, un periodo, una cuenta regresiva). */
.eyebrow { font-size: 0.875rem; line-height: 1.4; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
/* Encabezados de tabla: texto normal, sin mayúsculas ni monoespaciada. */
th { font-size: 0.8125rem; line-height: 1.4; font-weight: 500; letter-spacing: 0; text-transform: none; text-align: left; color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }

/* ── Botones. La respuesta ocurre al presionar, no al soltar. ── */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 44px; padding: 0 1.25em; border-radius: 999px;
  background: var(--fill); color: var(--text);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-press) ease;
}
.btn:active { transform: scale(0.97); background: var(--fill-press); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn.large { min-height: 56px; padding: 0 1.75em; font-size: 1.0625rem; }
.btn.block { width: 100%; }
.btn.plain { background: none; color: var(--accent-text); padding: 0 0.5em; }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled):not(:active) { background: var(--fill-press); }
  .btn.primary:hover:not(:disabled):not(:active) { background: color-mix(in srgb, var(--accent) 92%, #fff); }
  .btn.plain:hover:not(:disabled) { background: none; text-decoration: underline; }
}

/* ── Campos ── */
.field { display: grid; gap: 6px; }
/* Etiqueta de campo: texto normal en minúsculas, legible, pegada a su campo. */
.field > span { font-size: 0.875rem; line-height: 1.4; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text); }
.input, select.input {
  appearance: none; font: inherit; font-size: 1.0625rem; /* ≥16px: iOS no hace zoom */
  width: 100%; min-height: 48px; padding: 0 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  transition: border-color var(--t-ui) ease, box-shadow var(--t-ui) ease;
}
select.input {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2386868b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.error { color: var(--triple); font-size: 0.9375rem; }
.error:empty { display: none; }
/* Acceso con Google: separador «o» y el botón oficial, centrado. */
.google-login { display: grid; justify-items: center; gap: 20px; color-scheme: light; }
.google-login::before {
  content: "o"; width: 100%; text-align: center; color: var(--text-3); font-size: 0.875rem; line-height: 1;
  background:
    linear-gradient(var(--line) 0 0) left center / calc(50% - 20px) 1px no-repeat,
    linear-gradient(var(--line) 0 0) right center / calc(50% - 20px) 1px no-repeat;
}

/* ── Superficies ── */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }
.stack { display: grid; gap: 16px; }
.stack-l { display: grid; gap: 32px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.wrap { width: min(1040px, 100% - 40px); margin-inline: auto; }

/* Lista agrupada: una sola superficie, separadores finos alineados al texto. */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.list > li, .list > .item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; min-height: 56px; position: relative; }
.list > li + li::before, .list > .item + .item::before { content: ""; position: absolute; top: 0; left: 20px; right: 0; border-top: 1px solid var(--line); }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.item { appearance: none; border: 0; background: none; font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: background-color var(--t-press) ease; }
button.item:active { background: var(--fill); }
@media (hover: hover) and (pointer: fine) { button.item:hover { background: var(--fill); } }
.chev { color: var(--text-3); flex: none; }
.empty { padding: 28px 20px; text-align: center; color: var(--text-2); background: var(--surface); border-radius: var(--radius); }

/* Etiqueta de estado: pequeña y sin gritar. El color es del estado; el fondo, su tono suave. */
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 550; letter-spacing: 0; background: var(--fill); color: var(--text-2); white-space: nowrap; }
.tag.double, .tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.triple, .tag.danger { color: var(--danger); background: var(--danger-soft); }
.tag.ok { color: var(--ok); background: var(--ok-soft); }
.tag.info { color: var(--info); background: var(--info-soft); }

.notice { display: grid; gap: 4px; padding: 14px 18px; border-radius: var(--radius-s); background: var(--warn-soft); }
.notice strong { font-weight: 600; }
.notice.bad { background: var(--danger-soft); }
.notice.ok { background: var(--ok-soft); }
.notice.info { background: var(--fill); }
.notice ul { display: grid; gap: 2px; color: var(--text-2); font-size: 0.9375rem; }

/* ── Ilustración isométrica (web/static/img/iso/). Estado vacío con dibujo:
      el dibujo centrado encima de la frase. .iso-dots pone detrás la retícula
      de puntos del sistema; solo en composiciones grandes. ── */
.empty .iso, .iso { display: block; margin-inline: auto; max-width: 100%; height: auto; }
.iso-dots { background-image: radial-gradient(circle, var(--line) 1px, transparent 1.5px); background-size: 16px 16px; background-position: center; }

/* ── Barra superior: material translúcido, el contenido pasa por debajo. ── */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--chrome);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar-in { display: flex; align-items: center; gap: 20px; min-height: 52px; }
/* Solo el logotipo: <body class="brand"> no debe heredar este peso. */
a.brand, span.brand, .bar .brand { font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
/* Marca: reloj abierto cuyas manecillas forman la verificación. */
.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.logo .mark { width: 22px; height: 22px; flex: none; }
.logo .word { font-size: 1.0625rem; font-weight: 450; letter-spacing: -0.025em; }
.logo .word b { font-weight: 600; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
/* Cambiar de vista es frecuente: el cambio es inmediato, sin animación. */
.tab { appearance: none; border: 0; background: none; font: inherit; font-size: 0.9375rem; color: var(--text-2); padding: 8px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tab[aria-current="page"] { color: var(--text); background: var(--fill); font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--text); } }
.bar select.input { min-height: 36px; font-size: 0.9375rem; width: auto; max-width: min(300px, 42vw); border-radius: 999px; background-color: transparent; }
/* En pantallas angostas las secciones bajan a su propio renglón, deslizable. */
@media (max-width: 860px) {
  .bar-in { flex-wrap: wrap; gap: 4px 12px; padding-top: 6px; }
  .bar .brand { flex: 1; }
  .tabs { order: 3; flex: 0 0 100%; margin: 0 -20px; padding: 0 16px 8px; scroll-padding: 16px; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ── Hoja modal. Entra y sale por el mismo camino. En teléfono sube desde
      abajo; en pantallas amplias se materializa al centro. ── */
dialog.sheet {
  border: 0; padding: 0; color: inherit; background: var(--surface);
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0;
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-sheet);
  overflow: hidden; display: none; flex-direction: column;
  opacity: 1; transform: translateY(100%);
  transition: transform var(--t-sheet) var(--ease-drawer), opacity var(--t-ui) ease,
              overlay var(--t-sheet) allow-discrete, display var(--t-sheet) allow-discrete;
}
dialog.sheet[open] { display: flex; transform: none; }
@starting-style { dialog.sheet[open] { transform: translateY(100%); } }
dialog.sheet::backdrop {
  background: transparent;
  transition: background-color var(--t-sheet) ease, overlay var(--t-sheet) allow-discrete, display var(--t-sheet) allow-discrete;
}
dialog.sheet[open]::backdrop { background: var(--scrim); }
@starting-style { dialog.sheet[open]::backdrop { background: transparent; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px 14px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-body { padding: 24px; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) {
  dialog.sheet {
    width: min(720px, 100% - 48px); max-height: min(86dvh, 860px); margin: auto; border-radius: 22px;
    opacity: 0; transform: scale(0.96);
    transition: transform 260ms var(--ease-out), opacity 200ms var(--ease-out),
                overlay 260ms allow-discrete, display 260ms allow-discrete;
  }
  dialog.sheet[open] { opacity: 1; transform: none; }
  @starting-style { dialog.sheet[open] { opacity: 0; transform: scale(0.96); } }
}

/* ── Saldo semanal ── */
.figure { font-size: clamp(2.75rem, 8vw, 4.5rem); line-height: 1; letter-spacing: -0.04em; font-weight: 600; font-variant-numeric: tabular-nums; }
.figure small { font-size: 0.32em; letter-spacing: -0.01em; font-weight: 500; color: var(--text-2); margin-left: 0.3em; }
.meter { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--fill); gap: 2px; }
.meter > i { display: block; min-width: 0; }
.meter .ord { background: var(--text); }
.meter .dbl { background: var(--double-fill); }
.meter .tpl { background: var(--triple); }
.meter .rest { background: transparent; }
.meter .est { opacity: 0.45; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 20px; }
.stat dt { font-size: 0.8125rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat dd { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text); }
.dot.dbl { background: var(--double-fill); }
.dot.tpl { background: var(--triple); }
.dot.rest { background: none; box-shadow: inset 0 0 0 1.5px var(--text-3); }

/* ── Movimiento reducido: se conserva la opacidad, se elimina el desplazamiento. ── */
@media (prefers-reduced-motion: reduce) {
  .btn, .btn:active { transform: none; }
  dialog.sheet, dialog.sheet[open] { transform: none; opacity: 0; transition: opacity 200ms ease, overlay 200ms allow-discrete, display 200ms allow-discrete; }
  dialog.sheet[open] { opacity: 1; }
  @starting-style { dialog.sheet[open] { transform: none; opacity: 0; } }
}
