/* ResCore — mobile first, emergencias */
:root {
  --rojo: #c41e3a;
  --rojo-oscuro: #9e1830;
  --rojo-claro: #fde8ec;
  --texto: #1a1a1a;
  --borde: #e0e0e0;
  --sombra: 0 2px 12px rgba(0,0,0,.08);
  --radio: 10px;
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--texto);
  background: #fafafa;
  line-height: 1.45;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 3px solid var(--rojo);
  box-shadow: var(--sombra);
}
.app-header__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  max-width: 1100px;
  margin: 0 auto;
}
.nav-toggle {
  min-width: var(--tap);
  min-height: var(--tap);
  font-size: 1.5rem;
  border: 2px solid var(--borde);
  background: #fff;
  border-radius: var(--radio);
  cursor: pointer;
}
.app-logo img { display: block; max-height: 44px; width: auto; }
.app-header__user {
  margin-left: auto;
  font-size: 0.85rem;
  color: #555;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 0 1rem 1rem;
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
}
.app-nav.is-open { display: flex; }
.app-nav a {
  display: block;
  padding: 0.9rem 1rem;
  color: var(--texto);
  text-decoration: none;
  border-bottom: 1px solid var(--borde);
  font-weight: 500;
}
.app-nav a:hover, .app-nav a:focus { background: var(--rojo-claro); }
.app-nav .nav-highlight {
  background: var(--rojo);
  color: #fff;
  border-radius: var(--radio);
  border: none;
  margin: 0.25rem 0;
  text-align: center;
}

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .app-nav {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 1rem 0.75rem;
    gap: 0.25rem;
  }
  .app-nav a {
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radio);
  }
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 3rem;
}
.app-main--auth { max-width: 420px; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radio);
  margin-bottom: 1rem;
}
.flash--ok { background: #e8f5e9; border: 1px solid #a5d6a7; }
.flash--err { background: #ffebee; border: 1px solid #ef9a9a; }

h1 { font-size: 1.35rem; margin: 0 0 1rem; color: var(--rojo-oscuro); }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 1.25rem;
  border: none;
  border-radius: var(--radio);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn--primary {
  background: var(--rojo);
  color: #fff;
}
.btn--primary:hover { background: var(--rojo-oscuro); }
.btn--outline {
  background: #fff;
  color: var(--rojo);
  border: 2px solid var(--rojo);
}
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; font-size: 0.9rem; padding: 0 0.75rem; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 600px) {
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: #fff;
  border-radius: var(--radio);
  padding: 1rem;
  box-shadow: var(--sombra);
  border-left: 4px solid var(--rojo);
}
.stat-card strong { display: block; font-size: 1.5rem; color: var(--rojo); }
.stat-card span { font-size: 0.8rem; color: #666; }

.card {
  background: #fff;
  border-radius: var(--radio);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--sombra);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
@media (min-width: 600px) {
  .form-row--2 {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .form-row--2 > * { flex: 1 1 45%; }
}
label { font-size: 0.85rem; font-weight: 600; color: #444; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--borde);
  border-radius: 8px;
  font-size: 1rem;
}
textarea { min-height: 100px; resize: vertical; }

.check-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}
@media (min-width: 500px) {
  .check-grid { grid-template-columns: repeat(2, 1fr); }
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.check-item input { margin-top: 0.2rem; }

.details-section {
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  margin-bottom: 0.75rem;
  background: #fff;
}
.details-section > summary {
  list-style: none;
  padding: 0.85rem 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--rojo-claro);
  color: var(--rojo-oscuro);
}
.details-section > summary::-webkit-details-marker { display: none; }
.details-section[open] > summary { border-bottom: 1px solid var(--borde); }
.details-body { padding: 1rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
table.form-table th, table.form-table td {
  border: 1px solid var(--borde);
  padding: 0.35rem;
}
table.form-table input {
  min-height: 36px;
  font-size: 0.85rem;
}

.crono-display {
  font-family: ui-monospace, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rojo);
  text-align: center;
  padding: 0.5rem;
  background: #fff;
  border-radius: var(--radio);
  border: 2px dashed var(--rojo);
}

.body-map-wrap {
  max-width: 280px;
  margin: 0 auto;
}
.body-map-wrap svg {
  width: 100%;
  height: auto;
}
.body-zone { cursor: pointer; fill: rgba(196,30,58,.15); stroke: #999; stroke-width: .5; }
.body-zone:hover, .body-zone.is-sel { fill: rgba(196,30,58,.45); }

.avdi-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.avdi-btn {
  min-width: 52px;
  min-height: 52px;
  border: 2px solid var(--borde);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
}
.avdi-btn.is-on { background: var(--rojo); color: #fff; border-color: var(--rojo); }

.sig-pad {
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  touch-action: none;
  width: 100%;
  max-width: 400px;
  height: 140px;
  background: #fff;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, #fafafa 20%);
  padding-top: 1rem;
}

.auth-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
}
.auth-logo { text-align: center; margin-bottom: 1rem; }
.auth-logo img { max-width: 200px; height: auto; }

.list-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.list-table th, .list-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--borde);
  text-align: left;
}
.list-table tr:hover { background: #fff5f5; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--ok { background: #e8f5e9; color: #2e7d32; }
.badge--act { background: #fff3e0; color: #ef6c00; }
.badge--draft { background: #eceff1; color: #546e7a; }

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
@media (min-width: 700px) {
  .filters { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .filters .form-row { margin-bottom: 0; flex: 1 1 140px; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
