/* =========================================================
   WIRTZ HUB · RECURSOS · HERRAMIENTAS
   Control diario/técnico · préstamos · mantenimiento
   ========================================================= */

.tools-page {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 7px;
  min-height: calc(100vh - var(--topbar-height) - 44px);
  animation: fadeUp 0.2s ease both;
}

/* =========================================================
   HEADER COMPACTO
   ========================================================= */

.tools-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tools-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tools-brand__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.tools-brand__icon .icon {
  width: 15px;
  height: 15px;
}

.tools-brand h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.055em;
}

.tools-brand p {
  margin: 2px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 760;
  line-height: 1.25;
}

.tools-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

/* =========================================================
   BOTONES
   ========================================================= */

.tools-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.tools-btn .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2;
}

.tools-btn:active {
  transform: scale(0.98);
}

.tools-btn--light {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text-strong);
}

.tools-btn--light:hover {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.tools-btn--dark {
  border: 1px solid var(--text-strong);
  background: var(--text-strong);
  color: var(--white);
}

.tools-btn--dark:hover {
  opacity: 0.88;
}

html[data-theme="dark"] .tools-btn--dark {
  color: #090b10;
}

/* =========================================================
   MÉTRICAS COMPACTAS
   ========================================================= */

.tools-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.tools-metric {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 45px;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
}

.tools-metric:last-child {
  border-right: 0;
}

.tools-metric span {
  color: var(--muted);
  font-size: 7.2px;
  font-weight: 950;
  letter-spacing: 0.085em;
  line-height: 1;
  text-transform: uppercase;
}

.tools-metric strong {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.06em;
}

.tools-metric small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 820;
  line-height: 1;
}

/* =========================================================
   PANEL GENERAL
   ========================================================= */

.tools-panel,
.tools-history {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tools-toolbar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border-bottom: 1px solid var(--line);
}

.tools-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.tools-title span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.tools-title strong {
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

/* =========================================================
   FILTROS
   ========================================================= */

.tools-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.tools-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(390px, 100%);
  min-width: 240px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--muted);
  transition:
    background var(--transition),
    border-color var(--transition);
}

.tools-search:focus-within {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.tools-search .icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.tools-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  outline: none;
  font-size: 9px;
  font-weight: 780;
}

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

.tools-filters select {
  height: 28px;
  min-width: 104px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text-strong);
  outline: none;
  font-size: 8.5px;
  font-weight: 850;
}

/* =========================================================
   TABLA
   ========================================================= */

.tools-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}

.tools-table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
  background: var(--panel-solid);
}

.tools-table th,
.tools-table td {
  height: 31px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 8.6px;
  font-weight: 720;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.tools-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-solid);
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.tools-table tbody tr {
  transition:
    background var(--transition),
    color var(--transition);
}

.tools-table tbody tr:hover {
  background: var(--panel-hover);
}

.tools-table strong {
  color: var(--text-strong);
  font-weight: 950;
}

.tools-code {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text-strong);
  font-size: 7.5px;
  font-weight: 950;
}

.tools-name {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  color: var(--text-strong);
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.tools-kind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-strong);
  font-weight: 880;
}

.tools-kind .icon {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

.tools-status,
.tools-loan,
.tools-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text-strong);
  font-size: 7.5px;
  font-weight: 950;
}

.tools-status::before,
.tools-loan::before,
.tools-alert::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--muted);
}

.tools-status.is-ok::before,
.tools-loan.is-returned::before,
.tools-alert.is-clear::before {
  background: var(--success);
}

.tools-status.is-service::before,
.tools-loan.is-loaned::before,
.tools-alert.is-warning::before {
  background: var(--warning);
}

.tools-status.is-down::before,
.tools-alert.is-danger::before {
  background: var(--danger);
}

.tools-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-strong);
  font-weight: 870;
}

.tools-date .icon {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

/* =========================================================
   HISTORIAL ABAJO
   ========================================================= */

.tools-history {
  align-content: start;
}

.tools-history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.tools-history__head span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.tools-history__head strong {
  display: block;
  margin-top: 2px;
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.04em;
}

.tools-history__head .icon {
  width: 14px;
  height: 14px;
  color: var(--text-strong);
}

.tools-timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tools-event {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 7px;
  min-height: 62px;
  padding: 8px;
  border-right: 1px solid var(--line);
}

.tools-event:last-child {
  border-right: 0;
}

.tools-event__icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.tools-event__icon .icon {
  width: 12px;
  height: 12px;
}

.tools-event__body {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.tools-event__body strong {
  color: var(--text-strong);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.1;
}

.tools-event__body p {
  margin: 0;
  color: var(--muted);
  font-size: 7.8px;
  font-weight: 760;
  line-height: 1.3;
}

.tools-event__body small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 850;
  line-height: 1;
}

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

@media (max-width: 1380px) {
  .tools-head {
    grid-template-columns: 1fr;
  }

  .tools-actions {
    justify-content: flex-start;
  }

  .tools-toolbar {
    grid-template-columns: 1fr;
  }

  .tools-filters {
    justify-content: flex-start;
  }

  .tools-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tools-event:nth-child(2n) {
    border-right: 0;
  }

  .tools-event:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1100px) {
  .tools-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tools-metric:nth-child(3n) {
    border-right: 0;
  }

  .tools-metric:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .tools-actions,
  .tools-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tools-search {
    width: 100%;
    min-width: 0;
  }

  .tools-btn,
  .tools-filters select {
    width: 100%;
  }

  .tools-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tools-metric {
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .tools-metric:nth-child(1),
  .tools-metric:nth-child(2) {
    border-top: 0;
  }

  .tools-metric:nth-child(2n) {
    border-right: 0;
  }

  .tools-timeline {
    grid-template-columns: 1fr;
  }

  .tools-event {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .tools-event:first-child {
    border-top: 0;
  }

  .tools-brand {
    align-items: flex-start;
  }
}