:root {
  --color-bg: #eef1f5;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-primary: #1f3a5f;
  --color-primary-dark: #16314f;
  --color-muted: #5a6e8a;
  --sidebar-mobile: 0rem;
  --sidebar-tablet: 4.375rem;
  --sidebar-desktop: 13.75rem;
  --radius-md: 0.625rem;
  --radius-lg: 1.25rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
}

body {
  font-family: Arial, sans-serif;
  background: var(--color-bg);
  min-height: 100vh;
  color: #0f172a;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-mobile);
  min-width: var(--sidebar-mobile);
  background: #f8fafc;
  border-right: 1px solid #e9edf2;
  display: flex;
  flex-direction: column;
  height: inherit;
}

.sidebar-content {
  width: 100%;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: max-content;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.2s ease;
}

.sidebar-header {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid #eef2f8;
  text-align: center;
}

.sidebar-logo {
  max-width: 2.8rem;
  margin: 0 auto 0.4rem;
  display: block;
}

.sidebar-header h2,
.sidebar-nav .nav-item span,
.user-info .user-name,
.user-info .user-role,
.logout-btn-sidebar span {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.nav-item {
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  color: var(--color-muted);
  transition: all 0.2s;
  cursor: pointer;
  font-size: 0.9rem;
}

.nav-item i {
  font-size: 1.05rem;
}

.nav-item:hover,
.nav-item.active {
  background: #eef2f8;
  color: var(--color-primary);
}

.nav-item.active {
  border-left: 0.1875rem solid #2ecc71;
}

.nav-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-footer {
  padding: 0.6rem;
  border-top: 1px solid #eef2f8;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  justify-content: center;
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  background: #2ecc71;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
}

.logout-btn-sidebar {
  background: #8c929c;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  min-height: 2rem;
  min-width: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-contacts {
  display: none;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.55rem;
  gap: 0.45rem;
}

.sidebar-contact-link {
  display: block;
  color: var(--color-primary);
  word-break: break-word;
}

.sidebar-contact-link:hover {
  text-decoration: underline;
}

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: var(--color-surface);
  padding: 0.75rem;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mobile-sidebar-toggle {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #8c929c;
}

.page-title h1 {
  font-size: clamp(1.05rem, 3.5vw, 1.375rem);
  font-weight: 600;
  color: #0f172a;
}

.view-host {
  padding: 0.75rem;
}

.view-wrapper {
  padding: 0.75rem;
}

.container,
.form-card,
.login-box {
  width: min(100%, 76rem);
  margin: 0 auto;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid #edf2f7;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 1rem;
}

.form-card {
  border-radius: var(--radius-lg);
}

.login-box {
  width: min(100%, 28rem);
}

.form-section {
  margin-bottom: 1rem;
}

.form-card h2,
.container h2 {
  margin-bottom: 1.25rem;
}

.container h3,
.form-section h3 {
  margin-bottom: 0.75rem;
  color: var(--color-primary);
}

.form-section h3 {
  font-size: 1rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0.35rem;
}

.form-group {
  margin-bottom: 0.75rem;
}

label {
  font-weight: 700;
  display: block;
  margin-bottom: 0.3rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 0.375rem;
  padding: 0.65rem;
}

.input-with-icon {
  width: 100%;
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 0.375rem;
  padding-left: 0.625rem;
  background: white;
}

.input-with-icon i {
  color: var(--color-primary);
  margin-right: 0.5rem;
}

.input-with-icon input,
.input-with-icon select,
.input-with-icon textarea {
  border: none;
  outline: none;
  background: transparent;
  padding: 0.65rem 0;
}

button,
.btn-outline,
.btn-primary,
.btn-primary-green,
.volver-btn {
  min-height: 2.75rem;
  min-width: 2.75rem;
}

.btn-delete-icon,
.menu-trigger {
  min-height: 1.5rem;
  min-width: 1.5rem;
}

button {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 0.9rem;
}

.btn-primary {
  width: 100%;
  margin-top: 0.8rem;
}

.btn-primary i {
  margin-right: 0.5rem;
}

.link-button {
  background: transparent;
  color: var(--color-primary);
  border: none;
  padding: 0;
  margin-top: 0.8rem;
  min-height: auto;
  min-width: auto;
  font-size: 0.9rem;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--color-primary-dark);
  background: transparent;
}

.login-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #000000;
}

.login-reset-actions {
  display: flex;
  flex-direction: column;
}

.is-hidden {
  display: none !important;
}

.btn-outline {
  background: #8c929c;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
}

.consulta-header-actions .btn-outline {
  display: none;
}

.btn-primary-green {
  background: var(--color-primary);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
}

.btn-delete-icon {
  background: transparent;
  color: #5a6e8a;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-row-action {
  min-height: auto;
  min-width: auto;
  padding: 0.35rem 0.65rem;
  background: #eef2f8;
  color: var(--color-primary);
}

.btn-row-action-location {
  background: transparent;
  color: #5a6e8a;
}

.btn-delete-icon:hover,
.btn-row-action:hover,
.btn-outline:hover,
.logout-btn-sidebar:hover,
.menu-trigger:hover {
  background: #e2e8f0;
  color: var(--color-primary);
}

.table-action-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.actions-cell {
  white-space: nowrap;
}

.form-help {
  display: block;
  margin-top: 0.35rem;
  color: var(--color-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.consulta-header-actions,
.table-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.consulta-header-actions {
  position: relative;
}

.toolbar-menu-trigger {
  align-self: flex-end;
}

.table-toolbar {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #edf2f7;
}

@media (max-width: 1023px) {
  .table-toolbar {
    display: none;
  }

  .table-toolbar.mobile-open {
    display: flex;
  }
}

.search-wrapper {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  padding-inline: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}

.search-wrapper input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.45rem;
}

.consulta-header-actions .search-wrapper {
    margin-bottom: 0;
}

.filter-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
  width: 100%;
  align-items: end;
}

.grupo-filtro {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.grupo-filtro label {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-bottom: 0;
}

.form-section select,
.form-section input,
.form-section button {
  font-size: 0.85rem;
}

.ordenamiento-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  align-items: center;
}

.ordenamiento-controls span {
  font-size: 0.85rem;
  white-space: nowrap;

}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.form-section > div[style*="overflow-x:auto"],
.form-card > div[style*="overflow-x:auto"] {
  overflow-x: auto;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #ddd;
  font-size: 0.8rem;
  padding: 0.5rem;
  text-align: left;
}

th {
  background: var(--color-primary);
  color: white;
  text-align: center;
  font-weight: 400;
  white-space: nowrap;
}

.management-table {
  border-radius: 0.625rem;
}

.management-table td {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#tablaUsuarios td,
#tablaEquipos td {
  text-align: center;
}

.consulta-table .col-numero,
.consulta-table .col-estado,
.consulta-table .col-fecha-prog { width: 9%; }
.consulta-table .col-tipo { width: 10%; }
.consulta-table .col-equipo { width: 13%; }
.consulta-table .col-descripcion {
  width: 50%;
  min-width: 12rem;
}
.col-acciones { width: 1.6rem; }
#tablaEquipos .col-acciones {
  width: 4.75rem;
}

.consulta-table td.wrap-col,
.consulta-table td.nowrap-col {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.consulta-table {
  overflow: visible;
}

.consulta-table td.actions-menu {
  overflow: visible;
}

.actions-menu {
  position: relative;
}

.menu-trigger {
  cursor: pointer;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  color: var(--color-muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  min-width: 8.25rem;
  display: none;
}

.dropdown-menu a,
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  background: none;
  border: none;
  font-size: 0.8125rem;
  color: var(--color-muted);
  min-height: 1.2rem;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: #f1f5f9;
}

.dropdown-menu.show {
  display: block;
}

.modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: auto;
  background-color: rgba(0,0,0,0.4);
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 1rem;
  border: 1px solid #888;
  width: 95%;
  max-width: 45rem;
  border-radius: var(--radius-lg);
}

.modal-form-card {
  box-shadow: none;
  border: none;
  padding: 0.5rem 0 0;
}

.modal-form-card h3 {
  margin-bottom: 1.3rem;
  margin-top: 1.3rem;
}

#detallesContenido,
#detallesContenidoEditar {
  font-size: 0.9rem;
}

#detallesContenidoEditar {
  margin-bottom: 2rem;
}

.close {
  color: #aaa;
  float: right;
  font-size: 1.75rem;
  font-weight: 700;
  cursor: pointer;
}

.close:hover {
  color: black;
}

.detalle-linea {
  margin-bottom: 0.5rem;
}

.detalle-linea-item + .detalle-linea-item {
  margin-top: 0.5rem;
}

.detalle-label {
  font-weight: 600;
  display: inline-block;
  min-width: 8.5rem;
}

.kpi-card .kpi-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
}

.kpi-item {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 0.625rem;
  padding: 0.75rem;
}

.kpi-title {
  color: var(--color-primary);
  font-weight: 700;
  margin-bottom: 0.375rem;
}

.kpi-value {
  color: var(--color-muted);
}

.app-layout.sidebar-expanded .sidebar {
  width: min(15rem, 70vw);
  min-width: min(15rem, 70vw);
}

.app-layout.sidebar-expanded .sidebar-header h2,
.app-layout.sidebar-expanded .sidebar-nav .nav-item span,
.app-layout.sidebar-expanded .user-info .user-name,
.app-layout.sidebar-expanded .user-info .user-role,
.app-layout.sidebar-expanded .logout-btn-sidebar span {
  display: block;
}

.app-layout.sidebar-expanded .sidebar-header {
  padding-inline: 1rem;
}

.app-layout.sidebar-expanded .sidebar-logo {
  max-width: 5rem;
}

.app-layout.sidebar-expanded .nav-item {
  justify-content: flex-start;
  padding-inline: 1rem;
}

.app-layout.sidebar-expanded .user-info {
  justify-content: flex-start;
  gap: 0.75rem;
}

.app-layout.sidebar-expanded .logout-btn-sidebar {
  justify-content: center;
  gap: 0.5rem;
}

.app-layout.sidebar-expanded .sidebar-contacts {
  display: grid;
}

/* ── Checkboxes de ubicaciones en equipos ── */

.checkbox-ubicaciones {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0.4rem 0;
}

.checkbox-ubicacion-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  color: #0f172a;
}

.checkbox-ubicacion-item input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* ── Cliente selector (solo visible para superadmin) ── */
.cliente-selector-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.cliente-selector-label {
  font-size: 0.8rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.cliente-select {
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: #f8fafc;
  color: var(--color-primary);
  cursor: pointer;
  width: auto;
  min-width: 9rem;
  max-width: 16rem;
}

.cliente-select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

#loginForm {
  margin-top: 0.8rem;
}

@media (min-width: 640px) {
  
  .sidebar {
    width: var(--sidebar-tablet);
    min-width: var(--sidebar-tablet);
  }

  .view-host,
  .view-wrapper {
    padding: 1rem;
  }

  .container,
  .form-card,
  .login-box {
    padding: 1.25rem;
  }

  .top-bar {
    padding: 1rem;
  }

  .consulta-header-actions {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .search-wrapper {
    width: min(100%, 22rem);
  }

  .filter-group {
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  }

  .ordenamiento-controls {
    grid-template-columns: auto repeat(4, minmax(8rem, auto));
    justify-content: end;
  }

  th,
  td {
    font-size: 0.86rem;
  }

  .consulta-table td.nowrap-col {
    white-space: nowrap;
    text-align: center;
  }

  .modal-content {
    width: 92%;
    padding: 1.25rem;
  }

  .kpi-card .kpi-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-reset-actions {
    flex-direction: row;
    justify-content: space-between;
    gap: 0.2rem;
  }
}

@media (min-width: 1024px) {
  .toolbar-menu-trigger {
    display: none;
  }

  .table-toolbar {
    display: flex;
  }

  .sidebar {
    width: var(--sidebar-desktop);
    min-width: 10.3rem;
  }

  .sidebar-header {
    padding: 1.5rem 1rem;
  }

  .sidebar-logo {
    max-width: 7.5rem;
    margin-bottom: 0.75rem;
  }

  .sidebar-header h2,
  .sidebar-nav .nav-item span,
  .user-info .user-name,
  .user-info .user-role,
  .logout-btn-sidebar span {
    display: block;
  }

  .sidebar-nav {
    padding: 1rem 0;
  }

  .nav-item {
    justify-content: flex-start;
    padding: 0.75rem 1.25rem;
  }

  .user-info {
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .logout-btn-sidebar {
    justify-content: center;
    gap: 0.5rem;
  }

  .sidebar-contacts {
    display: grid;
  }

  .mobile-sidebar-toggle {
    display: none;
  }

  .top-bar {
    padding: 1.25rem;
  }

  .view-host {
    padding: 1.25rem;
  }

  .container,
  .form-card {
    padding: 1.5rem;
  }
      
  .consulta-header-actions .btn-outline {
  display: inline-block;
  }

  .btn-primary {
    width: auto;
    min-width: 12rem;
  }

  .kpi-card .kpi-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── Push prompt banner (Notificaciones) ───────────────────────────────── */
.push-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: #e3f2fd;
  border: 1px solid #1976d2;
  border-radius: 6px;
  color: #0d3b66;
  font-size: 14px;
}
.push-prompt.is-hidden { display: none; }
.push-prompt > .fa-bell { font-size: 18px; color: #1976d2; }
.push-prompt-text { flex: 1; }
.push-prompt-btn {
  background: #1976d2;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}
.push-prompt-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.push-prompt-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #0d3b66;
  cursor: pointer;
  padding: 0 4px;
}
@media (max-width: 600px) {
  .push-prompt { flex-wrap: wrap; }
  .push-prompt-text { flex: 1 1 100%; order: 1; }
  .push-prompt > .fa-bell { order: 0; }
  .push-prompt-btn { order: 2; }
  .push-prompt-close { order: 3; }
}
