/* ===== Design tokens ===== */
:root {
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --page-plane: #f2f3f1;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.16);

  --series-1: #2a78d6; /* blue */
  --series-2: #1baf7a; /* aqua */
  --series-3: #eda100; /* yellow */
  --series-4: #008300; /* green */
  --series-5: #4a3aa7; /* violet */
  --series-6: #e34948; /* red */
  --series-7: #e87ba4; /* magenta */
  --series-8: #eb6834; /* orange */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --brand: #1baf7a;
  --brand-ink: #0a5c3e;
  --brand-wash: #e8f7f1;

  --sidebar-bg: #0f2f26;
  --sidebar-bg-active: #16473a;
  --sidebar-text: #d7ece4;
  --sidebar-text-muted: #8fb3a6;
  --sidebar-accent: #35d69b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11,11,11,0.06);
  --shadow-md: 0 4px 16px rgba(11,11,11,0.08);
  --shadow-lg: 0 12px 32px rgba(11,11,11,0.14);
}

:root[data-theme="dark"] {
  --surface-1: #1a1a19;
  --surface-2: #212120;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --series-1: #3987e5;
  --series-2: #199e70;
  --series-3: #c98500;
  --series-4: #2fb52f;
  --series-5: #9085e9;
  --series-6: #e66767;
  --series-7: #d55181;
  --series-8: #d95926;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --brand: #199e70;
  --brand-ink: #6fe0b8;
  --brand-wash: #10291f;

  --sidebar-bg: #0a1a15;
  --sidebar-bg-active: #14332a;
  --sidebar-text: #cfe6dc;
  --sidebar-text-muted: #6f9384;
  --sidebar-accent: #35d69b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #1a1a19;
    --surface-2: #212120;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --series-1: #3987e5; --series-2: #199e70; --series-3: #c98500; --series-4: #2fb52f;
    --series-5: #9085e9; --series-6: #e66767; --series-7: #d55181; --series-8: #d95926;
    --brand: #199e70; --brand-ink: #6fe0b8; --brand-wash: #10291f;
    --sidebar-bg: #0a1a15; --sidebar-bg-active: #14332a; --sidebar-text: #cfe6dc; --sidebar-text-muted: #6f9384;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
#root { height: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
table { font-variant-numeric: tabular-nums; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 20px 18px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--sidebar-accent);
  color: #06231b;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.sidebar-brand-name { font-weight: 700; font-size: 14.5px; line-height: 1.25; }
.sidebar-brand-sub { font-size: 11px; color: var(--sidebar-text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px; font-weight: 600;
  border: none; background: transparent; width: 100%; text-align: left;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text); }
.sidebar-link.active { background: var(--sidebar-bg-active); color: #ffffff; }
.sidebar-link .icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.sidebar-user:hover { background: rgba(255,255,255,0.06); cursor: pointer; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sidebar-accent); color: #06231b;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.sidebar-user-name { font-size: 12.5px; font-weight: 700; color: #fff; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text-muted); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 22px; flex: 1; min-width: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-primary);
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--page-plane); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-danger { background: var(--status-critical); border-color: var(--status-critical); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--page-plane); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); }

/* ===== Cards ===== */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14.5px; font-weight: 700; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 18px; }

/* ===== KPI tiles ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-delta { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.kpi-delta.up { color: var(--status-good); }
.kpi-delta.down { color: var(--status-critical); }

/* ===== Grid helpers ===== */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.field .hint { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.input, select.input, textarea.input {
  padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1); color: var(--text-primary);
  outline: none; width: 100%;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
textarea.input { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field.full { grid-column: 1 / -1; }
.field-error { border-color: var(--status-critical) !important; }
.error-text { font-size: 11.5px; color: var(--status-critical); }
.char-count { font-size: 11px; color: var(--text-muted); text-align: right; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface-2); }
table.data-table th {
  text-align: left; padding: 10px 12px; font-weight: 700; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted);
  background: var(--page-plane); border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0;
}
table.data-table th:hover { color: var(--text-primary); }
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--page-plane); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.sort-arrow { margin-left: 4px; opacity: 0.6; }
.cell-muted { color: var(--text-muted); }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* Columna "Ver" (ícono de ojo): solo existe para simplificar la tabla en celular —
   en pantallas anchas ya hay suficiente espacio para todas las columnas. */
.data-table .col-ver { display: none; }
.eye-icon { color: var(--text-muted); }
.prio-dot { display: none; width: 8px; height: 8px; border-radius: 50%; margin-left: 7px; vertical-align: middle; }
.prio-dot.badge-prioridad-normal { background: var(--text-muted); }
.prio-dot.badge-prioridad-intermedia { background: var(--series-8); }
.prio-dot.badge-prioridad-critica { background: var(--status-critical); }

/* Texto de plot mostrado junto al fundo, solo en celular (en escritorio ya tiene su
   propia columna "Plot"). Ícono que reemplaza un texto de botón, solo en celular
   (ej. "Ver" → 👁 en revisión de plataforma). */
.cell-plot-mobile { display: none; }
.icon-mobile-only { display: none; }

@media (max-width: 640px) {
  .data-table .col-hide-mobile { display: none; }
  .data-table .col-ver { display: table-cell; width: 36px; text-align: center; padding: 10px 12px 10px 0; }
  .prio-dot { display: inline-block; }
  .cell-plot-mobile { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; }
  .icon-mobile-only { display: inline-flex; }
}

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.badge-good { background: rgba(12,163,12,0.12); color: var(--status-good); }
.badge-good .badge-dot { background: var(--status-good); }
.badge-warning { background: rgba(250,178,25,0.16); color: #8a5a00; }
.badge-warning .badge-dot { background: var(--status-warning); }
.badge-serious { background: rgba(236,131,90,0.16); color: #a1441c; }
.badge-serious .badge-dot { background: var(--status-serious); }
.badge-critical { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.badge-critical .badge-dot { background: var(--status-critical); }
.badge-neutral { background: var(--page-plane); color: var(--text-secondary); }
.badge-neutral .badge-dot { background: var(--text-muted); }
:root[data-theme="dark"] .badge-warning { color: #fab219; }
:root[data-theme="dark"] .badge-serious { color: #ec835a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-warning { color: #fab219; }
  :root:not([data-theme="light"]) .badge-serious { color: #ec835a; }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,11,11,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--surface-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 640px;
  max-height: 88vh; display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.modal.modal-lg { max-width: 860px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Lightbox (adjuntos a pantalla completa) ===== */
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center; z-index: 300;
  padding: 32px;
}
.lightbox-media { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: fixed; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.15); color: #fff; font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* ===== Toasts ===== */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 360px; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.toast-icon { font-size: 15px; margin-top: 1px; }
.toast-success { border-left: 3px solid var(--status-good); }
.toast-error { border-left: 3px solid var(--status-critical); }
.toast-info { border-left: 3px solid var(--series-1); }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--brand-wash), var(--page-plane) 60%);
  padding: 20px;
}
.login-card { width: 100%; max-width: 400px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 30px 28px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-title { font-size: 18px; font-weight: 800; }
.login-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.login-demo { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.login-demo summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.demo-user-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 12px; }
.demo-user-row button { font-size: 11px; }

/* ===== Misc ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--page-plane); border: 1px solid var(--border); cursor: pointer; color: var(--text-secondary);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.progress-track { width: 100%; height: 6px; border-radius: 999px; background: var(--gridline); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--text-muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mono { font-variant-numeric: tabular-nums; }
.skeleton { background: linear-gradient(90deg, var(--gridline) 25%, var(--page-plane) 37%, var(--gridline) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 6px; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
.chart-legend-dot { width: 9px; height: 9px; border-radius: 3px; }
.chart-canvas-wrap { position: relative; }

.pill-select { position: relative; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
#btnSidebarToggle { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  #btnSidebarToggle { display: inline-flex; }
  .sidebar { position: fixed; z-index: 90; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(11,11,11,0.4); z-index: 80; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ===================================================================
   Seguimiento de Observaciones — estilos específicos de la app
   =================================================================== */

/* ===== Paleta con significado: Estado y Prioridad =====
   Estado    Pendiente = ámbar (series-3) | En progreso = azul (series-1) | Completada = verde (brand)
   Prioridad Normal = gris (text-muted) | Intermedia = naranja (series-8) | Crítica = rojo (status-critical), con pulso */
.badge-estado-pendiente { background: rgba(237,161,0,0.16); color: #8a5a00; }
.badge-estado-pendiente .badge-dot { background: var(--series-3); }
.badge-estado-progreso { background: rgba(42,120,214,0.14); color: var(--series-1); }
.badge-estado-progreso .badge-dot { background: var(--series-1); }
.badge-estado-completada { background: var(--brand-wash); color: var(--brand-ink); }
.badge-estado-completada .badge-dot { background: var(--brand); }
:root[data-theme="dark"] .badge-estado-pendiente { color: #fab219; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-estado-pendiente { color: #fab219; } }

.badge-prioridad-normal { background: var(--page-plane); color: var(--text-secondary); }
.badge-prioridad-normal .badge-dot { background: var(--text-muted); }
.badge-prioridad-intermedia { background: rgba(235,104,52,0.16); color: #a1441c; }
.badge-prioridad-intermedia .badge-dot { background: var(--series-8); }
:root[data-theme="dark"] .badge-prioridad-intermedia { color: #eb6834; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-prioridad-intermedia { color: #eb6834; } }
.badge-prioridad-critica { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.badge-prioridad-critica .badge-dot { background: var(--status-critical); animation: pulse-dot 1.4s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.45; transform:scale(1.3); } }

.badge-vencida { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.badge-proxima { background: rgba(250,178,25,0.16); color: #8a5a00; }
:root[data-theme="dark"] .badge-proxima { color: #fab219; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-proxima { color: #fab219; } }

/* ===== Notification badge (sidebar / topbar) ===== */
.notif-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--status-critical); color: #fff; font-size: 10.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}

/* ===== Filter bar ===== */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filter-bar .input, .filter-bar select.input { width: auto; min-width: 140px; }
.search-input-wrap { position: relative; flex: 1; min-width: 220px; }
.search-input-wrap input { padding-left: 32px; }
.search-input-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: 0.5; font-size: 13px; }
.date-filter-group { display: flex; flex-direction: column; gap: 3px; }
.date-filter-label { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }

/* El botón "Filtros" solo existe para el celular: en pantallas anchas los filtros ya
   caben en la fila y no hace falta esconderlos detrás de un toggle. */
.filter-toggle-btn { display: none; }
/* "contents": sus hijos actúan como si fueran hijos directos de .filter-bar, para que
   en escritorio el acomodo sea idéntico al de antes (una sola fila que se ajusta sola). */
.filter-collapsible { display: contents; }

@media (max-width: 640px) {
  .filter-toggle-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    background: var(--surface-2); color: var(--text-primary);
    font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  }
  .filter-toggle-btn .chevron { font-size: 11px; color: var(--text-muted); transition: transform 0.15s ease; }
  .filter-toggle-btn.open .chevron { transform: rotate(180deg); }
  .filter-count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: 7px; border-radius: 999px;
    background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
  }
  .filter-collapsible { display: none; }
  .filter-collapsible.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 10px;
    width: 100%; margin-top: 2px;
  }
  .filter-collapsible.open > * { width: 100%; }
  .filter-collapsible.open .row { flex-wrap: wrap; }

  /* Botones con texto largo ("+ Nueva observación", "+ Registrar") se quedan solo
     con el símbolo "+" en celular — el texto ocupa mucho espacio en filas de tabla
     y en la barra superior. */
  .btn-icon-collapse .btn-label-full { display: none; }
  .btn-icon-collapse { padding-left: 12px; padding-right: 12px; }
}

/* ===== Observation detail / form ===== */
.item-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; padding: 0 0 10px 12px; border-left: 4px solid transparent; border-bottom: 1px dashed var(--gridline); }
.item-row:last-child { border-bottom: none; }
.item-row .field { margin-bottom: 0; }
.item-row-desc { grid-column: 1 / -1; }
.item-row-label { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
.item-row-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment-thumb { width: 68px; height: 68px; border-radius: var(--radius-sm); border: 1px solid var(--border); object-fit: cover; background: var(--page-plane); }
.attachment-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--text-muted); max-width: 68px; position: relative; }
.attachment-remove { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--status-critical); color: #fff; border: none; cursor: pointer; font-size: 11px; line-height: 1; }
.file-drop { display: block; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); padding: 16px; text-align: center; font-size: 12.5px; color: var(--text-muted); cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.file-drop:hover, .file-drop:focus { border-color: var(--brand); color: var(--brand-ink); outline: none; }
.file-drop.drag-over { border-color: var(--brand); background: var(--brand-wash); color: var(--brand-ink); }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item { display: flex; gap: 10px; font-size: 12.5px; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex-shrink: 0; }
.history-meta { color: var(--text-muted); font-size: 11px; }

.detail-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-plot-title { font-size: 16px; font-weight: 800; }
.detail-plot-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.detail-section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 18px 0 8px; }
.detail-section-title:first-child { margin-top: 0; }
.material-item-card { background: var(--page-plane); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.material-item-name { font-weight: 700; font-size: 12.5px; }
.material-item-problem { font-size: 11.5px; color: var(--series-8); font-weight: 600; margin-top: 2px; }
.material-item-desc { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

.autocomplete-wrap { position: relative; }
.filter-bar .autocomplete-wrap { min-width: 160px; }
.filter-bar .autocomplete-wrap input { width: 100%; }
.sel-combo input { padding-right: 30px; cursor: pointer; }
.sel-combo::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 9px; height: 9px;
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
}
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto;
}
.autocomplete-item { padding: 9px 12px; cursor: pointer; font-size: 12.5px; border-bottom: 1px solid var(--gridline); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--brand-wash); }
.autocomplete-item .ac-fundo { font-weight: 700; }
.autocomplete-item .ac-meta { color: var(--text-muted); font-size: 11px; }

/* ===== Zone legend / palette key ===== */
.palette-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-secondary); }
.palette-legend .badge { pointer-events: none; }

/* ===== Theme toggle ===== */
.theme-toggle { display: flex; align-items: center; gap: 6px; }

@media (max-width: 860px) {
  .item-row { grid-template-columns: 1fr; }
}
