/* Plataforma Control Facility V11.34 · claridad visual y contraste */
:root {
  --ui-brand: #0479a2;
  --ui-brand-strong: #056487;
  --ui-brand-deep: #063f58;
  --ui-brand-bright: #08abeb;
  --ui-brand-soft: #eaf7fc;
  --ui-canvas: #f3f6f8;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f7f9fa;
  --ui-text: #17313d;
  --ui-text-soft: #506773;
  --ui-border: #d4e0e5;
  --ui-border-strong: #afc6cf;
  --ui-success: #087647;
  --ui-success-soft: #eaf7f0;
  --ui-warning: #8a5900;
  --ui-warning-soft: #fff4cc;
  --ui-danger: #b42318;
  --ui-danger-soft: #fff0ef;
  --ui-radius-sm: 8px;
  --ui-radius: 12px;
  --ui-radius-lg: 16px;
  --ui-shadow-sm: 0 2px 8px rgba(23, 49, 61, 0.07);
  --ui-shadow: 0 12px 34px rgba(23, 49, 61, 0.12);
}

html {
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  color: var(--ui-text) !important;
  background: var(--ui-canvas) !important;
}

body,
button,
input,
select,
textarea,
table {
  font-family:
    Aptos, "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif !important;
}

/* Navegación lateral */
.sidebar {
  border-right: 1px solid #0c536f !important;
  background: #063f58 !important;
  box-shadow: 5px 0 18px rgba(6, 63, 88, 0.15) !important;
}

.brand {
  border-bottom: 1px solid rgba(255, 255, 255, 0.16) !important;
}

.brandmark {
  border: 1px solid rgba(255, 255, 255, 0.7) !important;
  background: #ffffff !important;
  box-shadow: 0 5px 16px rgba(2, 30, 42, 0.2) !important;
}

.brand strong,
.sidebar nav > button,
.sidebar nav .cf-nav-group-title,
.sidebar-foot button {
  color: #f4fbfd !important;
}

.brand span,
.nav-label,
.user small {
  color: #bfe9f7 !important;
}

.site-switch {
  border-color: rgba(255, 255, 255, 0.2) !important;
  background: #07364c !important;
}

.sidebar nav > button,
.sidebar nav .cf-nav-group-title,
.sidebar-foot button {
  border-radius: 8px !important;
}

.sidebar nav > button:hover,
.sidebar nav .cf-nav-group-title:hover,
.sidebar-foot button:hover {
  border-color: rgba(255, 255, 255, 0.25) !important;
  background: #0a526e !important;
}

.sidebar nav > button.active,
.sidebar nav > button.cf-nav-direct.active,
.sidebar nav .cf-nav-group.open .cf-nav-group-title {
  border-color: #35b9ea !important;
  background: #0479a2 !important;
  color: #ffffff !important;
  box-shadow: inset 4px 0 0 #7fdcff !important;
}

.sidebar nav .cf-nav-option {
  border-left-color: #4b8197 !important;
  color: #dff4fb !important;
}

.sidebar nav .cf-nav-option:hover {
  background: #0a4d67 !important;
  color: #ffffff !important;
}

.sidebar nav .cf-nav-option.active {
  border-left-color: #7fdcff !important;
  background: #0a5b79 !important;
  color: #ffffff !important;
}

.sidebar > #facilityLogout {
  border-color: #7fdcff !important;
  background: transparent !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

.sidebar > #facilityLogout:hover {
  background: #0a526e !important;
}

/* Cabeceras y estructura */
.top-strip {
  border-bottom: 1px solid var(--ui-border) !important;
  background: #ffffff !important;
  color: var(--ui-text-soft) !important;
}

main:not(.cf-dashboard-view) > header,
main.cf-dashboard-view > header {
  border: 1px solid var(--ui-border) !important;
  border-left: 5px solid var(--ui-brand-bright) !important;
  border-radius: var(--ui-radius) !important;
  background: #ffffff !important;
  box-shadow: var(--ui-shadow-sm) !important;
}

header h1,
main.cf-dashboard-view > header h1 {
  color: var(--ui-brand-deep) !important;
  font-weight: 780 !important;
  letter-spacing: -0.025em !important;
}

header p,
.toolbar p,
.panel-head p,
.installation-selector p {
  color: var(--ui-text-soft) !important;
}

.eyebrow {
  color: var(--ui-brand) !important;
}

/* Paneles y bloques */
.panel,
.filters-card,
.installation-selector,
.installation-card,
.asset-profile,
.bulk-import-card,
.cf-equipment-action-menu,
.kpis article,
.calendar,
.cf-dashboard-panel,
.cf-dashboard-filters {
  border-color: var(--ui-border) !important;
  border-radius: var(--ui-radius) !important;
  background: #ffffff !important;
  box-shadow: var(--ui-shadow-sm) !important;
}

.panel-head,
.toolbar {
  border-bottom-color: var(--ui-border) !important;
}

.panel-head h2,
.toolbar h2,
.installation-selector h2,
.profile-main h2,
.cal-head h3 {
  color: var(--ui-brand-deep) !important;
  font-weight: 760 !important;
}

.cf-equipment-action-menu,
.bulk-import-card {
  border-left: 4px solid var(--ui-brand-bright) !important;
  background: #f4fbfe !important;
}

.cf-form-section {
  border-color: #b8dce9 !important;
  border-left-color: var(--ui-brand) !important;
  background: var(--ui-brand-soft) !important;
}

/* Formularios */
.installation-form label,
.filter-row label,
.modal label,
.life-search label,
.provider-filter-grid label,
.cf-execution-filter-grid label,
.cf-qr-details label {
  color: #34505d !important;
  font-weight: 760 !important;
}

input,
select,
textarea,
.search,
.installation-form input,
.installation-form select,
.modal input,
.modal select,
.modal textarea,
.filter-row select,
.filters select,
.life-search input,
.life-search select,
.provider-filter-grid input,
.provider-filter-grid select,
.installation-selector-actions select,
.cf-execution-filter-grid input,
.cf-execution-filter-grid select {
  border-color: var(--ui-border-strong) !important;
  border-radius: var(--ui-radius-sm) !important;
  background: #ffffff !important;
  color: var(--ui-text) !important;
  box-shadow: inset 0 1px 1px rgba(23, 49, 61, 0.03) !important;
}

input::placeholder,
textarea::placeholder {
  color: #748893 !important;
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover,
.search:hover {
  border-color: #7fa9ba !important;
}

input:focus,
select:focus,
textarea:focus,
.search:focus-within {
  border-color: var(--ui-brand) !important;
  box-shadow: 0 0 0 3px rgba(4, 121, 162, 0.15) !important;
}

/* Acciones */
.primary,
.connection-warning button {
  border-color: var(--ui-brand) !important;
  background: var(--ui-brand) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 8px rgba(4, 121, 162, 0.18) !important;
}

.primary:hover,
.connection-warning button:hover {
  border-color: var(--ui-brand-strong) !important;
  background: var(--ui-brand-strong) !important;
  box-shadow: 0 5px 12px rgba(5, 100, 135, 0.22) !important;
}

.secondary,
.icon-btn,
.dashboard-clear,
.panel-head button,
.complete,
.cf-register-completed,
.cf-asset-qr-action,
.cf-asset-list-qr {
  border-color: #86bacc !important;
  background: #ffffff !important;
  color: var(--ui-brand-strong) !important;
  box-shadow: none !important;
}

.secondary:hover,
.icon-btn:hover,
.dashboard-clear:hover,
.panel-head button:hover,
.complete:hover,
.cf-register-completed:hover,
.cf-asset-qr-action:hover,
.cf-asset-list-qr:hover {
  border-color: var(--ui-brand) !important;
  background: var(--ui-brand-soft) !important;
  color: var(--ui-brand-deep) !important;
}

.danger-button,
.asset-list-delete,
.danger {
  border-color: #d89c97 !important;
  background: #ffffff !important;
  color: var(--ui-danger) !important;
}

.danger-button:hover,
.asset-list-delete:hover,
.danger:hover {
  border-color: var(--ui-danger) !important;
  background: var(--ui-danger-soft) !important;
}

button:disabled {
  cursor: not-allowed !important;
  opacity: 0.5 !important;
  box-shadow: none !important;
}

/* Indicadores */
.kpis {
  gap: 16px !important;
}

.kpis article,
.cf-execution-kpis article {
  position: relative;
  overflow: hidden;
  border-top: 4px solid var(--ui-brand) !important;
  background: #ffffff !important;
}

.kpis article::after,
.cf-execution-kpis article::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 58px;
  height: 58px;
  border-radius: 0 0 0 58px;
  background: rgba(8, 171, 235, 0.07);
  content: "";
  pointer-events: none;
}

.kpis article[data-cf-dashboard-tone="success"],
.cf-execution-kpis article[data-tone="realizada"] {
  border-top-color: var(--ui-success) !important;
}

.kpis article[data-cf-dashboard-tone="warning"],
.cf-execution-kpis article[data-tone="pendiente"] {
  border-top-color: #d19318 !important;
}

.kpis article[data-cf-dashboard-tone="danger"],
.cf-execution-kpis article[data-tone="vencida"] {
  border-top-color: var(--ui-danger) !important;
}

.kpi-top span,
.cf-execution-kpis span {
  color: var(--ui-text-soft) !important;
}

.kpis strong,
.cf-execution-kpis b {
  color: var(--ui-brand-deep) !important;
}

/* Equipos y hojas de vida */
.asset-cards button,
.asset-grid article,
.life-list > button {
  border-color: var(--ui-border) !important;
  border-radius: 10px !important;
  background: #ffffff !important;
  box-shadow: none !important;
}

.asset-cards button:hover,
.life-list > button:hover {
  border-color: #78bcd4 !important;
  background: #f5fbfd !important;
  box-shadow: 0 4px 12px rgba(23, 49, 61, 0.08) !important;
}

.back {
  border-bottom-color: var(--ui-border) !important;
  background: #f4f8fa !important;
  color: var(--ui-brand-strong) !important;
}

.profile-main {
  background: #ffffff !important;
}

.profile-grid {
  border-top: 1px solid var(--ui-border) !important;
  background: #f7f9fa !important;
}

.profile-grid div {
  border-color: var(--ui-border) !important;
}

.profile-grid span {
  color: var(--ui-text-soft) !important;
  font-weight: 760 !important;
}

.profile-grid b {
  color: var(--ui-text) !important;
}

.cf-qr-mobile-banner {
  border-color: #afdce9 !important;
  background: #eef9fd !important;
}

/* Tablas */
.table-wrap,
.cf-execution-table-wrap {
  border-color: #c8d6dc !important;
  border-radius: 10px !important;
  background: #ffffff !important;
  box-shadow: none !important;
}

thead th {
  border-bottom: 2px solid #9fb8c2 !important;
  background: #e9f2f6 !important;
  color: #234858 !important;
  font-size: 10.5px !important;
  font-weight: 820 !important;
  letter-spacing: 0.045em !important;
}

tbody td {
  border-bottom-color: #dde6ea !important;
  background: transparent !important;
  color: #233f4b !important;
}

tbody tr:nth-child(even) {
  background: #f8fafb !important;
}

tbody tr:hover {
  background: #ebf6fa !important;
}

td small {
  color: var(--ui-text-soft) !important;
}

.badge {
  border-width: 1px !important;
  font-weight: 800 !important;
}

.badge.red,
.cf-execution-status.vencida {
  border-color: #d48d87 !important;
  background: var(--ui-danger-soft) !important;
  color: var(--ui-danger) !important;
}

.badge.amber,
.cf-execution-status.proxima-vencer {
  border-color: #d7ae54 !important;
  background: var(--ui-warning-soft) !important;
  color: #684400 !important;
}

.badge.green,
.cf-execution-status.realizada {
  border-color: #74b596 !important;
  background: var(--ui-success-soft) !important;
  color: #075d38 !important;
}

.badge.gray,
.cf-execution-status.sin-fecha {
  border-color: #aebec5 !important;
  background: #f1f4f5 !important;
  color: #3f5863 !important;
}

.cf-execution-status.pendiente,
.cf-execution-status.en-ejecucion {
  border-color: #79b7cd !important;
  background: #eaf6fa !important;
  color: #075c7a !important;
}

/* Calendario */
.cal-head,
.weekdays b {
  border-color: var(--ui-border) !important;
  background: #edf4f7 !important;
  color: #34535f !important;
}

.days > div {
  border-color: #dce5e8 !important;
  background: #ffffff !important;
}

.days > div.outside {
  background: #f5f7f8 !important;
  color: #7b8d95 !important;
}

.days > div:hover {
  background: #f1f9fc !important;
}

.event {
  border: 1px solid #73b8d0 !important;
  background: #e8f6fb !important;
  color: #075a78 !important;
  font-weight: 760 !important;
}

.event.vencida,
.event.red {
  border-color: #d48d87 !important;
  background: var(--ui-danger-soft) !important;
  color: var(--ui-danger) !important;
}

.event.proxima-vencer,
.event.amber {
  border-color: #d7ae54 !important;
  background: var(--ui-warning-soft) !important;
  color: #684400 !important;
}

.event.realizada,
.event.green {
  border-color: #74b596 !important;
  background: var(--ui-success-soft) !important;
  color: #075d38 !important;
}

.month,
.cf-execution-filters {
  border-color: var(--ui-border) !important;
  background: #f7f9fa !important;
}

.cf-preventive-alert-row {
  background: #ffffff !important;
}

.cf-preventive-alert-row.vencida {
  background: var(--ui-danger-soft) !important;
}

.cf-preventive-alert-row.proxima-vencer {
  background: var(--ui-warning-soft) !important;
}

/* Ventanas */
.modal-backdrop {
  background: rgba(6, 36, 49, 0.7) !important;
  backdrop-filter: blur(3px) !important;
}

.modal {
  border-color: #c6d5db !important;
  border-radius: var(--ui-radius-lg) !important;
  background: #ffffff !important;
  box-shadow: 0 28px 70px rgba(5, 36, 49, 0.28) !important;
}

.modal-head,
.modal-actions {
  border-color: var(--ui-border) !important;
}

.modal-head > button {
  color: #405b67 !important;
}

.modal-head > button:hover {
  background: #e9f1f4 !important;
}

.cf-record-file-field,
.cf-completion-summary,
.cf-day-task,
.cf-next-maintenance-preview,
.cf-qr-note {
  border-color: #b7d7e2 !important;
  border-left-color: var(--ui-brand) !important;
  background: #f2f9fc !important;
}

.cf-qr-label-preview {
  border-color: var(--ui-brand) !important;
  box-shadow: 0 6px 20px rgba(4, 121, 162, 0.1) !important;
}

th[data-cf-equipment-type],
td[data-cf-equipment-type] {
  min-width: 128px;
}

.cf-equipment-type-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #a9cbd7;
  border-radius: 999px;
  background: #edf7fa;
  color: #07506c;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  line-height: 1.1;
  text-transform: uppercase;
}

.cf-equipment-type-badge[data-tone="servicio"] {
  border-color: #c7b5df;
  background: #f5f0fb;
  color: #68408b;
}

.cf-equipment-type-badge[data-tone="proyecto"] {
  border-color: #e1c586;
  background: #fff8e8;
  color: #855d08;
}

/* Pantalla de acceso */
#facilityAccess {
  background: #eef4f6 !important;
}

.facility-access-card {
  border: 1px solid #b9ccd4 !important;
  border-top: 5px solid var(--ui-brand-bright) !important;
  border-radius: 16px !important;
  background: #ffffff !important;
  box-shadow: 0 18px 46px rgba(23, 49, 61, 0.16) !important;
}

.facility-access-brand {
  border: 1px solid var(--ui-border) !important;
  box-shadow: none !important;
}

.facility-access-card h1 {
  color: var(--ui-brand-deep) !important;
}

.facility-access-card p {
  color: var(--ui-text-soft) !important;
}

.facility-access-card input {
  border-color: var(--ui-border-strong) !important;
  color: var(--ui-text) !important;
}

.facility-access-card button {
  background: var(--ui-brand) !important;
}

.facility-access-card button:hover {
  background: var(--ui-brand-strong) !important;
}

/* Apertura directa de fichas desde código QR */
.cf-qr-route-status {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9800;
  display: flex;
  width: min(460px, calc(100vw - 36px));
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid #a8ccd9;
  border-left: 5px solid var(--ui-brand);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(15, 53, 68, 0.2);
  color: var(--ui-text);
}

.cf-qr-route-status > div:first-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.cf-qr-route-status b {
  color: var(--ui-brand-deep);
  font-size: 0.93rem;
}

.cf-qr-route-detail {
  color: var(--ui-text-soft);
  font-size: 0.83rem;
  line-height: 1.4;
}

.cf-qr-route-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 7px;
}

.cf-qr-route-actions button {
  min-height: 38px;
  white-space: nowrap;
}

.cf-qr-route-status[data-tone="warning"],
.cf-qr-route-status[data-tone="connection"] {
  border-color: #e3c583;
  border-left-color: #bd7c08;
  background: #fffaf0;
}

.cf-qr-route-status[data-tone="success"] {
  border-color: #9bd0b0;
  border-left-color: #198754;
  background: #f3fbf6;
}

.cf-qr-route-status[data-tone="success"] .cf-qr-route-actions {
  display: none;
}

@media (max-width: 760px) {
  .sidebar {
    box-shadow: 3px 0 12px rgba(6, 63, 88, 0.14) !important;
  }

  .panel,
  .page-panel,
  .modal {
    border-radius: 10px !important;
  }

  main:not(.cf-dashboard-view) > header,
  main.cf-dashboard-view > header {
    border-radius: 10px !important;
  }

  .cf-qr-route-status {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .cf-qr-route-actions {
    grid-template-columns: 1fr;
  }

  .cf-qr-route-actions button {
    width: 100%;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
