/* Huellas Eternas — application layer on top of the Modernist design system.
   Tokens and base components live in modernist.css (do not restyle them here);
   this file only adds the screen layouts from the design canvas. */

html, body { min-height: 100%; }
body { background: var(--color-bg); -webkit-font-smoothing: antialiased; }
body.is-dark { background: var(--color-neutral-900); }
#app { min-height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; }
a.btn { text-decoration: none; }

/* ── small utilities ─────────────────────────────────────────────────────── */
.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; }
.spacer { flex: 1; }
.rule { height: 2px; background: var(--color-divider); flex: none; }
.kicker { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-600); }
.kicker--wide { letter-spacing: 0.1em; }
.kicker--accent { color: var(--color-accent); letter-spacing: 0.1em; }
.kicker--7 { color: var(--color-neutral-700); }
.kicker--row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.text-6 { color: var(--color-neutral-600); }
.text-7 { color: var(--color-neutral-700); }
.link { color: var(--color-accent); text-decoration: none; font-weight: 600; font-size: 13px; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; text-align: left; }
.link:hover { color: var(--color-accent-600); }
.link--deep { color: var(--color-accent-700); }
.link--deep:hover { color: var(--color-accent-800); }
.brand { font-family: var(--font-heading); font-weight: 800; font-size: 16px; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand::before { content: ''; width: 14px; height: 14px; background: var(--color-accent); display: inline-block; flex: none; }
.brand--sm { font-size: 15px; gap: 8px; }
.brand--sm::before { width: 10px; height: 10px; }
.brand--inverse::before { background: var(--color-bg); }
.form-error { color: var(--color-accent-700); font-size: 13px; margin-top: var(--space-2); }
.form-error[hidden] { display: none; }
.input.is-invalid { border-color: var(--color-accent); }
.input.h44 { height: 44px; }
.field-hint { font-size: 12px; color: var(--color-neutral-600); margin-top: 6px; }

/* buttons — app-level modifiers (the DS owns the variants) */
.btn--between { justify-content: space-between; }
.btn--tall { height: 52px; font-size: 15px; }
.btn--md { height: 44px; gap: 8px; }
.btn--48 { height: 48px; }
.btn-block { margin-top: 0; }
.btn--inverse { color: var(--color-bg); border-color: var(--color-neutral-600); }
.btn--inverse:hover { background: color-mix(in srgb, var(--color-bg) 10%, transparent); }
.btn--inverse:active { background: color-mix(in srgb, var(--color-bg) 18%, transparent); }
.btn-ghost.btn--inverse { color: var(--color-neutral-400); }

/* ── mobile screen shell (family + operator flows) ───────────────────────── */
.screen {
  flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 480px; margin: 0 auto;
  min-height: 100dvh;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 24px calc(32px + env(safe-area-inset-bottom, 0px));
  color: var(--color-text);
}
.screen--dark { background: var(--color-neutral-900); color: var(--color-bg); }
.screen--dark .kicker { color: var(--color-neutral-400); }
.screen--dark h3 { color: var(--color-bg); }

/* family — access */
.fam-title { font-size: 34px; margin: 0 0 12px; text-wrap: pretty; }
.fam-lead { font-size: 16px; line-height: 1.5; color: var(--color-neutral-700); margin: 0 0 40px; text-wrap: pretty; }
.fam-foot { font-size: 13px; color: var(--color-neutral-700); margin: 24px 0 0; text-wrap: pretty; }
.pin { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pin__box {
  height: 64px; background: var(--color-surface); border: 1px solid var(--color-divider);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 28px;
}
.pin__box.is-active { border-color: var(--color-accent); }
.pin__caret { width: 2px; height: 30px; background: var(--color-accent); animation: pin-blink 1.1s steps(1) infinite; }
.pin__input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; padding: 0; border: 0;
  font-size: 28px; color: transparent; caret-color: transparent; background: transparent; cursor: text;
}
.pin.is-error .pin__box { border-color: var(--color-accent); }
.pin.is-locked .pin__box { opacity: 0.5; }
@keyframes pin-blink { 50% { opacity: 0; } }

/* family — tracking */
.trk-title { font-size: 32px; margin: 8px 0 12px; line-height: 1.1; text-wrap: pretty; }
.trk-lead { font-size: 15px; line-height: 1.5; color: var(--color-neutral-700); margin: 0 0 28px; text-wrap: pretty; }
.timeline { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }
.tl-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 0 14px; min-height: 50px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 14px; height: 14px; flex: none; margin-top: 3px; box-sizing: border-box; border: 2px solid var(--color-neutral-400); background: transparent; }
.tl-line { width: 2px; flex: 1; margin-top: 4px; background: var(--color-neutral-300); }
.tl-row.is-done .tl-dot { background: var(--color-text); border-color: var(--color-text); }
.tl-row.is-done .tl-line { background: var(--color-text); }
.tl-row.is-current .tl-dot { background: var(--color-accent); border-color: var(--color-accent); }
.tl-row:last-child .tl-line { background: transparent; }
.tl-name { font-size: 16px; line-height: 1.25; padding-bottom: 16px; }
.tl-row.is-pending .tl-name { color: var(--color-neutral-500); }
.tl-row.is-current .tl-name { font-weight: 800; }
.tl-time { font-size: 12px; color: var(--color-neutral-600); white-space: nowrap; padding-top: 2px; }
.trk-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.trk-foot__title { font-family: var(--font-heading); font-weight: 800; font-size: 15px; }
.trk-foot__sub { font-size: 13px; color: var(--color-neutral-700); }

/* operator — scan */
.scan-stage { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; margin: 32px 0; min-height: 300px; }
.viewfinder { width: 280px; height: 280px; position: relative; background: var(--color-neutral-800); overflow: hidden; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder__corner { position: absolute; width: 40px; height: 40px; border: 0 solid var(--color-accent); z-index: 2; }
.viewfinder__corner.tl { top: -2px; left: -2px; border-top-width: 3px; border-left-width: 3px; }
.viewfinder__corner.tr { top: -2px; right: -2px; border-top-width: 3px; border-right-width: 3px; }
.viewfinder__corner.bl { bottom: -2px; left: -2px; border-bottom-width: 3px; border-left-width: 3px; }
.viewfinder__corner.br { bottom: -2px; right: -2px; border-bottom-width: 3px; border-right-width: 3px; }
.viewfinder__line { position: absolute; left: 20px; right: 20px; top: 50%; height: 2px; background: var(--color-accent); z-index: 2; }
.viewfinder.is-live .viewfinder__line { animation: scan-sweep 2.2s ease-in-out infinite alternate; }
.viewfinder__off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--color-neutral-500); }
@keyframes scan-sweep { from { top: 24px; } to { top: calc(100% - 26px); } }
.scan-title { font-size: 24px; margin: 0 0 8px; }
.scan-help { font-size: 14px; color: var(--color-neutral-400); margin: 0 0 24px; text-wrap: pretty; }
.scan-status { font-size: 13px; color: var(--color-accent-400); min-height: 20px; margin: -12px 0 12px; }
.scan-status:empty { display: none; }
.scan-search { display: flex; gap: 8px; margin-bottom: 12px; }
.scan-search .input { height: 52px; background: var(--color-neutral-800); border-color: var(--color-neutral-600); color: var(--color-bg); text-transform: uppercase; }
.scan-search .input::placeholder { text-transform: none; color: var(--color-neutral-500); }
.scan-search[hidden] { display: none; }

/* operator — stage change */
.stage-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.stage-head h2 { font-size: 30px; margin: 4px 0 4px; }
.stage-head__sub { font-size: 14px; color: var(--color-neutral-700); }
.options { display: flex; flex-direction: column; border-top: 1px solid var(--color-divider); }
.option.radio { display: flex; justify-content: space-between; min-height: 52px; border-bottom: 1px solid var(--color-divider); font-size: 15px; gap: 12px; padding: 6px 0; }
.option__main { display: flex; align-items: center; gap: 12px; }
.option .tag { flex: none; }
.options__more { padding: 12px 0 0; }
.footnote { font-size: 12px; color: var(--color-neutral-600); margin-top: 10px; }

/* ── staff login ─────────────────────────────────────────────────────────── */
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; flex: 1; }
.login__poster { background: var(--color-accent); color: var(--color-bg); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login__poster .brand { font-size: 18px; gap: 12px; }
.login__poster .brand::before { width: 16px; height: 16px; background: var(--color-bg); }
.login__title { font-size: 64px; line-height: 1.02; margin: 0; letter-spacing: -0.02em; text-wrap: pretty; max-width: 480px; color: inherit; }
.login__foot { font-size: 14px; opacity: 0.85; }
.login__form { padding: 56px 96px; display: flex; flex-direction: column; justify-content: center; gap: 24px; width: 100%; max-width: 720px; }
.login__form h2 { font-size: 32px; margin: 0 0 8px; }
.login__form p { margin: 0; color: var(--color-neutral-700); font-size: 15px; }
.login__hint { font-size: 12px; color: var(--color-neutral-600); border-top: 1px solid var(--color-divider); padding-top: 12px; }

/* ── admin shell ─────────────────────────────────────────────────────────── */
.admin { min-height: 100dvh; display: flex; flex-direction: column; flex: 1; }
.admin-nav { padding: 16px 40px; position: relative; }
.admin-nav .nav-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; color: inherit; }
.admin-nav .nav-brand:hover { color: inherit; }
.admin-nav__user { font-size: 13px; color: var(--color-neutral-700); border-left: 2px solid var(--color-divider); padding-left: 16px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.admin-nav__logout { height: 32px; font-size: 13px; gap: 6px; }
.admin-nav__menu { display: none; }
.admin-main { padding: 40px; display: flex; flex-direction: column; gap: 32px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-head h1 { font-size: 40px; margin: 6px 0 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; line-height: 1.05; }
.page-head h1 .tag { font-size: 12px; }
.actions { display: flex; gap: 12px; flex: none; }
.crumb a { color: inherit; text-decoration: none; }
.crumb a:hover { color: var(--color-accent); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); }
.stat { padding: 20px 24px; border-right: 1px solid var(--color-divider); }
.stat:first-child { padding-left: 0; }
.stat:last-child { border-right: 0; padding-right: 0; }
.stat__n { font-family: var(--font-heading); font-weight: 800; font-size: 44px; line-height: 1; }
.stat--accent .stat__n { color: var(--color-accent); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.search { position: relative; width: 320px; }
.search .input { height: 40px; padding-left: 36px; }
.search svg { position: absolute; left: 10px; top: 11px; color: var(--color-neutral-600); pointer-events: none; }
.table-wrap { overflow-x: auto; }
.table td.is-strong { font-weight: 600; }
.table td.is-right { text-align: right; }
.table td.is-muted { color: var(--color-neutral-600); }
.table td.is-note { color: var(--color-neutral-700); }
.table tr.is-link { cursor: pointer; }
.table tr.is-highlight { background: var(--color-accent-100); }
.table .empty { color: var(--color-neutral-600); padding: 24px 8px; }

.row-list { display: flex; flex-direction: column; border-top: 1px solid var(--color-divider); }
.row-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--color-divider); align-items: center; color: inherit; text-decoration: none; }
.row-item:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.row-item__title { font-weight: 600; font-size: 15px; }
.row-item__title span { color: var(--color-neutral-600); font-weight: 400; }
.row-item__meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--color-neutral-600); flex-wrap: wrap; }
.row-item > svg { grid-row: span 2; color: var(--color-neutral-500); }
.row-list .empty { color: var(--color-neutral-600); padding: 24px 0; font-size: 14px; }

/* record */
.info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 280px; border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); }
.info-col { padding: 24px; border-right: 1px solid var(--color-divider); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.info-col:first-child { padding-left: 0; }
.info-col:last-child { border-right: 0; padding-right: 0; }
.info-item__label { font-size: 12px; color: var(--color-neutral-600); }
.info-item__value { font-weight: 600; overflow-wrap: anywhere; }
.info-item__value.is-pending { color: var(--color-neutral-500); }
.qr-row { display: flex; gap: 16px; align-items: flex-start; }
.qr-box { width: 96px; height: 96px; flex: none; background: var(--color-text); padding: 6px; display: flex; align-items: center; justify-content: center; color: var(--color-bg); font-size: 10px; text-align: center; }
.qr-box canvas, .qr-box img { width: 100% !important; height: 100% !important; display: block; }
.qr-box canvas + img { display: none !important; }
.qr-side { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.qr-side strong { letter-spacing: 0.15em; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 22px; }
.section-head__meta { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--color-neutral-700); }

/* new service */
.form-layout { display: grid; grid-template-columns: 320px 1fr; gap: 64px; align-items: start; }
.form-intro { display: flex; flex-direction: column; gap: 24px; }
.form-intro h1 { font-size: 40px; margin: 6px 0 0; line-height: 1.05; }
.form-intro p { font-size: 14px; color: var(--color-neutral-700); margin: 0; text-wrap: pretty; }
.steps { border-top: 2px solid var(--color-divider); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.step { display: flex; gap: 12px; align-items: center; }
.step__n { width: 24px; height: 24px; background: var(--color-text); color: var(--color-bg); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex: none; }
.form-body { display: flex; flex-direction: column; gap: 40px; min-width: 0; }
.form-section { display: flex; flex-direction: column; gap: 16px; }
.form-section__title { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent); border-bottom: 2px solid var(--color-divider); padding-bottom: 10px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.seg--block { display: flex; }
.seg--block .seg-opt { flex: 1; padding: 11px 14px; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 2px solid var(--color-divider); padding-top: 24px; }

/* dialog (on top of the DS dialog) */
.dialog-backdrop { z-index: 100; }
.dialog { max-height: calc(100dvh - 32px); overflow: auto; }
.dialog form { display: flex; flex-direction: column; gap: 14px; }

/* stage settings */
.settings-note { font-size: 14px; color: var(--color-neutral-700); max-width: 720px; margin: 0; text-wrap: pretty; }
.danger-zone { border-top: 2px solid var(--color-divider); padding-top: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* label (print) */
.label-page { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px 24px; }
.label-card { width: 360px; max-width: 100%; border: 2px solid var(--color-text); padding: 24px; display: flex; flex-direction: column; gap: 16px; background: var(--color-bg); color: var(--color-text); }
.label-card__folio { font-family: var(--font-heading); font-weight: 800; font-size: 36px; line-height: 1; }
.label-card__pet { font-size: 18px; font-weight: 600; }
.label-card__qr { width: 200px; height: 200px; align-self: center; background: var(--color-text); padding: 8px; }
.label-card__qr canvas, .label-card__qr img { width: 100% !important; height: 100% !important; display: block; }
.label-card__qr canvas + img { display: none !important; }
.label-card__meta { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.label-card__meta strong { letter-spacing: 0.15em; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .label-page { padding: 0; }
  .label-card { border-width: 1px; }
}

/* toasts */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--color-text); color: var(--color-bg); padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow-md); animation: toast-in 0.2s ease; }
.toast--accent { background: var(--color-accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* empty / not-found */
.notice { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; max-width: 480px; }
.notice h2 { font-size: 30px; margin: 0; }
.notice p { color: var(--color-neutral-700); margin: 0; }

/* ── responsive: the design's mobile admin board (402px) ─────────────────── */
.only-mobile { display: none !important; }
@media (max-width: 840px) {
  .only-desktop { display: none !important; }
  .only-mobile { display: flex !important; }
  .only-mobile.row-list { display: flex !important; }

  .admin-nav { padding: 16px 20px; gap: 12px; flex-wrap: wrap; }
  .admin-nav .nav-brand { font-size: 15px; gap: 8px; }
  .admin-nav .nav-brand::before { width: 10px; height: 10px; }
  .admin-nav > a:not(.nav-brand) { display: none; }
  .admin-nav.is-open > a:not(.nav-brand) { display: block; width: 100%; order: 10; padding: 12px 0; border-top: 1px solid var(--color-divider); font-size: 15px; }
  .admin-nav__user { border-left: 0; padding-left: 0; margin-left: auto; font-size: 12px; }
  .admin-nav__logout span { display: none; }
  .admin-nav__menu { display: inline-flex; }

  .admin-main { padding: 20px; gap: 16px; }
  .page-head { align-items: flex-end; }
  .page-head h1 { font-size: 28px; margin-top: 4px; gap: 10px; }
  .actions { gap: 8px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 12px; }
  .stat:first-child { padding-left: 0; }
  .stat .kicker { font-size: 11px; letter-spacing: 0.06em; }
  .stat__n { font-size: 28px; }
  .stat--desktop-only { display: none; }
  .stats.stats--3 .stat:nth-child(3) { border-right: 0; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar .seg { display: flex; }
  .toolbar .seg-opt { flex: 1; justify-content: center; }
  .search { width: 100%; }
  .search .input { height: 44px; padding-left: 38px; }
  .search svg { left: 12px; top: 13px; }

  .info-grid { grid-template-columns: 1fr; }
  .info-col { padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--color-divider); }
  .info-col:last-child { border-bottom: 0; }

  .form-layout { grid-template-columns: 1fr; gap: 24px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .seg--block { flex-direction: column; }
  .seg--block .seg-opt + .seg-opt { border-left: 0; border-top: 1px solid var(--color-divider); }
  .form-footer { flex-direction: column-reverse; align-items: stretch; }
  .form-footer .btn { justify-content: space-between; }

  .login { grid-template-columns: 1fr; }
  .login__poster { padding: 32px 24px; gap: 32px; }
  .login__title { font-size: 40px; }
  .login__form { padding: 32px 24px; }
}
@media (max-width: 480px) {
  .screen { padding-left: 20px; padding-right: 20px; }
  .fam-title { font-size: 30px; }
  .trk-title { font-size: 28px; }
}
