:root {
  --ink: #102a43;
  --muted: #60758a;
  --line: #dbe7ef;
  --paper: #ffffff;
  --soft: #f4f9fb;
  --blue: #176d9f;
  --blue-dark: #0e5179;
  --aqua: #31b7b7;
  --danger: #b9333a;
  --shadow: 0 18px 45px rgba(19, 64, 94, .12);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7fbfd 0%, #eef7fa 100%);
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
input, textarea, button { font: inherit; }
.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.button, .button-primary, .button-secondary { display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; min-height: 44px; }
.badge { display: inline-flex; border-radius: 999px; padding: 6px 10px; font-weight: 700; font-size: 13px; }
.form-group { display: grid; gap: 7px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px; }
.gallery-viewer { width: min(1180px, calc(100% - 28px)); margin: 0 auto 42px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-centered { justify-content: center; width: 100%; }
.brand-logo { width: 172px; height: auto; display: block; }
.topbar, .admin-header, .viewer-header {
  display: flex; align-items: center; justify-content: space-between;
  width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0;
}
.hero-shell { min-height: 100vh; position: relative; overflow: hidden; }
.hero-shell:before {
  content: ""; position: absolute; inset: auto -10% -20% auto; width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(49,183,183,.18), transparent 62%); pointer-events: none;
}
.hero { width: min(1180px, calc(100% - 32px)); margin: 42px auto 0; display: grid; grid-template-columns: 1fr .82fr; gap: 58px; align-items: center; }
.hero h1 { font-size: clamp(42px, 6vw, 76px); line-height: .98; margin: 12px 0 22px; max-width: 780px; }
.hero p { font-size: 20px; line-height: 1.55; color: var(--muted); max-width: 680px; }
.eyebrow { color: var(--blue-dark); font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }
.hero-actions, .admin-nav, .action-cell, .viewer-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; min-height: 44px;
  background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(23,109,159,.12); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-secondary { background: #eef8fb; color: var(--blue-dark); border-color: #c9e8ef; }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 34px; padding: 8px 10px; font-size: 14px; }
.btn-wide { width: 100%; }
.link-soft { color: var(--blue-dark); font-weight: 700; }
.notice, .medical-notice {
  border: 1px solid #cce8e8; background: #f0fbfb; color: #315f68; border-radius: 8px; padding: 14px 16px;
}
.notice.error { background: #fff1f1; border-color: #ffd1d4; color: #8c252b; }
.delivery-feature {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid #c9e8ef;
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin: 24px 0;
}
.delivery-feature h2 { font-size: 32px; margin: 8px 0 8px; }
.delivery-feature p { font-size: 17px; margin: 0 0 18px; }
.delivery-card .brand-logo { margin-bottom: 18px; }
.hero-visual { position: relative; min-height: 470px; }
.scan-frame {
  position: absolute; inset: 20px 30px 30px 0; border-radius: 8px; background: #0f2637;
  box-shadow: var(--shadow); overflow: hidden; border: 10px solid #ffffff;
}
.scan-lines {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255,255,255,.08) 49%, transparent 51%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.06) 0 2px, transparent 2px 18px),
    radial-gradient(circle at 50% 50%, #d8eef5 0 9%, #91c6d7 10% 14%, transparent 15% 100%);
}
.scan-pulse { position: absolute; left: 0; right: 0; top: 38%; height: 3px; background: var(--aqua); box-shadow: 0 0 22px var(--aqua); animation: pulse 2.8s infinite; }
@keyframes pulse { 0%,100%{ transform: translateY(-90px);} 50%{ transform: translateY(120px);} }
.trust-panel { position: absolute; right: 0; bottom: 0; width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); }
.trust-panel span, .small-muted { display: block; color: var(--muted); font-size: 14px; line-height: 1.45; margin-top: 6px; }
.center-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.access-card, .table-card, .study-form, .detail-card {
  width: min(520px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: var(--shadow);
}
.access-card h1, .form-hero h1, .admin-intro h1, .viewer-title h1 { margin: 14px 0 10px; }
.access-card p, .form-hero p, .admin-intro p, .detail-card p { color: var(--muted); line-height: 1.5; }
.stack-form, .study-form { display: grid; gap: 14px; }
.study-form { width: 100%; }
.two-column-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; color: #24455d; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px; background: #fbfdfe; color: var(--ink);
}
textarea { resize: vertical; }
.alert { border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.alert-error { background: #fff1f1; color: #8c252b; border: 1px solid #ffd1d4; }
.admin-page { background: #f5fafc; }
.admin-shell { width: min(1180px, calc(100% - 32px)); margin: 24px auto 60px; }
.admin-shell.narrow { width: min(760px, calc(100% - 32px)); }
.admin-intro { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 22px; }
.search-form { display: flex; gap: 10px; min-width: min(480px, 100%); }
.table-card { width: 100%; padding: 0; overflow: auto; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 0 0 18px; }
.metric { padding: 18px; }
.metric span { display: block; color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.metric strong { display: block; font-size: 34px; margin-top: 8px; color: var(--blue-dark); }
.user-chip { background: #eef8fb; color: var(--blue-dark); border: 1px solid #c9e8ef; border-radius: 999px; padding: 9px 12px; font-weight: 700; }
.study-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.study-table th, .study-table td { padding: 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.study-table th { font-size: 13px; color: var(--muted); background: #f8fbfc; }
.study-table td span, .study-table code { display: block; margin-top: 6px; color: var(--muted); }
.status { display: inline-flex; border-radius: 999px; padding: 6px 10px; font-weight: 700; font-size: 13px; }
.status-activo { background: #e9f8ef; color: #247343; }
.status-vencido { background: #fff7df; color: #826000; }
.status-inactivo, .status-desactivado { background: #f2f2f2; color: #656565; }
.empty { text-align: center; color: var(--muted); padding: 40px !important; }
.form-hero { margin-bottom: 18px; }
.progress { height: 10px; background: #e3eef4; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--aqua); transition: width .2s ease; }
.upload-message { min-height: 22px; color: var(--muted); }
.form-step { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--blue-dark); }
.form-step span { width: 32px; height: 32px; display: grid; place-items: center; background: #e8f7fb; border: 1px solid #c9e8ef; border-radius: 999px; font-weight: 800; }
.origin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.origin-card {
  position: relative; display: grid; gap: 8px; min-height: 150px; padding: 18px;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfdfe; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.origin-card:hover, .origin-card.selected { border-color: #72c7d6; box-shadow: 0 14px 34px rgba(23,109,159,.10); transform: translateY(-1px); }
.origin-card input { position: absolute; top: 16px; right: 16px; width: auto; }
.origin-card strong { font-size: 22px; color: var(--blue-dark); padding-right: 34px; }
.origin-card small { color: var(--muted); line-height: 1.45; font-size: 15px; }
.badge {
  width: max-content; display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px;
  border-radius: 999px; background: #e4f8f5; color: #19746e; font-size: 12px; font-weight: 800;
}
.file-info { color: var(--muted); background: #f8fbfc; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 42px; }
.file-info:empty { display: none; }
.file-error { color: #8c252b; background: #fff1f1; border-color: #ffd1d4; }
.success-panel { padding: 24px; margin-bottom: 18px; }
.success-panel h2 { margin: 10px 0; font-size: 28px; }
.published-summary {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  background: #f8fbfc; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 12px 0;
}
.published-summary p { margin: 0; color: var(--muted); }
.dicom-shell { width: min(1240px, calc(100% - 32px)); }
.diagnostic-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px;
}
.diagnostic-grid div {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: var(--muted);
}
.diagnostic-grid strong { color: var(--blue-dark); }
.dicom-runtime {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 14px; margin: 0 0 18px;
}
.dicom-runtime h3 { margin: 0 0 10px; font-size: 17px; color: var(--blue-dark); }
.runtime-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.runtime-grid span { border-radius: 8px; padding: 9px 10px; font-size: 13px; font-weight: 700; }
.runtime-grid .ok { background: #e9f8ef; color: #247343; }
.runtime-grid .bad { background: #fff1f1; color: #8c252b; }
.codec-list { display: grid; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.codec-list strong { color: var(--blue-dark); }
.dicom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.dicom-panel, .dicom-upload { padding: 22px; }
.dicom-panel h2, .dicom-upload h2 { margin: 0 0 14px; font-size: 22px; }
.analysis-summary p { margin: 8px 0; color: var(--muted); }
.dicom-debug {
  margin-top: 12px; border: 1px solid #ffd8a8; background: #fffaf0; color: #684719; border-radius: 8px; padding: 12px;
}
.dicom-debug h3 { margin: 0 0 8px; font-size: 16px; color: #684719; }
.dicom-debug ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.dicom-debug small { display: block; color: #76592b; margin-top: 3px; line-height: 1.35; }
.dicom-ts { margin-top: 12px; overflow-x: auto; }
.dicom-ts h3 { margin: 0 0 8px; font-size: 16px; color: var(--blue-dark); }
.dicom-ts table { width: 100%; min-width: 760px; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dicom-ts th, .dicom-ts td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
.dicom-ts th { background: #f8fbfc; color: var(--muted); }
.dicom-ts code { white-space: nowrap; color: var(--blue-dark); }
.series-list { display: grid; gap: 10px; max-height: 300px; overflow: auto; }
.series-option {
  display: grid; grid-template-columns: 22px 1fr; align-items: start; gap: 10px;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfdfe;
}
.series-option input { width: auto; margin-top: 3px; }
.series-option span { color: var(--muted); line-height: 1.4; }
.series-option strong { color: var(--ink); }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fbfdfe; color: var(--ink);
}
.preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; min-height: 120px; }
.preview-grid:empty:before {
  content: "La vista previa aparecerá después de convertir.";
  color: var(--muted); grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 8px; padding: 26px; text-align: center;
}
.preview-grid img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #102a43; border-radius: 8px; border: 1px solid var(--line);
}
.dicom-log {
  min-height: 140px; max-height: 260px; overflow: auto; background: #102a43; color: #d9edf4;
  border-radius: 8px; padding: 12px; font-family: Consolas, monospace; font-size: 13px;
}
.dicom-log div { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.soft-box, .link-box { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.link-box { display: flex; gap: 10px; }
.viewer-page { background: #f4f8fa; }
.viewer { width: min(1180px, calc(100% - 28px)); margin: 0 auto 42px; }
.viewer-title { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 10px 0 18px; }
.viewer-stage {
  display: grid; grid-template-columns: 54px 1fr 54px; gap: 10px; align-items: center;
  background: #0f2637; padding: 14px; border-radius: 8px; min-height: 56vh;
}
.image-wrap { height: min(66vh, 720px); display: grid; place-items: center; overflow: auto; }
.image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .18s ease; }
.image-wrap.zoomed img { max-width: none; max-height: none; transform: scale(1.8); cursor: zoom-out; }
.nav-btn { height: 100%; min-height: 120px; border: 0; border-radius: 8px; background: rgba(255,255,255,.08); color: #fff; font-size: 42px; cursor: pointer; }
.viewer-controls { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; padding: 12px; }
.viewer-controls label { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.thumb-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; }
.thumb-strip button { border: 2px solid transparent; padding: 0; background: none; border-radius: 8px; overflow: hidden; cursor: pointer; flex: 0 0 78px; height: 62px; }
.thumb-strip button.active { border-color: var(--aqua); }
.thumb-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.medical-notice { margin-top: 8px; }
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; gap: 20px; margin-top: 18px; }
  .hero-visual { min-height: 330px; }
  .hero h1 { font-size: 42px; }
  .topbar, .admin-header, .viewer-header, .admin-intro, .viewer-title { align-items: flex-start; flex-direction: column; }
  .search-form, .link-box { flex-direction: column; width: 100%; }
  .viewer-stage { grid-template-columns: 1fr; }
  .nav-btn { min-height: 46px; }
  .image-wrap { height: 52vh; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .diagnostic-grid, .dicom-grid, .runtime-grid { grid-template-columns: 1fr; }
  .origin-grid, .two-column-form, .published-summary { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .summary-grid { grid-template-columns: 1fr; }
  .option-grid { grid-template-columns: 1fr; }
}
