/* ═══════════════════════════════════════════════
   03-COMPONENTS.CSS
   Botones, Tablas, Formularios, Modales, etc.
   ═══════════════════════════════════════════════ */

/* ═══ BOTONES ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; /* 8px */
    padding: 0.6875rem 1.1875rem; /* 11px 19px */
    border-radius: 0.6875rem; /* 11px */
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.84375rem; /* 13.5px */
    line-height: 1.2; /* misma altura en <button> y <a> */
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: 0.15s;
  }
  
  .btn svg {
    width: 0.9375rem; /* 15px */
    height: 0.9375rem;
  }
  
  .btn-primary {
    background: var(--acc-strong);
    color: #fff;
    box-shadow: 0 4px 16px hsl(var(--h) var(--s) 40% / 0.25), inset 0 1px 0 hsl(0 0% 100% / 0.22);
  }
  
  .btn-primary:hover {
    filter: brightness(1.14);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px hsl(var(--h) var(--s) 40% / 0.35), inset 0 1px 0 hsl(0 0% 100% / 0.22);
  }
  
  .btn-ghost {
    background: var(--field);
    color: var(--text);
    border-color: var(--brd-2);
  }
  
  .btn-ghost:hover {
    background: var(--hover);
  }
  
  .btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
  }
  
  .btn-danger:hover {
    background: var(--danger);
    color: #fff;
  }
  
  .btn-sm {
    padding: 0.5rem 0.875rem; /* 8px 14px */
    font-size: 0.78125rem; /* 12.5px */
    border-radius: 0.5625rem; /* 9px */
  }
  
  .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem; /* 7px */
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.8125rem; /* 13px */
    font-weight: 600;
    padding: 0.25rem 0; /* 4px 0 */
    margin-bottom: 0.625rem; /* 10px */
    transition: 0.15s;
  }
  
  .btn-back:hover {
    color: var(--acc-txt);
  }
  
  .btn-back svg {
    width: 0.9375rem; /* 15px */
    height: 0.9375rem;
    transition: transform 0.15s;
  }
  
  .btn-back:hover svg {
    transform: translateX(-0.1875rem); /* -3px */
  }
  
  /* ═══ ICON BUTTONS ═══ */
  .icon-btn {
    width: 2.375rem; /* 38px */
    height: 2.375rem;
    border-radius: 0.625rem; /* 10px */
    border: 1px solid var(--brd-2);
    background: var(--field);
    color: var(--text-2);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: 0.15s;
    position: relative;
  }
  
  .icon-btn:hover {
    color: var(--text);
    border-color: var(--acc);
    transform: translateY(-1px);
  }
  
  .icon-btn svg {
    width: 1rem; /* 16px */
    height: 1rem;
  }
  
  .icon-btn .ping {
    position: absolute;
    top: 0.4375rem; /* 7px */
    right: 0.5rem; /* 8px */
    width: 0.5rem; /* 8px */
    height: 0.5rem;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px var(--danger);
  }
  
  .icon-btn.active {
    border-color: var(--acc);
    color: var(--acc-txt);
  }
  
  .avatar-btn {
    width: 2.375rem; /* 38px */
    height: 2.375rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    color: #fff;
    font-weight: 700;
    font-size: 0.78125rem; /* 12.5px */
    font-family: inherit;
    background: var(--acc-strong);
    box-shadow: 0 0 12px var(--glow);
    transition: 0.15s;
  }
  
  .avatar-btn:hover {
    transform: scale(1.06);
  }
  
  .avatar-btn.active {
    border-color: var(--acc);
  }
  


  /* ═══ FILTROS ═══ 
  .filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem; 
    border-radius: 0.875rem; 
    margin-bottom: 1.125rem; 
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
  }
  */




/* ═══ TOOLBAR (Barra de herramientas sobre la tabla) ═══ */
.toolbar {
  width: 100%;
  margin-bottom: 1.125rem; /* 18px de separación con la tabla */
  position: relative;
}

/* El formulario es el que hace la magia de poner todo en fila */
.toolbar-form {
  display: flex;
  gap: 1rem;
  width: 100%;
  align-items: center; 
  flex-wrap: wrap;
}

/* Los campos dentro de la toolbar se reparten el espacio */
.toolbar .field {
  flex: 1;
  min-width: 200px; 
  margin: 0; 
}

/* Ocultamos los labels de forma agresiva (!important) para ganarle a la regla global .field label */
.toolbar .field label {
  display: none !important; 
}

/* Ocultamos el select nativo desde CSS para evitar el pestañeo inicial */
.toolbar select.vanilla-select {
  display: none;
}

/* Ajuste para que el input date ocupe todo el ancho de su caja */
.toolbar .input {
  width: 100%;
  color: var(--text);
}








/* ═══ TOOLBAR BÚSQUEDA ═══ */
.toolbar {
  display: flex;
  gap: 1rem;
  width: 100%;
  align-items: center;
  flex-wrap: nowrap; /* <--- Mantiene el botón al lado del buscador */
  margin-bottom: 1.125rem;
  position: relative;
}

/* El buscador */
.f-search {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  height: 42px;
  padding: 0 13px;
  border-radius: 0.6875rem;
  flex: 1; /* Esto empuja el botón a la derecha automáticamente */
  min-width: 0; 
  background: var(--field);
  border: 1px solid var(--brd-2);
  transition: 0.2s;
}

.f-search:focus-within {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--ring);
}

.f-search svg {
  width: 0.9375rem;
  height: 0.9375rem;
  color: var(--text-2);
  flex-shrink: 0;
}

.f-search input {
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.84375rem;
  width: 100%;
  min-width: 0; /* Arregla el problema de la "J" */
  padding-left: 4px; /* Separa el texto de la lupa */
}

.f-search kbd {
  font-size: 0.65625rem;
  color: var(--text-2);
  border: 1px solid var(--brd-2);
  border-radius: 0.3125rem;
  padding: 0.125rem 0.4375rem;
}

/* El botón de Limpiar */
.toolbar .btn {
  height: 42px; /* Igual altura que el buscador */
  box-sizing: border-box;
  flex-shrink: 0; /* Evita que el botón se deforme */
  white-space: nowrap; /* Evita que el texto se rompa en dos líneas */
}

/* Responsive para celulares (si la pantalla es muy chica, que baje el botón) */
@media (max-width: 600px) {
  .toolbar {
    flex-wrap: wrap;
  }
}






  
  /* ═══ TABS ═══ */
  .tabs {
    display: flex;
    gap: 1.375rem; /* 22px */
    align-self: stretch;
    align-items: stretch;
    margin-left: 0.375rem; /* 6px */
  }
  
  .tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0 0.125rem; /* 0 2px */
    border: none;
    background: none;
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.84375rem; /* 13.5px */
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s;
    white-space: nowrap;
  }
  
  .tab::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.9375rem; /* -15px */
    height: 0.15625rem; /* 2.5px */
    border-radius: 0.1875rem 0.1875rem 0 0; /* 3px */
    background: var(--acc);
    box-shadow: 0 0 0.625rem var(--glow); /* 10px */
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.22s;
  }
  
  .tab:hover {
    color: var(--text);
  }
  
  .tab.on {
    color: var(--acc-txt);
  }
  
  .tab.on::after {
    transform: scaleX(1);
  }
  
  .tab .t-count {
    font-size: 0.65625rem; /* 10.5px */
    font-weight: 700;
    margin-left: 0.3125rem; /* 5px */
    opacity: 0.6;
  }
  
  /* ═══ TABLA ═══ */
  .panel {
    border-radius: 1rem; /* 16px */
    overflow: visible; 
    display: flex;
    flex-direction: column;
}
  
  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem; /* 12px */
    padding: 0.875rem 1.375rem; /* 14px 22px */
    padding: 0.5rem 1.375rem 0.875rem 1.375rem; 

    border-bottom: 1px solid var(--brd);
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
  }
  
  .panel-head h2 {
    font-size: 0.9375rem; /* 15px */
    font-weight: 700;
  }
  
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84375rem;
    table-layout: fixed; /* <--- CAMBIA 'auto' POR 'fixed' */
  }


  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84375rem; /* 13.5px */
    table-layout: auto;
  }
  
  th {
    text-align: left;
    font-size: 0.65625rem; /* 10.5px */
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-2);
    padding: 0.8125rem 1.25rem; /* 13px 20px */
    border-bottom: 1px solid var(--brd);
    background: var(--th-bg);
    white-space: nowrap;
  }
  
  td {
    padding: 0.9375rem 1.25rem; /* 15px 20px */
    border-bottom: 1px solid var(--brd);
    vertical-align: middle;
  }
  
  tbody tr {
    transition: background 0.12s;
  }
  
  tbody tr:hover {
    background: var(--hover);
  }
  
  tbody tr:last-child td {
    border-bottom: none;
  }
  
  tbody tr.selected {
    background: var(--acc-soft);
  }
  

  
  th.c-id, td.c-id {
    width: 5.625rem; /* 90px */
    padding: 0.9375rem 0.625rem; /* 15px 10px */
  }
  

  
  th.c-state, td.c-state {
    width: 7.5rem; /* 120px */
  }
  
  th.c-actions, td.c-actions {
    width: 3.5rem; /* 56px */
    text-align: right;
  }
  

  
  /* ═══ ID CLICKEABLE EN TABLA ═══ */
  .id-cell {
    font-family: ui-monospace, monospace;
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    color: var(--acc-txt);
    cursor: pointer;
    transition: 0.15s;
    padding: 0.25rem 0.5rem; /* 4px 8px */
    border-radius: 0.375rem; /* 6px */
    display: inline-block;
    background: var(--acc-soft);
    border: 1px solid transparent;
  }
  
  .id-cell:hover {
    color: #fff;
    background: var(--acc-strong);
    border-color: var(--acc-strong);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--glow);
  }
  
  .id-cell:hover {
    color: var(--text);
    background: var(--hover);
  }
  
  .cell-name {
    min-width: 0;
  }
  
  .cell-name b {
    font-weight: 600;
    display: block;
  }
  
  .cell-name span {
    display: block;
    font-size: 0.75rem; /* 12px */
    color: var(--text-2);
    margin-top: 0.125rem; /* 2px */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 26.25rem; /* 420px */
  }
  
  .qty {
    font-weight: 600;
    font-size: 0.84375rem; /* 13.5px */
  }
  
  /* ═══ SKELETON ═══ */
  .skel {
    border-radius: 0.4375rem; /* 7px */
    height: 0.8125rem; /* 13px */
    background: linear-gradient(90deg, var(--hover) 25%, var(--brd-2) 50%, var(--hover) 75%);
    background-size: 200% 100%;
    animation: skel 1.3s infinite linear;
  }
  
  tr.skel-row td {
    padding: 1rem 1.25rem; /* 16px 20px */
  }
  
  /* ═══ PÍLDORAS ═══ */
  .status {
    display: inline-flex;
    align-items: center;
    font-size: 0.71875rem; /* 11.5px */
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.1875rem 0.625rem; /* 3px 10px */
    border-radius: 0.4375rem; /* 7px */
    background: color-mix(in srgb, currentColor 14%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 34%, transparent);
    box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.07);
  }
  
  .status.ok {
    color: var(--ok);
  }
  
  .status.off {
    color: var(--text-2);
  }
  
  /* ═══ DROPDOWNS ═══ */
  .row-actions {
    position: relative;
    display: inline-block;
  }
  
  .kebab {
    width: 1.9375rem; /* 31px */
    height: 1.9375rem;
    border-radius: 0.5rem; /* 8px */
    border: 1px solid transparent;
    background: none;
    color: var(--text-2);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: 0.15s;
        z-index: 1;
    position: relative;
  }
  
  .kebab:hover {
    background: var(--hover);
    color: var(--text);
    border-color: var(--brd-2);
  }
  
  .kebab svg {
    width: 0.9375rem; /* 15px */
    height: 0.9375rem;
  }
  
  .dd {
    position: absolute;
    top: calc(100% + 0.375rem); /* 6px */
    right: 0;
    min-width: 10.3125rem; /* 165px */
    z-index: 80;
    border-radius: 0.75rem; /* 12px */
    padding: 0.3125rem; /* 5px */
    opacity: 0;
    transform: translateY(-0.3125rem) scale(0.97); /* 5px */
    pointer-events: none;
    transition: 0.15s;
    transform-origin: top right;    
    
    background: var(--bg) !important;
    
    border: 1px solid var(--brd-2) !important;
    box-shadow: var(--shadow) !important;
    backdrop-filter: blur(1rem); /* 16px */
    -webkit-backdrop-filter: blur(1rem);
  }
  
  .dd.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  
  .dd button {
    display: flex;
    align-items: center;
    gap: 0.625rem; /* 10px */
    width: 100%;
    padding: 0.5625rem 0.75rem; /* 9px 12px */
    border: none;
    border-radius: 0.5rem; /* 8px */
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8125rem; /* 13px */
    cursor: pointer;
    text-align: left;
    transition: 0.12s;
    position: relative;
    z-index: 1;
  }
  
  .dd button svg {
    width: 0.875rem; /* 14px */
    height: 0.875rem;
    color: var(--text-2);
  }
  
  .dd button:hover {
    background: var(--hover);
  }
  
  .dd button.danger, .dd button.danger svg {
    color: var(--danger);
  }
  
  .dd button.danger:hover {
    background: var(--danger-bg);
  }
  
  /* ═══ EMPTY STATES ═══ */
  .empty {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 3.5rem 1.25rem; /* 56px 20px */
    text-align: center;
    position: relative;
    z-index: 1;
  }
  
  .empty.show {
    display: flex;
  }
  
  .empty .fig {
    width: 4.125rem; /* 66px */
    height: 4.125rem;
    border-radius: 1.125rem; /* 18px */
    display: grid;
    place-items: center;
    margin-bottom: 1.125rem; /* 18px */
    background: radial-gradient(circle at center, var(--acc-soft) 0%, transparent 70%), var(--acc-soft);
    color: var(--acc-txt);
    border: 1px solid var(--acc-soft);
    animation: float 4s ease-in-out infinite;
  }
  
  .empty .fig svg {
    width: 1.8125rem; /* 29px */
    height: 1.8125rem;
    filter: drop-shadow(0 4px 12px var(--glow));
  }
  
  .empty h3 {
    font-size: 0.96875rem; /* 15.5px */
    font-weight: 700;
    margin-bottom: 0.375rem; /* 6px */
  }
  
  .empty p {
    font-size: 0.84375rem; /* 13.5px */
    color: var(--text-2);
    margin-bottom: 1.25rem; /* 20px */
    max-width: 20rem; /* 320px */
  }
  
  /* ═══ PANEL FOOT & PAGINATION ═══ */
  .panel-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.375rem; /* 14px 22px */
    flex-wrap: wrap;
    gap: 0.625rem; /* 10px */
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--brd);
    background: var(--th-bg);
  }
  
  .panel-foot span {
    font-size: 0.78125rem; /* 12.5px */
    color: var(--text-2);
  }
  
  .pager {
    display: flex;
    gap: 0.3125rem; /* 5px */
  }
  
  .pager button {
    min-width: 2.0625rem; /* 33px */
    height: 2.0625rem;
    border-radius: 0.5rem; /* 8px */
    border: 1px solid var(--brd-2);
    background: var(--field);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.78125rem; /* 12.5px */
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    padding: 0 0.375rem; /* 0 6px */
  }
  
  .pager button:hover:not(:disabled) {
    color: var(--text);
  }
  
  .pager button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  
  .pager button.on {
    background: var(--acc-strong);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 0.625rem var(--glow); /* 10px */
  }
  

  /* ═══ ERROR VIEW ═══ */
  .error-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 5.625rem 1.25rem 3.75rem; /* 90px 20px 60px */
    max-width: 30rem; /* 480px */
    margin: 0 auto;
    position: relative;
    z-index: 1;
  }
  
  .error-view .fig {
    width: 5.5rem; /* 88px */
    height: 5.5rem;
    border-radius: 1.5rem; /* 24px */
    display: grid;
    place-items: center;
    margin-bottom: 1.5rem; /* 24px */
    background: var(--acc-soft);
    color: var(--acc-txt);
    border: 1px solid var(--acc-soft);
  }
  
  .error-view .fig svg {
    width: 2.5rem; /* 40px */
    height: 2.5rem;
  }
  
  .error-view h1 {
    font-size: 1.625rem; /* 26px */
    letter-spacing: -0.03em;
    font-weight: 800;
    margin-bottom: 0.625rem; /* 10px */
  }
  
  .error-view p {
    font-size: 0.875rem; /* 14px */
    color: var(--text-2);
    margin-bottom: 1.75rem; /* 28px */
    max-width: 22.5rem; /* 360px */
    line-height: 1.6;
  }
  
  .error-actions {
    display: flex;
    gap: 0.75rem; /* 12px */
    flex-wrap: wrap;
    justify-content: center;
  }
  
  /* ═══ FORMULARIOS ═══ */
  .form-panel {
    padding: 1.75rem 1.875rem; /* 28px 30px */
    position: relative;
    z-index: 1;
  }
  
  .form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0 1.25rem; /* 0 20px */
  }
  
  .fw-1 { grid-column: span 1; }
  .fw-2 { grid-column: span 2; }
  .fw-3 { grid-column: span 3; }
  .fw-full { grid-column: 1 / -1; }
  
  .field {
    margin-bottom: 1.25rem; /* 20px */
  }
  
  .field label {
    display: block;
    font-size: 0.78125rem; /* 12.5px */
    font-weight: 600;
    margin-bottom: 0.5rem; /* 8px */
  }
  
  .field .opt {
    font-weight: 400;
    color: var(--text-2);
  }
  




    /* 1. Estilos base SOLO para Inputs de una línea */
    .input {
      width: 100%;
      height: 42px;
      padding: 0 13px;
      border-radius: 0.6875rem;
      border: 1px solid var(--brd-2);
      background: var(--field);
      color: var(--text);
      font-family: inherit;
      font-size: 0.84375rem;
      outline: none;
      transition: 0.15s;
      box-sizing: border-box;
    }
  
    /* 2. Estilos base para el Textarea */
    .textarea {
      width: 100%;
      padding: 0.75rem 0.875rem;
      border-radius: 0.6875rem;
      border: 1px solid var(--brd-2);
      background: var(--field);
      color: var(--text);
      font-family: inherit;
      font-size: 0.84375rem;
      outline: none;
      transition: 0.15s;
      resize: vertical;
      min-height: 6rem;
      box-sizing: border-box;
    }
    
    /* 3. Estados Focus */
    .input:focus, .textarea:focus {
      border-color: var(--acc);
      box-shadow: 0 0 0 3px var(--ring);
    }
    
    /* 4. Estado de Error */
    .input.error {
      border-color: var(--danger);
      box-shadow: 0 0 0 3px var(--danger-bg);
    }
    
    /* 5. Placeholders */
    .input::placeholder, .textarea::placeholder {
      color: var(--text-2);
    }
    
    /* 6. Campos en modo solo lectura */
    .input.readonly, .textarea.readonly {
      border-color: transparent;
      background: var(--hover);
      color: var(--text);
      cursor: text;
      pointer-events: none;
    }
    
    .input.readonly:focus, .textarea.readonly:focus {
      border-color: transparent;
      box-shadow: none;
    }
  
    /* 7. Input Date: Adaptación automática al Tema (Claro/Oscuro) */
    
    /* Modo Oscuro: Calendario oscuro e icono blanco */
    html[data-theme="dark"] input[type="date"].input {
      color-scheme: dark; 
    }
    html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
      filter: invert(1); 
      opacity: 0.6;
    }
  
    /* Modo Claro: Calendario claro e icono oscuro (nativo) */
    html[data-theme="light"] input[type="date"].input {
      color-scheme: light; 
    }
    html[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
      filter: none; 
      opacity: 0.5;
    }
  
    /* Hover del icono del calendario (aplica a ambos) */
    input[type="date"]::-webkit-calendar-picker-indicator:hover {
      opacity: 1;
      cursor: pointer;
    }







  .err-msg {
    display: none;
    font-size: 0.75rem; /* 12px */
    color: var(--danger);
    margin-top: 0.4375rem; /* 7px */
    align-items: center;
    gap: 0.375rem; /* 6px */
  }
  
  .err-msg.show {
    display: flex;
  }
  
  .err-msg svg {
    width: 0.8125rem; /* 13px */
    height: 0.8125rem;
  }
  
  .hint {
    font-size: 0.75rem; /* 12px */
    color: var(--text-2);
    margin-top: 0.4375rem; /* 7px */
  }
  
  /* ═══ SWITCH ═══ */
  .field .switch-row {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem; /* 10px */
    margin: 0;
    padding: 0.375rem 0; /* 6px 0 */
    font-size: 0.84375rem; /* 13.5px */
    font-weight: 400;
    cursor: pointer;
    user-select: none;
    width: fit-content;
  }
  
  input.switch {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    flex-shrink: 0;
    display: inline-block;
    width: 2.5rem; /* 40px */
    height: 1.375rem; /* 22px */
    border-radius: 999px;
    border: none;
    position: relative;
    cursor: pointer;
    background: hsl(0 0% 50% / 0.4);
    transition: background 0.2s, box-shadow 0.2s;
    outline: none;
  }
  
  html[data-theme="dark"] input.switch {
    background: hsl(0 0% 100% / 0.18);
  }
  
  input.switch::after {
    content: '';
    position: absolute;
    top: 0.1875rem; /* 3px */
    left: 0.1875rem; /* 3px */
    width: 1rem; /* 16px */
    height: 1rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
    transition: transform 0.2s;
  }
  
  input.switch:checked {
    background: var(--acc-strong);
    box-shadow: 0 0 12px var(--glow);
  }
  
  input.switch:checked::after {
    transform: translateX(1.125rem); /* 18px */
  }
  
  input.switch:focus-visible {
    box-shadow: 0 0 0 3px var(--ring), 0 0 12px var(--glow);
  }
  
  /* Switch en modo solo lectura */
  input.switch.readonly {
    pointer-events: none;
    opacity: 0.7;
  }
  
  .switch-state {
    font-size: 0.84375rem; /* 13.5px */
    font-weight: 500;
    color: var(--text-2);
    transition: color 0.2s;
  }
  
  .switch-state::before {
    content: 'Inactivo';
  }
  
  input.switch:checked ~ .switch-state {
    color: var(--text);
    font-weight: 600;
  }
  
  input.switch:checked ~ .switch-state::before {
    content: 'Activo';
  }
  
  .form-sep {
    height: 1px;
    background: var(--brd);
    margin: 1.5rem -1.875rem; /* 24px -30px */
  }
  
  .form-actions {
    display: flex;
    gap: 0.75rem; /* 12px */
    align-items: center;
  }
  
  .form-actions .spacer {
    flex: 1;
  }
  
  .form-note {
    font-size: 0.75rem; /* 12px */
    color: var(--text-2);
  }
  
  /* ═══ MODAL ═══ */
  .ov {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--ov-bg);
    display: grid;
    place-items: center;
    padding: 1.25rem; /* 20px */
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
  }
  
  .ov.show {
    opacity: 1;
    pointer-events: auto;
  }
  
  .modal {
    width: 100%;
    max-width: 26.25rem; /* 420px */
    border-radius: 1.125rem; /* 18px */
    padding: 1.625rem; /* 26px */
    transform: translateY(0.875rem) scale(0.97); /* 14px */
    transition: 0.2s;
  }
  
  .ov.show .modal {
    transform: none;
  }
  
  .modal h3 {
    font-size: 1.0625rem; /* 17px */
    font-weight: 700;
    letter-spacing: -0.01em;
    position: relative;
    z-index: 1;
  }
  
  .modal .sub-t {
    font-size: 0.84375rem; /* 13.5px */
    color: var(--text-2);
    margin: 0.3125rem 0 1.25rem; /* 5px 0 20px */
    position: relative;
    z-index: 1;
  }
  
  .modal-foot {
    display: flex;
    gap: 0.625rem; /* 10px */
    justify-content: flex-end;
    margin-top: 0.25rem; /* 4px */
    position: relative;
    z-index: 1;
  }
  
  /* ═══ TOASTS ═══ */
.toasts {
    position: fixed;
    bottom: 1.375rem;
    right: 1.375rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 25rem; /* 400px */
    width: 100%; /* <--- AGREGAR ESTO */
    pointer-events: none;
}

  
.toast {
    display: flex;
    gap: 0.8125rem;
    padding: 0.9375rem 1rem 1.0625rem 1.25rem;
    border-radius: 0.875rem;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    animation: tIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
    min-width: 280px; /* <--- AGREGAR ESTO */
    pointer-events: auto;
}
  
  .toast.out {
    animation: tOut 0.22s forwards;
  }
  
  .toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0.25rem; /* 4px */
    background: currentColor;
  }
  
  .toast .ic {
    width: 2.25rem; /* 36px */
    height: 2.25rem;
    border-radius: 0.6875rem; /* 11px */
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: color-mix(in srgb, currentColor 16%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
    position: relative;
    z-index: 1;
  }
  
  .toast .ic svg {
    width: 1.1875rem; /* 19px */
    height: 1.1875rem;
  }
  
  .toast b {
    font-size: 0.875rem; /* 14px */
    display: block;
    margin-bottom: 0.1875rem; /* 3px */
    position: relative;
    z-index: 1;
    letter-spacing: -0.01em;
  }
  
  .toast p {
    font-size: 0.8125rem; /* 13px */
    color: var(--text);
    opacity: 0.75;
    line-height: 1.5;
    position: relative;
    z-index: 1;
  }
  
  .toast .x {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    padding: 0.125rem 0.25rem; /* 2px 4px */
    font-size: 0.8125rem; /* 13px */
    position: relative;
    z-index: 1;
    border-radius: 0.375rem; /* 6px */
    transition: 0.12s;
  }
  
  .toast .x:hover {
    color: var(--text);
    background: var(--hover);
  }
  
  .toast .bar {
    position: absolute;
    left: 0.25rem; /* 4px */
    right: 0;
    bottom: 0;
    height: 0.1875rem; /* 3px */
    width: auto;
    transform-origin: left;
    animation: bar 4s linear forwards;
    z-index: 1;
    opacity: 0.85;
  }
  
  .toast.ok {
    color: var(--ok);
    background: color-mix(in srgb, var(--ok) 9%, var(--panel-2));
    border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  }
  
  .toast.err {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 9%, var(--panel-2));
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  }
  
  .toast.warn {
    color: var(--warn);
    background: color-mix(in srgb, var(--warn) 9%, var(--panel-2));
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  }
  
  .toast.info {
    color: var(--acc);
    background: color-mix(in srgb, var(--acc) 9%, var(--panel-2));
    border: 1px solid color-mix(in srgb, var(--acc) 30%, transparent);
  }
  
  /* ═══ TOOLTIP ═══ */
  .tooltip {
    position: fixed;
    z-index: 400;
    pointer-events: none;
    background: var(--panel-2);
    border: 1px solid var(--brd-2);
    color: var(--text);
    font-size: 0.71875rem; /* 11.5px */
    font-weight: 600;
    padding: 0.34375rem 0.6875rem; /* 5.5px 11px */
    border-radius: 0.5rem; /* 8px */
    box-shadow: var(--shadow);
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, calc(-100% - 0.5rem)) scale(0.96); /* 8px */
    transition: opacity 0.15s, transform 0.15s;
    backdrop-filter: blur(0.75rem); /* 12px */
    -webkit-backdrop-filter: blur(0.75rem);
  }
  
  .tooltip.show {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 0.75rem)) scale(1); /* 12px */
  }
  
  .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 0.3125rem solid transparent; /* 5px */
    border-top-color: var(--brd-2);
  }
  
  .tooltip.below {
    transform: translate(-50%, 0.5rem) scale(0.96); /* 8px */
  }
  
  .tooltip.below.show {
    transform: translate(-50%, 0.75rem) scale(1); /* 12px */
  }
  
  .tooltip.below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--brd-2);
  }
  
  /* ═══ MENÚS DE USUARIO Y NOTIFICACIONES ═══ */
  .user-wrap {
    position: relative;
  }
  
  .user-menu {
    position: absolute;
    top: calc(100% + 0.625rem); /* 10px */
    right: 0;
    z-index: 100;
    width: 16rem; /* 256px */
    border-radius: 0.9375rem; /* 15px */
    padding: 0.4375rem; /* 7px */
    opacity: 0;
    transform: translateY(-0.375rem) scale(0.97); /* 6px */
    pointer-events: none;
    transition: 0.18s;
    transform-origin: top right;
  }
  
  .user-menu.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  
  .u-head {
    display: flex;
    align-items: center;
    gap: 0.6875rem; /* 11px */
    padding: 0.625rem 0.6875rem 0.75rem; /* 10px 11px 12px */
  }
  
  .u-avatar {
    width: 2.375rem; /* 38px */
    height: 2.375rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 0.78125rem; /* 12.5px */
    background: var(--acc-strong);
    box-shadow: 0 0 12px var(--glow);
  }
  
  .u-info {
    min-width: 0;
  }
  
  .u-info b {
    display: block;
    font-size: 0.84375rem; /* 13.5px */
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .u-info span {
    display: block;
    font-size: 0.71875rem; /* 11.5px */
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .u-sep {
    height: 1px;
    background: var(--brd);
    margin: 0.3125rem 0.375rem; /* 5px 6px */
  }
  
  .u-item {
    display: flex;
    align-items: center;
    gap: 0.6875rem; /* 11px */
    width: 100%;
    padding: 0.59375rem 0.6875rem; /* 9.5px 11px */
    border: none;
    border-radius: 0.5625rem; /* 9px */
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8125rem; /* 13px */
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: 0.12s;
    position: relative;
    z-index: 1;
  }
  
  .u-item svg {
    width: 0.9375rem; /* 15px */
    height: 0.9375rem;
    color: var(--text-2);
    flex-shrink: 0;
  }
  
  .u-item:hover {
    background: var(--hover);
  }
  
  .u-item.danger, .u-item.danger svg {
    color: var(--danger);
  }
  
  .u-item.danger:hover {
    background: var(--danger-bg);
  }
  
  .u-item .badge {
    margin-left: auto;
    font-size: 0.625rem; /* 10px */
    font-weight: 700;
    padding: 0.125rem 0.4375rem; /* 2px 7px */
    border-radius: 999rem;
    background: var(--danger-bg);
    color: var(--danger);
  }
  
  .u-item .badge.hide {
    display: none;
  }
  
  .u-colors {
    padding: 0.25rem 0.5rem 0.5rem; /* 4px 8px 8px */
    position: relative;
    z-index: 1;
  }
  
  .u-colors-label {
    font-size: 0.625rem; /* 10px */
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-2);
    margin-bottom: 0.5625rem; /* 9px */
  }
  
  .u-swatches {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
  }
  
  .swatch {
    width: 1.375rem; /* 22px */
    height: 1.375rem;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.15s;
    flex-shrink: 0;
    box-shadow: inset 0 1px 2px hsl(0 0% 100% / 0.35), 0 1px 4px hsl(0 0% 0% / 0.25);
  }
  
  .swatch:hover {
    transform: scale(1.15);
  }
  
  .swatch.active {
    border-color: var(--text);
    transform: scale(1.08);
  }
  
  .u-custom {
    position: relative;
    width: 1.375rem; /* 22px */
    height: 1.375rem;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    background: conic-gradient(hsl(0 80% 55%), hsl(60 80% 50%), hsl(120 70% 45%), hsl(180 80% 45%), hsl(240 80% 60%), hsl(300 70% 55%), hsl(0 80% 55%));
    border: 2px solid var(--brd-2);
    transition: 0.15s;
  }
  
  .u-custom:hover {
    transform: scale(1.15);
  }
  
  .u-custom input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
  }
  
  .notif-wrap {
    position: relative;
  }
  
  .notif-menu {
    position: absolute;
    top: calc(100% + 0.625rem); /* 10px */
    right: 0;
    z-index: 100;
    width: 20.625rem; /* 330px */
    border-radius: 0.9375rem; /* 15px */
    padding: 0.4375rem; /* 7px */
    opacity: 0;
    transform: translateY(-0.375rem) scale(0.97); /* 6px */
    pointer-events: none;
    transition: 0.18s;
    transform-origin: top right;
  }
  
  .notif-menu.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  
  .n-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5625rem 0.6875rem 0.625rem; /* 9px 11px 10px */
  }
  
  .n-head b {
    font-size: 0.84375rem; /* 13.5px */
    letter-spacing: -0.01em;
  }
  
  .n-mark {
    border: none;
    background: none;
    color: var(--acc-txt);
    font-family: inherit;
    font-size: 0.71875rem; /* 11.5px */
    font-weight: 600;
    cursor: pointer;
    padding: 0.1875rem 0.4375rem; /* 3px 7px */
    border-radius: 0.4375rem; /* 7px */
    transition: 0.12s;
  }
  
  .n-mark:hover {
    background: var(--acc-soft);
  }
  
  .n-list {
    list-style: none;
    max-height: 20rem; /* 320px */
    overflow-y: auto;
  }
  
  .n-item {
    display: flex;
    gap: 0.6875rem; /* 11px */
    padding: 0.6875rem; /* 11px */
    border-radius: 0.625rem; /* 10px */
    cursor: pointer;
    transition: 0.12s;
    position: relative;
    z-index: 1;
  }
  
  .n-item:hover {
    background: var(--hover);
  }
  
  .n-dot {
    width: 0.5rem; /* 8px */
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.375rem; /* 6px */
    background: var(--acc);
    box-shadow: 0 0 0.5rem var(--glow); /* 8px */
  }
  
  .n-item.read .n-dot {
    background: transparent;
    box-shadow: none;
  }
  
  .n-body {
    min-width: 0;
  }
  
  .n-body b {
    display: block;
    font-size: 0.78125rem; /* 12.5px */
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  
  .n-item.read .n-body b {
    color: var(--text-2);
    font-weight: 500;
  }
  
  .n-body p {
    font-size: 0.75rem; /* 12px */
    color: var(--text-2);
    line-height: 1.45;
    margin-top: 0.0625rem; /* 1px */
  }
  
  .n-body time {
    font-size: 0.65625rem; /* 10.5px */
    color: var(--text-2);
    opacity: 0.8;
  }
  
  .n-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 2.125rem 1rem; /* 34px 16px */
    text-align: center;
  }
  
  .n-empty.show {
    display: flex;
  }
  
  .n-empty .fig {
    width: 3.25rem; /* 52px */
    height: 3.25rem;
    border-radius: 0.9375rem; /* 15px */
    display: grid;
    place-items: center;
    margin-bottom: 0.75rem; /* 12px */
    background: var(--acc-soft);
    color: var(--acc-txt);
  }
  
  .n-empty .fig svg {
    width: 1.5rem; /* 24px */
    height: 1.5rem;
  }
  
  .n-empty b {
    font-size: 0.8125rem; /* 13px */
    margin-bottom: 0.1875rem; /* 3px */
  }
  
  .n-empty p {
    font-size: 0.75rem; /* 12px */
    color: var(--text-2);
    max-width: 13.75rem; /* 220px */
  }
  
  /* ═══ SCRIM ═══ */
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgb(0 0 0 / 0.5);
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
  }
  
  .scrim.show {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* ═══ RESPONSIVE COMPONENTES ═══ */
  @media (max-width: 820px) {
    .cell-name span { display: none; }
    th, td { padding: 0.8125rem 0.875rem; /* 13px 14px */ }
    .form-panel { padding: 1.375rem 1.125rem; /* 22px 18px */ }
    .form-sep { margin: 1.25rem -1.125rem; /* 20px -18px */ }
    .error-view { padding: 3.75rem 1rem 2.5rem; /* 60px 16px 40px */ }
  }
  
  @media (max-width: 640px) {
    th.c-id, td.c-id { display: none; }
    th.c-state, td.c-state { display: none; }
    .f-clear { margin-left: 0; }
    .content { padding: 1.375rem 1rem 5rem; /* 22px 16px 80px */ }
    .crumbs .hide-m { display: none; }
    .toasts { left: 1rem; right: 1rem; max-width: none; bottom: 5.5rem; /* 88px */ }
    .tabs { width: 100%; justify-content: center; gap: 1rem; margin-left: 0; }
    .bulkbar { flex-wrap: wrap; justify-content: center; }
  }
  
  @media (max-width: 1000px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .fw-3 { grid-column: span 2; }
  }
  
  @media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .fw-1, .fw-2, .fw-3 { grid-column: 1 / -1; }
  }



/* Ocultar flechas de inputs numéricos */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}




/* ═══ BUSCADOR GLOBAL (Command Palette) ═══ */
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-2);
}

.search-input:focus {
  outline: none;
}


