/* Estilos del piloto - sobrios, coherentes con la propuesta */

:root {
  --primary: #1F4E79;
  --accent: #2E75B6;
  --light: #D9E2F3;
  --bg: #F7F9FC;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.topbar {
  background: var(--primary);
  color: white;
  padding: 14px 0;
  margin-bottom: 28px;
}
.brand { color: white; text-decoration: none; display: flex; align-items: baseline; gap: 14px; }
.brand-name { font-weight: 600; font-size: 18px; }
.brand-product { font-size: 13px; opacity: 0.8; }

footer { margin-top: 60px; padding: 24px 0; font-size: 13px; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}

h1 { font-size: 22px; color: var(--primary); margin: 0 0 12px; }
h2 { font-size: 18px; color: var(--accent); margin: 0 0 12px; }
h3 { font-size: 15px; color: var(--primary); margin: 20px 0 6px; }
.summary-title { font-size: 20px; }

.muted { color: var(--muted); font-size: 14px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field input, .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: white;
}

.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--accent); }
.btn-secondary {
  background: white; color: var(--primary); border-color: var(--primary);
  margin-left: 6px;
}
.btn-secondary:hover { background: var(--light); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }

.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pending { background: #e5e7eb; color: #374151; }
.status-transcribing { background: #fef3c7; color: #92400e; }
.status-summarizing { background: #dbeafe; color: #1e40af; }
.status-done { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.error {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca; padding: 10px 14px;
  border-radius: 6px; font-size: 14px; margin-top: 10px;
}

ul { margin: 6px 0 12px; padding-left: 22px; }
li { margin-bottom: 4px; }

.transcript {
  white-space: pre-wrap;
  background: #f3f4f6;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* Tabla de datos de reunion (cabecera del resumen) */
.meta-table {
  margin: 12px 0 18px;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.meta-table th {
  background: var(--light);
  color: var(--primary);
  padding: 6px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  min-width: 120px;
  border-bottom: 1px solid var(--border);
}
.meta-table td {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
}
.meta-table tr:last-child th,
.meta-table tr:last-child td { border-bottom: none; }

/* Bloque para propuestas/competencias evaluadas */
.prop-block {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 0 4px 4px 0;
  font-size: 14px;
}
.prop-block ul { margin: 4px 0; }

.badge {
  display: inline-block;
  background: var(--light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-super { background: #fce7f3; color: #9d174d; }
.badge-org { background: #e0f2fe; color: #075985; font-weight: 600; }
.badge-me { background: var(--primary); color: white; font-size: 11px; }

/* ============ Admin: usuarios con cards por org ============ */
.org-section {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  /* overflow visible para que los dropdowns "..." puedan salir del card */
  overflow: visible;
  background: white;
  position: relative;
}
.org-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}
.org-section table {
  border-radius: 0 0 8px 8px;
}
.org-section tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
.org-section tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
.org-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.org-section-title .org-icon {
  display: inline-flex;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #075985;
  align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.org-section-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  gap: 12px;
}
.org-section-meta .pill {
  background: white;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}
.org-section table {
  margin: 0;
  border: none;
  box-shadow: none;
}
.org-section thead {
  background: white;
}
.org-section th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.org-section tbody tr.row-me {
  background: #fff7ed;
  box-shadow: inset 3px 0 0 #ea580c;
}
.org-section tbody tr.user-inactive {
  opacity: 0.55;
}

/* Estado pills nuevos */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-pill.active { background: #dcfce7; color: #166534; }
.status-pill.active::before { background: #16a34a; }
.status-pill.inactive { background: #fee2e2; color: #991b1b; }
.status-pill.inactive::before { background: #dc2626; }

/* Selector rol modernizado */
.role-select {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}
.role-select:focus { outline: 2px solid var(--accent); }

/* Menú de acciones "..." */
.actions-menu {
  position: relative;
  display: inline-block;
}
.actions-menu-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.actions-menu-btn:hover { background: #f8fafc; color: var(--primary); }
.actions-menu-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.actions-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  z-index: 1000;
  overflow: hidden;
  padding: 4px 0;
}
/* Si el botón está cerca del borde inferior del card, abrir hacia arriba */
.actions-menu.open-up .actions-menu-dropdown {
  top: auto;
  bottom: calc(100% + 4px);
}
.actions-menu.open .actions-menu-dropdown { display: block; }
.actions-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.actions-menu-dropdown button:hover { background: #f1f5f9; }
.actions-menu-dropdown button.danger { color: #b91c1c; }
.actions-menu-dropdown button.danger:hover { background: #fef2f2; }
.actions-menu-dropdown .menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.actions-menu-dropdown .menu-section-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 6px 14px 2px;
  letter-spacing: 0.06em;
}

/* Toolbar superior del panel */
.users-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.users-toolbar .toolbar-spacer { flex: 1; }
.users-toolbar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; min-width: 220px; }
.users-summary {
  margin: 6px 0 2px;
  color: #64748b;
  font-size: 13px;
}

/* ============ Historial: chips por tipo de reunión ============ */
.meeting-type-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.type-acta        { background: #dbeafe; color: #1e3a8a; }
.type-consultoria { background: #e9d5ff; color: #6b21a8; }
.type-evaluacion  { background: #fef3c7; color: #92400e; }
.type-entrevista  { background: #ccfbf1; color: #115e59; }
.type-comite      { background: #fee2e2; color: #991b1b; }
.type-comercial   { background: #dcfce7; color: #166534; }
.type-soporte     { background: #ffedd5; color: #9a3412; }

.jobs-table { margin: 0; box-shadow: none; border: none; }
.jobs-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
}
.job-name {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.job-name:hover { text-decoration: underline; }
.job-org-section + .job-org-section { margin-top: 14px; }

/* ============ Página de detalle de reunión (job.html) con pestañas ============ */
.job-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}
.job-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.job-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.job-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.job-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.job-chip .chip-label {
  color: #64748b;
  font-weight: 500;
}
.job-chip .chip-value {
  font-weight: 600;
  color: var(--text);
}
.job-chip select.chip-select {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 12px;
  padding: 0 4px;
  cursor: pointer;
  color: var(--primary);
}
.job-chip select.chip-select:focus { outline: none; }
.job-id-code {
  font-family: SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: #64748b;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin: 16px 0 0;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: color .12s, border-color .12s;
  white-space: nowrap;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-btn .tab-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  font-weight: 700;
}
.tab-panel {
  display: none;
  padding-top: 18px;
}
.tab-panel.active { display: block; }

/* Cabecera del panel Resumen */
.summary-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

/* Estado pill grande */
.status-big {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-big::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-big.s-done    { background: #dcfce7; color: #166534; }
.status-big.s-done::before { background: #16a34a; }
.status-big.s-error   { background: #fee2e2; color: #991b1b; }
.status-big.s-error::before { background: #dc2626; }
.status-big.s-pending,
.status-big.s-transcribing,
.status-big.s-summarizing { background: #fef3c7; color: #92400e; }
.status-big.s-pending::before,
.status-big.s-transcribing::before,
.status-big.s-summarizing::before { background: #ea580c; animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Botón danger zone en panel "Más" */
.danger-zone {
  border: 1px dashed #dc2626;
  border-radius: 8px;
  padding: 16px;
  background: #fef2f2;
  margin-top: 16px;
}
.danger-zone h3 {
  margin: 0 0 6px;
  color: #991b1b;
  font-size: 14px;
}

/* ============ Dashboard ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--primary);
}
.kpi-card.kpi-accent::before { background: var(--accent); }
.kpi-card.kpi-ok::before { background: #16a34a; }
.kpi-card.kpi-warn::before { background: #ea580c; }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 600;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0 0;
  line-height: 1.1;
}
.kpi-unit { font-size: 14px; color: #64748b; font-weight: 500; margin-left: 4px; }
.kpi-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}
@media (max-width: 800px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.chart-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--primary);
}
.chart-canvas-wrap {
  position: relative;
  height: 260px;
}

.dashboard-recent {
  margin-top: 18px;
}
.dashboard-recent table { margin: 0; }
.dashboard-recent th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 600;
}
.org-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.org-bar-name { min-width: 160px; font-weight: 600; font-size: 13px; }
.org-bar-track {
  flex: 1;
  height: 14px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}
.org-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
}
.org-bar-count {
  min-width: 50px;
  text-align: right;
  font-weight: 700;
  font-size: 13px;
}

/* Plan SaaS - tarjeta destacada en dashboard */
.plan-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.plan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.plan-card-name {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
.plan-card-name .plan-pill {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}
.plan-card-numbers {
  font-size: 22px;
  font-weight: 700;
}
.plan-card-numbers .small { font-size: 14px; opacity: 0.75; font-weight: 500; }

.plan-progress-track {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  position: relative;
}
.plan-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .35s ease;
}
.plan-progress-fill.lvl-ok    { background: #22c55e; }
.plan-progress-fill.lvl-warn  { background: #f59e0b; }
.plan-progress-fill.lvl-crit  { background: #ef4444; }
.plan-progress-fill.lvl-over  { background: #b91c1c; }

.plan-card-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.92;
}
.plan-card-meta .extra-cost {
  background: rgba(255,255,255,0.18);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}

.plan-empty {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  color: #64748b;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Tabla detallada de orgs para superadmin */
.orgs-margin-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.orgs-margin-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: #64748b; font-weight: 600; text-align: left;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.orgs-margin-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; }
.orgs-margin-table tr:last-child td { border-bottom: none; }
.orgs-margin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.orgs-margin-table .num-detail { text-align: right; font-variant-numeric: tabular-nums; padding-right: 12px; }
.orgs-margin-table .num-detail .main { font-weight: 600; }
.orgs-margin-table .num-detail .sub  { font-size: 11px; color: #64748b; margin-top: 2px; font-variant-numeric: normal; }
.orgs-margin-table .margin-pos { color: #166534; font-weight: 700; }
.orgs-margin-table .margin-neg { color: #991b1b; font-weight: 700; }
.orgs-margin-table .dash { color: #cbd5e1; }
.orgs-margin-table .plan-none { color: #94a3b8; font-style: italic; font-size: 12px; }
.orgs-margin-table tbody tr:hover { background: #f8fafc; }
.orgs-margin-table tbody td { vertical-align: middle; }

/* ============ Página de ayuda ============ */
.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.help-toc a {
  display: inline-block;
  padding: 5px 12px;
  background: var(--light);
  color: var(--primary);
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.help-toc a:hover { background: var(--primary); color: white; }
.help-steps { padding-left: 22px; line-height: 1.7; }
.help-steps li { margin-bottom: 4px; }
.help-type {
  border-left: 4px solid var(--primary);
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
}
.help-type p { margin: 8px 0 0; font-size: 14px; }
.help-faq {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  background: white;
}
.help-faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  font-size: 14px;
  list-style: none;
}
.help-faq summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform .15s;
  color: var(--accent);
}
.help-faq[open] summary::before { content: "▾ "; }
.help-faq p { margin: 10px 0 0; font-size: 14px; }
.help-faq ul { font-size: 14px; }

/* Botón "?" pequeño junto al selector de tipo */
.type-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--primary);
  background: white;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
.type-help-btn:hover {
  background: var(--primary);
  color: white;
}

/* ============ MOBILE RESPONSIVE ============ */

/* Botón hamburguesa (oculto en escritorio) */
.topbar-menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

@media (max-width: 768px) {
  /* Cabecera */
  .topbar-row {
    position: relative;
    flex-wrap: nowrap;
  }
  .brand-name { font-size: 14px; }
  .brand-product { font-size: 12px; }
  .topbar-menu-toggle { display: inline-block; }

  .user-menu {
    display: none !important;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--primary);
    padding: 10px 16px;
    z-index: 200;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    gap: 4px;
  }
  .user-menu.open { display: flex !important; }
  .user-menu .user-info,
  .user-menu .user-link,
  .user-menu .user-link-btn {
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    width: 100%;
    text-align: left;
  }
  .user-menu .user-link-btn { background: transparent; border: 0; color: white; cursor: pointer; }

  /* Tabla de admin_users como cards en móvil */
  .org-section { overflow: visible; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; box-sizing: border-box; }
  .admin-table tr {
    margin: 0 0 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
  }
  .admin-table tr.row-me { background: #fff7ed; box-shadow: inset 4px 0 0 #ea580c; }
  .admin-table td {
    padding: 6px 0;
    border: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .admin-table td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 600;
    flex-shrink: 0;
  }
  .admin-table td:first-child { flex-direction: column; align-items: flex-start; }
  .admin-table td:first-child::before { display: none; }
  .admin-table td.num { justify-content: flex-end; }

  /* Tabla de jobs/historial: simplificar columnas en móvil */
  .jobs-table thead { display: none; }
  .jobs-table, .jobs-table tbody, .jobs-table tr { display: block; width: 100%; }
  .jobs-table tr {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .jobs-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: 0;
    gap: 12px;
  }

  /* Cards generales con más aire */
  .container { padding: 0 12px; }
  .card { padding: 16px 14px; }
  h1 { font-size: 22px !important; }
  h2 { font-size: 18px !important; }

  /* Filtros del historial: que se apilen */
  .row-between { flex-wrap: wrap; gap: 8px; }

  /* KPIs del dashboard: 1 columna */
  .kpi-grid { grid-template-columns: 1fr !important; }
  .chart-grid { grid-template-columns: 1fr !important; }

  /* Pestañas del job con scroll horizontal si no caben */
  .tabs-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 12px; font-size: 13px; }

  /* Tabla orgs-margin con cards */
  .orgs-margin-table thead { display: none; }
  .orgs-margin-table, .orgs-margin-table tbody, .orgs-margin-table tr, .orgs-margin-table td { display: block; width: 100%; }
  .orgs-margin-table tr { margin: 0 0 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
}

/* Checkbox del upload */
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: normal; cursor: pointer; user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; cursor: pointer;
}
.help-text { font-size: 12px; margin: 6px 0 0 26px; }

/* Historial acumulado de instrucciones aplicadas */
.history-list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px 10px 32px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text);
}
.history-list li { margin: 4px 0; line-height: 1.4; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover { color: var(--primary); }
.btn-link.btn-danger { color: var(--err); }
.btn-link.btn-danger:hover { color: #991b1b; }
.btn-link.btn-danger:disabled { color: var(--muted); cursor: wait; }
.btn-link.btn-edit-title {
  font-size: 14px;
  text-decoration: none;
  margin-left: 4px;
  padding: 0 4px;
  opacity: 0.55;
}
.btn-link.btn-edit-title:hover { opacity: 1; }
.file-orig { font-size: 12px; margin-top: 2px; font-style: italic; }

/* Caja de regenerar resumen con instrucciones */
.regen-textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: white;
  resize: vertical;
  box-sizing: border-box;
}
.regen-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.15);
}

/* Aviso de calidad de transcripcion */
.quality-note {
  background: #fef3c7;
  border-left: 4px solid var(--warn);
  color: #78350f;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin: 12px 0 16px;
}

/* Topbar con menú de usuario */
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: white;
}
.user-info {
  opacity: 0.9;
}
.user-role-badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  color: white;
  font-size: 11px;
  text-transform: uppercase;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.04em;
}
.user-role-badge-super {
  background: #ec4899;
  color: white;
}
.user-link {
  color: white;
  text-decoration: none;
  opacity: 0.85;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 4px 8px;
}
.user-link:hover {
  opacity: 1;
  text-decoration: underline;
}
.user-link-btn {
  /* nada extra, ya está estilado como .user-link */
}

/* Tabla simple para listados administrativos */
.admin-table { font-size: 14px; }
.admin-table td .role-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--light);
  color: var(--primary);
}
.admin-table td.actions { white-space: nowrap; }
.user-inactive { opacity: 0.5; }
