/* =========================
   RESET GENERAL
========================= */
* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #d9e2ec;
  --line-soft: #e8eef5;

  --primary: #114c7d;
  --primary-2: #1f6aa5;
  --primary-3: #eaf3fb;

  --text: #1f2937;
  --muted: #5f6b7a;

  --success: #2e7d32;
  --success-bg: #e8f5e9;

  --danger: #c62828;
  --danger-bg: #fdecea;

  --shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
  --radius: 14px;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =========================
   TOPBAR
========================= */

.topbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 14px 0;
  box-shadow: var(--shadow);
}

.topbar-inner {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand p {
  display: none;
}

.user-box {
  min-width: 250px;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.3;
  backdrop-filter: blur(2px);
}

.user-box strong {
  color: #fff;
}

/* =========================
   CONTENEDOR
========================= */
.container {
  width: min(1400px, calc(100% - 32px));
  margin: 22px auto 32px;
}

/* =========================
   MENSAJES
========================= */
.message {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}

.message.success {
  display: block;
  background: var(--success-bg);
  border-color: #c8e6c9;
  color: var(--success);
}

.message.error {
  display: block;
  background: var(--danger-bg);
  border-color: #f5c2c0;
  color: var(--danger);
}

/* =========================
   CARDS
========================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(15, 76, 129, 0.03);
  width: 100%;
  min-width: 0;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 800;
  color: #17324d;
}

/* =========================
   GRID PRINCIPAL
========================= */

.grid {
  display: grid;
  gap: 20px;
  align-items: start;
}

.grid > * {
  min-width: 0;
}

.grid-top {
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
}

.stack-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
  width: 100%;
}

.stack-item {
  width: 100%;
}

.card-full {
  width: 100%;
  display: block;
}



/* =========================
   INFO BOX
========================= */
.info-box {
  background: var(--surface-soft);
  border: 1px solid #cfe0f2;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.info-box-title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 6px;
  color: #17324d;
}

.info-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* =========================
   BADGES
========================= */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #e7f0fb;
  color: var(--primary);
  border: 1px solid #cfe0f2;
}

.state-ok {
  background: #e6f4ea;
  color: var(--success);
  border-color: #c8e6c9;
}

/* =========================
   FORMULARIOS
========================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #304458;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cfd8e3;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #7aa7d6;
  box-shadow: 0 0 0 3px rgba(31, 106, 165, 0.12);
  background: #fcfeff;
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
}

/* =========================
   TOOLTIP / AYUDA DE CAMPOS
========================= */
.field-with-help {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.help-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #1f6aa5;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: help;
  user-select: none;
  line-height: 1;
}

.help-icon::after {
  content: attr(data-help);
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: 240px;
  max-width: 280px;
  background: #17324d;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2000;
  white-space: normal;
}

.help-icon::before {
  content: "";
  position: absolute;
  left: 8px;
  bottom: calc(100% + 4px);
  border-width: 6px;
  border-style: solid;
  border-color: #17324d transparent transparent transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2001;
}

.help-icon:hover::after,
.help-icon:hover::before,
.help-icon:focus::after,
.help-icon:focus::before {
  opacity: 1;
  transform: translateY(0);
}

.field-help-text {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.35;
}

/* =========================
   ACCIONES
========================= */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.04s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn:active {
  transform: translateY(1px);
}

.btn:hover {
  opacity: 0.94;
}

.btn-primary {
  background: var(--primary-2);
  color: #fff;
}

.btn-secondary {
  background: #eef3f8;
  color: #28425c;
  border: 1px solid #d5e0eb;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

/* =========================
   RESUMEN
========================= */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-box {
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  min-width: 0;
}

.summary-box .label {
  font-size: 12px;
  color: var(--muted);
  min-height: 30px;
}

.summary-box .value {
  font-size: 18px;
  font-weight: 800;
  color: #17324d;
  margin-top: 4px;
  word-break: break-word;
}

/* =========================
   TABLAS
========================= */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}



.table-wrap table {
  width: max-content;
  min-width: 1250px;
  border-collapse: collapse;
  font-size: 13px;
}


.table-wrap.table-compact table {
  min-width: 1050px;
}



.table-wrap th,
.table-wrap td {
  white-space: nowrap;
}


thead {
  background: #123f69;
  color: #fff;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #e7edf5;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #f1f7fd;
}

/* =========================
   FILTROS
========================= */

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(160px, 1fr)) minmax(130px, auto);
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

.filters .form-group {
  margin: 0;
  min-width: 0;
}

.filters .form-group label {
  display: block;
  margin-bottom: 8px;
  white-space: nowrap;
}

.filters .btn {
  min-width: 120px;
  width: 100%;
}

.filter-action {
  align-self: end;
}



/* =========================
   BLOQUES COLAPSABLES
========================= */
.form-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: visible;
  background: #fff;
  position: relative;
  z-index: 1;
}

.field-with-help,
.label-row,
.help-icon {
  position: relative;
}

.label-row {
  overflow: visible;
}

.help-icon {
  flex: 0 0 auto;
  z-index: 20;
}

.help-icon::after,
.help-icon::before {
  z-index: 9999;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #174f82;
  color: #fff;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
}

.block-header:hover {
  background: #15466f;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.block-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  transition: transform 0.2s ease;
}

.block-content {
  padding: 16px;
  background: #fff;
}

.form-block.collapsed .block-content {
  display: none;
}

.form-block.collapsed .block-toggle {
  transform: rotate(-90deg);
}

/* =========================
   LOGIN
========================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-header h1 {
  margin: 0 0 8px;
  color: #17324d;
}

.login-header p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.login-body {
  margin-top: 18px;
}

.help-box {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
}

/* =========================
   ESTADO DE CARGA
========================= */
body.loading {
  cursor: progress;
}

body.loading .btn {
  pointer-events: none;
  opacity: 0.8;
}

/* =========================
   USER MINI CARD
========================= */
.user-mini-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-mini-name {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.user-mini-email {
  font-size: 13px;
  color: rgba(255,255,255,0.92);
  word-break: break-word;
}

.user-mini-role {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1180px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters .btn {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .user-box {
    min-width: auto;
    max-width: none;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .container,
  .topbar-inner {
    width: min(100% - 20px, 1400px);
  }

  .form-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

.card-full {
  width: 100%;
}

  .block-header {
    padding: 12px 14px;
  }

  .help-icon::after {
    width: 210px;
    max-width: 210px;
  }

  table {
    min-width: 880px;
  }
}






.column-picker {
  position: absolute;
  top: 48px;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  padding: 12px;
  z-index: 2000;
}

.column-picker-title {
  font-weight: 800;
  margin-bottom: 10px;
  color: #17324d;
  font-size: 13px;
}

.column-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: #304458;
  cursor: pointer;
}

.column-picker input[type="checkbox"] {
  accent-color: #1f6aa5;
}

.col-brand,
.col-model,
.col-serial,
.col-dependency,
.col-responsible,
.col-value_total {
  display: table-cell;
}

/* BARRA SUPERIOR DE DESPLAZAMIENTO */
.table-scroll-top {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 18px;
  margin-bottom: 8px;
  background: #f1f5f9;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
}

.table-scroll-top div {
  height: 1px;
}

.table-scroll-top::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  height: 12px;
}

.table-scroll-top::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: #9fb3c8;
  border-radius: 999px;
}

.table-scroll-top::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: #e8eef5;
  border-radius: 999px;
}

tr.print-none {
  background: #fdecea !important;
}

tr.print-partial {
  background: #fff8e1 !important;
}

tr.print-full {
  background: #e8f5e9 !important;
}

/* =========================
   TABLA INVENTARIO - COLUMNA NOMBRE EN 2 LÍNEAS
========================= */

/* fija mejor la estructura de la tabla principal */
.table-wrap table {
  table-layout: fixed;
  width: max-content;
  min-width: 1450px;
}

/* alinear mejor las celdas */
.table-wrap th,
.table-wrap td {
  vertical-align: top;
}

/* columna 1: ID más compacta */
.table-wrap table thead tr th:nth-child(1),
.table-wrap table tbody tr td:nth-child(1) {
  width: 145px;
  min-width: 145px;
  max-width: 145px;
  white-space: nowrap;
}

/* columna 4: Nombre */
.table-wrap table thead tr th:nth-child(4),
.table-wrap table tbody tr td:nth-child(4) {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}

/* máximo 2 líneas visibles en el nombre */
.table-wrap table tbody tr td:nth-child(4) {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* columnas numéricas más ordenadas */
.table-wrap table thead tr th:nth-child(8),
.table-wrap table thead tr th:nth-child(14),
.table-wrap table tbody tr td:nth-child(8),
.table-wrap table tbody tr td:nth-child(14) {
  text-align: center;
  white-space: nowrap;
}

/* =========================
   CONTROL DE INVENTARIO
========================= */
.control-alert-ok {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.control-alert-observed {
  background: #fff8e1;
  color: #8a6d00;
  border: 1px solid #f0d98c;
}

.control-alert-missing {
  background: #fdecea;
  color: #c62828;
  border: 1px solid #f5c2c0;
}

#selectedControlItems textarea {
  min-width: 180px;
  min-height: 70px;
}

#selectedControlItems input[type="text"],
#selectedControlItems select,
#selectedControlItems textarea {
  width: 100%;
  box-sizing: border-box;
}

/* =========================
   CONTROL - SELECCION MULTIPLE
========================= */
#tableControlSearch th:first-child,
#tableControlSearch td:first-child {
  width: 55px;
  text-align: center;
}

#tableControlSearch input[type="checkbox"] {
  transform: scale(1.1);
  cursor: pointer;
}

/* =========================
   CONTROL - PAGINACION BUSQUEDA
========================= */
#controlSearchPagination {
  margin-top: 15px;
}

#controlSearchPaginationInfo {
  font-size: 13px;
  font-weight: 700;
  color: #304458;
}

/* =========================
   CONTROL - COLUMNAS TABLA CONTROLADAS
========================= */
#selectedColumnPicker {
  top: 44px;
  min-width: 250px;
  max-height: 420px;
  overflow-y: auto;
}

#tableSelectedControlItems th,
#tableSelectedControlItems td {
  vertical-align: top;
}