:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --text: #202d35;
  --muted: #586975;
  --line: #d7dfe3;
  --primary: #126080;
  --primary-dark: #0b475f;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 2px 10px rgba(28, 54, 65, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

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

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 24px;
  border-top: 4px solid #176b65;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  font-weight: 700;
  min-width: 0;
}

.brand-logo {
  height: 42px;
  object-fit: contain;
  width: 42px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.badge,
.status,
.priority {
  display: inline-flex;
  align-items: center;
  background: #e7f0f3;
  border-radius: 999px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  padding: 5px 9px;
  white-space: nowrap;
}

.status-nuevo { background: #fff1db; color: #88500b; }
.status-en_revision { background: #e5f1fa; color: #175b85; }
.status-en_seguimiento { background: #e2f3ed; color: #17664c; }
.status-cerrado { background: #edf0f1; color: #52616b; }
.priority-urgente, .priority-alta { background: #fce9e6; color: #a22b20; }
.priority-media { background: #fff1db; color: #88500b; }
.priority-baja { background: #e2f3ed; color: #17664c; }
.priority-sin_asignar { background: #edf0f1; color: #52616b; }

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

.history-search { max-width: 670px; }
.history-search .inline input { min-width: 0; }
.history-subtitle { margin: 10px 0 0; }
.history-results-head { margin-top: 30px; }
.reopen-panel { margin-top: 20px; }
.reopen-panel form { max-width: 760px; }
.reopen-panel .button { margin-top: 18px; }

.nav a {
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 10px;
}

.nav a:hover,
.nav a:focus,
.nav a[aria-current="page"] {
  background: #e7f0f3;
  color: var(--primary-dark);
}

.shell {
  margin: 0 auto;
  max-width: 1240px;
  padding: 28px 20px 48px;
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin-top: 12px;
}

.footer-inner {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1240px;
  padding: 18px 20px;
}

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

.footer-logo {
  flex: 0 0 22px;
  height: 22px !important;
  max-height: 22px;
  max-width: 22px;
  object-fit: contain;
  width: 22px !important;
}

.footer-brand strong {
  color: var(--text);
  display: block;
  font-size: 13px;
}

.footer-brand span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  justify-content: flex-end;
}

.footer-meta span {
  background: #f3f7f7;
  border: 1px solid #d5e2e2;
  border-radius: 999px;
  color: var(--primary-dark);
  font-weight: 700;
  padding: 5px 10px;
}

.login {
  display: grid;
  min-height: calc(100vh - 150px);
  place-items: center;
}

.login-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel {
  max-width: 420px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.login-logo {
  height: 42px;
  object-fit: contain;
  width: 42px;
}

.page-head {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-head h1 { font-size: clamp(24px, 2.3rem, 32px); line-height: 1.15; }
.panel h2 { font-size: 19px; line-height: 1.3; }
.login-panel h1 { font-size: 26px; line-height: 1.2; }
.section-caption { font-size: 13px; margin: 3px 0 0; }
.case-labels { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.page-head h1,
.panel h2,
.login-panel h1 {
  margin: 0;
}

.user-card {
  display: grid;
  gap: 4px;
  min-width: 180px;
  text-align: right;
}

.user-card strong {
  font-weight: 700;
}

.user-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.print-only {
  display: none;
}

.hidden {
  display: none;
}

.search-hint {
  margin-bottom: 0;
}

.layout {
  display: grid;
  gap: 20px;
}

.layout.two {
  grid-template-columns: 1fr 1.2fr;
}

.inline {
  display: flex;
  gap: 10px;
}

.actions {
  display: flex;
  gap: 10px;
}

label {
  color: var(--text);
  display: grid;
  font-weight: 700;
  gap: 8px;
  margin-top: 16px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.button {
  align-items: center;
  background: #eef2f7;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 9px 14px;
}

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

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

.button.ghost {
  background: transparent;
}

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.button.small {
  min-height: 36px;
  padding: 6px 10px;
}

.button.wide {
  width: 100%;
}

.alert {
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.alert.error {
  background: #ffebe9;
  color: var(--danger);
}

.alert.success {
  background: #dcfae6;
  color: var(--success);
}

.student-result {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
}

.student-result.selected {
  background: #edf7f5;
  border: 1px solid #92c8be;
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

.student-result span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.report-form {
  margin-top: 20px;
}

.report-form .table-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.field-hint { color: var(--muted); font-size: 13px; margin: 5px 0 0; }
.report-form form { max-width: 760px; }

.priority-form {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 2px;
}

.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  border-top: 3px solid var(--line);
  transition: border-color 150ms ease, background 150ms ease;
}

.stat:hover, .stat.active { background: #f7fbfa; border-color: #9cc9be; }
.stat-new { border-top-color: #bd8134; }
.stat-review { border-top-color: #4f91b4; }
.stat-followup { border-top-color: #398b71; }
.stat-closed { border-top-color: #88979d; }
.stat.active { outline: 2px solid var(--primary); outline-offset: -2px; }

.stat span {
  color: var(--muted);
  display: block;
}

.stat strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

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

.table-head h2 { margin: 0; }
.empty-state { margin: 20px 0; }

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f7f9f9;
}

tbody tr:hover {
  background: #f8fbff;
}

.details {
  display: grid;
  gap: 10px;
  grid-template-columns: 140px 1fr;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.details dd {
  margin: 0;
}

.details .long-text, .followup p { white-space: pre-wrap; overflow-wrap: anywhere; }
.details dt, .details dd { border-bottom: 1px solid #edf0f1; padding: 5px 0 12px; }

.attachment {
  border-top: 1px solid var(--line);
  display: block;
  margin-top: 14px;
  padding-top: 14px;
}

.followup {
  border-left: 2px solid #c8d9d8;
  border-top: 0;
  display: block;
  margin: 0 0 0 7px;
  padding: 18px 0 18px 22px;
  position: relative;
}

.followup::before { background: #fff; border: 3px solid #2b7d76; border-radius: 50%; content: ""; height: 12px; left: -7px; position: absolute; top: 23px; width: 12px; }
.followup + .followup { border-top: 1px solid #edf0f1; }

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

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

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

.attachment.compact {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 0;
  padding: 8px 10px;
}

.followup header {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.followup header span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.followup-upload {
  align-items: center;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) auto;
  margin-top: 14px;
  padding-top: 14px;
}

.public-summary {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0;
  padding: 14px;
}

.public-summary p {
  margin: 8px 0 0;
}

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

.diagnostic-item {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px;
}

.diagnostic-item p {
  color: var(--muted);
  margin: 6px 0 0;
}

.diagnostic-item span {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
  text-transform: uppercase;
}

.diagnostic-item.ok {
  background: #f6fef9;
  border-color: #abefc6;
}

.diagnostic-item.ok span {
  background: #dcfae6;
  color: var(--success);
}

.diagnostic-item.fail {
  background: #fffbfa;
  border-color: #fecdca;
}

.diagnostic-item.fail span {
  background: #ffebe9;
  color: var(--danger);
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid #d79d3f;
  outline-offset: 2px;
}

.button:hover { background: #e1e9ed; }
.button.primary:hover { background: var(--primary-dark); }
.button.danger:hover { background: #8e211a; }
.button.ghost:hover { background: #e7f0f3; }

@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 20px; }
  .nav { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 14px 16px; }
  .brand-copy > div { font-size: 14px; }
  .nav { flex-wrap: wrap; }
  .nav a, .nav .button { font-size: 13px; }
  .shell { padding: 22px 14px 36px; }
  .panel, .login-panel { padding: 18px; }
  .page-head h1 { font-size: 25px; }
  .topbar,
  .page-head,
  .inline,
  .actions,
  .student-result,
  .footer-inner,
  .followup header,
  .followup-upload,
  .diagnostic-item {
    align-items: stretch;
    flex-direction: column;
  }

  .followup-upload {
    grid-template-columns: 1fr;
  }

  .user-card {
    min-width: 0;
    text-align: left;
  }

  .footer-meta {
    justify-content: flex-start;
  }

  .layout.two,
  .stats {
    grid-template-columns: 1fr;
  }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 25px; margin-top: 2px; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
  table thead { display: none; }
  table tbody { display: grid; gap: 12px; }
  table tr { border: 1px solid var(--line); border-radius: 6px; display: grid; padding: 10px 14px; }
  table td { align-items: start; display: grid; gap: 8px; grid-template-columns: minmax(105px, 38%) minmax(0, 1fr); padding: 8px 0; overflow-wrap: anywhere; }
  table td::before { color: var(--muted); content: attr(data-label); font-size: 12px; font-weight: 700; }
  table td.row-action { display: block; border-bottom: 0; }
  table td.row-action::before { display: none; }
  table td.row-action .button { width: 100%; }
  .details { grid-template-columns: 105px minmax(0, 1fr); }
}

@media print {
  .topbar,
  .site-footer,
  .no-print,
  .button {
    display: none;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 12px;
  }

  .shell {
    max-width: none;
    padding: 0 18px;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 12px 0;
  }

  .print-only {
    display: block;
  }

  .print-header {
    align-items: center;
    border-bottom: 2px solid #111111;
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 12px;
  }

  .print-header img {
    height: 64px;
    object-fit: contain;
    width: 64px;
  }

  .print-header div {
    display: grid;
    gap: 3px;
  }

  .print-header strong {
    font-size: 18px;
  }

  .page-head {
    border-bottom: 1px solid #999999;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .page-head h1 {
    font-size: 18px;
  }

  .layout.two {
    grid-template-columns: 1fr;
  }

  .details {
    grid-template-columns: 120px 1fr;
  }

  .followup {
    break-inside: avoid;
  }

  .signature-block {
    margin-top: 72px;
    text-align: center;
  }

  .signature-line {
    border-top: 1px solid #000000;
    margin: 0 auto 8px;
    width: 320px;
  }

  .signature-block span {
    display: block;
    margin-top: 3px;
    text-transform: uppercase;
  }
}
