:root {
  --bg: #f2f2f0;
  --bg-elevated: #ffffff;
  --bg-soft: #ebebe8;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --ink: #0a0a0a;
  --ink-soft: #5c5c5c;
  --line: rgba(10, 10, 10, 0.12);
  --line-dark: rgba(10, 10, 10, 0.18);
  --brand: #c8102e;
  --brand-deep: #9a0c23;
  --brand-soft: rgba(200, 16, 46, 0.1);
  --accent: #ffb81c;
  --accent-ink: #0a0a0a;
  --green: #00875a;
  --yellow: #ffb81c;
  --blue: #0018a8;
  --success: #00875a;
  --danger: #c8102e;
  --warning: #d97706;
  --heat: #c8102e;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 0 rgba(10, 10, 10, 0.04), 0 12px 28px rgba(10, 10, 10, 0.06);
  --font-display: "Space Grotesk", "IBM Plex Sans", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--bg);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  background: #0a0a0a;
  border-right: 1px solid #1f1f1f;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #f5f5f5;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 6px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand img {
  width: min(100%, 168px);
  height: auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  animation: brandIn 0.8s ease both;
}

.brand small {
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 600;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.62);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 184, 28, 0.14);
  color: #ffb81c;
  transform: none;
}

.nav .icon {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: inherit;
}

.sidebar-foot {
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
}

.sidebar-foot .user-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.sidebar-foot .user-role {
  font-size: 0.75rem;
  color: rgba(255, 184, 28, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 12px;
}

.main {
  padding: 24px 28px 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--ink);
  animation: rise 0.45s ease both;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 2.4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-transform: uppercase;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 500;
}

.panel {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  animation: rise 0.5s ease both;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.panel-sub {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  animation: rise 0.55s ease both;
}

.stat::after {
  display: none;
}

.stat .label {
  color: var(--ink-soft);
  font-size: 0.68rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stat .value {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.stat .value-sm {
  font-family: var(--font-display);
  font-size: 1.15rem;
  padding-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}

.filters input,
.filters select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filters input:focus,
.filters select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.auth-card input:focus {
  border-color: rgba(225, 29, 46, 0.55);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

.btn-primary:hover {
  background: #222;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-dark);
}

.btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-danger {
  background: #fff1f1;
  color: var(--danger);
}

.btn-sm {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: #f4f4f2;
  font-weight: 700;
  font-family: var(--font-display);
}

tr:hover td {
  background: #fafafa;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.badge-green {
  background: rgba(0, 135, 90, 0.12);
  color: #006b48;
}

.badge-red {
  background: rgba(200, 16, 46, 0.1);
  color: var(--brand-deep);
}

.badge-muted {
  background: #ececec;
  color: var(--ink-soft);
}

.badge-yellow {
  background: rgba(255, 184, 28, 0.28);
  color: #7a5a00;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
  align-items: stretch;
}

.dash-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dash-grid > .panel-chart {
  height: 100%;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-chart > .toolbar {
  flex: none;
}

.panel-chart > .empty {
  flex: 1;
  display: grid;
  place-items: center;
}

.chart-box,
.heatmap-wrap.heatmap-compact,
.hallazgo-slider {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 260px;
  height: 260px;
  max-height: 260px;
  overflow: hidden;
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: 260px !important;
}

.heatmap-wrap.heatmap-compact {
  overflow: auto;
  display: flex;
  align-items: center;
}

.heatmap-compact .heatmap {
  min-width: 520px;
  width: 100%;
  grid-template-columns: 36px repeat(15, minmax(24px, 1fr));
  gap: 2px;
}

.heatmap-compact .heat-cell {
  font-size: 0.55rem;
}

.heatmap-compact .heat-hour,
.heatmap-compact .heat-day {
  font-size: 0.58rem;
}

.panel-hallazgos .toolbar {
  margin-bottom: 8px;
}

.hallazgo-nav {
  display: flex;
  gap: 4px;
}

.hallazgo-nav .btn {
  min-width: 34px;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
}

.hallazgo-slider {
  display: flex;
  flex-direction: column;
}

.hallazgo-track {
  position: relative;
  flex: 1;
  min-height: 0;
}

.hallazgo-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #fff 0%, var(--bg-soft) 100%);
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hallazgo-slide.is-active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.hallazgo-slide.tone-brand {
  border-top: 3px solid var(--brand);
}

.hallazgo-slide.tone-accent {
  border-top: 3px solid var(--accent);
}

.hallazgo-slide.tone-blue {
  border-top: 3px solid var(--blue);
}

.hallazgo-slide.tone-green {
  border-top: 3px solid var(--green);
}

.hallazgo-slide.tone-warn {
  border-top: 3px solid var(--warning);
}

.hallazgo-slide.tone-muted {
  border-top: 3px solid var(--ink-soft);
}

.hallazgo-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hallazgo-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.hallazgo-body {
  margin: 0;
  flex: 1;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.hallazgo-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.hallazgo-metric strong {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.hallazgo-metric span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.hallazgo-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.hallazgo-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(10, 10, 10, 0.18);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.hallazgo-dot.is-active {
  background: var(--brand);
  transform: scaleX(1.6);
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.heat-legend-bar {
  width: 88px;
  height: 8px;
  border-radius: 0;
  background: linear-gradient(90deg, rgba(200, 16, 46, 0.1), #c8102e);
}

.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap {
  display: grid;
  grid-template-columns: 44px repeat(15, minmax(34px, 1fr));
  gap: 3px;
  min-width: 720px;
}

.heat-corner {
  min-height: 24px;
}

.heat-hour,
.heat-day {
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.heat-day {
  justify-content: start;
  padding-left: 2px;
  text-transform: uppercase;
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: rgba(10, 10, 10, 0.8);
  background: color-mix(in srgb, var(--heat) calc(var(--i) * 100%), #ececec);
  border: 1px solid rgba(10, 10, 10, 0.04);
  transition: transform 0.12s ease, outline 0.12s ease;
}

.heat-cell:hover {
  transform: scale(1.05);
  outline: 1px solid var(--accent);
  z-index: 1;
  box-shadow: none;
}

.heat-cell.is-empty {
  background: #ececec;
  color: transparent;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-list li {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 4px 10px;
  align-items: center;
}

.rank-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  grid-column: 1;
}

.rank-meta strong {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.rank-bar {
  grid-column: 1;
  height: 6px;
  border-radius: 0;
  background: #ececec;
  overflow: hidden;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.rank-bar-alt span {
  background: var(--ink);
}

.rank-count {
  grid-column: 2;
  grid-row: 1 / span 2;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #2b3340;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}

.alert-success {
  background: rgba(31, 138, 76, 0.12);
  color: var(--success);
}

.alert-error {
  background: rgba(198, 40, 40, 0.12);
  color: var(--danger);
}

.empty {
  text-align: center;
  padding: 42px 16px;
  color: var(--ink-soft);
}

.item-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1.4fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px dashed rgba(20, 24, 32, 0.18);
  border-radius: 14px;
  background: #fff;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffcf9;
  box-shadow: 0 8px 22px rgba(60, 35, 30, 0.05);
}

.item-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.item-inline {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.meta-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.meta-card span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.meta-card strong {
  font-size: 1rem;
}

/* Auth — layout tipo Nalia: foto izquierda + formulario derecha */
.auth-shell {
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  display: grid;
  grid-template-columns: 1fr;
  background: #f7f4ef;
}

@media (min-width: 1024px) {
  .auth-shell {
    grid-template-columns: 1.05fr 1fr;
  }
}

.auth-aside {
  position: relative;
  display: none;
  overflow: hidden;
  isolation: isolate;
  min-height: 100vh;
}

@media (min-width: 1024px) {
  .auth-aside {
    display: flex;
  }
}

.auth-aside > img {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, rgba(12, 10, 10, 0.9), rgba(12, 10, 10, 0.38) 52%, rgba(12, 10, 10, 0.2)),
    linear-gradient(125deg, rgba(225, 29, 46, 0.42), rgba(0, 156, 59, 0.16));
}

.auth-aside-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  padding: 2.4rem 2.5rem;
  color: #fff;
}

.auth-aside-brand {
  width: 100%;
}

.auth-aside-brand img {
  width: min(420px, 88%);
  max-width: none;
  height: auto;
  filter: drop-shadow(0 14px 32px rgba(0, 0, 0, 0.45));
  animation: brandIn 0.85s ease both;
}

.auth-card-logo-mobile img {
  width: min(260px, 78vw);
}

.auth-aside-copy {
  max-width: 28rem;
}

.auth-eyebrow,
.section-eyebrow {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.section-eyebrow {
  color: var(--ink);
  margin-bottom: 0.45rem;
  background: var(--accent);
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
}

.auth-aside-copy h2 {
  margin: 0.85rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 3.4vw, 3.15rem);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.auth-lead {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.86);
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
}

.auth-stat-label {
  margin-top: 0.25rem;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.auth-form-side {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: #f2f2f0;
  animation: rise 0.45s ease both;
}

.auth-card {
  width: 100%;
  max-width: 27rem;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
  animation: rise 0.55s ease both;
}

.auth-card-logo-mobile {
  display: none;
  margin-bottom: 1.4rem;
}

@media (max-width: 1023px) {
  .auth-card-logo-mobile {
    display: grid;
    place-items: center;
  }
}

.auth-card-head {
  margin-bottom: 1.35rem;
}

.auth-card-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-transform: uppercase;
}

.auth-card-head p {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.auth-card .field {
  margin-bottom: 0.95rem;
}

.auth-card .field:last-of-type {
  margin-bottom: 0;
}

.auth-submit {
  width: 100%;
  margin-top: 1.35rem;
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
}

.mobile-toggle {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes brandIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (max-width: 1100px) {
  .stats,
  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-row:not(.item-card) {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1100px) {
  .dash-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-hallazgos {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-flex;
    margin-bottom: 14px;
  }

  .main {
    padding: 18px 16px 28px;
  }

  .form-grid,
  .stats,
  .meta-grid,
  .photo-grid,
  .dash-grid,
  .dash-grid-3 {
    grid-template-columns: 1fr;
  }

  .backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 30;
  }

  .backdrop.show {
    display: block;
  }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.photo-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.photo-card-title {
  font-weight: 800;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.photo-preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 1px dashed rgba(20, 24, 32, 0.22);
  background: #f3efe8;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.photo-preview.has-image,
a.photo-preview {
  border-style: solid;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-actions label.btn {
  cursor: pointer;
  margin: 0;
}

.thumb-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.thumb {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f3efe8;
  display: block;
  flex-shrink: 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  background: rgba(15, 17, 21, 0.72);
  color: #fff;
  padding: 2px 0;
  letter-spacing: 0.02em;
}

.thumb-empty {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
}

/* ---------- Formularios mobile-first ---------- */

.form-panel {
  padding-bottom: 110px;
}

.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
}

.form-section-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.btn-touch {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.mobile-form input,
.mobile-form select,
.mobile-form textarea,
.form-stack input,
.form-stack select,
.form-stack textarea,
.item-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: none;
}

.photo-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.photo-preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 11;
  min-height: 160px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(10, 10, 10, 0.2);
  background: #f4f4f2;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.form-sticky-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 1rem;
}

@media (max-width: 860px) {
  .form-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 18px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
    box-shadow: 0 -8px 24px rgba(10, 10, 10, 0.06);
  }

  .mobile-toggle {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    margin-bottom: 10px;
    background: #0a0a0a;
    border: 1px solid #0a0a0a;
    color: #fff;
  }
}

.form-hint {
  margin: -0.25rem 0 0.9rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.4;
}

.form-stack,
.mobile-form .form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.mobile-form label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #2b3340;
}

.mobile-form input,
.mobile-form select,
.mobile-form textarea,
.form-stack input,
.form-stack select,
.form-stack textarea,
.item-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 16px; /* evita zoom automático en iOS */
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mobile-form textarea,
.form-stack textarea {
  min-height: 96px;
  resize: vertical;
}

.mobile-form input:focus,
.mobile-form select:focus,
.mobile-form textarea:focus,
.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus,
.item-card input:focus {
  border-color: rgba(212, 24, 40, 0.55);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.check-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

.btn-touch {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.98rem;
}

.btn-block {
  width: 100%;
}

.form-sticky-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 1rem;
}

.toolbar-mobile {
  align-items: center;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-actions .btn {
  width: 100%;
}

.photo-preview {
  aspect-ratio: 16 / 11;
  min-height: 160px;
}

@media (max-width: 860px) {
  .main {
    padding: 14px 12px 28px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .topbar-mobile-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar-mobile-stack .btn {
    width: 100%;
  }

  .topbar h1 {
    font-size: 1.85rem;
  }

  .form-panel {
    padding-bottom: 120px;
  }

  .form-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 18px -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 252, 249, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
    box-shadow: 0 -10px 30px rgba(40, 25, 20, 0.08);
  }

  .item-row:not(.item-card) {
    grid-template-columns: 1fr;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }

  .mobile-toggle {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
  }

  .table-wrap {
    margin: 0 -4px;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}

@media (min-width: 861px) {
  .form-sticky-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .form-sticky-actions .btn-block {
    width: auto;
    min-width: 180px;
  }

  .photo-actions {
    flex-direction: row;
  }

  .photo-actions .btn {
    width: auto;
  }

  .form-panel {
    padding-bottom: 22px;
  }
}

/* Filters + pagination */
.filter-panel {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.filter-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-panel .field label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  font-family: var(--font-mono);
}

.filter-panel input,
.filter-panel select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  font-size: 0.92rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pagination-meta {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.pagination-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.page-num {
  min-width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
}

.page-num.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.page-gap {
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 900px) {
  .filter-grid,
  .filter-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .filter-grid,
  .filter-grid-3 {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-links {
    justify-content: center;
  }

  .filter-actions .btn {
    flex: 1;
  }
}
