:root {
  color-scheme: light;
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #172033;
  --muted: #667085;
  --line: #dce3ec;
  --primary: #173f73;
  --primary-dark: #0f2d54;
  --primary-soft: #eaf1fa;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #9a6700;
  --warning-soft: #fff7d6;
  --success: #067647;
  --success-soft: #eaf8f1;
  --radius: 16px;
  --shadow: 0 16px 40px rgba(28, 49, 78, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button,
select {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.brand {
  display: none;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-weight: 750;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.05em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a {
  padding: 9px 12px;
  border-radius: 10px;
  color: #344054;
  font-weight: 650;
}

.nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.account form,
.row-actions form,
.delete-form {
  margin: 0;
}

.page {
  width: min(1380px, calc(100% - 36px));
  min-height: calc(100vh - 130px);
  margin: 0 auto;
  padding: 34px 0 56px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 18px;
  font-size: 21px;
  line-height: 1.25;
}

.page-heading p:not(.eyebrow),
.panel > p:not(.eyebrow),
.help,
.muted,
.empty {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

.metrics article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metrics span {
  display: block;
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
}

.metrics .metric-danger {
  border-color: #f3c4c0;
  background: var(--danger-soft);
}

.metrics .metric-danger strong {
  color: var(--danger);
}

.panel {
  margin-bottom: 22px;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.narrow {
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
}

.stack {
  display: grid;
  gap: 18px;
}

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

.form-grid.one-column {
  grid-template-columns: 1fr;
}

.field-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  align-content: start;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #c9d3df;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-weight: 450;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: #5b85b7;
  box-shadow: 0 0 0 3px rgba(23, 63, 115, 0.12);
}

.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.check-label input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.split-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
  line-height: 1.2;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary {
  border-color: #cbd5e1;
  background: #fff;
  color: #344054;
}

.button.danger {
  border-color: #efb7b1;
  background: #fff;
  color: var(--danger);
}

.button.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 24px;
}

.filters .grow {
  flex: 1 1 320px;
}

.filters label:not(.grow) {
  flex: 0 1 210px;
}

.filter-button {
  flex: 0 0 auto;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #e6ebf1;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f9fbfd;
}

.route-column {
  width: 74px;
  text-align: center;
}

.route-menu {
  position: relative;
  display: inline-block;
}

.route-menu summary {
  list-style: none;
}

.route-menu summary::-webkit-details-marker {
  display: none;
}

.route-trigger,
.route-unavailable {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.route-trigger {
  color: var(--primary);
  cursor: pointer;
}

.route-trigger:hover,
.route-menu[open] .route-trigger {
  background: var(--primary-soft);
}

.route-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.route-trigger svg,
.route-unavailable svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.route-unavailable {
  color: #a7b0bd;
  cursor: not-allowed;
}

.route-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 32px rgba(28, 49, 78, 0.18);
  text-align: left;
}

.route-popover a {
  padding: 10px 12px;
  border-radius: 7px;
  color: #253652;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.route-popover a:hover,
.route-popover a:focus-visible {
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-decoration: none;
}

.table-wrap:has(.route-menu[open]) {
  padding-bottom: 112px;
  margin-bottom: -112px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-risk-alto {
  background: transparent;
  color: var(--danger);
}

.badge-risk-medio {
  background: transparent;
  color: var(--warning);
}

.badge-risk-baixo {
  background: transparent;
  color: var(--success);
}

.badge-status-em_acompanhamento {
  background: transparent;
  color: var(--primary);
}

.badge-status-suspenso {
  background: transparent;
  color: var(--warning);
}

.badge-status-desligado {
  background: transparent;
  color: #475467;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #e7ecf2;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.visit-form {
  margin-bottom: 28px;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  padding: 18px;
  border-left: 4px solid var(--primary);
  border-radius: 0 12px 12px 0;
  background: #f8fafc;
}

.timeline-item p {
  margin-bottom: 10px;
}

.timeline-item small,
.timeline-meta span {
  color: var(--muted);
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.upload-form {
  margin-bottom: 10px;
}

.attachment-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.attachment-item strong,
.attachment-item span {
  display: block;
}

.attachment-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.attachment-actions,
.delete-form,
.row-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.delete-form input {
  width: 190px;
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}

.alert {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--primary-dark);
  font-weight: 600;
}

.alert-success {
  color: #05603a;
}

.alert-error {
  color: #8f1f15;
}

.alert-warning {
  color: #775000;
}

.one-time-secret code {
  display: inline-block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #172033;
  font-size: 16px;
  user-select: all;
}

.auth-body,
.unavailable-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-page {
  width: min(470px, 100%);
}

.auth-card,
.unavailable-card {
  padding: clamp(28px, 6vw, 44px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(28, 49, 78, 0.14);
}

.auth-card {
  text-align: center;
}

.auth-card label,
.auth-card input {
  text-align: left;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 80px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  min-height: 32px;
  padding: 4px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--primary-soft);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.auth-card h1,
.unavailable-card h1 {
  margin-bottom: 22px;
  font-size: clamp(27px, 6vw, 36px);
}

.auth-card h1 {
  margin-bottom: 44px;
}

.auth-note {
  margin: 18px 0 0;
  color: #7b8796;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.error-panel {
  max-width: 680px;
  margin: 8vh auto;
  text-align: center;
}

.footer {
  padding: 0 20px 24px;
  color: #7b8796;
  font-size: 12px;
  text-align: center;
}

.chart-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.chart-card {
  min-width: 0;
  margin-bottom: 0;
}

.chart-list {
  display: grid;
  gap: 20px;
}

.chart-item {
  display: grid;
  gap: 8px;
}

.chart-item-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.chart-item-heading strong {
  color: var(--text);
  font-size: 17px;
}

.chart-progress {
  --chart-color: var(--primary);
  display: block;
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e8edf3;
  color: var(--chart-color);
  appearance: none;
}

.chart-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e8edf3;
}

.chart-progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--chart-color);
}

.chart-progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--chart-color);
}

.chart-status-em_cadastro {
  --chart-color: #5b6b82;
}

.chart-status-em_acompanhamento,
.chart-month {
  --chart-color: var(--primary);
}

.chart-status-suspenso,
.chart-risk-medio {
  --chart-color: #d69e00;
}

.chart-status-desligado,
.chart-panic-disabled {
  --chart-color: #8b95a5;
}

.chart-risk-baixo,
.chart-panic-enabled {
  --chart-color: var(--success);
}

.chart-risk-alto {
  --chart-color: var(--danger);
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav {
    grid-column: 1;
    grid-row: 1;
    overflow-x: auto;
  }

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

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

@media (max-width: 760px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .nav {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    padding-bottom: 4px;
  }

  .account {
    grid-row: 2;
    justify-content: space-between;
  }

  .page {
    width: min(100% - 24px, 1380px);
    padding-top: 24px;
  }

  .page-heading,
  .panel-heading,
  .attachment-item,
  .attachment-actions,
  .delete-form {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading .button {
    width: 100%;
  }

  .metrics,
  .chart-metrics,
  .chart-grid,
  .form-grid,
  .split-panels {
    grid-template-columns: 1fr;
  }

  .field-span {
    grid-column: auto;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filters label:not(.grow),
  .filters .grow {
    flex: 0 0 auto;
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .button {
    width: 100%;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .timeline-meta {
    flex-direction: column;
    gap: 4px;
  }

  .attachment-actions,
  .delete-form,
  .delete-form input {
    width: 100%;
  }

  .attachment-actions .button,
  .delete-form .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 18px;
    border-radius: 13px;
  }
}

.badge-archived {
  color: #475467;
}

.archive-zone {
  border-color: #d7dee8;
  background: #f8fafc;
}

.archive-zone form {
  margin-top: 18px;
}
