:root {
  --navy: #183a5a;
  --navy-900: #102842;
  --blue: #0b8fc9;
  --blue-soft: #eaf6fb;
  --ink: #172332;
  --muted: #68788c;
  --line: #dce5ee;
  --surface: #ffffff;
  --page: #f5f8fb;
  --red: #d94848;
  --amber: #e4a52b;
  --green: #18875b;
  --shadow: 0 18px 45px rgba(24, 58, 90, .12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f9fbfd 0%, #eef5fa 58%, #f8fafc 100%);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

body:has(#dashboard:target) .login-screen,
body:has(#ficha:target) .login-screen,
body:has(#casos:target) .login-screen,
body:has(#intervencion:target) .login-screen,
body:has(#seguimiento:target) .login-screen,
body:has(#reportes:target) .login-screen {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(220, 229, 238, .85);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px);
}

.navbar {
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  font-weight: 800;
}

.brand small,
.eyebrow,
.metric span,
.metric small {
  color: var(--muted);
}

.brand small {
  display: block;
  font-size: 12px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #34465b;
  font-size: 14px;
}

.nav-links a,
.nav-action {
  padding: 10px 12px;
  border-radius: 8px;
}

.nav-links a:hover {
  background: var(--blue-soft);
  color: var(--navy);
}

.nav-action {
  color: #fff;
  background: var(--navy);
}

main {
  overflow: hidden;
}

.login-screen,
.module,
.workspace {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.login-screen {
  min-height: 100vh;
  padding: 64px 0 48px;
  display: grid;
  grid-template-columns: .82fr 1.18fr;
  align-items: center;
  gap: 34px;
}

.login-intro h1 {
  max-width: 660px;
  margin: 0;
  font-size: clamp(34px, 6vw, 72px);
  line-height: .98;
}

.login-intro p {
  max-width: 630px;
  color: #46596f;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.form-actions,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button,
button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--navy);
  box-shadow: 0 10px 22px rgba(24, 58, 90, .22);
}

.secondary {
  color: var(--navy);
  background: #e7eef6;
}

.success {
  color: #fff;
  background: var(--green);
}

.danger {
  color: #fff;
  background: var(--red);
}

.login-panel {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.institution-card {
  display: grid;
  place-content: center;
  padding: 36px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 25% 20%, rgba(11, 143, 201, .36), transparent 32%),
    linear-gradient(145deg, var(--navy-900), var(--navy));
}

.institution-card h2 {
  margin: 16px 0 8px;
  font-size: 30px;
}

.institution-card p {
  max-width: 320px;
  margin: 0 auto;
  color: rgba(255, 255, 255, .76);
}

.institution-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  font-size: 28px;
}

.login-card,
.grid-form,
.visit-form {
  display: grid;
  gap: 16px;
}

.login-card {
  align-content: center;
  padding: 42px;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.login-card h2,
.section-heading h2,
.module h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #33465c;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(11, 143, 201, .12);
}

.workspace {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 620px;
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px 16px;
  color: rgba(255, 255, 255, .78);
  background: var(--navy);
}

.sidebar-brand {
  margin-bottom: 22px;
  color: #fff;
  font-weight: 800;
}

.sidebar a {
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
}

.sidebar a.active,
.sidebar a:hover {
  color: #fff;
  background: var(--blue);
}

.content-shell {
  padding: 28px;
  background: var(--page);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  color: #44576b;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric,
.data-card,
.form-panel,
.timeline article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(24, 58, 90, .06);
}

.metric {
  padding: 20px;
}

.metric strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 34px;
  line-height: 1;
}

.data-card {
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.card-head h3,
.data-card h3,
.timeline h3 {
  margin: 0;
}

.card-head a,
td a {
  color: var(--blue);
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: #657489;
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.critical {
  color: #9d2626;
  background: #fdecec;
}

.high {
  color: #8a5b00;
  background: #fff4d6;
}

.medium {
  color: #176b8f;
  background: #e7f6fd;
}

.pending {
  color: #8a5b00;
  background: #fff4d6;
}

.open {
  color: #176b8f;
  background: #e7f6fd;
}

.module {
  padding: 72px 0 0;
}

.content-shell > .module {
  width: 100%;
  margin: 0;
  padding: 0;
}

.content-shell > .dashboard-panel {
  animation: panelFade .18s ease-out;
}

@keyframes panelFade {
  from {
    opacity: .35;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-panel {
  padding: 24px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  padding: 11px 8px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.tab.active {
  color: var(--blue);
  border-bottom: 3px solid var(--blue);
}

.grid-form,
.visit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide,
fieldset,
.upload-box,
.form-actions {
  grid-column: 1 / -1;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

legend {
  padding: 0 8px;
  color: #42566b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
}

fieldset input {
  width: auto;
  min-height: auto;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 210px 170px;
  gap: 12px;
  margin-bottom: 18px;
}

.split {
  display: grid;
  grid-template-columns: .46fr .54fr;
  align-items: start;
  gap: 32px;
}

.module-intro {
  max-width: 460px;
  color: #54667a;
}

.upload-box {
  display: grid;
  min-height: 76px;
  place-items: center;
  border: 1px dashed #b8c9da;
  border-radius: 8px;
  color: #657489;
  background: #f8fbfd;
  font-size: 14px;
  font-weight: 700;
}

.form-actions {
  justify-content: flex-end;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.timeline article {
  padding: 22px;
  border-left: 4px solid var(--blue);
}

time {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.timeline p {
  margin-bottom: 0;
  color: #596b7e;
}

.report-grid {
  display: grid;
  grid-template-columns: 1.35fr .65fr;
  gap: 18px;
}

.filters.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 52px;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
}

.bar-row div {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef4;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
}

.bar-row.amber i {
  background: var(--amber);
}

.bar-row.green i {
  background: var(--green);
}

.donut {
  width: 190px;
  height: 190px;
  margin: 20px auto;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0 52%, var(--green) 52% 82%, var(--red) 82% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.legend {
  display: grid;
  gap: 8px;
  color: #55677b;
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
}

.dot.blue {
  background: var(--blue);
}

.dot.green {
  background: var(--green);
}

.dot.red {
  background: var(--red);
}

footer {
  width: min(1180px, calc(100% - 32px));
  margin: 72px auto 0;
  padding: 28px 0 40px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: #5f7085;
  font-size: 14px;
}

footer p {
  margin: 0;
}

body:not(:has(#dashboard:target)):not(:has(#ficha:target)):not(:has(#casos:target)):not(:has(#intervencion:target)):not(:has(#seguimiento:target)):not(:has(#reportes:target)) .authenticated {
  display: none !important;
}

.dashboard-panel {
  display: none;
}

body:has(#dashboard:target) .site-header.authenticated,
body:has(#ficha:target) .site-header.authenticated,
body:has(#casos:target) .site-header.authenticated,
body:has(#intervencion:target) .site-header.authenticated,
body:has(#seguimiento:target) .site-header.authenticated,
body:has(#reportes:target) .site-header.authenticated {
  display: block;
}

body:has(#dashboard:target) .workspace.authenticated,
body:has(#ficha:target) .workspace.authenticated,
body:has(#casos:target) .workspace.authenticated,
body:has(#intervencion:target) .workspace.authenticated,
body:has(#seguimiento:target) .workspace.authenticated,
body:has(#reportes:target) .workspace.authenticated {
  display: grid;
}

body:has(#dashboard:target) .dashboard-home,
body:has(#ficha:target) #ficha,
body:has(#casos:target) #casos,
body:has(#seguimiento:target) #seguimiento,
body:has(#reportes:target) #reportes {
  display: block;
}

body:has(#intervencion:target) #intervencion {
  display: grid;
}

body:has(#dashboard:target) footer.authenticated,
body:has(#ficha:target) footer.authenticated,
body:has(#casos:target) footer.authenticated,
body:has(#intervencion:target) footer.authenticated,
body:has(#seguimiento:target) footer.authenticated,
body:has(#reportes:target) footer.authenticated {
  display: flex;
}

body:has(#dashboard:target) .sidebar a[href="#dashboard"],
body:has(#ficha:target) .sidebar a[href="#ficha"],
body:has(#casos:target) .sidebar a[href="#casos"],
body:has(#intervencion:target) .sidebar a[href="#intervencion"],
body:has(#seguimiento:target) .sidebar a[href="#seguimiento"],
body:has(#reportes:target) .sidebar a[href="#reportes"] {
  color: #fff;
  background: var(--blue);
}

body:has(#dashboard:target) .nav-links a[href="#dashboard"],
body:has(#ficha:target) .nav-links a[href="#ficha"],
body:has(#casos:target) .nav-links a[href="#casos"],
body:has(#intervencion:target) .nav-links a[href="#intervencion"],
body:has(#seguimiento:target) .nav-links a[href="#seguimiento"],
body:has(#reportes:target) .nav-links a[href="#reportes"] {
  color: var(--navy);
  background: var(--blue-soft);
}

@media (max-width: 940px) {
  .navbar,
  .section-heading,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .login-screen,
  .login-panel,
  .workspace,
  .split,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: 0;
  }

  .sidebar {
    flex-direction: row;
    overflow-x: auto;
  }

  .sidebar-brand {
    min-width: 110px;
    margin-bottom: 0;
  }

  .metrics-grid,
  .timeline,
  .tabs,
  fieldset {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .login-screen,
  .module {
    padding-top: 46px;
  }

  .content-shell > .module {
    padding-top: 0;
  }

  .login-card,
  .institution-card,
  .content-shell,
  .form-panel,
  .data-card {
    padding: 18px;
  }

  .metrics-grid,
  .grid-form,
  .visit-form,
  .filters,
  .filters.compact,
  .tabs,
  .timeline,
  fieldset {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .login-intro p {
    font-size: 16px;
  }
}
