  :root {
    --primary: #007BFF;
    --primary-light: #3395ff;
    --bg: #f8f9fa;
    --card: #ffffff;
    --border: #dee2e6;
    --text: #212529;
    --text-light: #6c757d;
    --danger: #DC3545;
    --success: #28A745;
    --warning: #ffc107;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Roboto', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
  }
  .app-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #1d4ed8 100%);
    background-image: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #1d4ed8 100%), url('../img/header-watermark.svg');
    background-size: cover, cover;
    background-blend-mode: normal, overlay;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
  .app-header h1 { font-size: 1.3rem; font-weight: 600; }
  .header-buttons { display: flex; gap: 0.5rem; }
  .btn {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
  .btn-pdf { background: var(--danger); color: white; }
  .btn-word { background: #007BFF; color: white; }
  .btn-clear { background: #6c757d; color: white; }
  .btn-save { background: var(--success); color: white; }
  .btn-load { background: var(--warning); color: white; }
  .btn-add {
    background: var(--success);
    color: white;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
  }
  .btn-remove {
    background: var(--danger);
    color: white;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
  }
  .container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
  .section {
    background: var(--card);
    border-radius: 10px;
    padding: 1.8rem;
    margin-bottom: 1.4rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 4px solid var(--primary);
  }
  .section h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
  }
  .section h3 {
    font-size: 0.95rem;
    color: var(--primary-light);
    margin: 1rem 0 0.5rem 0;
  }
  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.6rem;
  }
  .form-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .form-row.full { grid-template-columns: 1fr; }
  .form-group { margin-bottom: 0.8rem; }
  .form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  input[type="text"], input[type="number"], input[type="date"],
  input[type="email"], input[type="tel"],
  select, textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
  }
  textarea { resize: vertical; min-height: 60px; }
  .check-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }
  .check-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    padding: 0.25rem 0;
  }
  .check-item input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
  }
  .check-item-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    padding: 0.3rem 0;
  }
  .check-item-date input[type="date"] { width: 160px; }
  table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.85rem;
  }
  table.data-table th {
    background: var(--primary);
    color: white;
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
  }
  table.data-table td {
    padding: 0.3rem;
    border-bottom: 1px solid var(--border);
  }
  table.data-table input, table.data-table select {
    border: 1px solid #eee;
    padding: 0.3rem;
    font-size: 0.83rem;
  }
  .urgency-options { display: flex; flex-direction: column; gap: 0.5rem; }
  .urgency-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
  }
  .urgency-option:hover { background: #f8f9fa; }
  .urgency-option.selected-baja { border-color: var(--success); background: #eafaf1; }
  .urgency-option.selected-media { border-color: var(--warning); background: #fef9e7; }
  .urgency-option.selected-alta { border-color: var(--danger); background: #fdedec; }
  .urgency-option input[type="radio"] { margin-top: 0.2rem; }
  .urgency-option strong { font-size: 0.9rem; }
  .urgency-option p { font-size: 0.82rem; color: var(--text-light); margin-top: 0.2rem; }
  .signature-area {
    text-align: center;
    padding: 1.5rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    margin-top: 1rem;
  }
  .signature-pad-container {
    margin: 1rem auto;
    max-width: 450px;
  }
  .signature-pad-container canvas {
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: crosshair;
    width: 100%;
    background: white;
  }
  .signature-buttons { margin-top: 0.5rem; display: flex; gap: 0.5rem; justify-content: center; }
  .firma-preview { max-width: 200px; max-height: 80px; margin: 0.5rem auto; display: none; border: 1px dashed #ccc; }
  .tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: 1.2rem;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
  .tab {
    flex: 1;
    padding: 0.7rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    color: var(--text-light);
  }
  .tab:hover { background: #f0f0f0; }
  .tab.active { border-bottom-color: var(--primary); color: var(--primary); background: #e7f1ff; }

  /* Colores por sección/tab (6 tabs) */
  /* 1=Usuarios */
  .tab:nth-child(1).active  { border-bottom-color: #007BFF; color: #007BFF; background: #e7f1ff; }
  .tab:nth-child(1):hover   { background: #d0e4ff; }
  /* 2=Datos generales */
  .tab:nth-child(2).active  { border-bottom-color: #28A745; color: #28A745; background: #e6f7ec; }
  .tab:nth-child(2):hover   { background: #d4edda; }
  /* 3=Metodología */
  .tab:nth-child(3).active  { border-bottom-color: #6f42c1; color: #6f42c1; background: #f0e8f8; }
  .tab:nth-child(3):hover   { background: #e2d5f0; }
  /* 4=Ejes */
  .tab:nth-child(4).active  { border-bottom-color: #fd7e14; color: #fd7e14; background: #fff3e6; }
  .tab:nth-child(4):hover   { background: #ffe5cc; }
  /* 5=Reportes */
  .tab:nth-child(5).active  { border-bottom-color: #DC3545; color: #DC3545; background: #fce8ea; }
  .tab:nth-child(5):hover   { background: #f8d7da; }
  /* 6=Administración */
  .tab:nth-child(6).active  { border-bottom-color: #495057; color: #495057; background: #edf0f2; }
  .tab:nth-child(6):hover   { background: #dee2e6; }

  .tab-content { display: none; }
  .tab-content.active { display: block; }

  /* Borde lateral en h2 por sección */
  #tab6 .section h2 { border-left: 4px solid #007BFF; padding-left: 0.6rem; }
  #tab0 .section h2 { border-left: 4px solid #28A745; padding-left: 0.6rem; }
  #tab1 .section h2 { border-left: 4px solid #6f42c1; padding-left: 0.6rem; }
  #tab2 .section h2 { border-left: 4px solid #fd7e14; padding-left: 0.6rem; }
  #tab7 .section h2 { border-left: 4px solid #DC3545; padding-left: 0.6rem; }
  #tab9 .section h2 { border-left: 4px solid #495057; padding-left: 0.6rem; }
  .progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 1rem;
    overflow: hidden;
  }
  .progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
  }
  .notification {
    position: fixed;
    top: 70px;
    right: 20px;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 200;
    transform: translateX(120%);
    transition: transform 0.3s;
    font-size: 0.9rem;
  }
  .notification.show { transform: translateX(0); }
  .notification.success { background: var(--success); }
  .notification.error { background: var(--danger); }

  /* PRINT / EXPORT STYLES — Formato APA 7.a edición */
  .report-output {
    display: none;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 2.0;
    color: #000;
    background: white;
    padding: 2.54cm;
    max-width: 21.59cm;
    min-height: 27.94cm;
    margin: 0 auto;
    text-align: left;
  }
  .report-output h1 {
    font-size: 14pt;
    font-weight: bold;
    text-align: center;
    margin-bottom: 0;
    line-height: 2.0;
  }
  .report-output h2 {
    font-size: 12pt;
    font-weight: bold;
    text-align: left;
    margin: 0 0 0 0;
    padding-bottom: 0;
    border-bottom: none;
    line-height: 2.0;
  }
  .report-output h3 {
    font-size: 12pt;
    font-weight: bold;
    font-style: italic;
    text-align: left;
    margin: 0;
    line-height: 2.0;
  }
  .report-output p {
    margin: 0;
    text-align: left;
    text-indent: 1.27cm;
    line-height: 2.0;
  }
  .report-output p.no-indent {
    text-indent: 0;
  }
  .report-output table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.3cm 0;
    font-size: 10pt;
    line-height: 1.5;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
    text-align: left;
  }
  .report-output table th, .report-output table td {
    border: none;
    border-bottom: 1px solid #000;
    padding: 0.15cm 0.3cm;
    text-align: left;
  }
  .report-output table th {
    background: none;
    font-weight: bold;
    border-bottom: 1px solid #000;
  }
  .report-output table tr:last-child td {
    border-bottom: none;
  }

  .report-output .firma-block {
    text-align: right;
    margin-top: 2cm;
    page-break-inside: avoid;
  }
  .report-output .firma-block .firma-img-container {
    width: 10cm;
    margin-left: auto;
    margin-right: 0;
    text-align: center;
    margin-bottom: 0;
  }
  .report-output .firma-block .linea {
    border-top: none;
    width: 10cm;
    margin-left: auto;
    margin-right: 0;
    padding-top: 0.2cm;
    text-align: right;
  }
  .report-output .report-footer {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: 9pt;
    margin-top: 1.5cm;
    padding-top: 0.3cm;
    border-top: 1px solid #999;
    color: #555;
    text-align: left;
    text-indent: 0;
    line-height: 1.5;
  }
  .report-output .report-footer p {
    margin: 0 0 0.1cm 0;
    font-size: 9pt;
    text-indent: 0;
    line-height: 1.5;
  }
  .report-output .firma-img { max-width: 250px !important; max-height: 80px !important; display: block !important; margin: 0 auto !important; }
  .report-output .checklist-item { margin: 0.1cm 0; font-size: 10pt; text-indent: 0; }
  .report-output .fecha-top-right { text-align: right; margin-bottom: 0.2cm; font-size: 11pt; text-indent: 0; }
  .report-output .header-info { text-align: center; margin-bottom: 0.5cm; font-size: 11pt; text-indent: 0; }
  .report-output .urgencia-badge {
    display: inline-block;
    padding: 0.1cm 0.4cm;
    font-weight: bold;
    border: 2px solid #000;
    margin: 0.2cm 0;
    text-indent: 0;
  }
  @media print {
    body * { visibility: hidden; }
    .report-output, .report-output * { visibility: visible; }
    .report-output {
      display: block;
      position: absolute;
      left: 0; top: 0;
      width: 100%;
      padding: 2.54cm;
      font-size: 12pt;
      line-height: 2.0;
      text-align: left;
    }
    .report-output p {
      text-align: left;
      text-indent: 1.27cm;
    }
    .report-output p.no-indent {
      text-indent: 0;
    }
    @page {
      size: letter;
      margin: 2.54cm;
    }

    .report-output .report-footer {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 0.3cm 1cm;
      border-top: 1px solid #999;
      background: white;
      font-family: 'Times New Roman', Times, serif;
      font-style: italic;
      font-size: 9pt;
      color: #555;
    }
    .report-output .firma-img {
      max-width: 250px !important;
      max-height: 80px !important;
    }
    .app-header, .container, .notification { display: none !important; }
  }

  @media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .form-row.three { grid-template-columns: 1fr; }
    .check-group { grid-template-columns: 1fr; }
    .app-header { flex-direction: column; gap: 0.5rem; }
    .header-buttons { flex-wrap: wrap; justify-content: center; }
    .tab { font-size: 0.7rem; padding: 0.5rem 0.2rem; }
  }

  /* PACIENTES */
  .paciente-search {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center;
  }
  .paciente-search input {
    flex: 1; padding: 0.65rem 0.9rem; border: 2px solid var(--border);
    border-radius: 8px; font-size: 0.95rem;
    transition: border-color 0.2s;
  }
  .paciente-search input:focus {
    border-color: var(--primary); outline: none;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
  }
  .paciente-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem; margin-bottom: 0.8rem; display: flex; justify-content: space-between;
    align-items: center; transition: box-shadow 0.2s;
  }
  .paciente-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
  .paciente-info { flex: 1; }
  .paciente-info strong { font-size: 1rem; color: var(--text); }
  .paciente-info .paciente-dni { font-size: 0.85rem; color: var(--text-light); }
  .paciente-info .paciente-dir { font-size: 0.82rem; color: var(--text-light); margin-top: 0.2rem; }
  .paciente-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
  .badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px;
    font-size: 0.72rem; font-weight: 600; color: white;
  }
  .badge-cronico { background: #6f42c1; }
  .badge-judicializado { background: #DC3545; }
  .badge-discapacidad { background: #007BFF; }
  .badge-menor { background: #fd7e14; }
  .badge-adulto-mayor { background: #20c997; }
  .badge-riesgo { background: #e83e8c; }
  .badge-salud-mental { background: #6610f2; }
  .badge-carnet { background: #28A745; font-size: 0.7rem; }
  .paciente-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
  .paciente-actions .btn { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
  .btn-edit { background: var(--primary-light); color: white; }
  .btn-use { background: var(--success); color: white; }
  /* DRAWER LATERAL PARA FORMULARIO DE PACIENTE */
  .drawer-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35); z-index: 1000;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }
  .drawer-overlay.open { opacity: 1; visibility: visible; }
  .drawer-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 480px; max-width: 90vw; z-index: 1001;
    background: var(--card, #fff);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .drawer-overlay.open .drawer-panel { transform: translateX(0); }
  .drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
    background: var(--primary, #007BFF); color: white; flex-shrink: 0;
  }
  .drawer-header h3 { margin: 0; font-size: 1.05rem; }
  .drawer-close {
    background: none; border: none; color: white; font-size: 1.5rem;
    cursor: pointer; padding: 0; line-height: 1; opacity: 0.8;
  }
  .drawer-close:hover { opacity: 1; }
  .drawer-body {
    flex: 1; overflow-y: auto; padding: 1.2rem;
  }
  .paciente-form-container {
    display: block;
  }

  /* ESTADO VACIO - BUSQUEDA DE PACIENTES */
  /* SUB-TABS INTERNAS */
  .sub-tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
  }
  .sub-tab {
    padding: 0.6rem 1.2rem; font-size: 0.88rem; font-weight: 600;
    color: var(--text-light); cursor: pointer; border-bottom: 3px solid transparent;
    margin-bottom: -2px; transition: color 0.2s, border-color 0.2s;
  }
  .sub-tab:hover { color: var(--primary); }
  .sub-tab.active {
    color: var(--primary); border-bottom-color: var(--primary);
  }
  .sub-tab-content { display: none; }
  .sub-tab-content.active { display: block; }

  .paciente-empty-state {
    text-align: center; padding: 2.5rem 1rem;
    color: var(--text-light);
  }
  .paciente-empty-state .empty-icon {
    font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.5;
  }
  .paciente-empty-state .empty-title {
    font-size: 1.05rem; font-weight: 600; color: var(--text);
    margin-bottom: 0.3rem;
  }
  .paciente-empty-state .empty-subtitle {
    font-size: 0.88rem; color: var(--text-light);
  }
  .clasificaciones-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem;
  }
  .carnet-section {
    background: #e7f1ff; border: 1px solid #b8d4fe; border-radius: 8px;
    padding: 1rem; margin-top: 0.8rem;
  }

  /* PLANTILLA NARRATIVA — Formato APA */
  .plantilla-textarea {
    width: 100%; min-height: 200px; padding: 1rem;
    font-family: 'Times New Roman', Times, serif; font-size: 12pt;
    line-height: 2.0; border: 1px solid var(--border); border-radius: 6px;
    resize: vertical; text-align: left; tab-size: 4;
  }
  .plantilla-textarea-lg { min-height: 400px; }
  .plantilla-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
  .tab.tab-hidden { display: none; }

  /* Plantilla narrativa integrada en Ejes */
  .section.plantilla-integrada {
    border-left: 4px solid #17a2b8;
    background: #f0fafb;
  }

  /* MAPA GEOLOCALIZACIÓN */
  .mapa-container {
    margin-top: 0.8rem; padding: 1rem;
    background: #f8f9fa; border: 1px solid var(--border); border-radius: 8px;
  }
  .mapa-container h3 { margin-bottom: 0.5rem; }
  #mapaVisita { height: 350px; border-radius: 6px; border: 1px solid var(--border); margin-bottom: 0.5rem; }
  .mapa-coords {
    display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
    font-size: 0.85rem; color: var(--text-light); margin-top: 0.4rem;
  }
  .mapa-coords input { width: 130px; }
  .mapa-actions { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
  .btn-geo { background: #007BFF; color: white; }
  .btn-geo:disabled { background: #aaa; cursor: not-allowed; }

  /* LOGIN OVERLAY */
  .login-overlay {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #2563eb 100%);
    z-index: 1000;
    align-items: center;
    justify-content: center;
  }
  .login-box {
    background: rgba(255,255,255,0.97);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
    backdrop-filter: blur(8px);
  }
  .login-box h1 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
  }
  .login-box .tagline {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    font-style: italic;
  }
  .login-box .form-group {
    text-align: left;
    margin-bottom: 1rem;
  }
  .login-box .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
  }
  .login-box input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
  }
  .login-box .btn-login {
    width: 100%;
    padding: 0.8rem;
    background: #28A745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s;
  }
  .login-box .btn-login:hover {
    background: #218838;
  }
  .login-box .btn-login:disabled {
    background: #aaa;
    cursor: not-allowed;
  }
  .login-error {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.2rem;
    margin-top: 0.5rem;
  }

  /* USER INFO IN HEADER */
  .user-info-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: white;
    font-size: 0.85rem;
  }
  .user-info-container .user-name {
    font-weight: 600;
  }
  .user-info-container .user-role {
    opacity: 0.8;
    font-size: 0.78rem;
  }
  .btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    border: 1px solid rgba(255,255,255,0.3);
  }
  .btn-logout:hover {
    background: rgba(255,255,255,0.3);
  }

  /* STATS GRID - Contadores de reporte visitas */
  .stats-grid {
    display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.8rem 0;
  }
  .stat-card {
    flex: 1; min-width: 100px; padding: 0.8rem;
    background: var(--card); border-radius: 8px; text-align: center;
    border: 1px solid var(--border); border-left: 4px solid var(--text-light);
  }
  .stat-card .stat-num { font-size: 1.5rem; font-weight: 700; }
  .stat-card .stat-label { font-size: 0.75rem; color: var(--text-light); }

  /* VISITA CARDS por paciente */
  .visita-card {
    background: var(--card); border: 1px solid var(--border);
    border-left: 4px solid var(--text-light); border-radius: 8px;
    padding: 1rem; margin-bottom: 0.8rem;
  }
  .visita-card-header {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.3rem;
  }
  .visita-card-header strong { font-size: 1rem; }
  .visita-card-visits { margin-top: 0.5rem; font-size: 0.85rem; }
  .visita-card-visits .visita-item {
    padding: 0.3rem 0; border-bottom: 1px dashed var(--border);
    display: flex; gap: 0.5rem; align-items: baseline;
  }
  .visita-card-visits .visita-item:last-child { border-bottom: none; }
  .visita-card-info { font-size: 0.82rem; color: var(--text-light); margin-top: 0.2rem; }

  /* FOTO PACIENTE */
  .pac-foto-preview {
    width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--border); display: none;
  }
  .pac-foto-preview.visible { display: block; }
  .foto-paciente-container { display: flex; align-items: center; gap: 1rem; }
  .foto-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
  .paciente-card .pac-foto-mini {
    width: 45px; height: 45px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--border); margin-right: 0.8rem; flex-shrink: 0;
  }

  /* LOGIN TOGGLE & SUCCESS */
  .login-toggle {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--primary-light);
    cursor: pointer;
    text-decoration: underline;
  }
  .login-toggle:hover { color: var(--primary); }
  .login-success {
    background: #eafaf1;
    color: var(--success);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
  }

  /* USER CARDS - Gestion de usuarios */
  .user-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
  }
  .user-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
  .user-card-info { flex: 1; }
  .user-card-info strong { font-size: 1rem; color: var(--text); }
  .user-card-info .user-card-email { font-size: 0.85rem; color: var(--text-light); }
  .user-card-info .user-card-detail { font-size: 0.82rem; color: var(--text-light); margin-top: 0.2rem; }
  .user-card-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
  .user-card-actions .btn { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

  /* APPROVE / REJECT BUTTONS */
  .btn-approve { background: var(--success); color: white; }
  .btn-reject { background: var(--danger); color: white; }

  /* BADGE STATUS */
  .badge-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: white;
  }
  .badge-status.pendiente { background: var(--warning); }
  .badge-status.activo { background: var(--success); }
  .badge-status.inactivo { background: #6c757d; }

  /* TAB BADGE - Pending count */
  .tab-badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    margin-left: 0.3rem;
    vertical-align: top;
  }

  /* (Removed: tab 11 no longer exists) */

  /* FILTER ROW for user management */
  .filter-row {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center;
  }
  .filter-row select {
    padding: 0.5rem 0.7rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem;
  }

  /* BADGE MEDICACION */
  .badge-medicacion {
    background: #6f42c1;
    color: white;
    font-size: 0.7rem;
  }

  /* PANEL ALARMAS */
  .panel-alarmas {
    background: var(--card);
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 4px solid var(--warning);
    overflow: hidden;
  }
  .alarma-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
  }
  .alarma-header:hover {
    background: #fef9e7;
  }
  .alarma-header h3 {
    font-size: 0.9rem;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .alarma-toggle {
    font-size: 0.7rem;
    color: var(--text-light);
    transition: transform 0.2s;
  }
  .panel-alarmas-expanded .alarma-toggle {
    transform: rotate(180deg);
  }
  .alarma-body {
    padding: 0 1rem 0.8rem 1rem;
    max-height: 300px;
    overflow-y: auto;
  }
  .alarma-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.4rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
  }
  .alarma-item:hover {
    filter: brightness(0.95);
  }
  .alarma-item .alarma-icono {
    font-size: 1.1rem;
    flex-shrink: 0;
  }
  .alarma-item .alarma-texto {
    flex: 1;
  }
  .alarma-item .alarma-dias {
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
  }
  .alarma-amarilla {
    background: #fff8e1;
    border: 1px solid #ffc107;
    color: #856404;
  }
  .alarma-roja {
    background: #fce8ea;
    border: 1px solid #f5c6cb;
    color: #721c24;
  }
  .alarma-critica {
    background: #f5c6cb;
    border: 1px solid #DC3545;
    color: #491217;
    font-weight: 600;
  }
  .alarma-grupo {
    margin-bottom: 0.8rem;
  }
  .alarma-grupo h4 {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .tab-badge-alarmas {
    background: var(--warning);
  }

  /* Alarma badges en tarjetas de paciente */
  .pac-alarmas {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: 0.5rem;
    vertical-align: middle;
  }
  .pac-alarma {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: default;
    line-height: 1.3;
  }
  .pac-alarma-critica {
    background: #DC3545;
    color: #fff;
    animation: parpadeo 1.2s ease-in-out infinite;
  }
  .pac-alarma-roja {
    background: #fce8ea;
    border: 1px solid #DC3545;
    color: #721c24;
  }
  .pac-alarma-amarilla {
    background: #fff8e1;
    border: 1px solid #ffc107;
    color: #856404;
  }
  @keyframes parpadeo {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
  }

  /* TAB ICONS */
  .tab-icon {
    font-size: 1.1rem;
    display: block;
    margin: 0 auto 0.15rem auto;
  }

  /* BUTTON ICONS */
  .btn-icon {
    font-size: 1rem;
    vertical-align: middle;
  }

  /* ESTADISTICAS / DASHBOARD */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  .kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 1.2rem 1rem;
    text-align: center;
  }
  .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
  }
  .kpi-label {
    font-size: 0.82rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 0.3rem;
  }
  .charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
  }
  .chart-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
  }
  .chart-container h3 {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
  }
  .chart-container-wide {
    grid-column: 1 / -1;
  }
  @media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
  }

