:root {
  --ink: #171717;
  --muted: #626262;
  --paper: #fff;
  --canvas: #f5f5f3;
  --line: #dededb;
  --line-strong: #b8b8b3;
  --brand: #a71919;
  --brand-dark: #781010;
  --brand-soft: #f8eaea;
  --success: #167647;
  --success-soft: #e9f5ee;
  --warning: #a85b00;
  --warning-soft: #fff4df;
  --danger: #b42318;
  --focus: #1c66b2;
  color-scheme: light;
  font-family: Aptos, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.mobile-only { display: none; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.overline {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.15; }
h2 { margin-bottom: 5px; font-size: 17px; }

.app-header {
  position: relative;
  z-index: 10;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.identity { display: flex; align-items: center; gap: 18px; min-width: 0; }
.wordmark {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 25px;
  letter-spacing: .025em;
}
.product-name {
  padding-left: 18px;
  border-left: 1px solid var(--line-strong);
  font-size: 17px;
  font-weight: 750;
  white-space: nowrap;
}
.header-status { display: flex; align-items: center; gap: 18px; font-size: 12px; }
.connector-dot { color: var(--muted); font-weight: 700; }
.connector-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
}
.connector-dot.online { color: var(--success); }
.logout-form { margin: 0; }
.text-button { padding: 5px; border: 0; background: none; color: var(--brand); cursor: pointer; }
.messages { padding: 8px 24px; border-bottom: 1px solid #b7ddc7; background: var(--success-soft); }
.messages p { margin: 0; }

.app-shell {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}
.sidebar {
  padding: 20px 12px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}
.nav-heading {
  margin: 4px 12px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--canvas); }
.nav-item.active {
  border-left-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 750;
}
.main-content { min-width: 0; padding: 24px; }
.page-head {
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head .muted { margin: 6px 0 0; font-size: 13px; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}
.button:hover { border-color: var(--ink); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--brand-dark); }
.button.full { width: 100%; }

.status-filters { display: flex; gap: 4px; margin-bottom: 12px; }
.filter {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.filter.active { border-color: var(--line-strong); background: var(--paper); font-weight: 750; }
.capture-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.capture-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.capture-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #efefec;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
}
.capture-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.capture-table tr:last-child td { border-bottom: 0; }
.capture-table tbody tr:hover { background: #fafaf8; }
.table-link { color: var(--brand); font-weight: 750; white-space: nowrap; }
.empty-cell { height: 160px; color: var(--muted); text-align: center; }
.status-tag {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: var(--muted);
  background: #f5f5f3;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-requiere_revision, .status-posible_duplicado, .status-excel_ocupado {
  color: var(--warning);
  background: var(--warning-soft);
}
.status-guardado { color: var(--success); background: var(--success-soft); }
.status-error { color: var(--danger); background: #fdecea; }

.auth-shell {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-panel {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.auth-panel h1 { margin-bottom: 8px; }
.auth-form { display: grid; gap: 8px; margin-top: 24px; }
.auth-form label, .auth-form p label { font-size: 12px; font-weight: 750; }
.auth-form input:not([type="checkbox"]) {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}
.auth-form ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 38px; }
.form-error, .inline-error { padding: 9px 11px; border-left: 3px solid var(--danger); background: #fdecea; color: var(--danger); font-size: 12px; }

.capture-page { max-width: 1080px; margin: 0 auto; }
.camera-panel, .pages-panel {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.camera-stage {
  position: relative;
  min-height: 430px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #292826;
}
.camera-stage video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.camera-placeholder { width: min(80%, 470px); display: grid; gap: 7px; color: #fff; text-align: center; }
.camera-placeholder span { color: #cfcecb; font-size: 12px; line-height: 1.45; }
.capture-guide {
  position: absolute;
  width: min(72%, 450px);
  aspect-ratio: .73;
  border: 2px solid rgb(255 255 255 / 80%);
  clip-path: polygon(0 0, 16% 0, 16% 3px, 3px 3px, 3px 16%, 0 16%, 0 0, 84% 0, 100% 0, 100% 16%, calc(100% - 3px) 16%, calc(100% - 3px) 3px, 84% 3px, 0 84%, 3px 84%, 3px calc(100% - 3px), 16% calc(100% - 3px), 16% 100%, 0 100%, 84% 100%, 84% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 84%, 100% 84%, 100% 100%);
  pointer-events: none;
}
.camera-instruction { position: absolute; top: 16px; color: #fff; font-size: 13px; font-weight: 750; }
.quality-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quality-grid span { min-height: 42px; display: grid; place-items: center; padding: 6px; color: var(--muted); font-size: 11px; text-align: center; }
.quality-grid span + span { border-left: 1px solid var(--line); }
.quality-grid .good { color: var(--success); font-weight: 750; }
.quality-grid .bad { color: var(--warning); font-weight: 750; }
.camera-controls { display: flex; justify-content: center; gap: 10px; padding: 14px; }
.file-button input { display: none; }
.section-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin-bottom: 3px; }
.section-head p { margin: 0; color: var(--muted); font-size: 11px; }
.page-previews { min-height: 132px; display: flex; gap: 12px; padding: 16px; overflow-x: auto; }
.empty-hint { margin: auto; color: var(--muted); font-size: 12px; }
.page-preview {
  position: relative;
  flex: 0 0 90px;
  aspect-ratio: .73;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--canvas);
}
.page-preview img { width: 100%; height: 100%; object-fit: cover; }
.page-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 74%);
  color: #fff;
  cursor: pointer;
}
.sticky-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-bottom: 24px; }

.process-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: -24px -24px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.process-rail span {
  position: relative;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.process-rail span::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.process-rail b { width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font: 800 10px "Cascadia Mono", monospace; }
.process-rail .done { color: var(--success); }
.process-rail .active { color: var(--brand); }
.process-rail .active::after { background: var(--brand); }
.duplicate-alert {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
}
.duplicate-alert div { margin-left: auto; display: flex; gap: 8px; }
.review-grid {
  min-height: 650px;
  display: grid;
  grid-template-columns: minmax(380px, 44%) minmax(460px, 56%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}
.document-viewer { min-width: 0; display: grid; grid-template-columns: 76px 1fr; background: var(--paper); }
.document-thumbs { display: flex; flex-direction: column; gap: 9px; padding: 12px; background: #efefec; border-right: 1px solid var(--line); }
.document-thumb { aspect-ratio: .73; padding: 5px; border: 2px solid transparent; background: var(--paper); }
.document-thumb.active { border-color: var(--brand); }
.document-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.document-canvas { display: grid; place-items: center; padding: 26px; background: #e6e5e1; }
.document-image { max-width: 100%; max-height: 610px; object-fit: contain; box-shadow: 0 3px 12px rgb(0 0 0 / 11%); }
.document-placeholder {
  width: min(100%, 440px);
  aspect-ratio: .73;
  display: grid;
  place-content: center;
  gap: 9px;
  padding: 40px;
  background: var(--paper);
  box-shadow: 0 3px 12px rgb(0 0 0 / 11%);
  text-align: center;
}
.document-placeholder span { color: var(--muted); font-size: 12px; }
.review-form { min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.form-scroll { flex: 1; padding: 20px 22px; overflow: auto; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 20px; }
.field.full { grid-column: 1/-1; }
.field label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 750; }
.field label small { color: var(--muted); font: 500 10px "Cascadia Mono", monospace; }
.field input, .field select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper); }
.field.warning input { border-color: var(--warning); background: #fffbf4; }
.field.warning p { margin: 4px 0 0; color: var(--warning); font-size: 11px; }
.rule-note { margin-top: 18px; padding: 11px 12px; border-left: 3px solid var(--line-strong); background: var(--canvas); color: var(--muted); font-size: 12px; line-height: 1.45; }
.form-actions { min-height: 70px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--line); }
.supervision-page { max-width: 1080px; margin: 0 auto; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.metric-strip div { display: grid; gap: 3px; padding: 18px; }
.metric-strip div + div { border-left: 1px solid var(--line); }
.metric-strip strong { font: 750 22px "Cascadia Mono", monospace; }
.metric-strip span { color: var(--muted); font-size: 11px; }
.supervision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.operation-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.enrollment-output { margin: 12px 16px 0; padding: 11px; border-left: 3px solid var(--brand); background: var(--brand-soft); font: 700 12px "Cascadia Mono", monospace; }
.simple-list { display: grid; padding: 4px 16px 14px; }
.simple-list > div { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.simple-list > div:last-child { border-bottom: 0; }
.simple-list span { display: grid; gap: 2px; }
.simple-list small, .simple-list > div > span:last-child { color: var(--muted); font-size: 11px; }
.button.compact { min-height: 32px; padding: 0 10px; font-size: 11px; }

@media (max-width: 900px) {
  .mobile-only { display: flex; }
  .app-header { height: 56px; padding: 0 16px; }
  .wordmark { font-size: 20px; }
  .product-name { padding-left: 11px; font-size: 14px; }
  .user-label, .connector-dot { display: none; }
  .header-status { gap: 6px; }
  .app-shell { min-height: calc(100vh - 56px); display: block; }
  .sidebar { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; height: 58px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; border: 0; border-top: 1px solid var(--line); }
  .nav-heading { display: none; }
  .nav-item { min-height: 58px; justify-content: center; padding: 0 6px; border-left: 0; border-top: 3px solid transparent; font-size: 11px; }
  .nav-item.active { border-top-color: var(--brand); }
  .main-content { padding: 16px 16px 76px; }
  .page-head { align-items: flex-start; }
  .capture-table { min-width: 680px; }
  .status-filters { overflow-x: auto; }
  .filter { white-space: nowrap; }
  .offline-notice { justify-content: space-between; gap: 12px; margin: -16px -16px 14px; padding: 10px 16px; border-bottom: 1px solid #efd2d2; background: var(--brand-soft); color: var(--brand-dark); font-size: 10px; }
  .capture-heading { margin-bottom: 12px; }
  .camera-stage { min-height: 52vh; max-height: 560px; }
  .capture-guide { width: 80%; }
  .quality-grid span { font-size: 9px; }
  .camera-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .capture-trigger { grid-column: 1/-1; grid-row: 1; min-height: 52px; font-size: 16px; }
  .sticky-actions { position: sticky; bottom: 60px; margin: 0 -16px; padding: 10px 16px; border-top: 1px solid var(--line); background: rgb(255 255 255 / 96%); }
  .sticky-actions .button { width: 100%; }
  .process-rail { margin: -16px -16px 18px; }
  .process-rail span { min-height: 48px; justify-content: center; padding: 0 3px; font-size: 9px; }
  .process-rail b { width: 20px; height: 20px; }
  .review-grid { min-height: 0; display: block; }
  .document-viewer { min-height: 360px; grid-template-columns: 58px 1fr; border-bottom: 1px solid var(--line); }
  .document-thumbs { padding: 8px; }
  .document-canvas { padding: 18px; }
  .document-placeholder { aspect-ratio: auto; min-height: 300px; padding: 20px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-actions { position: sticky; bottom: 58px; flex-wrap: wrap; background: var(--paper); }
  .form-actions .button { flex: 1 1 180px; }
  .duplicate-alert { align-items: flex-start; flex-direction: column; }
  .duplicate-alert div { margin-left: 0; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric-strip div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric-strip div:nth-child(4) { border-top: 1px solid var(--line); }
  .supervision-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .nav-item, .filter { transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease; }
}
