/* =====================================================================
   cloud / style.css
   Sistema de diseno unico para toda la app. Ver DESIGN.md.
   ===================================================================== */

/* 1. Tokens */
:root {
  --bg:        #1a1a1a;
  --surface:   #242526;
  --border:    #383838;
  --row-hover: #2d2e2f;
  --primary:   #D08310;
  --primary-h: #B06E0D;
  --primary-fg: #fff;      /* texto/borde para usar SOBRE el primary */
  --danger:    #e62a2a;
  --success:   #22c55e;
  --warn:      #f59e0b;
  --info:      #3b82f6;
  --purple:    #8b5cf6;
  --text:      #f0f0f0;
  --muted:     #9ca0a4;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.65);

  /* Paleta categorica de los graficos del dashboard. Son DOS series y el
     orden es fijo: --serie-1 primero, --serie-2 despues; nunca se cicla.
     No se reusan los tokens semanticos (--success/--warn) porque esos estan
     reservados para estados. Validada con el script de la skill `dataviz`
     para modo oscuro sobre --surface: banda de luminosidad, piso de croma,
     separacion CVD (ΔE 30.3 protan / 24.9 tritan), piso de vision normal
     (ΔE 32.8) y contraste >= 3:1. Si se cambian, hay que volver a validar. */
  --serie-1:   #c87f10;
  --serie-2:   #3b82f6;
}

/* 2. Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* 3. Layout */
.layout  { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--primary);
           border-right: 1px solid rgba(0,0,0,.25);
           display: flex; flex-direction: column; flex-shrink: 0; }
.main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar  { background: var(--primary);
           border-bottom: 1px solid rgba(0,0,0,.25);
           padding: 0 24px; height: 60px;
           display: flex; align-items: center; justify-content: space-between;
           box-shadow: var(--shadow); position: relative; }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* 4. Sidebar */
.sidebar-logo       { height: 60px; padding: 0 20px;
                      border-bottom: 1px solid rgba(0,0,0,.2);
                      display: flex; align-items: center; justify-content: center;
                      flex-shrink: 0; }
.sidebar-logo-mark  { display: block; width: 133px; height: 39px;
                      max-width: 100%; object-fit: contain;
                      margin-top: -3px; }
/* `flex: 1` para que la navegacion ocupe el 100% del alto restante: el shell
   NO lleva footer de version al pie (ver crear_backoffice §3). */
.sidebar-nav        { padding: 8px 0 12px; flex: 1; overflow-y: auto; }

.nav-item { display: flex; align-items: center; gap: 10px;
            padding: 10px 20px; font-size: .9rem; color: rgba(255,255,255,.85);
            cursor: pointer; border-left: 3px solid transparent;
            transition: background .15s, color .15s; text-decoration: none; }
.nav-item:hover  { background: rgba(0,0,0,.18); color: var(--primary-fg); }
.nav-item.active { background: rgba(0,0,0,.28); color: var(--primary-fg);
                   border-left-color: var(--primary-fg); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* Grupos colapsables del sidebar (DESIGN.md §4) */
.nav-group-wrap                       { display: block; }
.nav-group-toggle                     { width: 100%; background: none; border: none;
                                        text-align: left; cursor: pointer;
                                        font-family: inherit; color: rgba(255,255,255,.85); }
.nav-group-label                      { flex: 1; }
.nav-group-arrow                      { margin-left: auto; font-size: 1rem; font-weight: 700;
                                        line-height: 1; color: rgba(255,255,255,.7);
                                        transition: transform .2s; }
.nav-group-wrap.open .nav-group-arrow { transform: rotate(45deg); }
.nav-sub                              { display: none; background: rgba(0,0,0,.18);
                                        border-top: 1px solid rgba(0,0,0,.2);
                                        border-bottom: 1px solid rgba(0,0,0,.2); }
.nav-group-wrap.open .nav-sub         { display: block; }
.nav-sub-item                         { padding-left: 44px; font-size: .85rem; }
.nav-sub-item.active                  { background: rgba(0,0,0,.32); }

/* 5. Topbar */
.topbar-title    { font-size: 1rem; font-weight: 600; flex: 1; color: var(--primary-fg); }
.topbar-user     { display: flex; align-items: center; gap: 10px; flex-shrink: 0;
                   position: relative; }
.topbar-username { background: none; border: none; cursor: pointer;
                   font-size: .85rem; color: rgba(255,255,255,.85);
                   display: flex; align-items: center; gap: 4px;
                   padding: 6px 10px; border-radius: 8px;
                   transition: background .15s, color .15s; font-family: inherit; }
.topbar-username:hover { background: rgba(0,0,0,.18); color: var(--primary-fg); }

.topbar .hamburger { color: var(--primary-fg); }

.user-dropdown   { display: none; position: absolute; right: 0; top: calc(100% + 6px);
                   background: var(--surface); border: 1px solid var(--border);
                   border-radius: 10px; box-shadow: var(--shadow-lg);
                   min-width: 180px; overflow: hidden; z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown .action-menu-item { display: flex; align-items: center; gap: 10px; width: 100%;
                                   padding: 10px 16px; font-size: .85rem; color: var(--text);
                                   background: none; border: none; cursor: pointer;
                                   text-align: left; font-family: inherit; }
.user-dropdown .action-menu-item:hover:not(:disabled) { background: var(--bg); color: var(--primary); }
.user-dropdown .action-menu-item:disabled { opacity: .5; cursor: not-allowed; }
.user-dropdown .action-menu-item i { width: 16px; text-align: center; color: var(--muted); }

/* 6. Botones */
.btn { padding: 8px 16px; border-radius: var(--radius); border: none;
       font-size: .88rem; font-weight: 600; cursor: pointer;
       display: inline-flex; align-items: center; gap: 6px;
       transition: background .15s, transform .1s; font-family: inherit; }
.btn:active        { transform: scale(.97); }
.btn-primary       { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger        { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c91515; }
.btn-secondary     { background: var(--surface); color: var(--text);
                     border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover           { background: inherit; }
.btn-ghost         { background: transparent; color: var(--muted);
                     border: 1px solid var(--border); }
.btn-ghost:hover   { background: var(--bg); color: var(--text); }
.btn-sm            { padding: 5px 12px; font-size: .8rem; }
.btn-icon-sm       { background: none; border: none; cursor: pointer;
                     padding: 4px 8px; border-radius: 6px; font-size: .85rem;
                     color: var(--muted); font-family: inherit; }
.btn-icon-sm:hover { background: var(--bg); color: var(--text); }

/* 10. Tablas */
.table-card { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); box-shadow: var(--shadow);
              overflow-x: auto; overflow-y: hidden; }
table       { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead tr    { background: var(--bg); }
th          { padding: 10px 14px; text-align: left;
              font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--muted); font-weight: 600;
              border-bottom: 1px solid var(--border); white-space: nowrap; }
td          { padding: 10px 14px; border-bottom: 1px solid var(--border);
              vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
.td-nombre  { font-weight: 600; }
.td-id      { color: var(--muted); font-size: .8rem; }
.table-empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* 11. Badges */
.badge         { display: inline-block; padding: 2px 10px;
                 border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-info    { background: rgba(59,130,246,.18); color: #93c5fd; }
.badge-success { background: rgba(34,197,94,.18);  color: #86efac; }
.badge-danger  { background: rgba(230,42,42,.2);   color: #f5a8a8; }
.badge-warn    { background: rgba(245,158,11,.18); color: #fcd34d; }

/* 12. Stat cards */
.stats-bar  { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card  { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); padding: 14px 20px;
              display: flex; flex-direction: column; gap: 2px;
              flex: 1; min-width: 140px; }
.stat-label { font-size: .75rem; color: var(--muted);
              text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-value.green  { color: var(--success); }
.stat-value.orange { color: var(--primary); }
.stat-value.red    { color: var(--danger); }
.stat-value.blue   { color: var(--info); }

.dash-link { cursor: pointer; transition: opacity .15s; }
.dash-link:hover { opacity: .75; }
.stat-card.dash-link:hover { background: var(--bg); }

/* 13. Dashboard grid */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 4px; }
.dash-table-header { padding: 14px 20px 10px;
                     font-weight: 600; font-size: .95rem;
                     border-bottom: 1px solid var(--border);
                     display: flex; align-items: center; justify-content: space-between; }
.dash-ver-mas      { font-size: .78rem; font-weight: 500; color: var(--primary); cursor: pointer; }
.dash-ver-mas:hover { text-decoration: underline; }

/* 18. Spinner */
.spin { display: inline-block; width: 28px; height: 28px;
        border: 3px solid var(--border); border-top-color: var(--primary);
        border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 19. Responsive */
.hamburger        { display: none; background: none; border: none; cursor: pointer;
                    font-size: 1.4rem; color: var(--text);
                    padding: 4px 8px; margin-right: 8px; line-height: 1; }
.sidebar-overlay  { display: none; position: fixed; inset: 0;
                    background: rgba(0,0,0,.45); z-index: 199; }
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  .hamburger { display: inline-flex; align-items: center; }
  .sidebar   { position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
               transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .dash-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}

/* 7. Inputs, selects, textareas */
input[type=text], input[type=number], input[type=url], input[type=tel],
input[type=email], input[type=date], input[type=time], input[type=datetime-local],
input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: .88rem; background: var(--surface);
  color: var(--text); outline: none; transition: border .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(208,131,16,.25);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  color: var(--muted); background: var(--bg); cursor: not-allowed; opacity: .75;
}
textarea { resize: vertical; min-height: 60px; }

.field-error   { margin-top: 4px; font-size: .78rem; color: var(--danger); }
.input-invalid { border-color: var(--danger) !important;
                 box-shadow: 0 0 0 2px rgba(239,68,68,.18); }

/* 8. Formularios */
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row-4  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: .8rem; font-weight: 600; color: var(--muted);
}
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }

/* 9. Toolbar */
.toolbar       { display: flex; align-items: center; gap: 12px;
                 flex-wrap: wrap; margin-bottom: 20px; }
.toolbar-left  { display: flex; align-items: center; gap: 10px;
                 flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; }

.search-wrap        { position: relative; display: inline-flex; align-items: center; }
/* 300px y no 240: los placeholders de este panel enumeran los campos por los
   que busca cada modulo ("nombre, DNI, teléfono o correo") y con 240 quedaban
   cortados justo donde empieza la lista. */
.search-wrap .search-input { width: 300px; max-width: 100%; padding-right: 28px; }
.search-clear       { position: absolute; right: 6px; background: none; border: none;
                      cursor: pointer; color: var(--muted); font-size: 1.1rem;
                      padding: 2px 4px; border-radius: 50%; transition: color .15s; }
.search-clear:hover { color: var(--text); }

.filter-chip        { padding: 6px 12px; border-radius: 20px;
                      border: 1.5px solid var(--border);
                      font-size: .8rem; font-weight: 600; cursor: pointer;
                      white-space: nowrap; background: var(--surface);
                      color: var(--muted); transition: all .15s;
                      font-family: inherit; }
.filter-chip:hover  { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }

/* Encabezado de modulo (titulo + subtitulo de pagina) */
.page-header   { margin-bottom: 20px; }
.page-title    { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-subtitle { margin-top: 4px; font-size: .88rem; color: var(--muted); }

/* Acciones de fila (iconos de la columna Acciones) */
.actions          { display: flex; gap: 6px; align-items: center; }
.action-icon      { background: none; border: none; cursor: pointer;
                    padding: 6px 8px; border-radius: 6px; color: var(--muted);
                    font-size: .95rem; transition: background .15s, color .15s;
                    font-family: inherit; }
.action-icon:hover           { background: var(--bg); color: var(--text); }
.action-icon.view:hover      { color: var(--info); }
.action-icon.edit:hover      { color: var(--primary); }
.action-icon.delete:hover    { color: var(--danger); }
.action-icon:disabled,
.action-icon[disabled]       { opacity: .4; cursor: not-allowed; }
.action-icon:disabled:hover  { background: none; color: var(--muted); }

/* 14. Modales */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45);
                  display: flex; align-items: center; justify-content: center;
                  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
/* El scroll es del CUERPO, no del modal entero: las dos barras de arriba
   (titulo + acciones) quedan fijas aunque el contenido sea largo. El
   `min-height: 0` del body NO es opcional: sin el, un hijo flex no baja de su
   alto de contenido y el `overflow-y` nunca se activa. */
.modal          { background: var(--surface); border-radius: 14px;
                  width: 100%; max-width: 520px; max-height: 90vh;
                  overflow: hidden; display: flex; flex-direction: column;
                  box-shadow: var(--shadow-lg);
                  transform: scale(.96) translateY(12px); transition: transform .2s; margin: 16px; }
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header   { padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
                  display: flex; align-items: center; justify-content: space-between; }
.modal-title    { font-size: 1rem; font-weight: 700;
                  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.modal-subtitle { font-size: .8rem; font-weight: 500; color: var(--muted); }
.modal-body     { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px;
                  flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-footer   { padding: 16px 24px; border-top: 1px solid var(--border);
                  display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.modal-header, .modal-menubar, .modal-footer { flex: 0 0 auto; }
.modal.modal-wide { max-width: 760px; }
.modal.modal-xl   { max-width: 1040px; }
.modal.modal-tall { height: 90vh; }

/* 14-bis. Estandar de modales: barra de titulo en --primary + barra de
   acciones debajo, y SIN footer (ver ABM.md §Estandar de modales). */
.modal-header-primary {
  background: var(--primary); color: #fff;
  border-bottom: none;
  border-radius: 14px 14px 0 0;   /* mismo radio que el .modal */
  padding: 10px 24px;
}
.modal-header-primary .modal-title       { color: #fff; }
.modal-header-primary .modal-subtitle    { color: rgba(255,255,255,.75); }
.modal-header-primary .btn-icon-sm,
.modal-header-primary .btn-ghost         { color: #fff; }
.modal-header-primary .btn-icon-sm:hover { background: rgba(255,255,255,.18); color: #fff; }

.modal-menubar {
  /* 14px y no los 10 del titulo: aca hay botones de ~30px de alto. */
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  /* Un escalon mas oscuro que el cuerpo. La mezcla va ENTRE TOKENS para que
     el tono siga al tema y no a un #000 fijo. */
  background: color-mix(in srgb, var(--surface) 40%, var(--bg));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.modal-menubar .btn             { white-space: nowrap; padding: 5px 12px; font-size: .8rem; }
.modal-menubar .btn-ghost       { background: var(--surface); color: var(--text); }
.modal-menubar .btn-ghost:hover { background: var(--row-hover); color: var(--text); }
.modal-menubar-end  { margin-left: auto; }
.menubar-caret      { font-size: .7em; opacity: .65; margin-left: 2px; }

/* Nota al pie del cuerpo del modal: habla del formulario entero, no de un
   campo (lo de un campo va en el globito de .field-help). */
.modal-nota { font-size: .78rem; color: var(--muted); line-height: 1.5; }

/* 15. Confirm dialog */
.confirm-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5);
                    display: flex; align-items: center; justify-content: center;
                    z-index: 150; opacity: 0; pointer-events: none; transition: opacity .15s; }
.confirm-backdrop.open { opacity: 1; pointer-events: all; }
.confirm-box     { background: var(--surface); border-radius: 14px;
                   padding: 28px 28px 20px; max-width: 380px;
                   width: calc(100% - 32px); box-shadow: var(--shadow-lg);
                   transform: scale(.95); transition: transform .15s; }
.confirm-backdrop.open .confirm-box { transform: scale(1); }
.confirm-title   { font-weight: 700; margin-bottom: 8px; }
.confirm-msg     { font-size: .88rem; color: var(--muted); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* 22. Lista de datos (Consultar) */
.data-list  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.data-row   { background: color-mix(in srgb, var(--surface) 90%, #000);
              border-radius: var(--radius); padding: 12px 14px;
              display: flex; flex-direction: column; gap: 4px; border: none; }
.data-row.full   { grid-column: 1 / -1; }
.data-label      { font-size: .72rem; font-weight: 600;
                   text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.data-value      { font-size: .9rem; color: var(--text);
                   word-break: break-word; white-space: pre-wrap; }
.data-value.muted{ color: var(--muted); font-style: italic; }
.data-value code { font-family: monospace; font-size: .85rem;
                   background: var(--bg); border: 1px solid var(--border);
                   border-radius: 6px; padding: 2px 8px; }
@media (max-width: 768px) {
  .data-list { grid-template-columns: 1fr; }
}

/* 24. Tile grid (menu de navegacion / lanzadores) */
.tile-grid  { display: grid;
              grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
              gap: 16px; }
.tile-card  { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); padding: 20px;
              display: flex; flex-direction: column; gap: 6px;
              text-align: left; cursor: pointer; text-decoration: none;
              color: var(--text); font-family: inherit;
              transition: border-color .15s, background .15s, transform .1s; }
.tile-card:hover  { border-color: var(--primary); background: var(--row-hover); }
.tile-card:active { transform: scale(.98); }
.tile-icon  { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.tile-title { font-weight: 600; font-size: .95rem; color: var(--text); }
.tile-desc  { font-size: .8rem; color: var(--muted); }

/* 16. Toasts */
.toast { position: fixed; bottom: 24px; left: 50%;
         transform: translateX(-50%) translateY(16px);
         background: #0d0d0d; color: var(--text);
         border: 1px solid var(--border);
         padding: 10px 20px; border-radius: 99px;
         font-size: .88rem; opacity: 0; pointer-events: none;
         transition: opacity .2s, transform .2s;
         z-index: 200; white-space: nowrap;
         box-shadow: var(--shadow-lg); }
.toast.show  { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---- Auth: splash + login ---- */
.auth-checking .layout,
.auth-checking .login-screen,
.is-app .login-screen,
.is-app .auth-splash,
.is-login .layout,
.is-login .auth-splash { display: none !important; }

.auth-splash { position: fixed; inset: 0; display: flex;
               align-items: center; justify-content: center;
               background: var(--bg); z-index: 300; }

.login-screen { position: fixed; inset: 0; display: flex;
                align-items: center; justify-content: center;
                background: var(--bg); padding: 20px; z-index: 250; }

.login-card { width: 100%; max-width: 360px;
              background: var(--surface); border: 1px solid var(--border);
              border-radius: 14px; padding: 28px 24px;
              box-shadow: var(--shadow-lg);
              display: flex; flex-direction: column; gap: 14px; }

.login-logo  { width: 157px; height: 46px; object-fit: contain;
               margin: 0 auto 4px; }
.login-title { text-align: center; font-size: 1.05rem;
               font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-submit { margin-top: 6px; padding: 10px 16px; font-size: .95rem; }
.login-submit:disabled { opacity: .65; cursor: not-allowed; }

/* 25. Tarjeta de ayuda del módulo (ABM.md §Tarjeta de ayuda) */
.module-help { background: var(--surface); border: 1px solid var(--border);
               border-radius: var(--radius); padding: 14px 18px;
               margin-bottom: 16px; box-shadow: var(--shadow);
               display: flex; gap: 14px; align-items: center; }
.module-help .module-help-icon { font-size: 1.6rem; line-height: 1; }
.module-help .module-help-text { font-size: .88rem; color: var(--muted); line-height: 1.45; }

/* 26. Botones solo-ícono de la toolbar (ABM.md §Botones solo-ícono) */
.btn.btn-icon       { position: relative; width: 36px; height: 36px;
                      padding: 0; justify-content: center; }
.btn.btn-icon i     { font-size: .95rem; }
.btn.btn-icon.active { background: transparent;
                       border-color: var(--primary); color: var(--primary); }
.btn-icon-badge     { position: absolute; top: -4px; right: -4px;
                      min-width: 18px; height: 18px; padding: 0 5px;
                      border-radius: 99px; background: var(--warn); color: #1a1a1a;
                      font-size: .65rem; font-weight: 700; line-height: 1;
                      display: inline-flex; align-items: center; justify-content: center; }

/* 27. Menú contextual (filas del listado y modal Consultar) */
/* `max-height` + scroll porque los menus de los modulos con muchas acciones
   propias (Deudas lista sus siete cambios de estado) no entran en pantallas
   bajas, y un menu recortado esconde justo la accion del fondo. */
.ctx-menu        { position: fixed; z-index: 300; display: none;
                   min-width: 190px; max-height: 80vh; overflow-y: auto;
                   background: var(--surface); border: 1px solid var(--border);
                   border-radius: 10px; box-shadow: var(--shadow-lg);
                   padding: 4px 0; }
.ctx-menu.open   { display: block; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%;
                   padding: 8px 14px; background: none; border: none; cursor: pointer;
                   font-size: .85rem; color: var(--text);
                   text-align: left; font-family: inherit; }
.ctx-menu button:hover:not(:disabled)   { background: var(--bg); color: var(--primary); }
.ctx-menu button:disabled               { opacity: .5; cursor: not-allowed; }
.ctx-menu button i                      { width: 14px; text-align: center; color: var(--muted); }
.ctx-menu button:hover:not(:disabled) i { color: inherit; }
.ctx-menu-sep    { height: 1px; background: var(--border); margin: 4px 0; }
.ctx-menu-danger { color: var(--danger); }
.ctx-menu-danger:hover:not(:disabled),
.ctx-menu-danger:hover:not(:disabled) i { background: var(--danger) !important;
                                          color: #fff !important; }

/* 28. Filas del listado clickeables (ABM.md §Interacción con la fila) */
tbody tr.row-clickable { cursor: pointer; }

/* ---- Lista de permisos (ABM de Roles) ---- */
.perm-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
                margin-bottom: 8px; }
.perm-list    { border: 1px solid var(--border); border-radius: var(--radius);
                background: var(--bg); max-height: 280px; overflow-y: auto; }
.perm-item    { display: flex; align-items: center; gap: 10px;
                padding: 8px 12px; border-bottom: 1px solid var(--border);
                cursor: pointer; transition: background .15s; }
.perm-item:last-child { border-bottom: none; }
.perm-item:hover      { background: var(--row-hover); }
.perm-check   { width: 16px; height: 16px; accent-color: var(--primary);
                cursor: pointer; flex-shrink: 0; }
.perm-text    { flex: 1; display: flex; flex-direction: column; gap: 2px;
                min-width: 0; }
.perm-name    { font-size: .88rem; color: var(--text); font-weight: 500; }
.perm-desc    { font-size: .78rem; color: var(--muted); }
.perm-id      { font-family: monospace; font-size: .75rem; color: var(--muted);
                flex-shrink: 0; }

/* =====================================================================
   29. Ayuda de un campo: question-circle + globito al pasar el mouse.
   UNICA forma de explicar un campo en todo el proyecto (ver ABM.md).
   El icono se escribe DESPUES del rotulo en el HTML; el `:has()` acota el
   flex a los labels que realmente tienen ayuda.
   ===================================================================== */
.field-help {
  position: relative;
  display: inline-flex; align-items: center; vertical-align: middle;
  margin-left: 5px;
  color: var(--muted); cursor: help;
  transition: color .15s;
}
.form-group label:has(.field-help) { display: flex; align-items: center; gap: 5px; }
.form-group label .field-help      { margin-left: 0; }
.field-help:hover, .field-help:focus-visible { color: var(--text); outline: none; }
.field-help i { font-size: .85rem; }

.field-help-tip {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20;
  width: max-content; max-width: 280px;
  padding: 9px 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .78rem; font-weight: 400; line-height: 1.5;
  text-transform: none; letter-spacing: normal; white-space: normal;
  opacity: 0; visibility: hidden;
  transition: opacity .12s ease, visibility .12s;
  pointer-events: none;   /* si no, se come los clicks del campo de abajo */
}
.field-help:hover .field-help-tip,
.field-help:focus-visible .field-help-tip { opacity: 1; visibility: visible; }
/* En la ULTIMA columna de la grilla se ancla a la derecha: anclado a la
   izquierda se sale del modal y le aparece barra horizontal. */
.form-row   > *:last-child .field-help-tip,
.form-row-3 > *:last-child .field-help-tip,
.form-row-4 > *:last-child .field-help-tip { left: auto; right: 0; }

/* 30. Alerts (banners dentro de una vista o del cuerpo de un modal) */
.alert         { border-radius: var(--radius); padding: 10px 12px;
                 font-size: .85rem; margin-bottom: 14px;
                 border: 1px solid transparent;
                 display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alert i       { font-size: 1rem; }
.alert-error   { background: rgba(230,42,42,.12);  color: #f5a8a8; border-color: rgba(230,42,42,.3); }
.alert-warn    { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.alert-info    { background: rgba(59,130,246,.12); color: #93c5fd; border-color: rgba(59,130,246,.3); }
.alert-success { background: rgba(34,197,94,.12);  color: #86efac; border-color: rgba(34,197,94,.3); }
.alert-spacer  { margin-left: auto; }

/* 31. Interruptor (campos booleanos '1'/'0' del esquema legado) */
.switch-row    { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.switch        { position: relative; display: inline-block;
                 width: 40px; height: 22px; flex-shrink: 0; }
.switch input  { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track  { position: absolute; inset: 0; cursor: pointer;
                 background: var(--border); border-radius: 99px;
                 transition: background .15s; }
.switch-track::before { content: ''; position: absolute;
                 width: 16px; height: 16px; left: 3px; top: 3px;
                 background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + .switch-track            { background: var(--success); }
.switch input:checked + .switch-track::before    { transform: translateX(18px); }
.switch input:disabled + .switch-track           { opacity: .5; cursor: not-allowed; }
.switch-text   { font-size: .85rem; color: var(--text); }

/* 32. Campo de busqueda con sugerencias (combo con buscador).
   Sustituye al input "escriba el id" de los selectores grandes: el nombre se
   escribe ADENTRO del propio campo, no en una nota al costado. */
.lookup            { position: relative; }
.lookup-sugerencias{ position: absolute; top: calc(100% + 4px); left: 0; right: 0;
                     z-index: 30; max-height: 260px; overflow-y: auto;
                     background: var(--surface); border: 1px solid var(--border);
                     border-radius: var(--radius); box-shadow: var(--shadow-lg);
                     display: none; }
.lookup-sugerencias.open { display: block; }
.lookup-sugerencias button { display: block; width: 100%; text-align: left;
                     padding: 8px 12px; background: none; border: none;
                     cursor: pointer; font-size: .85rem; color: var(--text);
                     font-family: inherit; border-bottom: 1px solid var(--border); }
.lookup-sugerencias button:last-child { border-bottom: none; }
.lookup-sugerencias button:hover      { background: var(--bg); color: var(--primary); }
.lookup-sugerencias .lookup-vacio     { padding: 10px 12px; font-size: .82rem; color: var(--muted); }
.lookup-eco        { font-size: .75rem; color: var(--muted); min-height: 1em; }

/* 33. Grafico de barras del dashboard (SVG inline, sin librerias) */
.chart-card    { background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-header  { padding: 14px 20px 10px; border-bottom: 1px solid var(--border);
                 display: flex; align-items: center; justify-content: space-between;
                 gap: 10px; flex-wrap: wrap; }
.chart-title   { font-weight: 600; font-size: .95rem; }
.chart-meta    { font-size: .78rem; color: var(--muted); }
.chart-body    { padding: 16px 20px; overflow-x: auto; }
.chart-body svg{ display: block; width: 100%; height: auto; }
.chart-legend  { display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
                 padding: 0 20px 14px; font-size: .78rem; color: var(--muted); }
.chart-legend span.dot { display: inline-block; width: 9px; height: 9px;
                 border-radius: 50%; margin-right: 5px; vertical-align: middle; }
/* El tooltip del grafico sigue al cursor; `pointer-events:none` para que no se
   coma el mousemove del propio SVG. */
.chart-tip     { position: fixed; z-index: 120; pointer-events: none;
                 background: var(--bg); color: var(--text);
                 border: 1px solid var(--border); border-radius: var(--radius);
                 box-shadow: var(--shadow-lg); padding: 8px 10px;
                 font-size: .78rem; line-height: 1.5; white-space: nowrap;
                 opacity: 0; transition: opacity .1s; }
.chart-tip.open { opacity: 1; }
.chart-tip b   { color: var(--text); }
.chart-tabla   { padding: 0 20px 16px; }
.chart-tabla table      { font-size: .8rem; }
.chart-tabla[hidden]    { display: none; }

/* 34. Tira de totales al pie de un listado */
.list-footer   { margin-top: 12px; font-size: .82rem; color: var(--muted);
                 display: flex; gap: 18px; flex-wrap: wrap; }
.list-footer b { color: var(--text); }

/* 35. Consola de salida (acciones en lote) */
.consola { background: #0d0d0d; border: 1px solid var(--border);
           border-radius: var(--radius); padding: 12px 14px;
           font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
           font-size: .78rem; line-height: 1.55; color: #d7d7d7;
           max-height: 320px; overflow-y: auto; white-space: pre-wrap; }
.consola .ok   { color: #86efac; }
.consola .err  { color: #f5a8a8; }
.consola .warn { color: #fcd34d; }

/* 36. Celdas de dos renglones (el listado legado apilaba dos datos) */
.cell-stack       { display: flex; flex-direction: column; gap: 1px; line-height: 1.35; }
.cell-stack .sub  { font-size: .78rem; color: var(--muted); }
.cell-num         { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-icons       { display: flex; gap: 7px; justify-content: center; color: var(--muted); }
.cell-icons i.on  { color: var(--text); }

/* 37. Tabs internas de un modal */
.tabs      { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab       { padding: 8px 14px; font-size: .85rem; font-weight: 600;
             color: var(--muted); background: none; border: none; cursor: pointer;
             border-bottom: 2px solid transparent; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active{ color: var(--primary); border-bottom-color: var(--primary); }

/* 38. Grupo de campos del formulario (separa bloques largos) */
.form-fieldset        { display: flex; flex-direction: column; gap: 12px; }
.form-fieldset-title  { font-size: .72rem; font-weight: 700;
                        text-transform: uppercase; letter-spacing: .06em;
                        color: var(--muted); padding-bottom: 6px;
                        border-bottom: 1px solid var(--border); }

