  :root {
    --bg: #F5F4F1;
    --surface: #FFFFFF;
    --surface2: #F0EEE9;
    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.15);
    --text: #1A1915;
    --text-2: #6B6860;
    --text-3: #9E9C97;
    --blue: #1E4FBF;
    --blue-light: #EEF3FF;
    --blue-text: #1E4FBF;
    --green: #1A6B3C;
    --green-light: #EDFAF3;
    --amber: #7A4A00;
    --amber-light: #FFF8EC;
    --red: #8B1F1F;
    --red-light: #FFF0F0;
    --purple: #4A2D8B;
    --purple-light: #F3EEFF;
    --accent: #1E4FBF;
    --primary-hover: #163DA8;
    --chip-hover: #DDE8FF;
    --danger-border: #F09595;
    color-scheme: light;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 220px;
    --topbar-h: 56px;
  }

  /* Modo oscuro: sigue al dispositivo salvo que se elija claro u oscuro a mano
     (data-theme en <html>, ver aplicarTema() en app.js). Solo en pantalla:
     lo que se imprime sale siempre en claro. */
  @media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #141413;
      --surface: #1E1D1B;
      --surface2: #2A2926;
      --border: rgba(255,255,255,0.09);
      --border-strong: rgba(255,255,255,0.18);
      --text: #ECEAE4;
      --text-2: #A9A69E;
      --text-3: #7A776F;
      --blue: #4F78E6;
      --blue-light: rgba(79,120,230,0.18);
      --blue-text: #8FAEFF;
      --green: #4CC38A;
      --green-light: rgba(76,195,138,0.14);
      --amber: #F0B45A;
      --amber-light: rgba(240,180,90,0.14);
      --red: #F08080;
      --red-light: rgba(240,128,128,0.14);
      --purple: #B49CF5;
      --purple-light: rgba(180,156,245,0.15);
      --accent: #4F78E6;
      --primary-hover: #3D66D6;
      --chip-hover: rgba(79,120,230,0.28);
      --danger-border: rgba(240,128,128,0.45);
      color-scheme: dark;
    }
  }
  @media screen {
    :root[data-theme="dark"] {
      --bg: #141413;
      --surface: #1E1D1B;
      --surface2: #2A2926;
      --border: rgba(255,255,255,0.09);
      --border-strong: rgba(255,255,255,0.18);
      --text: #ECEAE4;
      --text-2: #A9A69E;
      --text-3: #7A776F;
      --blue: #4F78E6;
      --blue-light: rgba(79,120,230,0.18);
      --blue-text: #8FAEFF;
      --green: #4CC38A;
      --green-light: rgba(76,195,138,0.14);
      --amber: #F0B45A;
      --amber-light: rgba(240,180,90,0.14);
      --red: #F08080;
      --red-light: rgba(240,128,128,0.14);
      --purple: #B49CF5;
      --purple-light: rgba(180,156,245,0.15);
      --accent: #4F78E6;
      --primary-hover: #3D66D6;
      --chip-hover: rgba(79,120,230,0.28);
      --danger-border: rgba(240,128,128,0.45);
      color-scheme: dark;
    }
  }

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

  body {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
  }

  /* ── LAYOUT ── */
  .app { display: flex; height: 100vh; }

  /* ── SIDEBAR ── */
  .sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
  }

  .logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
  }
  .logo-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
  }
  .logo-icon {
    width: 32px; height: 32px;
    background: var(--blue);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
  }
  .logo-icon svg { width: 18px; height: 18px; }
  .logo-name { font-size: 15px; font-weight: 500; letter-spacing: -0.3px; }
  .logo-sub { font-size: 11px; color: var(--text-3); font-family: 'DM Mono', monospace; }

  .nav-section {
    padding: 18px 20px 6px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'DM Mono', monospace;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
  }
  .nav-item:hover { background: var(--bg); color: var(--text); }
  .nav-item.active {
    background: var(--blue-light);
    color: var(--blue);
    border-left-color: var(--blue);
    font-weight: 500;
  }
  .nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
  .nav-item.active svg { opacity: 1; }

  .sidebar-footer {
    margin-top: auto;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-size: 11px;
    font-weight: 500;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .sidebar-footer-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tema-btn { font-size: 15px; line-height: 1; padding: 4px 6px !important; color: var(--text-3) !important; }
  .sidebar-footer-role { font-size: 11px; color: var(--text-3); }

  /* ── MAIN ── */
  .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

  .topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }
  .topbar-left { display: flex; align-items: center; gap: 12px; }
  .topbar h2 { font-size: 16px; font-weight: 500; letter-spacing: -0.3px; }
  .topbar-right { display: flex; align-items: center; gap: 8px; }

  .content { flex: 1; overflow-y: auto; padding: 24px 28px; }

  /* ── SCREENS ── */
  .screen { display: none; animation: fadeIn 0.2s ease; }
  .screen.active { display: block !important; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

  /* ── BUTTONS ── */
  .btn {
    padding: 7px 14px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    transition: all 0.12s;
    font-weight: 400;
  }
  .btn:hover { background: var(--bg); }
  .btn-primary {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
  }
  .btn-primary:hover { background: var(--primary-hover); }
  .btn-sm { padding: 4px 9px; font-size: 11px; }
  .btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
  .btn-ghost:hover { background: var(--bg); color: var(--text); }
  .btn-danger { color: var(--red); border-color: var(--danger-border); }
  .btn-danger:hover { background: var(--red-light); }

  /* ── BADGES ── */
  .badge {
    display: inline-block;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.02em;
  }
  .badge-green { background: var(--green-light); color: var(--green); }
  .badge-amber { background: var(--amber-light); color: var(--amber); }
  .badge-blue  { background: var(--blue-light); color: var(--blue-text); }
  .badge-red   { background: var(--red-light); color: var(--red); }
  .badge-gray  { background: var(--surface2); color: var(--text-2); }
  .badge-purple{ background: var(--purple-light); color: var(--purple); }

  /* ── METRICS ── */
  .metrics-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
  .metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
  }
  .metric-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; font-family: 'DM Mono', monospace; }
  .metric-value { font-size: 26px; font-weight: 300; letter-spacing: -1px; }
  .metric-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }

  /* ── PANELS ── */
  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
  }
  .panel-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
  }

  /* ── TABLES ── */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th {
    text-align: left;
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'DM Mono', monospace;
    white-space: nowrap;
  }
  td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--bg); }
  .total-row td { font-weight: 500; background: var(--surface2); }

  .row-link { color: var(--blue); cursor: pointer; font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500; }
  .row-link:hover { text-decoration: underline; }

  /* ── TABS ── */
  .tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    gap: 0;
  }
  .tab {
    padding: 9px 18px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.12s;
    user-select: none;
  }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }

  /* ── FORM FIELDS ── */
  .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .field { display: flex; flex-direction: column; gap: 5px; }
  .field label { font-size: 11px; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; font-family: 'DM Mono', monospace; }
  .field input, .field select, .field textarea {
    padding: 8px 11px;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color 0.12s;
    outline: none;
  }
  .field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--blue);
  }
  .field input[readonly] { background: var(--surface2); color: var(--text-2); }
  .field textarea { resize: vertical; min-height: 64px; }

  /* ── GASTOS TABLE ── */
  .gasto-table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .gasto-table th {
    text-align: left; padding: 8px 10px;
    font-size: 10px; font-weight: 500; color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    text-transform: uppercase; letter-spacing: 0.07em;
    font-family: 'DM Mono', monospace;
  }
  .gasto-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .gasto-table tr:last-child td { border-bottom: none; }
  .gasto-table tr:hover td { background: var(--bg); }
  .gasto-table td input, .gasto-table td select {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    outline: none;
    transition: all 0.12s;
  }
  .gasto-table td input:hover, .gasto-table td select:hover { border-color: var(--border-strong); background: var(--surface); }
  .gasto-table td input:focus, .gasto-table td select:focus { border-color: var(--blue); background: var(--surface); }

  /* ── TOTALES BAR ── */
  .totales-bar { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
  .total-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
  }
  .total-card-label { font-size: 10px; color: var(--text-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.07em; font-family: 'DM Mono', monospace; }
  .total-card-val { font-size: 22px; font-weight: 300; letter-spacing: -0.5px; }

  /* ── DOC CHIP ── */
  .doc-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    color: var(--blue);
    background: var(--blue-light);
    font-family: 'DM Mono', monospace;
    transition: all 0.12s;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .doc-chip:hover { background: var(--chip-hover); }

  /* ── UPLOAD ZONE ── */
  .upload-zone {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.12s;
  }
  .upload-zone.arrastrando { background: var(--blue-light); border-color: var(--blue); border-style: solid; color: var(--blue-text); }
  .upload-zone:hover { background: var(--bg); border-color: var(--blue); color: var(--blue); }
  .upload-zone svg { width: 20px; height: 20px; margin-bottom: 6px; display: block; margin-left: auto; margin-right: auto; }

  /* ── DOC ITEMS ── */
  .doc-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 7px;
    transition: all 0.12s;
  }
  .doc-item:hover { background: var(--bg); }
  .doc-icon {
    width: 32px; height: 32px;
    border-radius: 7px;
    background: var(--blue-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .doc-name { flex: 1; font-size: 13px; font-weight: 500; }
  .doc-meta { font-size: 11px; color: var(--text-3); min-width: 160px; text-align: right; }

  /* ── AUDIT ── */
  .audit-item { display: flex; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
  .audit-item:last-child { border-bottom: none; }
  .audit-line { display: flex; flex-direction: column; align-items: center; gap: 0; }
  .audit-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex-shrink: 0; margin-top: 4px; }
  .audit-dot.green { background: var(--green); }
  .audit-dot.amber { background: var(--amber); }
  .audit-dot.red { background: var(--red); }
  .audit-text { font-size: 13px; }
  .audit-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; font-family: 'DM Mono', monospace; }

  /* ── FILTERS ── */
  .filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
  .filter-input, .filter-select {
    padding: 7px 11px;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
  }
  .filter-input { width: 200px; }
  .filter-input:focus, .filter-select:focus { border-color: var(--blue); }

  /* ── STATUS INDICATOR ── */
  .status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 5px; }
  .status-dot.green { background: var(--green); }
  .status-dot.amber { background: #D97706; }
  .status-dot.red { background: #DC2626; }

  /* ── SECTION DIVIDER ── */
  .section-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

  /* ── PRESET BUTTONS ── */
  .btn-preset { border-radius: 20px; font-size: 11px; padding: 5px 12px; }
  .btn-preset.active { background: var(--blue); color: white; border-color: var(--blue); }

  /* ── PRINT / PDF ── */
  @media print {
    .sidebar, .topbar, #r-presets-row, #r-filters-row { display: none !important; }
    body { overflow: auto !important; height: auto !important; }
    .app { display: block !important; height: auto !important; }
    .main { display: block !important; overflow: visible !important; }
    .content { overflow: visible !important; padding: 16px 20px !important; }
    .screen { display: none !important; }
    #screen-reportes { display: block !important; animation: none !important; }
    #r-print-header { display: block !important; }
    .no-print { display: none !important; }
    @page { margin: 1cm; size: A4 landscape; }
  }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

  /* ── NOTIFICATION ── */
  .notif {
    position: fixed;
    bottom: 24px; right: 24px;
    background: var(--text);
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s;
    pointer-events: none;
  }
  .notif.show { opacity: 1; transform: translateY(0); }

  /* ── FEEDBACK FAB ── */
  #feedback-fab { transition: transform 0.15s, background 0.15s; }
  #feedback-fab:hover { background: var(--primary-hover); transform: scale(1.06); }

  /* ── SELECTOR DE ETIQUETAS ── */
  .tag-picker {
    position: relative;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    min-height: 40px; padding: 6px 8px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); cursor: text;
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  .tag-picker:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
  .tag-chips { display: contents; }
  .tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 4px 3px 10px; border-radius: 999px;
    color: #fff; font-size: 12px; font-weight: 500; line-height: 1.3;
  }
  .tag-chip button {
    border: none; background: transparent; color: #fff; opacity: .75;
    width: 18px; height: 18px; border-radius: 50%; padding: 0;
    font-size: 13px; line-height: 1; cursor: pointer;
  }
  .tag-chip button:hover { opacity: 1; background: rgba(255,255,255,.2); }
  #etiqueta-input {
    flex: 1; min-width: 140px; border: none; outline: none;
    padding: 4px 2px; font-size: 13px; font-family: 'DM Sans', sans-serif;
    background: transparent; color: var(--text);
  }
  .tag-menu {
    position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 50;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,.10); padding: 4px; max-height: 260px; overflow: auto;
  }
  .tag-menu-titulo { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px 4px; font-family: 'DM Mono', monospace; }
  .tag-opcion {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 7px 8px; border: none; border-radius: 4px; background: transparent;
    font-size: 13px; color: var(--text); text-align: left; cursor: pointer; font-family: 'DM Sans', sans-serif;
  }
  .tag-opcion.activa, .tag-opcion:hover { background: var(--bg); }
  .tag-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .tag-opcion .tag-olvidar {
    margin-left: auto; opacity: 0; font-size: 11px; color: var(--text-3);
    border: none; background: transparent; cursor: pointer; padding: 2px 6px; border-radius: 4px;
  }
  .tag-opcion:hover .tag-olvidar { opacity: 1; }
  .tag-olvidar:hover { color: var(--red); background: var(--red-light); }
  .tag-crear { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
  .tag-colores { display: flex; gap: 6px; padding: 4px 8px 6px 26px; }
  .tag-colores button {
    width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
  }
  .tag-colores button.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor; }
  .tag-vacio { padding: 8px; font-size: 12px; color: var(--text-3); }

  /* ── BUSCADOR ── */
  .busq-global { position: relative; margin-bottom: 16px; }
  .busq-global > svg { position: absolute; left: 14px; top: 13px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
  .busq-global input { width: 100%; padding: 11px 14px 11px 38px; font-size: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-family: inherit; }
  .busq-global input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
  .busq-global-res { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 420px; overflow-y: auto; }
  .busq-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
  .busq-item:last-child { border-bottom: none; }
  .busq-item:hover { background: var(--bg); }
  .busq-item-hit { font-size: 12px; margin-top: 3px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  mark.busq-hit { background: var(--amber-light); color: var(--amber); border-radius: 2px; padding: 0 1px; }
  .busq-detalle td { padding-top: 0 !important; font-size: 12px; color: var(--text-2); border-top: none !important; }
  .busq-detalle td div { margin: 2px 0; }

  /* ── INSTALAR EN EL TELÉFONO ── */
  .inst-overlay { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.5); align-items: center; justify-content: center; padding: 16px; }
  .inst-overlay.show { display: flex; }
  .inst-box { background: var(--surface); border-radius: var(--radius); width: 640px; max-width: 100%; max-height: 100%; overflow-y: auto; padding: 20px; box-shadow: 0 4px 24px rgba(0,0,0,.15); }
  .inst-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
  .inst-title { font-size: 15px; font-weight: 500; }
  .inst-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
  .inst-tabs { margin-bottom: 16px; }
  .inst-body { display: flex; gap: 24px; align-items: flex-start; }
  .inst-demo { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
  .inst-phone { width: 190px; height: 380px; border-radius: 28px; background: #1A1915; padding: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
  .inst-screen { position: relative; width: 100%; height: 100%; border-radius: 20px; overflow: hidden; background: var(--bg); font-size: 10px; color: var(--text); animation: instFade .35s ease; }
  @keyframes instFade { from { opacity: .3; } to { opacity: 1; } }
  .inst-pasos { flex: 1; min-width: 0; }
  .inst-pasos ol { margin: 0 0 12px; padding-left: 0; list-style: none; counter-reset: paso; }
  .inst-pasos li { counter-increment: paso; display: flex; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; color: var(--text-2); cursor: pointer; transition: background .2s; }
  .inst-pasos li::before { content: counter(paso); flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--surface2); color: var(--text-2); font-size: 11px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
  .inst-pasos li.activo { background: var(--blue-light); color: var(--text); }
  .inst-pasos li.activo::before { background: var(--blue); color: #fff; }
  .inst-nota { font-size: 12px; color: var(--text-3); margin-bottom: 12px; line-height: 1.5; }

  /* piezas de la pantalla simulada */
  .ph-bar { display: flex; align-items: center; gap: 6px; padding: 22px 8px 6px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .ph-url { flex: 1; background: var(--surface2); border-radius: 999px; padding: 4px 8px; font-size: 8px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
  .ph-ico { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 12px; border-radius: 50%; position: relative; }
  .ph-page { padding: 10px 8px; }
  .ph-line { height: 7px; border-radius: 4px; background: var(--border-strong); margin-bottom: 6px; opacity: .5; }
  .ph-card { height: 34px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 6px; }
  .ph-menu { position: absolute; background: var(--surface); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); padding: 4px 0; }
  .ph-item { padding: 6px 10px; white-space: nowrap; position: relative; }
  .ph-sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface2); border-radius: 14px 14px 0 0; padding: 10px 8px 14px; box-shadow: 0 -4px 16px rgba(0,0,0,.12); }
  .ph-sheet .ph-item { background: var(--surface); border-radius: 0; border-bottom: 1px solid var(--border); }
  .ph-dialog { position: absolute; left: 12px; right: 12px; top: 40%; background: var(--surface); border-radius: 12px; padding: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.25); }
  .ph-dim { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
  .ph-app { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 7px; color: #fff; position: relative; }
  .ph-app i { display: block; width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.35); }
  .ph-app img { width: 30px; height: 30px; border-radius: 8px; }
  .ph-home { position: absolute; inset: 0; background: linear-gradient(160deg,#5B7BD5,#2C3E7A); display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); justify-items: center; align-content: start; gap: 14px 4px; padding: 34px 8px; }
  .ph-home .ph-tap { background: rgba(255,255,255,.18); outline-color: #fff; padding: 2px; }
  /* el toque: anillo que late sobre lo que hay que tocar */
  .ph-tap { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; background: var(--blue-light); }
  .ph-tap::after { content: ''; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: rgba(30,79,191,.35); animation: phTap 1.1s ease-out infinite; pointer-events: none; }
  @keyframes phTap { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

  /* ── TELÉFONO ── */
  .menu-btn, .sidebar-backdrop { display: none; }
  @media (max-width: 768px) {
    .app { height: 100dvh; }
    .sidebar {
      position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
      transform: translateX(-100%); transition: transform .2s ease;
      box-shadow: 0 0 24px rgba(0,0,0,.15); overflow-y: auto;
    }
    .menu-abierto .sidebar { transform: none; }
    .menu-abierto .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.3); }
    .menu-btn {
      display: flex; align-items: center; justify-content: center;
      width: 36px; height: 36px; margin-left: -8px; flex-shrink: 0;
      background: none; border: none; border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
    }
    .menu-btn svg { width: 20px; height: 20px; }

    .topbar { padding: 0 16px; gap: 8px; }
    .topbar-left { gap: 8px; min-width: 0; }
    .topbar h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-right { flex-shrink: 0; }
    .content { padding: 16px; }

    /* Grillas a una columna; las métricas, de a dos */
    .field-row, .field-row-3, .totales-bar { grid-template-columns: 1fr; }
    .metrics-row { grid-template-columns: 1fr 1fr; }
    .content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

    /* Tablas y pestañas se desplazan de costado en vez de romper la pantalla */
    .panel { padding: 14px; overflow-x: auto; }
    .tabs { overflow-x: auto; scrollbar-width: none; }
    .tab { white-space: nowrap; flex-shrink: 0; }
    .section-actions { flex-wrap: wrap; }
    .inst-body { flex-direction: column; align-items: center; gap: 14px; }
    .inst-phone { width: 170px; height: 340px; }
    input, select, textarea { font-size: 16px; }   /* evita el zoom automático de iPhone */
  }
