/* ============================================================
   Safety Hub — Demo · Safety 2011 S.A.S / FootSafe
   Sistema visual: "sala de control industrial"
   Slate profundo + ámbar de seguridad · Inter · elevación en capas
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar industrial slate */
  --sidebar-top:    #0b1220;
  --sidebar-bottom: #111a2e;
  --sidebar-line:   rgba(148, 163, 184, .12);
  --nav-text:       #97a6bd;
  --nav-text-hover: #e2e8f0;

  /* Ámbar de seguridad (marca EPP / hi-vis) */
  --accent:       #f59e0b;
  --accent-deep:  #d97706;
  --accent-hi:    #fbbf24;
  --accent-soft:  #fff7e6;
  --accent-tint:  #fef3c7;

  /* Neutros */
  --bg:           #f5f7fa;
  --bg-sunken:    #eef1f6;
  --surface:      #ffffff;
  --ink:          #0f172a;
  --ink-2:        #475569;
  --ink-3:        #64748b;
  --ink-muted:    #94a3b8;
  --line:         #e7ebf1;
  --line-soft:    #eef2f7;

  /* Semánticos */
  --success: #16a34a; --success-bg: #dcfce7;
  --warning: #d97706; --warning-bg: #fef3c7;
  --danger:  #dc2626; --danger-bg:  #fee2e2;
  --info:    #2563eb; --info-bg:    #dbeafe;

  /* Elevación */
  --sh-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --sh-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --sh-md: 0 2px 4px rgba(15, 23, 42, .04), 0 6px 16px rgba(15, 23, 42, .06);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 10px rgba(15, 23, 42, .05);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sidebar-w: 264px;
  --topbar-h: 60px;
  --banner-h: 34px;

  --num: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
}

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Sprite oculto */
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Render correcto de íconos (stroke, no relleno) — evita manchas negras */
.icon svg, .search svg, .icon-btn svg {
  width: 100%; height: 100%; display: block;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.search svg, .icon-btn svg { stroke-width: 2; }

/* Números tabulares para datos */
.kpi-value, table.data td, .bar-row .val, .bar-fill, .unit-card h3,
.ocr-field, .kpi-meta { font-variant-numeric: tabular-nums; }

/* ============================================================
   Banner demo
   ============================================================ */
.demo-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--banner-h);
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: linear-gradient(100deg, #0b1220 0%, #1e293b 100%);
  color: #fde9c8;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border-bottom: 1px solid rgba(245, 158, 11, .35);
}
.demo-banner::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-hi);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, .7);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(251, 191, 36, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* ============================================================
   Shell
   ============================================================ */
.app { display: flex; height: 100vh; padding-top: var(--banner-h); }

.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom));
  color: var(--nav-text);
  display: flex; flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid #0a0f1a;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a384f; border-radius: 999px; }

.sidebar-brand {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--sidebar-line);
  display: flex; align-items: center; gap: 11px;
  position: sticky; top: 0;
  background: linear-gradient(180deg, var(--sidebar-top), rgba(11,18,32,.96));
  z-index: 2;
}
.brand-mark {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 11px;
  background: radial-gradient(circle at 50% 35%, rgba(245,158,11,.16), rgba(245,158,11,.03));
  border: 1px solid rgba(245, 158, 11, .22);
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.sidebar-brand .logo { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.02em; line-height: 1.1; }
.sidebar-brand .logo span { color: var(--accent-hi); }
.sidebar-brand .sub { font-size: 9.5px; color: var(--ink-muted); margin-top: 3px; letter-spacing: .03em; }

nav { padding: 8px 10px 18px; }
.nav-group { padding: 6px 0 2px; }
.nav-group + .nav-group { margin-top: 4px; border-top: 1px solid var(--sidebar-line); padding-top: 10px; }

.nav-group-title {
  padding: 4px 10px 6px;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: #5b6b85;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin: 1px 0;
  cursor: pointer; border: none; background: none;
  color: var(--nav-text); font-size: 12.5px; font-weight: 500;
  width: 100%; text-align: left;
  border-radius: var(--r-sm);
  position: relative;
  transition: background .16s, color .16s;
}
.nav-item:hover { background: rgba(148, 163, 184, .08); color: var(--nav-text-hover); }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; transition: opacity .16s, color .16s; }
.nav-item:hover .icon { opacity: 1; }

.nav-item.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, .16), rgba(245, 158, 11, .04));
  color: #fff; font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); box-shadow: 0 0 10px rgba(245, 158, 11, .6);
}
.nav-item.active .icon { color: var(--accent-hi); opacity: 1; }

/* ============================================================
   Main + topbar
   ============================================================ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-shrink: 0;
}
.topbar-left { min-width: 0; }
.topbar h1 { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }
.topbar .breadcrumb { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink-muted);
  width: 230px;
  transition: border-color .16s, background .16s;
}
.search:focus-within { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
.search svg { width: 16px; height: 16px; flex-shrink: 0; }
.search input { border: none; background: none; outline: none; font-size: 12.5px; color: var(--ink); width: 100%; }
.search input::placeholder { color: var(--ink-muted); }

.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; cursor: pointer; color: var(--ink-2);
  transition: background .16s, border-color .16s, transform .12s;
}
.icon-btn:hover { background: var(--bg); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 15px; height: 15px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

.user-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; transition: background .16s;
}
.user-pill:hover { background: var(--bg); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-hi), var(--accent-deep));
  color: #1a1206; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}

.content { flex: 1; overflow-y: auto; padding: 22px 24px 36px; scroll-behavior: smooth; }

/* Entrada de vista */
.view { display: none; }
.view.active { display: block; animation: viewIn .32s cubic-bezier(.16,.84,.44,1); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Botones
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; font-family: inherit;
  transition: background .15s, box-shadow .15s, transform .1s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-deep));
  color: #1a1206;
  box-shadow: 0 1px 2px rgba(217,119,6,.4), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(217,119,6,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--sh-xs); }
.btn-secondary:hover { background: var(--bg); border-color: #d8dee7; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 11px; font-size: 11px; }

/* ============================================================
   Grid + cards
   ============================================================ */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.card:hover { box-shadow: var(--sh-md); }

.card-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h2, .card-header h3 { font-size: 13.5px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.card-body { padding: 18px; }

/* ============================================================
   KPI
   ============================================================ */
.kpi { padding: 18px; position: relative; overflow: hidden; }
.kpi::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  opacity: 0; transition: opacity .2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.kpi:hover::before { opacity: 1; }

.kpi-label {
  font-size: 10.5px; color: var(--ink-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.kpi-value {
  font-size: 30px; font-weight: 800; color: var(--ink);
  margin: 8px 0 5px; line-height: 1; letter-spacing: -.03em;
}
.kpi-meta { font-size: 11px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.kpi-meta.up   { color: var(--success); }
.kpi-meta.down { color: var(--danger); }
.kpi-meta.warn { color: var(--warning); }

.kpi-bar { height: 5px; background: var(--bg-sunken); border-radius: 999px; margin-top: 14px; overflow: hidden; }
.kpi-bar span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-hi));
  transform-origin: left;
  animation: growX .9s cubic-bezier(.16,.84,.44,1);
}
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: #15803d; border-color: #bbf7d0; }
.badge-warning { background: var(--warning-bg); color: #b45309; border-color: #fde68a; }
.badge-danger  { background: var(--danger-bg);  color: #b91c1c; border-color: #fecaca; }
.badge-info    { background: var(--info-bg);    color: #1d4ed8; border-color: #bfdbfe; }
.badge-neutral { background: var(--bg-sunken);  color: var(--ink-3); border-color: var(--line); }

/* ============================================================
   Tablas
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th, table.data td {
  padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
table.data th {
  background: var(--bg); font-weight: 700; color: var(--ink-3);
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  position: sticky; top: 0;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover td { background: #fbfcfe; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td:first-child { font-weight: 600; color: var(--ink); }
table.data .actions { white-space: nowrap; }

/* ============================================================
   Formularios
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .full { grid-column: 1 / -1; }

.field label { display: block; font-size: 11px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field label .req { color: var(--danger); }

.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--ink); background: #fff; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 30px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}
.field textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.field input[readonly], .field select[disabled] { background: var(--bg-sunken); color: var(--ink-3); }

.form-actions {
  display: flex; gap: 9px; justify-content: flex-end;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 11px 16px; border: none; background: none;
  font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit; transition: color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-deep); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: viewIn .3s ease; }

/* ============================================================
   Barras (charts CSS)
   ============================================================ */
.bar-chart { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 50px; align-items: center; gap: 10px; font-size: 11px; }
.bar-row .label { color: var(--ink-2); font-weight: 600; }
.bar-track { height: 24px; background: var(--bg-sunken); border-radius: 6px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-hi));
  border-radius: 6px;
  display: flex; align-items: center; padding-left: 9px;
  font-size: 10px; font-weight: 700; color: #fff; min-width: 30px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.bar-row .val { text-align: right; font-weight: 700; color: var(--ink); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 12px 15px; border-radius: var(--r-sm); font-size: 12.5px;
  margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.5;
  border: 1px solid transparent;
}
.alert::before {
  content: ""; width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px;
  background-repeat: no-repeat; background-position: center; background-size: contain;
}
.alert-warning { background: var(--warning-bg); border-color: #fde68a; color: #92400e; }
.alert-warning::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b45309' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.alert-info { background: var(--info-bg); border-color: #bfdbfe; color: #1e40af; }
.alert-info::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%231d4ed8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.alert-success { background: var(--success-bg); border-color: #bbf7d0; color: #065f46; }
.alert-success::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2315803d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.801 10A10 10 0 1 1 17 3.335'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E"); }

/* ============================================================
   Split
   ============================================================ */
.split { display: grid; grid-template-columns: 1fr 388px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* ============================================================
   Steps
   ============================================================ */
.steps { display: flex; gap: 0; margin-bottom: 22px; overflow-x: auto; padding: 6px 0; }
.step { flex: 1; min-width: 100px; text-align: center; position: relative; }
.step::after {
  content: ""; position: absolute; top: 15px; left: 50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.step.done::after { background: var(--success); }
.step:last-child::after { display: none; }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px; font-size: 12px; font-weight: 700;
  color: var(--ink-muted); position: relative; z-index: 1;
  box-shadow: var(--sh-xs);
}
.step.done .step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.active .step-dot {
  background: var(--accent); border-color: var(--accent); color: #1a1206;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .18);
}
.step-label { font-size: 10.5px; color: var(--ink-3); font-weight: 600; }
.step.active .step-label, .step.done .step-label { color: var(--ink); }

/* ============================================================
   Timeline
   ============================================================ */
.timeline { display: flex; flex-direction: column; gap: 4px; position: relative; }
.timeline-item { display: flex; gap: 13px; font-size: 12px; padding: 8px 0; position: relative; }
.timeline-item:not(:last-child)::before {
  content: ""; position: absolute; left: 4px; top: 20px; bottom: -4px;
  width: 2px; background: var(--line-soft);
}
.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-top: 4px; flex-shrink: 0; z-index: 1;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}
.timeline-content strong { display: block; color: var(--ink); font-weight: 600; }
.timeline-content span { color: var(--ink-3); font-size: 11px; }

/* ============================================================
   OCR mock
   ============================================================ */
.ocr-preview {
  border: 2px dashed #cbd5e1; border-radius: var(--r-md);
  padding: 26px 20px; background: var(--bg);
  text-align: center; color: var(--ink-3); font-size: 12px; font-weight: 500;
  transition: border-color .2s, background .2s;
}
.ocr-preview:hover { border-color: var(--accent); background: var(--accent-tint); }
.ocr-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 14px; text-align: left; }
.ocr-field {
  background: linear-gradient(180deg, #fffaf0, var(--accent-tint));
  border: 1px solid #fde68a; padding: 9px 11px; border-radius: var(--r-sm); font-size: 11.5px; color: var(--ink);
}
.ocr-field strong { color: var(--accent-deep); display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

/* ============================================================
   Unidades UPC / UPI / UPT
   ============================================================ */
.unit-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.unit-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px; background: var(--surface); box-shadow: var(--sh-sm);
  transition: box-shadow .2s, transform .2s;
}
.unit-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.unit-card h3 { font-size: 15px; margin-bottom: 4px; font-weight: 800; letter-spacing: -.02em; }
.unit-card .code {
  font-size: 10px; color: var(--ink-3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 6px;
}
.unit-progress { margin: 16px 0; }
.unit-progress .nums { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 7px; color: var(--ink-2); font-weight: 600; }
.unit-progress .track { height: 9px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.unit-progress .fill { height: 100%; border-radius: 999px; transform-origin: left; animation: growX 1s cubic-bezier(.16,.84,.44,1); }
.fill-upc { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }
.fill-upi { background: linear-gradient(90deg, var(--accent-deep), var(--accent-hi)); }
.fill-upt { background: linear-gradient(90deg, #15803d, #22c55e); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 26px; right: 26px;
  display: flex; align-items: center; gap: 10px;
  background: #0f172a; color: #fff;
  padding: 13px 18px; border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 600; z-index: 2000;
  box-shadow: var(--sh-lg);
  opacity: 0; transform: translateY(12px) scale(.98);
  transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast::before {
  content: ""; width: 18px; height: 18px; flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.801 10A10 10 0 1 1 17 3.335'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }

/* ============================================================
   Menú de usuario (dropdown + cambio de perfil)
   ============================================================ */
.user-menu-wrap { position: relative; }
.user-pill .chev { width: 14px; height: 14px; opacity: .55; margin-left: 1px; transition: transform .2s; }
.user-pill.open .chev { transform: rotate(180deg); }
.avatar.lg { width: 42px; height: 42px; font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 20px; border-radius: 16px; }

.user-menu {
  position: absolute; top: calc(100% + 9px); right: 0;
  width: 290px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); z-index: 1500; overflow: hidden;
  animation: menuIn .18s cubic-bezier(.16,.84,.44,1);
}
.user-menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.user-menu-head {
  display: flex; gap: 12px; align-items: center;
  padding: 16px; background: var(--bg); border-bottom: 1px solid var(--line-soft);
}
.user-menu-head strong { display: block; font-size: 13px; color: var(--ink); font-weight: 700; }
.user-menu-head span { font-size: 11px; color: var(--ink-3); }

.user-menu-section { padding: 8px; }
.user-menu-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-muted); padding: 6px 8px 4px;
}
.user-switch {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 7px 8px; border: none; background: none; border-radius: var(--r-sm);
  cursor: pointer; text-align: left; font-family: inherit; transition: background .14s;
}
.user-switch:hover { background: var(--bg); }
.user-switch.active { background: var(--accent-tint); }
.user-switch .avatar { width: 30px; height: 30px; font-size: 10px; flex-shrink: 0; }
.user-switch .sw-name { font-size: 12px; font-weight: 600; color: var(--ink); display: block; line-height: 1.25; }
.user-switch .sw-role { font-size: 10px; color: var(--ink-3); }
.user-switch.active::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

.user-menu-divider { height: 1px; background: var(--line-soft); margin: 4px 0; }
.user-menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 16px; border: none; background: none; cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); text-align: left;
  font-family: inherit; transition: background .14s, color .14s;
}
.user-menu-item:hover { background: var(--bg); color: var(--ink); }
.user-menu-item svg { width: 16px; height: 16px; opacity: .7; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.user-menu-item.danger { color: var(--danger); }
.user-menu-item.danger:hover { background: var(--danger-bg); }

/* ============================================================
   Configuración
   ============================================================ */
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head strong { display: block; font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.profile-head > div > span { font-size: 12px; color: var(--ink-3); }

.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.set-row:first-child { padding-top: 0; }
.set-row:last-child { border-bottom: none; padding-bottom: 0; }
.set-info strong { display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; }
.set-info span { font-size: 11px; color: var(--ink-3); }

.toggle { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 40px; height: 23px; border-radius: 999px; background: #cbd5e1;
  transition: background .2s; position: relative;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  box-shadow: var(--sh-sm); transition: transform .2s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(17px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(245, 158, 11, .25); }

.conn-row {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 12px; color: var(--ink-2); font-weight: 500;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }

/* Utilidades */
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--ink-3); font-size: 11px; }

/* ============================================================
   Panel «¿Por qué esto?» — contexto dolor → solución
   ============================================================ */
.btn-why {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid rgba(245, 158, 11, .45);
  background: linear-gradient(180deg, #fffbeb 0%, var(--accent-tint) 100%);
  color: var(--accent-deep); font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  box-shadow: var(--sh-xs); transition: background .15s, border-color .15s, transform .12s;
}
.btn-why svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-why:hover {
  background: #fffbeb; border-color: var(--accent);
  transform: translateY(-1px); box-shadow: var(--sh-sm);
}
.btn-why.active {
  background: var(--accent); border-color: var(--accent-deep); color: #fff;
}

.why-overlay {
  position: fixed; inset: 0; top: var(--banner-h);
  background: rgba(15, 23, 42, .42); backdrop-filter: blur(2px);
  z-index: 3000; opacity: 0; transition: opacity .22s;
}
.why-overlay.open { opacity: 1; }

.why-panel {
  position: fixed; top: var(--banner-h); right: 0; bottom: 0;
  width: min(440px, 100vw); max-width: 100%;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--sh-lg); z-index: 3010;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
}
.why-panel.open { transform: translateX(0); }

.why-panel-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
}
.why-panel-kicker {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent-deep); margin-bottom: 4px;
}
.why-panel-head h2 { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.why-panel-screen { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

.why-close {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; color: var(--ink-2); transition: background .14s;
}
.why-close:hover { background: var(--bg); color: var(--ink); }
.why-close svg { width: 16px; height: 16px; }

.why-panel-body {
  flex: 1; overflow-y: auto; padding: 16px 18px 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.why-block {
  border: 1px solid var(--line-soft); border-radius: var(--r-md);
  padding: 14px 15px; background: var(--surface);
}
.why-block.dolor { border-left: 3px solid var(--danger); background: #fffbfb; }
.why-block.fuente { border-left: 3px solid var(--info); background: #f8fbff; }
.why-block.solucion { border-left: 3px solid var(--success); background: #f8fdf9; }
.why-block.pantalla { border-left: 3px solid var(--accent); background: var(--accent-soft); }

.why-block-label {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: 8px;
}
.why-block.dolor .why-block-label { color: var(--danger); }
.why-block.fuente .why-block-label { color: var(--info); }
.why-block.solucion .why-block-label { color: var(--success); }
.why-block.pantalla .why-block-label { color: var(--accent-deep); }

.why-block p, .why-block li {
  font-size: 12px; color: var(--ink-2); line-height: 1.55;
}
.why-block p { margin-bottom: 8px; }
.why-block p:last-child { margin-bottom: 0; }
.why-block ul { margin: 6px 0 0 16px; }
.why-block li { margin-bottom: 5px; }
.why-block li:last-child { margin-bottom: 0; }

.why-meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.why-tag {
  font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--bg); color: var(--ink-2); border: 1px solid var(--line);
}
.why-tag.person { background: var(--accent-tint); color: var(--accent-deep); border-color: #fde68a; }

.why-quote {
  font-style: italic; color: var(--ink); border-left: 2px solid var(--line);
  padding-left: 10px; margin-top: 6px; font-size: 11.5px;
}

.why-panel-foot {
  padding: 10px 18px 14px; border-top: 1px solid var(--line-soft);
  font-size: 10px; color: var(--ink-muted); background: var(--bg);
}
.why-panel-foot code {
  font-size: 9px; background: var(--surface); padding: 1px 5px;
  border-radius: 4px; border: 1px solid var(--line);
}

@media (max-width: 640px) {
  .btn-why span.btn-why-text { display: none; }
  .btn-why { padding: 8px 10px; }
}

/* ============================================================
   Vista «¿Por qué Safety Hub?» — dolores → solución
   ============================================================ */
.why-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0b1220, #1e293b);
  color: #fff; border-radius: var(--r-lg);
  padding: 30px 32px; margin-bottom: 18px;
}
.why-hero::after {
  content: ""; position: absolute; right: -70px; top: -70px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, .22), transparent 70%);
}
.why-hero-kicker {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--accent-hi); margin-bottom: 12px; position: relative;
}
.why-hero h2 {
  font-size: 25px; font-weight: 800; letter-spacing: -.03em;
  line-height: 1.15; max-width: 640px; position: relative;
}
.why-hero h2 span { color: var(--accent-hi); }
.why-hero p { font-size: 13px; color: #cbd5e1; margin-top: 12px; max-width: 600px; line-height: 1.6; position: relative; }
.why-hero-stats { display: flex; gap: 30px; margin-top: 22px; flex-wrap: wrap; position: relative; }
.why-hero-stat strong { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.why-hero-stat span { font-size: 11px; color: #94a3b8; }

.pain-groups { display: flex; flex-direction: column; gap: 26px; }
.pain-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pain-group-name { font-size: 14px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; }
.pain-group-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pain {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-sm); overflow: hidden; margin-bottom: 12px;
  transition: box-shadow .2s, transform .2s;
}
.pain:last-child { margin-bottom: 0; }
.pain:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

.pain-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft); background: var(--bg);
}
.pain-screen { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.pain-link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 11.5px; font-weight: 700; color: var(--accent-deep);
  padding: 4px 9px; border-radius: var(--r-sm); transition: background .14s;
}
.pain-link:hover { background: var(--accent-tint); }
.pain-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pain-cols { display: grid; grid-template-columns: 1fr 1fr; }
.pain-col { padding: 15px 16px; }
.pain-col.dolor { background: #fffbfb; border-right: 1px solid var(--line-soft); }
.pain-col.sol { background: #f8fdf9; }
.pain-col-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.pain-col-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pain-col.dolor .pain-col-label { color: var(--danger); }
.pain-col.sol .pain-col-label { color: var(--success); }
.pain-col p { font-size: 12px; color: var(--ink-2); line-height: 1.55; }

@media (max-width: 760px) {
  .pain-cols { grid-template-columns: 1fr; }
  .pain-col.dolor { border-right: none; border-bottom: 1px solid var(--line-soft); }
}
