:root {
  --ink: #0a0a0a;
  --red: #d03018;
  --red-dark: #aa2814;
  --text: #171717;
  --muted: #687070;
  --soft-muted: #9a9a96;
  --line: #e0e0dc;
  --line-soft: #ededeb;
  --paper: #f8f8f8;
  --canvas: #e9e8e4;
  --white: #ffffff;
  --green: #2e7d5b;
  --blue: #1f6fb2;
  --amber: #b45309;
  --danger: #b3261e;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body.camera-open {
  overflow: hidden;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
}

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 56px;
  padding: 11px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 20px 34px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: grid;
  gap: 12px;
}

.view[hidden] {
  display: none;
}

.app-shell.is-home .app-main {
  overflow-y: auto;
}

.app-shell.is-register .app-main {
  padding: 10px 20px 34px;
}

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

.home-panel {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  min-height: 108px;
  padding: 16px 18px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, #df3520 0%, #d52d18 100%);
  color: var(--white);
  box-shadow: 0 16px 30px rgba(208, 48, 24, 0.26);
  text-align: left;
}

.home-panel[hidden] {
  display: none;
}

.home-action-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
}

.home-action-icon svg {
  width: 28px;
  height: 28px;
}

.home-action-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.home-action-copy strong {
  overflow: hidden;
  font-size: 1.08rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-action-copy small {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.85rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-chevron {
  justify-self: end;
  width: 24px;
  height: 24px;
}

.screen-heading h1,
.register-heading h1 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.16;
}

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

.home-stats div {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 74px;
  padding: 10px 6px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.home-stats span {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

#homePendingCount {
  color: #f08a00;
}

#homeProcessCount {
  color: #2d7cc7;
}

#homeCompletedCount {
  color: var(--green);
}

.home-stats small {
  color: #263232;
  font-size: 0.75rem;
  font-weight: 500;
}

.location-card,
.compact-location {
  display: grid;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--white);
}

.location-card {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  padding: 13px;
}

.location-icon,
.empty-icon,
.photo-drop-icon,
.sheet-icon {
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.location-icon {
  width: 44px;
  height: 44px;
  background: #fbe9e5;
  color: var(--red);
}

.location-card strong,
.compact-location strong {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.location-card span,
.compact-location span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.location-card.is-ready .location-icon {
  background: #e3f1ea;
  color: var(--green);
}

.location-card.is-denied .location-icon {
  background: #fff1ee;
  color: var(--danger);
}

.incident-map-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--white);
}

.incident-map-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.incident-map-topline > div:first-child {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.incident-map-topline strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-map-topline span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-map-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
}

.incident-map-tools {
  position: relative;
  flex: 0 0 auto;
}

.map-control-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: #0c6757;
  box-shadow: 0 5px 14px rgba(12, 103, 87, 0.18);
}

.map-control-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.map-control-button svg {
  width: 18px;
  height: 18px;
}

.map-filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  display: grid;
  gap: 4px;
  width: 188px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(0, 66, 52, 0.22);
}

.map-filter-menu[hidden] {
  display: none;
}

.map-filter-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.map-filter-menu label:has(input:checked) {
  background: #e3f1ea;
  color: #075d51;
}

.map-filter-menu input {
  width: 16px;
  height: 16px;
  accent-color: #08715e;
}

.incident-map {
  position: relative;
  height: clamp(248px, 68vw, 306px);
  overflow: hidden;
  border-radius: 15px;
  background: #d7eadf;
  cursor: grab;
  touch-action: none;
}

.incident-map.is-dragging {
  cursor: grabbing;
}

.map-tiles,
.map-markers {
  position: absolute;
  inset: 0;
}

.map-tiles {
  z-index: 1;
}

.map-polygons {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.map-polygons path {
  fill: rgba(208, 48, 24, 0.08);
  stroke: #d03018;
  stroke-width: 2;
  stroke-linejoin: round;
}

.map-polygons text {
  fill: #a5271a;
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 3px;
}

.map-control-button.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.map-tiles img {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}

.map-markers {
  z-index: 2;
}

.map-pin,
.map-cluster {
  position: absolute;
  z-index: 3;
  border: 0;
  background: transparent;
  color: var(--white);
  font: inherit;
  padding: 0;
}

.map-pin {
  width: 34px;
  height: 40px;
  transform: translate(-50%, -100%);
}

.map-pin:focus-visible {
  outline: none;
}

.map-pin::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 5px;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50% 50% 50% 0;
  background: #08715e;
  box-shadow: 0 6px 12px rgba(0, 66, 52, 0.32);
  transform: rotate(-45deg);
}

.map-pin.is-selected::before,
.map-pin:focus-visible::before {
  background: var(--amber);
  box-shadow: 0 7px 16px rgba(180, 83, 9, 0.38), 0 0 0 4px rgba(255, 255, 255, 0.36);
}

.map-pin::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 14px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--white);
}

.map-cluster {
  display: grid;
  place-items: center;
  width: var(--cluster-size, 48px);
  height: var(--cluster-size, 48px);
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: #08715e;
  box-shadow: 0 8px 18px rgba(0, 66, 52, 0.34), 0 0 0 1px rgba(4, 93, 75, 0.22);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.map-cluster[data-density="high"] {
  background: #075d51;
}

.map-empty {
  position: absolute;
  inset: auto 14px 14px 14px;
  z-index: 4;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.map-empty[hidden] {
  display: none;
}

.map-attribution {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 5;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.8);
  color: #245149;
  font-size: 0.62rem;
}

.map-attribution a {
  color: inherit;
  text-decoration: none;
}

.home-incident-detail {
  display: grid;
  gap: 12px;
}

.home-incident-detail[hidden] {
  display: none;
}

.record-card-home-detail {
  box-shadow: 0 12px 30px rgba(0, 66, 52, 0.12);
}

.screen-heading,
.register-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-heading h1 {
  font-size: 1.45rem;
  font-weight: 700;
}

.screen-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.register-heading {
  justify-content: flex-start;
  padding: 8px 0 10px;
}

.register-heading h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.incident-form {
  display: grid;
  gap: 14px;
  padding-bottom: 0;
}

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

.field label,
.field-label {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}

.field label span {
  color: var(--soft-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.select-wrap {
  position: relative;
}

select,
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

select {
  min-height: 54px;
  padding: 0 44px 0 16px;
  appearance: none;
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

textarea {
  min-height: 70px;
  padding: 13px 16px;
  resize: vertical;
}

select:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208, 48, 24, 0.15);
}

.primary-button,
.secondary-button,
.submit-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  letter-spacing: 0;
  text-decoration: none;
}

.primary-button,
.submit-button {
  min-height: 54px;
  padding: 0 16px;
  border-radius: 15px;
  background: var(--red);
  color: var(--white);
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(208, 48, 24, 0.28);
}

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

.secondary-button {
  min-height: 50px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font-weight: 600;
}

.text-button {
  min-height: 36px;
  padding: 0 8px;
  background: transparent;
  color: var(--red);
  font-size: 0.84rem;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--white);
  color: var(--muted);
}

.icon-button.light {
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.primary-button:disabled,
.secondary-button:disabled,
.submit-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.photo-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 148px;
  padding: 18px 16px;
  border: 2px dashed #c9c9c4;
  border-radius: 16px;
  background: var(--white);
  color: var(--ink);
  text-align: center;
}

.photo-drop-icon {
  width: 54px;
  height: 54px;
  background: #fbe9e5;
  color: var(--red);
}

.photo-drop-icon svg {
  width: 27px;
  height: 27px;
}

.photo-dropzone strong {
  font-size: 0.96rem;
  font-weight: 700;
}

.photo-dropzone small {
  max-width: 250px;
  color: var(--muted);
  font-size: 0.78rem;
}

.camera-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #050505;
  color: var(--white);
}

.camera-panel[hidden],
.camera-panel [hidden] {
  display: none;
}

.camera-topbar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  min-height: 64px;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(5, 5, 5, 0.96);
}

.camera-topbar strong {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.camera-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #000000;
}

.camera-stage video,
.camera-stage img {
  width: 100%;
  height: 100%;
  background: #000000;
  object-position: center center;
}

.camera-stage video {
  object-fit: cover;
}

.camera-stage img {
  object-fit: contain;
}

.camera-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.72), #050505 34%);
}

.camera-actions #captureButton {
  grid-column: 1 / -1;
}

.camera-actions .primary-button,
.camera-actions .secondary-button {
  min-height: 56px;
}

.photo-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1.5px dashed #c9c9c4;
  border-radius: 16px;
  background: var(--white);
  color: var(--soft-muted);
  font-weight: 600;
}

.photo-preview.is-empty {
  display: none;
}

.photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.photo-preview:not(.is-empty) {
  border-style: solid;
  background: var(--ink);
}

.compact-location {
  grid-template-columns: auto 1fr;
  padding: 10px 14px;
}

.compact-location .field-label {
  grid-column: 1 / -1;
}

.compact-location.is-ready {
  border-color: rgba(46, 125, 91, 0.25);
  background: #f5fbf8;
}

.compact-location.is-denied {
  border-color: rgba(179, 38, 30, 0.22);
  background: #fff4f2;
}

.form-alert {
  padding: 12px 14px;
  border: 1px solid rgba(179, 38, 30, 0.22);
  border-radius: 14px;
  background: #fff0ee;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.submit-bar {
  margin-top: 4px;
}

.submit-button {
  width: 100%;
  min-height: 56px;
}

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

.record-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  overflow: hidden;
  min-height: 128px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--white);
}

.record-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  background: var(--soft-muted);
}

.record-card.record-envio-completado::after {
  background: var(--green);
}

.record-card.record-envio-revision::after {
  background: #e0a400;
}

.record-card.record-envio-descartados::after {
  background: var(--danger);
}

.record-card.record-envio-incompletos::after {
  background: var(--soft-muted);
}

.records-tools {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.records-filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 4px;
  width: 200px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.records-filter-menu[hidden] {
  display: none;
}

.records-filter-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.records-filter-menu label:has(input:checked) {
  background: #e3f1ea;
  color: #075d51;
}

.records-filter-menu input {
  width: 16px;
  height: 16px;
  accent-color: #08715e;
}

.icon-button.is-active {
  color: var(--red);
}

.record-card-toggle {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.record-card-toggle:focus-visible {
  outline: 3px solid rgba(31, 111, 178, 0.28);
  outline-offset: 2px;
}

.record-card-toggle.is-expanded {
  border-color: rgba(46, 125, 91, 0.24);
  box-shadow: 0 10px 24px rgba(0, 66, 52, 0.09);
}

.record-thumb {
  align-self: start;
  padding: 12px 8px 12px 12px;
  background: transparent;
}

.record-thumb img {
  display: block;
  width: 100%;
  height: 104px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--line-soft);
}

.record-body {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 12px;
}

.record-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.record-title {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.22;
}

.record-meta,
.record-comment {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.record-comment {
  color: #303535;
}

.record-ai {
  display: grid;
  gap: 5px;
  margin-top: 3px;
  padding: 9px;
  border-radius: 12px;
  background: #f5fbf8;
  color: #214b39;
  font-size: 0.72rem;
}

.record-ai-full {
  grid-column: 1 / -1;
  padding: 0 12px 12px;
}

.record-ai-full .record-ai {
  margin-top: 0;
}

.record-ai div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.record-ai strong,
.record-ai small,
.record-ai span,
.record-ai p {
  margin: 0;
}

.record-ai strong {
  font-size: 0.72rem;
}

.record-ai small {
  color: var(--green);
  font-weight: 700;
}

.record-ai span {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e3f1ea;
  font-weight: 700;
}

.record-ai p {
  color: #315949;
}

.record-ai.is-pending {
  background: #fbf0e0;
  color: var(--amber);
}

.record-ai.is-pending p {
  color: #8a4d0a;
}

/* Color del bloque de IA segun estado_envio */
.record-envio-revision .record-ai {
  background: #fdf6e3;
  color: #6b5310;
}

.record-envio-revision .record-ai small {
  color: #8a6d0a;
}

.record-envio-revision .record-ai span {
  background: #f6ecc8;
}

.record-envio-revision .record-ai p {
  color: #6b5310;
}

.record-envio-descartados .record-ai {
  background: #fcefed;
  color: #7a241d;
}

.record-envio-descartados .record-ai small {
  color: #a3312a;
}

.record-envio-descartados .record-ai span {
  background: #f7dcd8;
}

.record-envio-descartados .record-ai p {
  color: #7a241d;
}

.record-envio-incompletos .record-ai {
  background: #f2f2f1;
  color: #4a4a48;
}

.record-envio-incompletos .record-ai small {
  color: #6a6a66;
}

.record-envio-incompletos .record-ai span {
  background: #e6e6e3;
}

.record-envio-incompletos .record-ai p {
  color: #4a4a48;
}

.state-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}

.state-pendiente {
  background: #fbf0e0;
  color: var(--amber);
}

.state-en-proceso {
  background: #e5eff7;
  color: var(--blue);
}

.state-completada {
  background: #e3f1ea;
  color: var(--green);
}

.text-card {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--white);
}

.text-card h2,
.text-card p {
  margin: 0;
}

.text-card h2 {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
}

.text-card p {
  color: var(--muted);
  font-size: 0.84rem;
}

.text-card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.text-card-topline h2 {
  min-width: 0;
}

.notif-pill {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  background: #e9e9e6;
  color: #5a5a56;
}

.notif-pill-completado {
  background: #e3f1ea;
  color: #075d51;
}

.notif-pill-revision {
  background: #f6ecc8;
  color: #7a5c0a;
}

.notif-pill-descartados {
  background: #f7dcd8;
  color: #9a2820;
}

.notif-pill-incompletos {
  background: #e9e9e6;
  color: #5a5a56;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 230px;
  padding: 28px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state.tall {
  min-height: 430px;
}

.empty-icon {
  width: 88px;
  height: 88px;
  margin-bottom: 8px;
  background: #f1f1ef;
  color: #bdbdb9;
}

.empty-icon svg {
  width: 42px;
  height: 42px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

.empty-state span {
  max-width: 260px;
  font-size: 0.86rem;
}

.bottom-nav {
  flex: 0 0 auto;
  position: relative;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr 1fr 74px 1fr 1fr;
  align-items: start;
  height: calc(84px + env(safe-area-inset-bottom));
  padding: 9px 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid var(--line-soft);
}

.nav-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--soft-muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.nav-button svg {
  width: 25px;
  height: 25px;
}

.nav-button.has-unread::after {
  content: "";
  position: absolute;
  top: 4px;
  right: calc(50% - 17px);
  width: 10px;
  height: 10px;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 2px 8px rgba(208, 48, 24, 0.35);
}

.nav-button span,
.nav-button small {
  max-width: 100%;
  overflow: hidden;
  color: currentColor;
  font-size: 0.68rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button.is-active {
  color: var(--red);
}

.nav-fab {
  width: 74px;
  gap: 2px;
}

.nav-fab > span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-top: -27px;
  border: 4px solid var(--paper);
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  box-shadow: 0 8px 18px rgba(208, 48, 24, 0.4);
}

.nav-fab svg {
  width: 28px;
  height: 28px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 10, 10, 0.55);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-backdrop[hidden] {
  display: none;
}

.bottom-sheet {
  display: grid;
  gap: 12px;
  width: min(100%, 392px);
  padding: 30px 24px 22px;
  border-radius: 24px;
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
}

.sheet-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto 6px;
}

.sheet-icon svg {
  width: 42px;
  height: 42px;
}

.sheet-icon.success {
  background: #e3f1ea;
  color: var(--green);
}

.sheet-icon.warning {
  background: #fbe9e5;
  color: var(--red);
}

.bottom-sheet h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.32rem;
  font-weight: 700;
}

.bottom-sheet p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ticket-id {
  justify-self: center;
  padding: 8px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 96px;
  left: 16px;
  z-index: 60;
  max-width: 398px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
}

.toast[hidden] {
  display: none;
}

/* ---------- Banner de invitado ---------- */
.guest-banner {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  min-height: 108px;
  padding: 16px 18px;
  border: 1.5px dashed var(--red);
  border-radius: 22px;
  background: #fdf1ee;
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(208, 48, 24, 0.12);
  text-align: left;
}

.guest-banner[hidden] {
  display: none;
}

.guest-banner-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(208, 48, 24, 0.12);
  color: var(--red);
}

.guest-banner-icon svg {
  width: 28px;
  height: 28px;
}

.guest-banner-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.guest-banner-copy strong {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--red);
}

.guest-banner-copy small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.guest-banner .home-chevron {
  justify-self: end;
  width: 24px;
  height: 24px;
  color: var(--red);
}

/* ---------- Botones de navegación bloqueados (invitado) ---------- */
.nav-button.is-locked {
  opacity: 0.55;
}

.nav-button.is-locked::before {
  content: "";
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  width: 13px;
  height: 13px;
  background: var(--soft-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
}

.nav-fab.is-locked {
  opacity: 1;
}

.nav-fab.is-locked > span {
  background: var(--soft-muted);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

/* ---------- Modales de autenticación ---------- */
.auth-backdrop {
  z-index: 70;
  align-items: center;
  padding: 32px 18px;
}

.auth-sheet {
  gap: 14px;
}

.auth-brand {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 4px;
  border-radius: 20px;
  background: #fbe9e5;
}

.auth-brand img {
  width: 46px;
  height: 46px;
}

.auth-form-sheet {
  position: relative;
  text-align: left;
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-form-sheet h2,
.auth-form-sheet > p {
  text-align: center;
}

.sheet-back {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 6px;
  text-align: left;
}

.text-field input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

.text-field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208, 48, 24, 0.15);
}

.auth-form .primary-button {
  margin-top: 4px;
}

/* ---------- Perfil ---------- */
.profile-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 24px 20px;
  border-radius: 20px;
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: #fbe9e5;
  color: var(--red);
}

.profile-avatar svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-name {
  font-size: 1.15rem;
  color: var(--ink);
}

.profile-role {
  font-size: 0.85rem;
  color: var(--muted);
}

.profile-details {
  display: grid;
  gap: 2px;
  margin: 16px 0 0;
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.profile-field {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.profile-field:last-child {
  border-bottom: 0;
}

.profile-field dt {
  font-size: 0.78rem;
  color: var(--muted);
}

.profile-field dd {
  margin: 0;
  font-size: 0.98rem;
  color: var(--ink);
  word-break: break-word;
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  border: 1.5px solid var(--danger);
  border-radius: 14px;
  background: var(--white);
  color: var(--danger);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.logout-button:active {
  background: #fdeceb;
}

.logout-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 520px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .app-shell {
    height: min(820px, calc(100vh - 48px));
    max-height: calc(100vh - 48px);
    border-radius: 38px;
    box-shadow: 0 0 0 11px var(--ink), 0 24px 50px rgba(0, 0, 0, 0.18);
  }
}

/* ---------- Galeria de hasta 3 fotografias ---------- */
.photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}
.photo-preview:not(.is-empty) #photoPlaceholder { display: none; }
.photo-thumb {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line, #e2e2e2);
  background: #f3f3f3;
  flex: none;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.photo-thumb-remove:hover { background: rgba(181, 27, 4, 0.9); }
.photo-count {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 12px;
  color: #7e7576;
  font-weight: 600;
}

/* Botones de foto bloqueados al alcanzar el maximo de imagenes */
.photo-dropzone.is-blocked,
.secondary-button.is-blocked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* ---------- Pestañas de detalle en registros (IA / Verificador) ---------- */
.record-detail { width: 100%; }
.record-detail-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.record-detail-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line, #e2e2e2);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: #4c4546;
  cursor: pointer;
}
.record-detail-tab.is-active {
  background: #fbe9e5;
  border-color: #b51b04;
  color: #b51b04;
}
.record-detail-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.record-detail-panel.is-hidden { display: none; }

/* Color del borde de la card segun el dictamen del verificador (prioridad
   sobre record-envio-* por ir despues en la hoja de estilos) */
.record-card.record-decision-admitida::after { background: var(--green); }
.record-card.record-decision-denegada::after { background: var(--danger); }
.record-card.record-decision-seguimiento::after { background: #e0a400; }
.record-card.record-decision-archivada::after { background: var(--soft-muted); }
.record-card.record-decision-otra::after { background: var(--green); }
