:root {
  --ink: #1f2933;
  --muted: #65717f;
  --line: #d8dee6;
  --surface: #ffffff;
  --soft: #f4f7f9;
  --brand: #8f1824;
  --brand-2: #1b6574;
  --accent: #c88a2c;
  --success: #1f7a52;
  --danger: #b42318;
  --shadow: 0 14px 32px rgba(25, 35, 45, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f6f8;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(25, 35, 45, .07);
}

.header-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 12px 24px 16px;
}

.brand-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 0 8px;
}

.brand-strip img {
  max-height: 48px;
  max-width: 230px;
  object-fit: contain;
}

.brand-strip img:last-child { justify-self: end; }
.brand-crum { height: 66px; }

.header-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-top: 10px;
  border-top: 1px solid #edf1f4;
}

.header-copy p {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.header-copy h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 10px;
  padding: 6px;
  background: #eef3f5;
  border: 1px solid #d8e2e8;
  border-radius: 8px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  color: #3d4c58;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
}

.tab.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 8px 18px rgba(143, 24, 36, .22);
}

.tab span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--brand);
  background: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

.tab:not(.is-active) span {
  color: #fff;
  background: var(--brand-2);
}

.logout-tab {
  color: #8a1f1f;
}

.logout-tab:hover {
  background: #fde8e8;
}

main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 24px 38px;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.capture-toolbar, .dashboard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

p {
  margin: 0;
  color: var(--muted);
}

.file-button, .primary, .secondary, .success, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 7px;
  font-weight: 700;
  white-space: nowrap;
}

.file-button input { display: none; }
.file-button, .primary { color: #fff; background: var(--brand); }
.success { color: #fff; background: var(--success); }
.secondary, .icon-button { color: var(--ink); background: #e7edf1; }
button:disabled { opacity: .55; cursor: not-allowed; }

.auth-locked {
  min-height: 100vh;
  overflow: hidden;
}

.auth-locked .app-header,
.auth-locked main,
.auth-locked dialog {
  display: none;
}

.login-screen {
  display: none;
}

.auth-locked .login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(143, 24, 36, .11), transparent 36%),
    linear-gradient(315deg, rgba(27, 101, 116, .14), transparent 42%),
    #f4f7f9;
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(430px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid #dce5eb;
  border-top: 5px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(25, 35, 45, .16);
}

.login-brand {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 14px;
  align-items: center;
}

.login-brand img {
  width: 100%;
  max-height: 70px;
  object-fit: contain;
  padding: 8px;
  background: #f8fafb;
  border: 1px solid #e1e8ee;
  border-radius: 8px;
}

.login-card p {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.login-card h1 {
  margin: 4px 0 0;
  font-size: 30px;
}

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #dce5eb;
  border-left: 5px solid var(--brand-2);
  border-radius: 8px;
  box-shadow: 0 20px 45px rgba(20, 30, 40, .18);
  animation: toastIn .22s ease-out;
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--brand-2);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
}

.toast-error .toast-icon { background: var(--danger); }
.toast-success .toast-icon { background: var(--success); }

.toast strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.toast p {
  color: #4f5d68;
  font-size: 13px;
  line-height: 1.35;
}

.toast button {
  min-height: 28px;
  padding: 0 8px;
  color: var(--muted);
  background: #f1f5f7;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  transition: .18s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.extract-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .92fr);
  gap: 18px;
  align-items: start;
}

.form-panel, .preview-panel, .table-shell, dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  background: #f7fafb;
  border: 1px solid #e1e8ee;
  border-radius: 8px;
}

.status {
  min-height: 36px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: #34515d;
  background: #f6f9fb;
  border: 1px solid #e1e8ee;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
}

.asset-form {
  display: grid;
  gap: 14px;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 16px;
  background: #fff;
  border: 1px solid #dde6ec;
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: var(--brand);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: #3e4a55;
  font-size: 13px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid #cfd8df;
  border-radius: 6px;
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(27, 101, 116, .16);
  border-color: var(--brand-2);
}

[aria-invalid="true"] {
  border-color: var(--danger);
  outline: 3px solid rgba(180, 35, 24, .14);
}

textarea { resize: vertical; }

.preview-panel {
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 720px;
  padding: 14px;
  background: #1f2a32;
  overflow: auto;
}

.preview-stage img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.preview-stage.is-zoomed img {
  max-width: none;
  max-height: none;
  width: 1180px;
}

.preview-stage p { color: #dce6ec; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
}

.metric {
  min-width: 122px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid #dce5eb;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(25, 35, 45, .05);
}

.metric span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

.table-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 240px 190px auto;
  gap: 10px;
  margin-bottom: 12px;
}

.inventory-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.type-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(25, 35, 45, .05);
  text-align: left;
}

.type-chip strong {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--brand-2);
  border-radius: 50%;
}

.type-chip span {
  font-weight: 800;
}

.type-chip.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(143, 24, 36, .12);
}

.asset-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.asset-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) minmax(145px, auto) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(25, 35, 45, .05);
}

.asset-thumb, .table-thumb {
  display: block;
  overflow: hidden;
  background: #edf2f5;
  border: 1px solid var(--line);
}

.asset-thumb {
  width: 76px;
  height: 62px;
  border-radius: 7px;
}

.asset-thumb img, .table-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-kicker {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.asset-card h3 {
  margin: 2px 0 3px;
  font-size: 16px;
}

.asset-card p {
  font-size: 13px;
}

.asset-card-meta {
  display: grid;
  gap: 3px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.asset-card-meta small {
  max-width: 210px;
  color: var(--muted);
  font-weight: 700;
}

.asset-card button {
  min-height: 36px;
  padding: 0 12px;
  color: #fff;
  background: var(--brand-2);
  border-radius: 6px;
  font-weight: 800;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #394653;
  background: #edf2f5;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

td strong { display: block; }
td small { color: var(--muted); }

.type-badge, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.type-badge {
  color: var(--brand);
  background: #f8eaec;
  border: 1px solid #e6c4c9;
}

.status-pill {
  justify-self: start;
  letter-spacing: .02em;
}

.status-pill.is-activo {
  color: #17613f;
  background: #e8f6ee;
  border: 1px solid #bfe5ce;
}

.status-pill.is-baja {
  color: #9b1c1c;
  background: #fde8e8;
  border: 1px solid #f3b8b8;
}

.table-asset {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.table-thumb {
  width: 52px;
  height: 44px;
  border-radius: 6px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: #fff;
  background: var(--brand-2);
  font-weight: 700;
}

.row-actions button.delete {
  background: #a53636;
}

dialog {
  width: min(1040px, calc(100vw - 28px));
  padding: 0;
}

dialog::backdrop { background: rgba(16, 24, 32, .55); }

.report {
  padding: 0;
}

.report-header {
  display: grid;
  grid-template-columns: 180px 1fr 116px;
  gap: 22px;
  align-items: center;
  padding: 20px 24px 18px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(143, 24, 36, .08), transparent 34%),
    #fff;
  border-bottom: 1px solid #dfe7ed;
  box-shadow: inset 0 -4px 0 var(--brand);
}

.report-logo, .report-header-side {
  display: grid;
  align-items: center;
}

.report-logo {
  min-height: 64px;
  padding: 9px;
  background: #f8fafb;
  border: 1px solid #e0e7ec;
  border-radius: 8px;
}

.report-logo img {
  width: 100%;
  max-height: 48px;
  object-fit: contain;
}

.report-title-block {
  min-width: 0;
}

.report h3 {
  margin: 4px 0 5px;
  color: var(--brand);
  font-size: 21px;
  line-height: 1.14;
}

.report-header span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.report-header p {
  color: var(--muted);
}

.report-header-side {
  justify-items: end;
  gap: 8px;
}

.report-header .status-pill {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

.report-header-side img {
  width: 74px;
  max-height: 64px;
  object-fit: contain;
  padding: 7px;
  background: #f8fafb;
  border: 1px solid #e0e7ec;
  border-radius: 8px;
}

.report-summary {
  display: grid;
  grid-template-columns: 2fr repeat(5, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.report-summary > div {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 14px;
  background: #fbfcfd;
}

.report-summary small, .photo-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.report-summary strong {
  font-size: 17px;
}

.report-summary span {
  color: var(--muted);
  font-size: 13px;
}

.report-body {
  display: block;
  padding: 22px 24px 26px;
}

.report h4 {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-bottom: 18px;
}

.report-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.report-item small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.report-photo-page {
  margin: 0 24px 24px;
  padding: 20px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.photo-page-header {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 16px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--brand);
}

.photo-page-header span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.photo-page-header h4 {
  margin: 3px 0 4px;
  color: var(--ink);
  font-size: 21px;
}

.photo-page-header img {
  width: 82px;
  max-height: 70px;
  object-fit: contain;
}

.photo-frame {
  display: grid;
  place-items: center;
  min-height: 620px;
  margin-top: 18px;
  padding: 14px;
  background: #fff;
  border: 1px solid #d9e2e8;
  border-radius: 8px;
}

.photo-frame img {
  width: 100%;
  max-height: 760px;
  object-fit: contain;
}

.photo-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.photo-meta div {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.photo-meta dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  .brand-strip {
    grid-template-columns: 1fr 1fr;
  }

  .brand-crum { display: none; }

  .extract-layout, .capture-toolbar, .dashboard-top {
    grid-template-columns: 1fr;
    display: grid;
  }

  .preview-panel { position: static; }
  .preview-stage { min-height: 460px; }
  fieldset { grid-template-columns: 1fr; }
  .table-tools { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .asset-card { grid-template-columns: 64px minmax(0, 1fr); }
  .asset-card-meta, .asset-card button { grid-column: 2; }
  .report-header, .report-summary { grid-template-columns: 1fr; }
  .report-header-side { justify-items: start; }
  .photo-page-header, .photo-meta { grid-template-columns: 1fr; }
}

@media print {
  @page {
    size: Letter;
    margin: 10mm;
  }

  html, body {
    width: 216mm;
    min-height: 279mm;
    background: #fff;
  }

  body * { visibility: hidden; }
  dialog, dialog * { visibility: visible; }
  dialog {
    position: absolute;
    inset: 0;
    width: 100%;
    border: 0;
    box-shadow: none;
    background: #fff;
    overflow: visible;
  }
  .dialog-actions { display: none; }

  .report {
    color: #111827;
    font-size: 11px;
  }

  .report-header {
    grid-template-columns: 42mm 1fr 32mm;
    gap: 8mm;
    padding: 6mm 8mm 5mm;
    color: #111827;
    background: #fff !important;
    border-bottom: 2mm solid #8f1824;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .report-logo {
    min-height: 18mm;
    padding: 2mm;
    border-radius: 2mm;
  }

  .report-logo img {
    max-height: 18mm;
  }

  .report-header-side {
    justify-items: end;
    gap: 2mm;
  }

  .report-header-side img {
    width: 18mm;
    max-height: 18mm;
    padding: 2mm;
    border-radius: 2mm;
  }

  .report h3 {
    color: #8f1824;
    font-size: 16px;
  }

  .report-header p {
    color: #4b5563;
  }

  .report-summary {
    grid-template-columns: 1.8fr repeat(5, 1fr);
    break-inside: avoid;
  }

  .report-summary > div {
    min-height: 18mm;
    padding: 4mm;
  }

  .report-body {
    display: block;
    padding: 7mm 9mm 8mm;
  }

  .report-grid {
    gap: 2mm 5mm;
    margin-bottom: 5mm;
  }

  .report-item {
    padding: 2.5mm 0;
  }

  .report-photo-page {
    page-break-before: always;
    break-before: page;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: calc(279mm - 20mm);
    margin: 0;
    padding: 8mm;
    background: #fff;
    border: 0;
    border-radius: 0;
  }

  .photo-page-header {
    grid-template-columns: 1fr 24mm;
    gap: 6mm;
    padding-bottom: 4mm;
    border-bottom: 1.2mm solid #8f1824;
  }

  .photo-page-header h4 {
    font-size: 16px;
  }

  .photo-page-header img {
    width: 22mm;
    max-height: 22mm;
  }

  .photo-frame {
    min-height: 0;
    margin-top: 6mm;
    padding: 4mm;
    border-radius: 2mm;
  }

  .photo-frame img {
    max-height: 205mm;
  }

  .photo-meta {
    grid-template-columns: repeat(4, 1fr);
    gap: 3mm;
    margin-top: 5mm;
  }

  .photo-meta div {
    padding: 3mm;
    border-radius: 1.5mm;
  }
}
