:root {
  color-scheme: light;
  --navy: #073763;
  --navy-deep: #032846;
  --blue: #0e7490;
  --cyan: #22a7c4;
  --red: #d52941;
  --ink: #17212b;
  --muted: #66717d;
  --line: #d9e0e5;
  --soft: #f3f6f8;
  --paper: #ffffff;
  --success: #16794b;
  --warning: #a45b00;
  --shadow: 0 16px 40px rgba(3, 40, 70, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #eef3f6; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.tecbar {
  background: #003d79; border-bottom: 3px solid #ed1c24;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 20px; gap: 10px; position: sticky; top: 0; z-index: 20;
}
.tecbar-inner { display: flex; align-items: center; gap: 14px; }
.tec-logo { height: 34px; display: block; width: auto; }
.tec-schoolname { color: #fff; font-size: 14px; font-weight: 600; border-left: 1px solid rgba(255,255,255,.35); padding-left: 14px; }
.tecnav { display: flex; flex-wrap: wrap; gap: 4px; }
.tecnav button {
  color: #fff; background: transparent; border: 1px solid transparent; cursor: pointer;
  font-size: 12px; padding: 6px 12px; border-radius: 6px; opacity: .85;
}
.tecnav button:hover { background: rgba(255,255,255,.15); opacity: 1; }
.tecnav button.active { background: rgba(255,255,255,.18); opacity: 1; border-color: rgba(255,255,255,.4); font-weight: 600; }
.account-area { display: flex; align-items: center; gap: 12px; color: white; }
.account-name { text-align: right; display: grid; }
.account-name strong { font-size: .86rem; }
.account-name small { color: #bcd0df; font-size: .72rem; }

main { width: min(1440px, 100%); margin: 0 auto; padding: 36px clamp(18px, 4vw, 60px) 72px; }
.view { display: none; }
.view.active { display: block; animation: appear .2s ease; }
@keyframes appear { from { opacity: .35; transform: translateY(4px); } }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 0 0 28px; }
.page-heading h1 { margin: 3px 0 0; color: var(--navy-deep); font-size: clamp(1.8rem, 3.2vw, 2.8rem); line-height: 1.08; letter-spacing: -.035em; }
.eyebrow, .section-label { margin: 0; color: var(--blue); text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: .72rem; }
.last-update { color: var(--muted); font-size: .86rem; margin: 0 0 4px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { min-height: 132px; padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 22px rgba(3,40,70,.045); display: grid; align-content: center; }
.metric.primary { color: white; background: linear-gradient(135deg, var(--navy), var(--blue)); border-color: transparent; }
.metric span { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.metric.primary span, .metric.primary small { color: #cce4ee; }
.metric strong { margin-top: 7px; color: var(--navy-deep); font-size: clamp(1.35rem, 2.5vw, 2rem); letter-spacing: -.03em; }
.metric.primary strong { color: white; }
.metric small { color: var(--muted); margin-top: 2px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.filter-panel, .table-panel, .chart-panel, .export-form, .upload-panel, #view-fuentes .panel, .admin-grid > .panel, #admin-auditoria .panel { padding: 24px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel h2, .dialog h2 { margin: 4px 0 0; color: var(--navy-deep); font-size: 1.2rem; letter-spacing: -.015em; }
.filters { display: grid; grid-template-columns: 1.05fr 1fr 1fr 1.3fr auto; gap: 12px; align-items: end; }
label { display: grid; gap: 7px; color: #43515d; font-size: .8rem; font-weight: 720; }
input, select { min-height: 42px; padding: 9px 11px; color: var(--ink); background: white; border: 1px solid #cbd4da; border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,167,196,.14); }
.button { min-height: 40px; padding: 9px 15px; border-radius: 8px; border: 1px solid transparent; font-weight: 760; font-size: .82rem; }
.button-primary { color: white; background: var(--navy); }
.button-primary:hover { background: var(--navy-deep); }
.button-outline { color: inherit; border-color: rgba(255,255,255,.3); background: transparent; }
main .button-outline { color: var(--navy); border-color: #b9c7d0; background: white; }
.button-quiet { color: var(--blue); background: #edf7f9; }
.button-danger { color: #a7192c; background: #fff1f3; border-color: #f0c5cc; }
.button-large { min-height: 48px; padding-inline: 20px; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0; }
.report-guide { display: grid; grid-template-columns: minmax(190px,.5fr) minmax(0,1.5fr); gap: 22px; margin-top: 18px; padding: 18px 22px; color: var(--ink); background: #eaf5fa; border: 1px solid #c8dfe9; border-left: 5px solid var(--blue); border-radius: 12px; }
.report-guide h2 { margin: 4px 0 0; color: var(--navy-deep); font-size: 1rem; }
.report-guide dl { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 22px; margin: 0; }
.report-guide dl div { display: grid; grid-template-columns: auto 1fr; gap: 7px; align-items: baseline; }
.report-guide dt { color: var(--navy); font-size: .8rem; font-weight: 850; white-space: nowrap; }
.report-guide dd { margin: 0; color: #53636f; font-size: .78rem; line-height: 1.4; }
.chart-wrap { position: relative; height: 300px; }
.chart-wrap canvas { max-width: 100%; }
.variable-heading select { width: min(270px, 48%); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; }
.chart-note { min-height: 18px; color: var(--muted); font-size: .76rem; margin: 7px 0 0; }
.count-pill { color: var(--blue); background: #edf7f9; border-radius: 999px; padding: 6px 11px; font-size: .78rem; font-weight: 750; }
.table-actions { display: flex; gap: 10px; align-items: center; }
.table-scroll { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .78rem; }
th, td { min-width: 95px; padding: 10px 12px; text-align: right; border-bottom: 1px solid #e6ebee; white-space: nowrap; }
th { color: white; background: var(--navy); position: sticky; top: 0; z-index: 1; font-size: .71rem; letter-spacing: .025em; vertical-align: bottom; }
th .field-label { display: block; min-width: 120px; font-weight: 800; line-height: 1.25; white-space: normal; }
th small { display: block; max-width: 150px; margin-top: 4px; color: #c9e1ee; font-size: .64rem; font-weight: 550; line-height: 1.2; white-space: normal; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover td { background: #f4fafb; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 18px; margin-top: 18px; color: var(--muted); font-size: .82rem; }
.page-jump { display: flex; align-items: center; gap: 8px; }
.page-jump label { display: inline; font-size: .78rem; }
.page-jump input { width: 78px; min-height: 40px; text-align: center; }

.source-list, .user-list, .audit-list, .result-list { display: grid; gap: 10px; }
.source-item, .user-item, .audit-item, .result-item { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 10px; }
.source-actions { display: flex; align-items: center; gap: 10px; }
.source-item strong, .user-item strong { color: var(--navy-deep); }
.source-meta, .user-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 5px; color: var(--muted); font-size: .76rem; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 9px; font-size: .7rem; font-weight: 800; }
.status.ok { color: var(--success); background: #eaf7f0; }
.status.off { color: var(--muted); background: #edf0f2; }
.status.protected { color: var(--navy); background: #e8f0f7; }
.field-legend { display: flex; flex-wrap: wrap; gap: 15px; margin: -4px 0 13px; color: var(--muted); font-size: .75rem; }
.field-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; vertical-align: 1px; }
.dot.meta { background: #82909c; }
.dot.med { background: #18a999; }
.dot.max { background: #d52941; }
.dot.min { background: #826bb3; }
.dot.unk { background: transparent; border: 1px dashed #82909c; }
.unresolved { color: var(--muted); font-style: italic; }
.schema-warning { margin: 0 0 13px; padding: 10px 12px; color: #8a5500; background: #fff7e8; border: 1px solid #ead09a; border-radius: 8px; font-size: .8rem; }

.export-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 20px; }
.supporting { color: var(--muted); line-height: 1.55; font-size: .9rem; }
fieldset { margin: 24px 0; padding: 0; border: 0; }
legend { margin-bottom: 11px; color: #43515d; font-size: .8rem; font-weight: 750; }
.check-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.check-option { display: inline-flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 8px; }
.check-option input { min-height: auto; width: 16px; height: 16px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.export-variables { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.json-export { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.json-export p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.export-preview { padding: 28px; color: white; background: var(--navy-deep); border-radius: 14px; box-shadow: var(--shadow); }
.export-preview .section-label { color: #7fd2e4; }
.export-preview ol { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 28px; }
.export-preview li { display: flex; gap: 16px; align-items: start; }
.export-preview li > span { color: #70c9dc; font-weight: 850; font-size: .75rem; letter-spacing: .08em; }
.export-preview strong, .export-preview small { display: block; }
.export-preview small { color: #bcd0df; line-height: 1.45; margin-top: 5px; }

.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid #cdd8de; margin-bottom: 18px; }
.admin-tab { padding: 12px 18px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 750; }
.admin-tab.active { color: var(--navy); border-bottom-color: var(--red); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.upload-panel { display: grid; gap: 18px; }
.upload-surface { padding: clamp(22px, 4vw, 42px); }
.drop-zone { min-height: 330px; place-content: center; justify-items: center; gap: 10px; text-align: center; color: var(--navy); border: 3px dashed #70a9c4; background: linear-gradient(145deg, #f8fcfe, #eaf5fa); border-radius: 18px; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.drop-zone:hover { border-color: var(--blue); background: #e6f4f9; transform: translateY(-2px); }
.drop-zone.drag { border-color: var(--cyan); background: #eaf7fa; }
.drop-zone.disabled { cursor: default; opacity: .68; transform: none; }
.drop-zone input { display: none; }
.drop-zone strong { font-size: clamp(1.2rem, 2vw, 1.65rem); }
.drop-zone > span:not(.upload-icon) { color: #415866; font-weight: 550; }
.drop-zone small { color: var(--muted); font-weight: 500; }
.upload-icon { display: grid; place-items: center; width: 64px; height: 64px; color: white; background: var(--blue); border-radius: 50%; font-size: 2rem; box-shadow: 0 10px 24px rgba(14,116,144,.24); }
.upload-gate { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 17px; color: var(--navy-deep); background: #eef5fa; border: 1px solid #c8dbe7; border-radius: 10px; }
.selected-files { color: var(--muted); font-size: .82rem; }
.upload-progress p { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.progress-track { height: 9px; overflow: hidden; background: #dbe7ed; border-radius: 999px; }
.progress-track span { display: block; width: 45%; height: 100%; background: var(--blue); border-radius: inherit; animation: upload-progress 1.2s ease-in-out infinite alternate; }
@keyframes upload-progress { to { transform: translateX(122%); } }
.result-item.ok { border-color: #a8d7bd; background: #f1faf5; }
.result-item.error { border-color: #e6b8bf; background: #fff5f6; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, .65fr) minmax(0, 1.35fr); gap: 18px; align-items: start; }
.stack-form, .dialog form { display: grid; gap: 14px; margin-top: 20px; }
.user-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: end; }
.audit-item { align-items: start; }
.audit-item small { color: var(--muted); }

.dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 30px 90px rgba(2,28,49,.3); }
.dialog::backdrop { background: rgba(2, 28, 49, .64); backdrop-filter: blur(3px); }
.dialog form { position: relative; margin: 0; padding: 30px; }
.dialog-close { position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: var(--soft); font-size: 1.3rem; }
.form-error { min-height: 18px; margin: 0; color: #a7192c; font-size: .8rem; }
.form-hint { margin: -4px 0 0; color: var(--muted); font-size: .76rem; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 390px; padding: 13px 17px; color: white; background: var(--navy-deep); border-radius: 9px; box-shadow: 0 12px 32px rgba(0,0,0,.2); transform: translateY(18px); opacity: 0; pointer-events: none; transition: .2s ease; z-index: 100; }
.toast.show { transform: translateY(0); opacity: 1; }

.about-view { margin: -36px calc(clamp(18px, 4vw, 60px) * -1) -72px; min-height: calc(100vh - 77px); padding: 0 clamp(18px, 4vw, 60px) 70px; background: #12161a; }
#sectionAcerca { --about-cyan: #38bde8; --about-ink: #f4f8fb; --about-muted: #a7b5c2; --about-line: rgba(190,217,236,.14); --tec-red: #ed1c24; color: var(--about-ink); }
#sectionAcerca .about-shell { width: min(1100px, 100%); padding: clamp(28px, 5vw, 56px) 0 20px; }
#sectionAcerca .eyebrow { display: flex; align-items: center; gap: 12px; margin: 0 0 17px; color: var(--about-cyan); font-size: .74rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
#sectionAcerca .eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--tec-red); }
#sectionAcerca h1 { max-width: 900px; margin: 0; color: var(--about-ink); font-size: clamp(2.35rem, 6vw, 5rem); line-height: .98; letter-spacing: -.055em; }
#sectionAcerca h1 span { color: var(--about-cyan); }
#sectionAcerca .lead { max-width: 800px; margin: 26px 0 0; color: #c9d4dd; font-size: clamp(1rem, 1.8vw, 1.22rem); line-height: 1.65; }
#sectionAcerca .grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(270px,.75fr); gap: 22px; margin-top: clamp(42px,7vw,72px); }
#sectionAcerca .card { position: relative; overflow: hidden; padding: clamp(26px,4vw,42px); background: linear-gradient(145deg,rgba(20,38,53,.96),rgba(13,28,40,.96)); border: 1px solid var(--about-line); border-radius: 20px; box-shadow: 0 28px 70px rgba(0,0,0,.32); }
#sectionAcerca .card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -80px; bottom: -100px; border-radius: 50%; background: rgba(56,189,232,.07); }
#sectionAcerca .card__label { margin: 0 0 18px; color: var(--about-muted); font-size: .72rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
#sectionAcerca .card h2 { margin: 0 0 18px; color: var(--about-ink); font-size: clamp(1.35rem,2.5vw,1.85rem); line-height: 1.2; letter-spacing: -.025em; }
#sectionAcerca .card p { margin: 0; color: #c6d1da; line-height: 1.72; }
#sectionAcerca .project-list { display: grid; gap: 20px; margin: 26px 0 0; padding: 0; list-style: none; }
#sectionAcerca .project-list li { padding: 0 0 0 19px; border-left: 2px solid var(--tec-red); line-height: 1.65; }
#sectionAcerca .project-list strong { display: block; margin-bottom: 4px; color: white; }
#sectionAcerca .credits { display: flex; flex-direction: column; }
#sectionAcerca .people { display: grid; gap: 14px; margin-top: 7px; }
#sectionAcerca .person { padding: 15px 16px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; color: #dfe8ef; font-size: .94rem; line-height: 1.45; }
#sectionAcerca .person strong { display: block; color: var(--about-cyan); font-size: 1.02rem; }
#sectionAcerca .institution { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--about-line); }
#sectionAcerca .institution strong { display: block; color: white; }

@media (max-width: 1250px) {
  .account-name { display: none; }
}

@media (max-width: 1050px) {
  .tecbar { align-items: flex-start; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav-link { min-height: 40px; flex: 0 0 auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .filters .button { grid-column: 2; }
  .chart-grid { grid-template-columns: 1fr; }
  .report-guide { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .tecbar { padding: 10px 14px; gap: 10px; }
  .tec-schoolname { display: none; }
  .account-name { display: none; }
  main { padding-inline: 14px; padding-top: 24px; }
  .page-heading { display: block; }
  .last-update { margin-top: 10px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 112px; padding: 17px; }
  .filters, .two-fields, .export-variables, .admin-grid, .export-layout { grid-template-columns: 1fr; }
  .filters .button { grid-column: auto; }
  .panel-title-row { align-items: start; }
  .variable-heading { display: grid; }
  .variable-heading select { width: 100%; }
  .report-guide dl { grid-template-columns: 1fr; }
  .source-item, .user-item, .upload-gate, .json-export { align-items: start; flex-direction: column; }
  .source-actions { width: 100%; justify-content: space-between; }
  .user-actions { justify-content: start; }
  .about-view { margin-top: -24px; margin-inline: -14px; padding-inline: 18px; }
  #sectionAcerca .grid { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr; }
  .nav-link { padding-inline: 12px; }
  #sectionAcerca h1 { font-size: clamp(2.35rem,13vw,3.6rem); }
  #sectionAcerca .card { border-radius: 16px; }
}
