:root {
  --ink: #172033;
  --muted: #657084;
  --line: #dfe5ef;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --blue: #052b5f;
  --blue-2: #0d4e8a;
  --teal: #007c89;
  --gold: #f2b632;
  --green: #138a5b;
  --red: #bc3b3b;
  --orange: #b86416;
  --shadow: 0 18px 48px rgba(20, 32, 54, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef3f8;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  background: #eef3f8;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 2;
}

.login-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand img {
  width: 132px;
  height: auto;
}

.login-title {
  margin: 34px 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-copy {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.5;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 18px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff8df;
  color: #5e4208;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(142, 83, 14, 0.12);
}

.access-badge strong {
  margin-left: 5px;
  color: var(--blue);
  overflow-wrap: anywhere;
}

.login-aside {
  position: relative;
  display: grid;
  align-items: end;
  padding: 56px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(5, 43, 95, 0.94), rgba(0, 124, 137, 0.86)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.12) 0 1px, transparent 1px 18px);
  color: white;
}

.login-aside h2 {
  max-width: 720px;
  margin: 0;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
}

.login-aside p {
  max-width: 620px;
  color: rgba(255,255,255,0.82);
  font-size: 17px;
  line-height: 1.6;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 124, 137, 0.13);
}

input[readonly] {
  background: #f7f9fc;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 15px;
  background: var(--blue);
  color: white;
  font-weight: 800;
  text-decoration: none;
}

.btn:hover {
  background: var(--blue-2);
}

.btn.secondary {
  background: white;
  color: var(--blue);
  border-color: var(--line);
}

.btn.secondary:hover {
  background: #f7fafc;
}

.btn.warn {
  background: var(--orange);
}

.btn.danger {
  background: var(--red);
}

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

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #061f43;
  color: white;
}

.sidebar .access-badge {
  margin: 14px 0 0;
  background: rgba(255,255,255,0.1);
  color: white;
  border-color: var(--gold);
  font-size: 12px;
}

.sidebar .access-badge strong {
  color: white;
}

.brand img {
  width: 118px;
  height: auto;
  filter: brightness(0) invert(1);
}

.brand-title {
  margin: 12px 0 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 900;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 8px;
  padding: 13px 12px;
  background: transparent;
  color: rgba(255,255,255,0.78);
  text-align: left;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  background: rgba(255,255,255,0.12);
  color: white;
}

.nav-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  flex: 0 0 auto;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: rgba(255,255,255,0.74);
  font-size: 13px;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: rgba(255,255,255,0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.backup-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: #bc3b3b;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.backup-banner strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.backup-banner span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

.backup-banner .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions .access-badge {
  margin: 0;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e2eef5;
  color: var(--blue);
  font-weight: 900;
}

.content {
  padding: 28px;
  display: grid;
  align-content: start;
  gap: 22px;
}

.surface {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(20, 32, 54, 0.08);
}

.surface-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.surface-header h2 {
  margin: 0;
  font-size: 18px;
}

.surface-body {
  padding: 22px;
}

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

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

.full {
  grid-column: 1 / -1;
}

.recipient-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px;
  border-radius: 8px;
  background: white;
  border: 1px solid #edf1f6;
}

.check-row input {
  width: auto;
  margin-top: 3px;
}

.check-row strong {
  display: block;
  font-size: 14px;
}

.check-row small {
  color: var(--muted);
}

.obs-list {
  display: grid;
  gap: 12px;
}

.form-section {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.form-section-header h2 {
  margin: 0;
  font-size: 16px;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.obs-row {
  display: grid;
  grid-template-columns: 160px 190px 1fr auto;
  gap: 10px;
  align-items: start;
}

.obs-row textarea {
  min-height: 44px;
}

.inline-upload,
.comment-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.inline-upload {
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
}

.comment-list {
  display: grid;
  gap: 10px;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.comment-item strong {
  display: inline-block;
  margin-right: 8px;
}

.comment-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.comment-item p {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-box {
  max-width: 520px;
  flex: 1 1 320px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f8fafc;
}

.status-chip,
.alert-chip,
.treatment-chip,
.role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-Enviado {
  background: #fde8e8;
  color: var(--red);
}

.status-Rechazado {
  background: #fde8e8;
  color: var(--red);
}

.status-Completado {
  background: #e8f7f0;
  color: var(--green);
}

.treatment-chip {
  border: 1px solid transparent;
}

.treatment-approved {
  background: #e8f1fb;
  color: var(--blue-2);
}

.treatment-return {
  background: #fff1dd;
  color: var(--orange);
}

.treatment-gde {
  background: #e8f7f0;
  color: var(--green);
}

.treatment-empty {
  background: #eef3f8;
  color: var(--muted);
}

.alert-chip {
  background: #eef3f8;
  color: var(--muted);
}

.alert-chip.on {
  background: #fff2d3;
  color: #8a530e;
}

.alert-chip.overdue {
  background: #fde8e8;
  color: var(--red);
}

tr.row-gde td {
  background: #f0fbf6;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 17px;
  box-shadow: 0 10px 28px rgba(20, 32, 54, 0.07);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 31px;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 16px;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 900;
}

.detail-grid dd {
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(7, 18, 35, 0.56);
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: 420px;
  border-radius: 8px;
  padding: 14px 16px;
  background: #12213a;
  color: white;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.warn {
  background: var(--orange);
}

.toast.error {
  background: var(--red);
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions select {
  width: 145px;
}

@media (max-width: 980px) {
  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-aside {
    display: none;
  }

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .grid-2,
  .grid-3,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .inline-upload {
    width: 100%;
    align-items: stretch;
    grid-template-columns: 1fr;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .login-panel,
  .content,
  .surface-body,
  .surface-header {
    padding: 18px;
  }

  .sidebar {
    padding: 18px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
