:root {
  --navy: #16386d;
  --navy-dark: #0b2347;
  --navy-soft: #214a8b;
  --yellow: #f2b31a;
  --yellow-soft: #ffd36b;
  --gray-50: #f4f7fb;
  --gray-100: #e9eef5;
  --gray-200: #d8e1ec;
  --gray-400: #8b97ab;
  --gray-600: #5a667a;
  --text: #14233c;
  --white: #ffffff;
  --shadow: 0 18px 40px rgba(9, 31, 63, 0.10);
  --shadow-soft: 0 12px 28px rgba(10, 27, 55, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(242, 179, 26, 0.08), transparent 28%),
    linear-gradient(180deg, #eef3f9 0%, #f7f9fc 100%);
  color: var(--text);
}

a { color: inherit; }

.topbar {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 58%, var(--navy-soft) 100%);
  color: var(--white);
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
}
.topbar-inner {
  max-width: 1460px;
  margin: 0 auto;
  padding: 24px 28px 30px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 1;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand-logo {
  width: 210px;
  max-width: 42vw;
  background: rgba(255,255,255,0.96);
  padding: 10px 14px;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.16);
}
.brand-copy h1 {
  margin: 4px 0 6px;
  font-size: clamp(1.55rem, 2.2vw, 2.1rem);
  line-height: 1.1;
}
.brand-copy p {
  margin: 0;
  color: rgba(255,255,255,0.82);
  font-size: 0.98rem;
}
.brand-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
}
.topbar-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.domain-pill,
.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  text-decoration: none;
  font-weight: 600;
  color: var(--white);
}
.version-pill {
  background: rgba(242, 179, 26, 0.18);
  border-color: rgba(242, 179, 26, 0.32);
}

.page-shell {
  max-width: 1460px;
  margin: -18px auto 0;
  padding: 0 20px 28px;
}
.hero-panel,
.toolbar-panel,
.panel {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(17, 43, 79, 0.08);
  box-shadow: var(--shadow-soft);
}
.hero-panel {
  border-radius: var(--radius-xl);
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: stretch;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.hero-label,
.section-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(22, 56, 109, 0.08);
  color: var(--navy);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-copy h2 {
  margin: 0;
  font-size: clamp(1.9rem, 2.7vw, 3rem);
  line-height: 1.08;
}
.hero-copy p {
  margin: 0;
  max-width: 720px;
  color: var(--gray-600);
  font-size: 1rem;
}
.hero-actions { display: flex; }
.export-card {
  width: 100%;
  background: linear-gradient(145deg, #fbfcfe 0%, #edf3fa 100%);
  border: 1px solid rgba(22, 56, 109, 0.12);
  border-radius: 22px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  overflow: hidden;
}
.export-card::before {
  content: "";
  position: absolute;
  right: -70px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 179, 26, 0.20), rgba(242, 179, 26, 0));
}
.export-card h3,
.support-actions h4,
.panel-head h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}
.export-card p,
.support-actions p,
.subtle {
  margin: 0;
  color: var(--gray-600);
  line-height: 1.55;
}
.export-card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-panel {
  margin-top: 18px;
  border-radius: 22px;
  padding: 18px 20px 20px;
}
.facility-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.facility-tabs button {
  border: 1px solid rgba(22, 56, 109, 0.14);
  background: #f7f9fc;
  color: var(--navy);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}
.facility-tabs button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(22, 56, 109, 0.10);
}
.facility-tabs button.active {
  background: linear-gradient(135deg, #2957a5 0%, var(--navy) 100%);
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(22, 56, 109, 0.18);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-card {
  min-height: 110px;
  border-radius: 18px;
  padding: 16px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,253,1) 100%);
  border: 1px solid rgba(18, 44, 79, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric-title {
  color: var(--gray-600);
  font-size: 0.88rem;
  font-weight: 600;
}
.metric-card strong {
  font-size: 2rem;
  line-height: 1;
  color: var(--navy-dark);
}
.metric-card small {
  color: var(--gray-400);
  font-size: 0.85rem;
}

.content-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.panel {
  border-radius: 24px;
  padding: 22px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.list-panel-head {
  align-items: center;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(22, 56, 109, 0.08);
  color: var(--navy);
  font-weight: 700;
  white-space: nowrap;
}
.panel-divider {
  height: 1px;
  margin: 22px 0;
  background: linear-gradient(90deg, rgba(22,56,109,0.14), rgba(22,56,109,0));
}

.form-row { margin-bottom: 14px; }
.form-row-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--navy-dark);
}
input,
select,
textarea,
button {
  font: inherit;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(22, 56, 109, 0.16);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: 0.18s ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(22, 56, 109, 0.45);
  box-shadow: 0 0 0 4px rgba(22, 56, 109, 0.08);
}
input[type="file"] {
  padding: 10px 12px;
  background: #f8fbff;
}
textarea { resize: vertical; min-height: 98px; }
small { color: var(--gray-600); }

.foto-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px dashed rgba(22, 56, 109, 0.18);
}
.foto-preview-wrapper span {
  font-size: 0.85rem;
  color: var(--gray-600);
  font-weight: 700;
}
#fotoPreview {
  display: none;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--white);
}
.form-actions,
.data-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(135deg, var(--navy) 0%, #2d5baa 100%);
  color: var(--white);
  box-shadow: 0 12px 20px rgba(22, 56, 109, 0.16);
}
.btn-secondary {
  background: #eef3fb;
  color: var(--navy);
}
.btn-outline {
  background: #fff;
  color: var(--navy);
  border: 1px solid rgba(22, 56, 109, 0.16);
}
.btn-excel {
  background: linear-gradient(135deg, var(--yellow) 0%, #ffcf5d 100%);
  color: #352400;
  box-shadow: 0 12px 20px rgba(242, 179, 26, 0.22);
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
#buscador {
  flex: 1 1 320px;
  min-width: 220px;
}
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f6f9fd;
  border: 1px solid rgba(22,56,109,0.10);
  font-weight: 600;
  color: var(--gray-600);
}
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  border: 1px solid rgba(22, 56, 109, 0.12);
  border-radius: 20px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  box-shadow: var(--shadow-soft);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--navy-dark);
}
.card-tag,
.facility-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}
.card-tag {
  background: rgba(242, 179, 26, 0.16);
  color: #6b4a00;
}
.facility-chip {
  margin-bottom: 12px;
  background: rgba(22, 56, 109, 0.10);
  color: var(--navy);
}
.status-chip {
  background: #edf3fa;
  color: var(--navy);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 12px;
}
.card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-field span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
  font-weight: 700;
}
.card-field strong,
.card-field p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.38;
  word-break: break-word;
}
.card-observaciones {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f9fc;
  color: var(--gray-600);
  font-size: 0.9rem;
}
.card-foto {
  margin-bottom: 14px;
}
.card-foto img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(22, 56, 109, 0.10);
}
.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.card-actions button {
  flex: 1;
  min-width: 120px;
}
.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px dashed rgba(22,56,109,0.16);
  border-radius: 22px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
  text-align: center;
  padding: 24px;
}
.empty-state h4 {
  margin: 0 0 8px;
  color: var(--navy-dark);
}
.empty-state p {
  margin: 0;
  max-width: 420px;
  color: var(--gray-600);
}
.support-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.footer {
  max-width: 1460px;
  margin: 0 auto;
  padding: 0 24px 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--gray-600);
  font-size: 0.92rem;
}
.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;
}

@media (max-width: 1080px) {
  .hero-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar-inner,
  .panel-head,
  .support-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-side {
    justify-content: flex-start;
  }
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .page-shell,
  .footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .hero-panel,
  .toolbar-panel,
  .panel {
    border-radius: 18px;
    padding: 18px;
  }
  .brand-wrap {
    align-items: flex-start;
    flex-direction: column;
  }
  .brand-logo {
    width: 170px;
  }
  .metric-grid,
  .form-row-inline,
  .card-grid {
    grid-template-columns: 1fr;
  }
  .card-actions button,
  .form-actions .btn,
  .data-actions .btn,
  .export-card-actions > * {
    width: 100%;
  }
}

/* V4: capa corporativa unificada y acentos por facilidad */
body[data-facility="CPF1"] { --facility: #007fa8; --facility-rgb: 0,127,168; }
body[data-facility="CPF2"] { --facility: #13876e; --facility-rgb: 19,135,110; }
body[data-facility="PER"]  { --facility: #a05e13; --facility-rgb: 160,94,19; }
body[data-facility="CSE"]  { --facility: #6d54ac; --facility-rgb: 109,84,172; }
body[data-facility="TODAS"], body:not([data-facility]) { --facility: #204b8e; --facility-rgb: 32,75,142; }

.topbar { background: linear-gradient(120deg, #091a35 0%, #132e57 58%, #1d457b 100%); border-bottom: 4px solid var(--yellow); }
.topbar-inner { padding-top: 20px; padding-bottom: 22px; align-items:center; }
.brand-logo { width: 185px; padding: 9px 12px; border-radius: 12px; }
.brand-copy h1 { font-size: clamp(1.35rem, 2vw, 1.85rem); }
.brand-copy p { font-size:.88rem; }
.page-shell { margin-top: 20px; }
.hero-panel {
  min-height: 255px; grid-template-columns: minmax(280px, 1.5fr) minmax(190px, .52fr) minmax(270px, .9fr);
  background: radial-gradient(circle at 55% 0%, rgba(242,179,26,.14), transparent 32%), linear-gradient(130deg,#fff 5%,#f1f5fa 100%);
  border: 1px solid rgba(22,56,109,.10); position: relative; overflow: hidden; align-items:center;
  box-shadow: 0 22px 48px rgba(13,40,84,.11);
}
.hero-panel::before { content:""; position:absolute; left:0; top:0; height:100%; width:5px; background:linear-gradient(var(--yellow),#f7d477); }
.hero-copy { position:relative; z-index:2; }
.hero-copy h2 { font-size:clamp(1.85rem,2.5vw,2.7rem); letter-spacing:-.035em; }
.hero-accent { color:var(--facility); }
.hero-label { background:rgba(242,179,26,.15); color:#76520e; }
.hero-light { width:7px; height:7px; background:var(--yellow); border-radius:50%; box-shadow:0 0 0 4px rgba(242,179,26,.15); }
.hero-graphic { position:relative; display:grid; place-items:center; min-height:210px; }
.hero-orbit { position:absolute; width:210px; height:210px; border:1px solid rgba(var(--facility-rgb),.18); border-radius:50%; }
.hero-orbit-b { width:150px; height:150px; border-style:dashed; transform:rotate(30deg); }
.hero-visual-card { position:relative; z-index:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; width:175px; min-height:175px; padding:16px; border-radius:26px; background:linear-gradient(145deg,#112b52,#1d467f); box-shadow:0 18px 38px rgba(11,34,75,.25); color:white; text-align:center; transform:rotate(-3deg); }
.hero-visual-logo { width:72px; height:72px; border-radius:18px; overflow:hidden; margin-bottom:6px; }
.hero-visual-logo img { width:100%; height:100%; object-fit:cover; }
.hero-visual-card span { font-size:.58rem; font-weight:700; letter-spacing:.18em; color:#cbd7e7; }
.hero-visual-card strong { font-size:.82rem; }
.hero-facility-dots { display:flex; gap:6px; padding-top:8px; }
.hero-facility-dots i { width:8px; height:8px; border-radius:50%; background:#007fa8; }
.hero-facility-dots i:nth-child(2) { background:#13876e; }
.hero-facility-dots i:nth-child(3) { background:#f2b31a; }
.hero-facility-dots i:nth-child(4) { background:#9474d7; }
.export-card { border-top:3px solid var(--yellow); background:rgba(255,255,255,.9); padding:18px; box-shadow:0 8px 20px rgba(13,40,84,.07); }
.export-card-actions { align-items:stretch; }
.export-card-actions select { flex:1 1 155px; }
.export-card-actions .btn { flex:1 1 130px; }
.toolbar-header { display:flex; gap:18px; align-items:center; justify-content:space-between; padding:1px 3px 14px; }
.toolbar-header h3 { margin:6px 0 0; font-size:1.12rem; }
.facility-context { color:var(--facility); background:rgba(var(--facility-rgb),.09); border:1px solid rgba(var(--facility-rgb),.14); border-radius:12px; padding:10px 14px; font-weight:750; }
.facility-tabs button[data-fac="CPF1"] { --tab: #007fa8; }
.facility-tabs button[data-fac="CPF2"] { --tab: #13876e; }
.facility-tabs button[data-fac="PER"] { --tab: #a05e13; }
.facility-tabs button[data-fac="CSE"] { --tab: #6d54ac; }
.facility-tabs button[data-fac="TODAS"] { --tab: #204b8e; }
.facility-tabs button.active { background:var(--tab); box-shadow:0 8px 17px color-mix(in srgb,var(--tab) 22%,transparent); }
.metric-card { border-top:3px solid var(--facility); min-height:98px; padding:12px 15px; }
.metric-card strong { font-size:1.8rem; }
.metric-title { font-size:.83rem; }
.metric-card small { font-size:.78rem; }
.metric-grid { gap:12px; }
.panel-head .section-tag { color:var(--facility); background:rgba(var(--facility-rgb),.08); }
.filter-pill, .facility-chip { color:var(--facility); background:rgba(var(--facility-rgb),.1); }
.select-add-row { display:flex; gap:8px; align-items:stretch; }
.select-add-row select { flex:1; min-width:0; }
.btn-add { flex-shrink:0; border:1px solid rgba(var(--facility-rgb),.2); color:var(--facility); border-radius:12px; background:rgba(var(--facility-rgb),.07); font-size:.83rem; font-weight:800; padding:0 12px; cursor:pointer; }
.btn-add:hover { background:rgba(var(--facility-rgb),.14); }
.inline-create { margin:10px 0 3px; padding:14px; border:1px solid rgba(var(--facility-rgb),.18); border-radius:14px; background:#f8fafc; }
.inline-create[hidden] { display:none !important; }
.inline-create-row { display:flex; gap:8px; align-items:stretch; }
.inline-create-row input { flex:1; min-width:0; }
.inline-create-row button { padding:0 12px; min-height:44px; }
.inline-create small { display:block; margin-top:8px; }
.card { border-top:3px solid var(--facility); }
@media(max-width:1200px) {
  .hero-panel { grid-template-columns: 1fr minmax(220px,.8fr); }
  .hero-graphic { display:none; }
}
@media(max-width:700px) {
  .hero-panel { grid-template-columns:1fr; }
  .hero-graphic { display:none; }
  .toolbar-header { flex-direction:column; align-items:flex-start; }
  .inline-create-row { flex-wrap:wrap; }
  .inline-create-row input { flex-basis:100%; }
  .inline-create-row button { flex:1; }
  .select-add-row { flex-wrap:nowrap; }
}
