/* =============================================
   🌓 Sistema de Temas — ManteIA Design System
   Basado en Shadcn/UI + Tailwind HSL variables
   ============================================= */

@custom-variant dark (&:where(.dark, .dark *));

:root {
  /* 🖤 LIGHT MODE — Fondo limpio, alto contraste */
  --background: 0 0% 100%;           /* #FFFFFF */
  --foreground: 240 10% 3.9%;        /* #09090B */

  --card: 0 0% 100%;                 /* #FFFFFF */
  --card-foreground: 240 10% 3.9%;   /* #09090B */

  --popover: 0 0% 100%;              /* #FFFFFF */
  --popover-foreground: 240 10% 3.9%;

  --primary: 221.2 83.2% 53.3%;      /* #3B82F6 */
  --primary-foreground: 210 40% 98%;

  --secondary: 240 4.8% 95.9%;       /* #F4F4F5 */
  --secondary-foreground: 240 5.9% 10%;

  --muted: 240 4.8% 95.9%;           /* #F4F4F5 */
  --muted-foreground: 240 3.8% 46.1%; /* #71717A */

  --accent: 240 4.8% 95.9%;          /* #F4F4F5 */
  --accent-foreground: 240 5.9% 10%;

  --destructive: 0 84.2% 60.2%;      /* #EF4444 */
  --destructive-foreground: 0 0% 98%;

  --border: 240 5.9% 90%;            /* #E4E4E7 */
  --input: 240 5.9% 90%;             /* #E4E4E7 */
  --ring: 221.2 83.2% 53.3%;        /* #3B82F6 */

  /* Sidebar Light */
  --sidebar-background: 0 0% 98%;
  --sidebar-foreground: 240 5.3% 26.1%;
  --sidebar-primary: 221.2 83.2% 53.3%;
  --sidebar-primary-foreground: 0 0% 98%;
  --sidebar-accent: 240 4.8% 95.9%;
  --sidebar-accent-foreground: 240 5.9% 10%;
  --sidebar-border: 220 13% 91%;
  --sidebar-ring: 221.2 83.2% 53.3%;

  --radius: 0.75rem;                 /* 12px */

  /* Tokens legacy (compatibilidad) */
  --bg-app: hsl(var(--background));
  --bg-card: hsl(var(--card));
  --border-ui: hsl(var(--border));
  --brand-primary: hsl(var(--primary));
  --sidebar-bg: hsl(240 5.9% 10%);
  --text-main: hsl(var(--foreground));
  --text-muted: hsl(var(--muted-foreground));
  --radius-2xl: 16px;
  --radius-xl: 12px;
  --transition-ui: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Tokens Phase 1: superficies, bordes y acciones semanticas */
  --surface-subtle: #f5f6f7;
  --border-hairline: 1px solid #e5e5e5;
  --action-success-bg: #ecfdf3;
  --action-success-text: #166534;
  --action-success-border: #bbf7d0;
  --action-danger-bg: #fef2f2;
  --action-danger-text: #991b1b;
  --action-danger-border: #fecaca;
}

.dark {
  /* 🌙 DARK MODE — Fondo profundo, bajo brillo */
  --background: 240 10% 3.9%;        /* #09090B */
  --foreground: 0 0% 98%;            /* #FAFAFA */

  --card: 240 10% 5.9%;             /* #0E0E10 */
  --card-foreground: 0 0% 98%;

  --popover: 240 10% 5.9%;
  --popover-foreground: 0 0% 98%;

  --primary: 221.2 83.2% 53.3%;      /* #3B82F6: azul de marca unico */
  --primary-foreground: 222.2 47.4% 11.2%;

  --secondary: 240 3.7% 15.9%;       /* #27272A */
  --secondary-foreground: 0 0% 98%;

  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;  /* #A1A1AA */

  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;

  --destructive: 0 62.8% 30.6%;      /* rojo oscuro */
  --destructive-foreground: 0 0% 98%;

  --border: 240 3.7% 15.9%;          /* #27272A */
  --input: 240 3.7% 15.9%;
  --ring: 221.2 83.2% 53.3%;

  /* Sidebar Dark */
  --sidebar-background: 240 5.9% 10%;
  --sidebar-foreground: 240 4.8% 95.9%;
  --sidebar-primary: 221.2 83.2% 53.3%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 240 3.7% 15.9%;
  --sidebar-accent-foreground: 240 4.8% 95.9%;
  --sidebar-border: 240 3.7% 15.9%;
  --sidebar-ring: 221.2 83.2% 53.3%;

  /* Tokens legacy (dark override) */
  --bg-app: hsl(var(--background));
  --bg-card: hsl(var(--card));
  --border-ui: hsl(var(--border));
  --brand-primary: hsl(var(--primary));
  --sidebar-bg: hsl(var(--sidebar-background));
  --text-main: hsl(var(--foreground));
  --text-muted: hsl(var(--muted-foreground));
}

/* Minimal base overrides to follow the GMAO PREMIUM manifesto */
html, body {
  background: var(--bg-app);
  color: var(--text-main);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

/* Prevención de 'Pull-to-refresh' o rebote vertical en el contenido principal */
#content-area {
  overscroll-behavior-y: none;
}

/* Keep the application inside the visible viewport as browser chrome changes. */
#main-app {
  height: 100dvh;
  min-height: 0;
}

#main-app[data-active-view="chat"] #mobile-header,
#main-app[data-active-view="chat"] #global-header {
  display: none !important;
}

#main-app[data-active-view="chat"] #content-area {
  padding: 0;
}

@media (max-width: 767px) {
  #main-app[data-active-view="planning"] #mobile-header {
    height: calc(3.5rem + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }

  #main-app[data-active-view="planning"] #content-area {
    padding-top: calc(3.5rem + env(safe-area-inset-top, 0px));
  }
}

/* Comportamiento táctil en contenedores scrolleables (Tablas y Sliders) */
.overflow-x-auto, 
.table-container, 
.custom-scrollbar-x,
#kanban-board,
.chat-markdown-table-wrapper {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.chat-markdown-table-wrapper {
  margin: 1rem 0;
  padding: 0.75rem;
  background: rgba(248,250,252,0.9);
  border-radius: 1rem;
  border: 1px solid rgba(226,232,240,0.9);
  position: relative;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  touch-action: pan-x pan-y !important;
  -webkit-overflow-scrolling: touch !important;
}
.chat-markdown-table-wrapper table,
.chat-markdown-container .chat-markdown-table-wrapper table,
.chat-markdown-container.prose .chat-markdown-table-wrapper table,
.chat-markdown-container.prose table {
  width: auto !important;
  min-width: 640px !important;
  max-width: none !important;
  display: inline-table !important;
  table-layout: auto !important;
  border-collapse: collapse !important;
}
.chat-markdown-table-wrapper th,
.chat-markdown-table-wrapper td,
.chat-markdown-container .chat-markdown-table-wrapper th,
.chat-markdown-container .chat-markdown-table-wrapper td,
.chat-markdown-container.prose .chat-markdown-table-wrapper th,
.chat-markdown-container.prose .chat-markdown-table-wrapper td,
.chat-markdown-container.prose table th,
.chat-markdown-container.prose table td {
  white-space: nowrap !important;
  padding: 0.75rem !important;
}

.chat-status-indicator {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.chat-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  display: inline-block;
}

.chat-status-indicator.chat-status-error {
  color: #b91c1c;
}

.chat-status-indicator.chat-status-error .chat-status-dot {
  background: #b91c1c;
}

.gmao-card { background: var(--bg-card); border-radius: var(--radius-2xl); border: 1px solid var(--border-ui); box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05); transition: var(--transition-ui); }
.gmao-card:hover { border-color: #cbd5e1; }

.material-modal-overlay {
  background: rgb(15 23 42 / 0.36) !important;
}

.material-modal-dialog {
  border: 1px solid #e5e7eb !important;
  border-radius: 24px !important;
  box-shadow: 0 18px 45px rgb(15 23 42 / 0.16) !important;
}

.material-modal-header {
  min-height: 62px;
  padding: 1.125rem 1.5rem !important;
  border-bottom-color: #edf0f2 !important;
}

.material-modal-title {
  color: #0f2747;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
}

.material-modal-close {
  color: #94a3b8;
  transition: color 150ms ease, background-color 150ms ease;
}

.material-modal-close:hover {
  color: #334155;
  background: var(--surface-subtle);
}

.material-modal-body {
  padding: 1.5rem !important;
  gap: 1.15rem !important;
}

.material-modal-field-label {
  color: #8495ad;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.material-modal-control {
  min-height: 43px;
  border-color: #dfe4ea !important;
  background: #fff !important;
  border-radius: 12px !important;
  color: #1e293b;
}

.material-modal-control:hover:not(:disabled) {
  border-color: #b8c5d4 !important;
}

.material-modal-control:focus {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.12) !important;
}

.material-modal-hint {
  color: #91a0b3;
}

.material-modal-selected {
  background: #f5f9ff !important;
  border-color: #d9e7fb !important;
}

.material-modal-footer {
  padding: 1rem 1.5rem 1.125rem !important;
  border-top-color: #edf0f2 !important;
  background: #fbfcfd !important;
}

.material-modal-cancel,
.material-modal-submit {
  min-height: 43px;
  border-radius: 11px !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.08em !important;
}

.material-modal-submit {
  background: #eaf2ff !important;
  border: 1px solid #d5e4fb !important;
  color: #7893b8 !important;
  box-shadow: none !important;
}

.material-modal-submit:not(:disabled) {
  background: #dceaff !important;
  color: #1d4f91 !important;
}

.material-modal-submit:not(:disabled):hover {
  background: #cfe0fb !important;
  color: #17447f !important;
}

.material-modal-submit:disabled {
  opacity: 1 !important;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .material-modal-header,
  .material-modal-body,
  .material-modal-footer {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

.gmao-input { border-radius: var(--radius-xl); border: 1px solid var(--border-ui); padding: 0.6rem 0.75rem; transition: var(--transition-ui); background: #f9fafb; }
.gmao-input:focus { outline: none; background: white; box-shadow: 0 0 0 4px rgba(59,130,246,0.08); border-color: var(--brand-primary); }

.asset-node-picker-panel { box-sizing: border-box; max-height: min(28rem, calc(100vh - 1.5rem)); overflow-y: auto; }
.asset-node-picker-panel--floating { position: absolute; top: calc(100% + 0.5rem); left: 50%; z-index: 120; width: min(28rem, calc(100vw - 2rem)); transform: translateX(-50%); }
.asset-node-picker-list { max-height: min(16rem, 50vh); overflow-y: auto; list-style: none; padding: 0; }
.asset-node-picker-toggle { display: inline-flex; align-items: center; justify-content: center; height: 1.5rem; }
.asset-node-picker-toggle svg { width: 0.875rem; height: 0.875rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.asset-node-picker-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.gmao-table td.machine-table-location { width: 14rem; max-width: 14rem; }
.machine-table-location-summary { display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* Creación de avisos: búsqueda explícita por nombre y navegación opcional por zonas. */
.physical-machine-search-controls { display: grid; grid-template-columns: minmax(0, 1fr) 2.75rem; align-items: start; gap: 0.5rem; }
.physical-machine-search-input { position: relative; min-width: 0; }
.physical-machine-search-icon { position: absolute; inset: 0 auto 0 0.875rem; display: flex; align-items: center; color: #94a3b8; pointer-events: none; }
.physical-machine-search-input .gmao-input { box-sizing: border-box; width: 100%; min-width: 0; height: 2.75rem; padding: 0.625rem 0.75rem 0.625rem 2.5rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; color: #334155; background: #f8fafc; font-size: 0.8125rem; }
.physical-machine-search-input .gmao-input::placeholder { color: #94a3b8; }
.physical-machine-search-input .gmao-input:disabled { opacity: 0.6; }
.physical-machine-zone-trigger { display: flex; width: 2.75rem; height: 2.75rem; align-items: center; justify-content: center; padding: 0; border: 1px solid #e2e8f0; border-radius: 0.75rem; color: #64748b; background: #fff; cursor: pointer; }
.physical-machine-zone-trigger:hover, .physical-machine-zone-trigger[aria-expanded="true"] { border-color: #bfdbfe; color: #2563eb; background: #eff6ff; }
.physical-machine-zone-trigger:disabled { opacity: 0.5; cursor: default; }
.physical-machine-zone-trigger svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.physical-machine-search-help, .physical-machine-search-status { margin: 0.5rem 0 0; color: #64748b; font-size: 0.6875rem; line-height: 1.5; }
.physical-machine-search-status:empty, .physical-machine-search [data-machine-zone-panel]:empty { display: none; }
.physical-machine-search-scope:not(.hidden) { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0.625rem; border: 1px solid #dbeafe; border-radius: 0.625rem; color: #1d4ed8; background: #eff6ff; font-size: 0.6875rem; }
.physical-machine-search-scope span { min-width: 0; overflow-wrap: anywhere; }
.physical-machine-search-scope button { flex-shrink: 0; padding: 0.25rem; border: 0; border-radius: 0.25rem; background: transparent; color: #64748b; font-size: 0.625rem; cursor: pointer; }
.physical-machine-zone-panel { max-height: none; padding: 0.75rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; background: #f8fafc; }
.physical-machine-zone-panel input[type="search"] { box-sizing: border-box; width: 100%; height: 2.375rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; background: #fff; font-size: 0.75rem; }
.physical-machine-zone-panel .asset-node-picker-list { max-height: 12rem; scrollbar-width: thin; }
.physical-machine-zone-panel .asset-node-picker-list button[aria-pressed="true"] { color: #1d4ed8; background: #eff6ff; }
.physical-machine-zone-panel button { overflow-wrap: anywhere; }
.physical-machine-search-results { max-height: 14rem; overflow-y: auto; padding: 0.375rem; border: 1px solid #e2e8f0; border-radius: 0.75rem; background: #fff; scrollbar-width: thin; }
.physical-machine-search-option { display: flex; width: 100%; min-width: 0; flex-direction: column; gap: 0.2rem; padding: 0.75rem; border: 0; border-radius: 0.5rem; color: #334155; background: transparent; text-align: left; cursor: pointer; }
.physical-machine-search-option + .physical-machine-search-option { margin-top: 0.125rem; }
.physical-machine-search-option:hover, .physical-machine-search-option[aria-pressed="true"] { color: #1d4ed8; background: #eff6ff; }
.physical-machine-search-option-name { font-size: 0.8125rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.physical-machine-search-option-detail { color: #64748b; font-size: 0.6875rem; line-height: 1.4; overflow-wrap: anywhere; }
.physical-machine-search-empty { margin: 0; padding: 0.75rem; color: #94a3b8; font-size: 0.75rem; text-align: center; }
.physical-machine-zone-trigger:focus-visible, .physical-machine-search-option:focus-visible, .physical-machine-search-scope button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* Nombres completos; el código y el tipo no restan ancho a la primera línea. */
.machine-zone-tree, .machine-zone-children { margin: 0; padding: 0; list-style: none; }
.machine-zone-tree > .machine-zone-item + .machine-zone-item { margin-top: 0.75rem; }
.machine-zone-row { display: flex; min-width: 0; align-items: flex-start; gap: 0.375rem; margin-left: calc(var(--machine-zone-level) * 0.75rem); padding: 0.5rem 0.5rem 0.5rem 0.25rem; border: 1px solid transparent; border-radius: 0.625rem; transition: background-color 150ms ease, border-color 150ms ease; }
.machine-zone-row--root { padding-top: 0.625rem; padding-bottom: 0.625rem; background: #f8fafc; }
.machine-zone-row:hover { background: #f1f5f9; }
.machine-zone-row--selected, .machine-zone-row--selected:hover { border-color: #dbeafe; background: #eff6ff; }
.machine-zone-row--partial { background: #f8fafc; }
.machine-zone-toggle { display: flex; flex: 0 0 1.375rem; align-items: center; justify-content: center; width: 1.375rem; height: 1.375rem; padding: 0; border: 0; border-radius: 0.3125rem; color: #94a3b8; background: transparent; cursor: pointer; }
.machine-zone-toggle:hover { color: #475569; background: #e2e8f0; }
.machine-zone-toggle:disabled { visibility: hidden; }
.machine-zone-toggle svg { width: 0.875rem; height: 0.875rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.machine-zone-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.machine-zone-label { display: flex; flex: 1; min-width: 0; align-items: flex-start; gap: 0.625rem; cursor: pointer; }
.machine-zone-checkbox { flex: 0 0 0.9375rem; width: 0.9375rem; height: 0.9375rem; margin: 0.1875rem 0 0; border: 1px solid #cbd5e1; border-radius: 0.25rem; accent-color: #2563eb; cursor: pointer; }
.machine-zone-checkbox:disabled { cursor: default; }
.machine-zone-text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 0.1875rem; }
.machine-zone-name { color: #475569; font-size: 0.8125rem; font-weight: 500; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
.machine-zone-row--root .machine-zone-name { color: #1e293b; font-weight: 650; }
.machine-zone-row--selected .machine-zone-name { color: #1d4ed8; }
.machine-zone-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; color: #64748b; font-size: 0.6875rem; line-height: 1.5; overflow-wrap: anywhere; }
.machine-zone-code { font-weight: 600; letter-spacing: 0.025em; }
.machine-zone-type { color: #64748b; }
.machine-zone-type::before { content: "·"; margin-right: 0.5rem; color: #94a3b8; }
.machine-zone-archived-badge { padding: 0.0625rem 0.375rem; border: 1px solid #e2e8f0; border-radius: 0.25rem; color: #64748b; background: #f1f5f9; font-size: 0.5625rem; }
.machine-zone-children { position: relative; margin-top: 0.125rem; }
.machine-zone-children::before { content: ""; position: absolute; top: 0.125rem; bottom: 0.75rem; left: calc(var(--machine-zone-level) * 0.75rem + 1rem); width: 1px; background: #e2e8f0; pointer-events: none; }
.machine-zone-toggle:focus-visible, .machine-zone-checkbox:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

.gmao-btn { display: inline-flex; items-center: center; justify-content: center; gap: 0.5rem; background: var(--brand-primary); color: white; padding: 0.6rem 1.25rem; border-radius: var(--radius-xl); font-weight: 600; font-size: 0.875rem; transition: var(--transition-ui); border: none; cursor: pointer; }
.gmao-btn:hover { filter: brightness(1.1); box-shadow: 0 4px 12px -2px rgba(59, 130, 246, 0.3); }
.gmao-btn.secondary { background: white; color: var(--text-muted); border: 1px solid var(--border-ui); }
.gmao-btn.secondary:hover { background: #f9fafb; color: var(--text-main); border-color: #cbd5e1; box-shadow: none; }
.gmao-btn.ghost { background: transparent; color: var(--text-muted); border: none; }
.gmao-btn.ghost:hover { background: #f1f5f9; color: var(--text-main); }
.gmao-ot-header-actions, .wo-assign-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.wo-assign-heading { margin-bottom: 4px; flex-shrink: 0; }
.wo-assign-heading h3 { min-width: 0; }
.gmao-ot-header-actions { justify-content: flex-end; }
.gmao-ot-cancel.gmao-btn, .wo-assign-form .gmao-ot-cancel.gmao-btn { align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 10px; color: #94a3b8; background: transparent; border: 0; border-radius: var(--radius-xl); box-shadow: none; }
.gmao-ot-cancel.gmao-btn:hover { color: var(--action-danger-text); background: var(--action-danger-bg); box-shadow: none; }
.gmao-ot-cancel.gmao-btn:focus-visible { outline: 2px solid var(--action-danger-text); outline-offset: 2px; }
.gmao-ot-cancel[hidden], [data-workflow-initial-actions][hidden], [data-assign-cancel-slot] .hidden { display: none !important; }

/* Aviso opcional: queda por debajo de los modales y no bloquea el trabajo en curso. */
.gmao-app-update-banner { position: fixed; z-index: 60; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); box-sizing: border-box; width: auto; max-width: 600px; margin-inline: auto; padding: 16px; border: 1px solid var(--border-ui); border-radius: var(--radius-2xl); background: var(--bg-card); box-shadow: 0 8px 24px #0f172a18; color: var(--text-main); }
.gmao-app-update-heading { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.gmao-app-update-heading > svg { flex-shrink: 0; margin-top: 2px; color: var(--brand-primary); }
.gmao-app-update-heading h2 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; }
.gmao-app-update-heading p { margin: 4px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.gmao-app-update-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.gmao-app-update-actions .gmao-btn { min-height: 44px; padding: 10px 14px; align-items: center; font-size: 12px; }
.gmao-app-update-feedback { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; }
.gmao-app-update-feedback:empty { display: none; }
.gmao-btn:active { transform: scale(0.98); }

/* Estado deshabilitado para botones */
.gmao-btn:disabled,
.gmao-btn.disabled {
  background: #cbd5e1 !important;
  color: #94a3b8 !important;
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none !important;
  transform: none !important;
}

.gmao-btn:disabled:hover,
.gmao-btn.disabled:hover {
  filter: none;
  box-shadow: none;
  transform: none;
}

/* Estado seleccionado para botones de filtro */
.gmao-btn.selected,
.filter-pill.active {
  background: var(--brand-primary) !important;
  color: white !important;
  border-color: var(--brand-primary) !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.gmao-badge { padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.025em; text-transform: uppercase; }
.badge-pending { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.badge-assigned { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-in_progress { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge-finished { background: #f5f3ff; color: #5b21b6; border: 1px solid #ddd6fe; }
.badge-validated { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-rejected { background: #fef2f2; color: #991b1b; border: 1px solid #fee2e2; }

.workorder-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(320px,1fr)); gap: 1rem; }
.workorder-card { padding: 1rem; display:flex; flex-direction:column; gap:0.5rem; }

.skeleton-row { height: 72px; border-radius: 12px; }

.hidden-mobile { display: none; }
@media (min-width: 768px) { .hidden-mobile { display: block; } }
.pending-mobile-only { display: block; }
/* Almacén: solicitudes vinculadas y fotografías de lectura sin montar controles de mantenimiento. */
.gmao-warehouse-purchases { display: grid; min-width: 0; gap: 12px; margin-top: 20px; padding: 20px 0; border-block: 1px solid var(--border-ui); }
.gmao-warehouse-purchases [hidden], .gmao-read-media-gallery [hidden], .gmao-read-image-dialog [hidden] { display: none !important; }
.gmao-warehouse-purchases-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.gmao-warehouse-purchases-heading h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-main); }
.gmao-warehouse-purchases .gmao-btn, .gmao-read-image-dialog .gmao-btn { min-height: 44px; align-items: center; font-size: 12px; padding: 10px 14px; white-space: normal; text-align: center; }
.gmao-warehouse-purchases-heading .gmao-btn { width: 100%; }
.gmao-warehouse-purchase-list { display: grid; gap: 8px; min-width: 0; }
.gmao-warehouse-purchase-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; min-width: 0; padding: 12px; border: 1px solid var(--border-ui); border-radius: var(--radius-xl); }
.gmao-warehouse-purchase-row > div { flex-basis: 100%; overflow-wrap: anywhere; }
.gmao-warehouse-purchase-status { display: inline-flex; max-width: 100%; border-radius: 999px; padding: 3px 8px; background: #f1f5f9; color: #475569; font-size: 10px; font-weight: 600; }
.gmao-warehouse-purchase-status[data-status="PENDING_APPROVAL"], .gmao-warehouse-purchase-status[data-status="RECEIVED_PARTIAL"] { color: #92400e; background: #fffbeb; }
.gmao-warehouse-purchase-status[data-status="ORDERED"] { color: #1d4ed8; background: #eff6ff; }
.gmao-warehouse-purchase-status[data-status="COMPLETED"] { color: #166534; background: #f0fdf4; }
.gmao-warehouse-purchase-status[data-status="CANCELLED"] { color: #991b1b; background: #fef2f2; }
.gmao-warehouse-purchase-pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gmao-warehouse-signatures { border: 1px solid var(--border-ui); border-radius: var(--radius-xl); padding: 0 12px; }
.gmao-warehouse-signatures summary { min-height: 44px; padding-block: 12px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.gmao-warehouse-signatures > div { padding-bottom: 12px; }
.gmao-production-detail-only [data-review-metadata] { overflow-wrap: anywhere; }
.gmao-read-media-gallery { display: grid; grid-template-columns: repeat(auto-fill, 88px); gap: 8px; min-width: 0; }
.gmao-read-media-gallery[hidden] { display: none; }
.gmao-read-media-item { position: relative; display: grid; place-items: center; width: 88px; height: 88px; padding: 0; overflow: hidden; border: 1px solid var(--border-ui); border-radius: var(--radius-xl); background: #f8fafc; cursor: pointer; }
.gmao-read-media-item:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.gmao-read-media-item img { width: 100%; height: 100%; object-fit: cover; }
.gmao-read-media-item span { position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; background: #f8fafc; }
.gmao-read-image-dialog { width: calc(100% - 24px); max-width: 960px; height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--border-ui); border-radius: var(--radius-2xl); background: var(--bg-card); color: var(--text-main); }
.gmao-read-image-dialog[open] { display: flex; flex-direction: column; }
.gmao-read-image-dialog::backdrop { background: #0f172acc; }
.gmao-read-image-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-ui); }
.gmao-read-image-heading h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gmao-read-image-heading button { flex-shrink: 0; }
.gmao-read-image-body { display: grid; place-items: center; flex: 1; min-height: 0; padding: 16px; overflow: auto; }
.gmao-read-image-body > * { grid-area: 1 / 1; }
.gmao-read-image-body img { max-width: 100%; max-height: calc(100dvh - 132px); object-fit: contain; }
@media (min-width: 640px) {
  .gmao-warehouse-purchases-heading .gmao-btn { width: auto; }
  .gmao-warehouse-purchase-row > div { flex-basis: 0; }
}
@media (max-width: 1023px) {
  .gmao-production-detail-only .gmao-production-detail-header { position: static; }
}
/* Pendientes de almacén: componentes compartidos con filas compactas y controles móviles. */
.gmao-pending-view { width: 100%; max-width: 1120px; margin: 0 auto; min-width: 0; flex-shrink: 0; }
.gmao-pending-view [hidden] { display: none !important; }
.gmao-pending-heading { margin-bottom: 20px; }
.gmao-pending-heading h2 { margin: 0; font-size: 20px; font-weight: 700; color: #0f172a; letter-spacing: -.025em; }
.gmao-pending-heading p { margin: 4px 0 0; color: #64748b; font-size: 13px; }
.gmao-pending-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e2e8f0; margin-bottom: 20px; }
.gmao-pending-tabs .gmao-btn { min-height: 44px; flex: 1; white-space: normal; border: 0; border-radius: 0; margin-bottom: -1px; background: transparent; box-shadow: none; color: #64748b; font-size: 12px; padding: 10px 8px; border-bottom: 2px solid transparent; }
.gmao-pending-tabs .gmao-btn[aria-selected="true"] { color: #2563eb; border-bottom-color: #2563eb; background: #eff6ff80; }
.gmao-material-waits-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.gmao-material-waits-search { flex: 1 1 280px; min-width: 0; }
.gmao-material-waits-search .gmao-filter-tags { display: none; }
.gmao-material-waits-search .gmao-filter-input { height: 40px; font-weight: 500; }
.gmao-material-waits-status { display: flex; gap: 4px; padding: 3px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; }
.gmao-material-waits-status .gmao-btn { height: 32px; min-height: 32px; padding: 4px 10px; font-size: 11px; background: transparent; border: 0; color: #64748b; box-shadow: none; }
.gmao-material-waits-status .gmao-btn[aria-pressed="true"] { background: #fff; color: #1d4ed8; box-shadow: 0 1px 3px #0f172a12; }
.gmao-material-waits-summary { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 12px; gap: 8px; color: #64748b; font-size: 11px; }
.gmao-material-waits-summary .gmao-btn { min-height: 32px; padding: 5px 10px; font-size: 11px; }
.gmao-material-waits-feedback { border: 1px solid #fde68a; background: #fffbeb; color: #92400e; padding: 12px; border-radius: 10px; font-size: 12px; line-height: 1.5; margin-bottom: 12px; overflow-wrap: anywhere; }
.gmao-material-waits-state { display: flex; align-items: center; flex-direction: column; text-align: center; padding: 48px 16px; border: 1px dashed #e2e8f0; border-radius: 12px; color: #64748b; }
.gmao-material-waits-state svg { color: #94a3b8; margin-bottom: 12px; }
.gmao-material-waits-state h3 { font-size: 13px; color: #334155; font-weight: 600; }
.gmao-material-waits-state p { font-size: 12px; line-height: 1.5; margin: 6px 0 12px; max-width: 400px; }
.gmao-material-waits-list { display: grid; gap: 8px; }
.gmao-material-wait-row.gmao-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px; margin: 0; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: none; }
.gmao-material-wait-main { min-width: 0; }
.gmao-material-wait-reference { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 11px; }
.gmao-material-wait-reference > span:first-child { color: #1e40af; font-weight: 700; font-variant-numeric: tabular-nums; }
.gmao-material-wait-badge { font-size: 10px; font-weight: 600; border: 1px solid #fde68a; background: #fffbeb; color: #92400e; border-radius: 999px; padding: 2px 8px; }
.gmao-material-wait-badge[data-status="in_progress"] { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.gmao-material-wait-cycle { color: #64748b; font-size: 10px; }
.gmao-material-wait-main h3 { color: #0f172a; font-size: 13px; font-weight: 600; margin: 7px 0 12px; line-height: 1.45; overflow-wrap: anywhere; }
.gmao-material-wait-meta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 0; }
.gmao-material-wait-meta > div { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 6px; min-width: 0; }
.gmao-material-wait-meta dt { font-size: 10px; color: #94a3b8; }
.gmao-material-wait-meta dd { margin: 0; font-size: 11px; color: #475569; overflow-wrap: anywhere; }
.gmao-material-wait-side { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 12px; min-width: 0; }
.gmao-material-wait-manager { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 10px; color: #64748b; }
.gmao-material-wait-manager strong { font-weight: 600; color: #334155; }
.gmao-material-wait-manager time { color: #94a3b8; }
.gmao-material-wait-actions { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.gmao-material-wait-actions .gmao-btn { min-height: 36px; padding: 7px 10px; font-size: 11px; flex: 1; justify-content: center; white-space: normal; text-align: center; }
.gmao-material-waits-pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; font-size: 11px; color: #64748b; }
.gmao-material-waits-pagination > div { display: flex; gap: 6px; }
.gmao-material-waits-pagination .gmao-btn { min-height: 36px; font-size: 11px; padding: 7px 10px; }
.gmao-material-wait-dialog { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #0f172a66; backdrop-filter: blur(2px); }
.gmao-material-wait-dialog.hidden { display: none; }
.gmao-material-wait-dialog > .gmao-card { width: calc(100% - 24px); max-width: 420px; margin: 12px; padding: 22px; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior-y: contain; border-radius: 16px; background: #fff; }
.gmao-material-wait-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gmao-material-wait-dialog-heading h3 { font-size: 16px; font-weight: 700; color: #0f172a; }
.gmao-material-wait-dialog-heading button { min-height: 30px; padding: 6px; }
.gmao-material-wait-dialog-order { font-size: 11px; color: #2563eb; margin: 8px 0; font-weight: 600; }
.gmao-material-wait-dialog-help { font-size: 12px; line-height: 1.6; color: #64748b; margin-bottom: 18px; }
.gmao-material-wait-dialog label { display: block; font-size: 11px; color: #334155; font-weight: 600; margin-bottom: 7px; }
.gmao-material-wait-dialog textarea.gmao-input { width: 100%; resize: vertical; min-height: 88px; padding: 10px 12px; font-size: 12px; line-height: 1.5; margin-bottom: 12px; }
.gmao-material-wait-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.gmao-material-wait-dialog-actions .gmao-btn { min-height: 36px; font-size: 11px; padding: 8px 12px; }
@media (max-width: 767px) {
  .gmao-material-waits-status { width: 100%; }
  .gmao-material-waits-status .gmao-btn { flex: 1; height: 40px; min-height: 40px; }
  .gmao-material-wait-actions .gmao-btn, .gmao-material-waits-pagination .gmao-btn, .gmao-material-wait-dialog-actions .gmao-btn { min-height: 44px; }
  .gmao-material-wait-dialog > .gmao-card { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}
@media (min-width: 768px) {
  .gmao-pending-tabs .gmao-btn { flex: none; padding-inline: 20px; }
  .gmao-material-wait-row.gmao-card { grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; }
  .gmao-material-wait-side { align-items: flex-end; }
  .gmao-material-wait-manager { justify-content: flex-end; }
  .gmao-material-wait-meta { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .gmao-material-wait-meta > div { display: block; }
  .gmao-material-wait-meta dd { margin-top: 3px; }
}
.pending-mobile-only.hidden { display: none; }
@media (min-width: 768px) { .pending-mobile-only { display: none; } }
.pending-mobile-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
}
.pending-mobile-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
}
@media (min-width: 768px) { .pending-mobile-actions { display: none !important; } }

.transition-ui { transition: var(--transition-ui); }

/* Empty state */
.empty-state { text-align:center; padding:2rem; }

/* --- ASISTENTE DE CAMPO (CHAT OT) --- */

/* Reformulación Final del Layout del Modal */
#wo-detail-modal > div {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 42rem; /* Estado normal (Cerrado) */
    height: 99vh;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    background: white;
    position: relative;
}

#wo-detail-modal.chat-open > div {
    width: min(96vw, 1440px);
    max-width: min(96vw, 1440px); /* Más espacio para el chat manteniendo una OT cómoda */
}

#wo-detail-modal.chat-expanded > div {
    max-width: 100%; /* Todo el ancho disponible */
}

/* Zona principal de la OT (Recuperando el scroll espectacular) */
#wo-detail-modal > div > div:first-of-type {
    flex: 1; /* Ocupa todo el espacio disponible */
    display: flex;
    flex-direction: column;
    min-width: 0; /* Permitir que sea flexible */
    height: 100%;
    background: white;
    z-index: 10;
    transition: all 0.3s ease-in-out;
}

#wo-detail-modal.chat-expanded > div > div:first-of-type {
    flex: 0;
    width: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Scroll interno de la OT */
#wo-detail-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
    min-height: 0; /* Importante para que el flex-1 funcione en contenedores con scroll */
}

/* Contenedor del Asistente (Derecha, Deslizante) */
.ot-assistant-container {
    width: 0;
    /* Cerrado, su cabecera desbordaba el diálogo y scrollIntoView desplazaba toda la ficha hacia la izquierda. */
    overflow: hidden;
    flex-shrink: 0;
    height: 100%;
    background: #F8FAFC;
    border-left: 1px solid #F1F5F9;
    display: flex;
    flex-direction: column;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

#wo-detail-modal.chat-open .ot-assistant-container {
    width: clamp(420px, 36%, 520px);
    visibility: visible;
}

@media (min-width: 768px) and (max-width: 1099px) {
    #wo-detail-modal.chat-open .ot-assistant-container {
        width: clamp(300px, 36vw, 420px);
    }
}

#wo-detail-modal.chat-expanded .ot-assistant-container {
    width: 100%;
    flex: 1;
    border-left: none;
    visibility: visible;
}

@media (min-width: 768px) {
    #wo-detail-modal.chat-expanded #chat-messages-list {
        width: min(100%, 960px);
        margin-inline: auto;
    }
}

.ot-chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
}

/* FAB (Botón Flotante) */
.ot-chat-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    background: #3B82F6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.5);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    border: none;
    outline: none;
}

.ot-chat-fab:hover { transform: scale(1.1) rotate(5deg); }

.pulse-notification {
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.ot-chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 0.75rem;
    height: 0.75rem;
    background: #10B981;
    border: 2px solid white;
    border-radius: 9999px;
}

/* Responsive (Mobile < 768px) */
.body-lock { overflow: hidden !important; }

.metadata-field-pending {
  border: 1px dashed #93c5fd !important;
  border-radius: 0.5rem;
  background: #eff6ff !important;
  min-height: 1.75rem;
  padding: 0.25rem 0.5rem !important;
}

.metadata-field-pending::placeholder {
  color: #94a3b8;
  font-style: italic;
}

@media (max-width: 767px) {
    #wo-detail-modal.chat-open > div {
        max-width: 100%;
    }
    
    .ot-assistant-container {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100% !important;
        height: 98vh;
        z-index: 200;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
        border-left: none !important;
        box-shadow: 0 -20px 25px -5px rgba(0,0,0,0.1), 0 -10px 10px -5px rgba(0,0,0,0.04);
    }
    
    #wo-detail-modal.chat-open .ot-assistant-container {
        transform: translateY(0);
    }
    
    .body-lock { overflow: hidden !important; }
}

/* Chat UI */
.ot-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #F8FAFC;
    scroll-behavior: smooth;
}

.ot-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ot-msg-user {
    align-self: flex-end;
    background: #3B82F6;
    color: white;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.ot-msg-ai {
    align-self: flex-start;
    background: white;
    color: #1E293B;
    border: 1px solid #E2E8F0;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Markdown simple styles inside chat */
.ot-msg-ai p { margin-bottom: 0.5rem; }
.ot-msg-ai p:last-child { margin-bottom: 0; }
.ot-msg-ai ul, .ot-msg-ai ol { margin-left: 1.25rem; margin-bottom: 0.5rem; }
.ot-msg-ai code { background: #F1F5F9; padding: 0.1rem 0.3rem; border-radius: 0.25rem; font-size: 0.8rem; }

.ot-suggested-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #E2E8F0;
}

.ot-action-btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ot-action-btn:hover:not(:disabled) {
    background: #E2E8F0;
    border-color: #CBD5E1;
    transform: translateX(4px);
}

.ot-action-btn.btn-loading {
    background: #F8FAFC;
    color: #94A3B8;
    cursor: wait;
}

.ot-action-btn.btn-success {
    background: #DCFCE7;
    color: #166534;
    border-color: #BBF7D0;
}

/* Nuevos estilos para acciones sugeridas con aceptar/rechazar */
.suggested-action-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 1rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
}

.suggested-action-card:hover {
    border-color: #CBD5E1;
    background: #F1F5F9;
}

.suggested-action-card.accepted {
    border-color: #10B981;
    background: #ECFDF5;
}

.suggested-action-card.rejected {
    opacity: 0.6;
    filter: grayscale(0.5);
    background: #F1F5F9;
}

.chat-locked {
    pointer-events: none;
    opacity: 0.7;
}

.chat-locked textarea, .chat-locked button {
    cursor: not-allowed;
}

.ot-action-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Estilos WhatsApp Recording */
.recording-active-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #FEF2F2;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    flex: 1;
    border: 1px solid #FEE2E2;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background: #EF4444;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.waveform-sim {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
    flex: 1;
}

.waveform-sim span {
    width: 3px;
    background: #EF4444;
    border-radius: 10px;
}

/* Pre-escucha styles */
.audio-preview-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #F1F5F9;
    padding: 0.5rem;
    border-radius: 0.75rem;
    flex: 1;
}

.audio-preview-container audio {
    height: 32px;
    flex: 1;
}

.btn-trash {
    padding: 0.5rem;
    color: #94A3B8;
    transition: color 0.2s;
}
.btn-trash:hover { color: #EF4444; }

    /* --- COMPONENTES DE CHAT REUTILIZABLES --- */

/* Animación suave para las transiciones de carga entre vistas */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-toast-slide-up {
  animation: toastSlideUp 0.28s ease-out both;
}
@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#toast-container {
  z-index: 9999;
  pointer-events: none;
}

#toast-container > .toast-card {
  pointer-events: auto;
}

/* Los avisos van arriba: abajo tapaban (y bloqueaban el toque de) los botones de acción de formularios y modales. */
#toast-container {
  top: 4.5rem;
  bottom: auto;
}

/* En escritorio la ficha de OT ocupa el centro: los avisos se estrechan para quedar a su derecha sin tapar sus botones. */
@media (min-width: 768px) {
  #toast-container {
    width: 17.5rem;
  }

  #toast-container > .toast-card {
    min-width: 0;
    max-width: 17.5rem;
  }
}

@media (max-width: 767px) {
  #toast-container {
    top: max(0.75rem, env(safe-area-inset-top));
    right: 0.75rem;
    left: 0.75rem;
    align-items: stretch;
  }

  #toast-container > .toast-card {
    max-width: none;
  }
}

/* Guías visuales para el árbol de carpetas */
.tree-line {
  position: relative; /* Necesario para las líneas de conexión */
}
.tree-line > div::before {
  content: "";
  position: absolute; /* Línea vertical */
  left: -1rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #e5e7eb;
}

/* Animación para rotar el cheurón */
.chevron-icon {
  transition: transform 0.2s ease;
}
.is-collapsed .chevron-icon {
  transform: rotate(-90deg);
}
.is-collapsed .folder-content {
  display: none;
}
.is-collapsed .folder-icon-main {
  color: #9ca3af;
}

/* Estilo para el scrollbar del historial fusionado */
.custom-scrollbar::-webkit-scrollbar {
  width: 3px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Asegura el centrado vertical del login */
#login-section {
  min-height: 100vh !important;
}

/* Optimización para impresión de informes (PDF) */
@media print {
  #main-sidebar,
  #mobile-header,
  #toast-container,
  #upload-status-container,
  .no-print,
  button {
    display: none !important;
  }
  #main-app {
    display: block !important;
  }
  #content-area {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    overflow: visible !important;
  }
}

/* Animación Slide Up para Menús Móviles */
@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.animate-slide-up {
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Animación Slide In Right para Paneles Laterales */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}
.animate-slide-in-right {
  animation: slide-in-right 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Skeleton Screen (Brillo pulsante) */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #f9fafb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite ease-in-out;
  border-radius: 0.5rem;
}
@keyframes skeleton-loading {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* Estilos para acordeones del sidebar */
.accordion-content {
  display: block;
  overflow: visible;
  max-height: 500px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.accordion-content.hidden {
  display: none;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

/* Estilos visuales del sidebar: ver assets/sidebar.css */

#main-sidebar #nav-chat-history-section:not(.hidden) {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
}

#main-sidebar #nav-chat-history-section.hidden {
  display: none;
}

#main-sidebar #nav-chat-history-section > div:last-child {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.custom-scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.custom-scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.chat-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.animate-bounce-in {
    animation: bounceIn 0.5s cubic-bezier(0.36, 0, 0.66, -0.56) both;
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* Bottom Sheet Mobile */
.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.bottom-sheet-overlay.active {
    display: block;
    opacity: 1;
}

.bottom-sheet-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    z-index: 10001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.1);
}

.bottom-sheet-container.active {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 9999px;
    margin: 12px auto;
    flex-shrink: 0;
}

.bottom-sheet-content {
    overflow-y: auto;
    padding: 0 16px 32px 16px;
}

.bottom-sheet-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    transition: background-color 0.2s;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

.bottom-sheet-item:active {
    background-color: #f8fafc;
}

/* Animaciones de Almacén */
.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ============================================
   GMAO SELECT — Misma apariencia que gmao-input
   ============================================ */
.gmao-select {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-ui);
  padding: 0.6rem 0.75rem;
  transition: var(--transition-ui);
  background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2rem;
  cursor: pointer;
}
.gmao-select:focus {
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.08);
  border-color: var(--brand-primary);
}

/* ============================================
   GMAO BTN DANGER — Botón destructivo rojo
   ============================================ */
.gmao-btn.danger {
  background: hsl(var(--destructive));
  color: white;
  border: none;
}
.gmao-btn.danger:hover {
  filter: brightness(0.9);
  box-shadow: 0 4px 12px -2px hsl(var(--destructive) / 0.3);
}

/* ============================================
   GMAO BTN ICON — Botón cuadrado solo icono 36x36
   ============================================ */
.gmao-btn.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  #assets-manage-header {
    padding: 0.75rem 1rem;
  }

  #assets-manage-header #create-machine-btn,
  #assets-manage-header #export-machines-btn {
    display: none;
  }

  #assets-manage-content {
    padding: 0 1rem 2rem;
  }

  #machines-container {
    gap: 0.75rem;
  }

  #machines-container .machine-asset-card {
    padding: 0.75rem;
  }

  #machines-container .machine-asset-heading {
    margin-bottom: 0.5rem;
  }

  #machines-container .machine-subtitle {
    margin-bottom: 0.5rem;
  }

  #machines-container .machine-technical-summary {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
  }

  #machines-container .machine-asset-footer {
    padding-top: 0.5rem;
  }
}

/* ============================================
   BADGES DE USUARIO
   ============================================ */
.badge-active {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.badge-inactive {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fee2e2;
}
.badge-role {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ============================================
   GMAO TABLE — Tabla base semántica
   ============================================ */
.gmao-table {
  width: 100%;
  text-align: left;
  border-collapse: collapse;
}
.gmao-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid var(--border-ui);
  padding: 1rem;
}
.gmao-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}
.gmao-table tbody tr:hover {
  background: hsl(var(--muted) / 0.4);
  transition: background-color 0.15s ease;
}

/* ============================================
   GMAO EMPTY STATE — Estado vacío centrado
   ============================================ */
.gmao-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 0.75rem;
}
.gmao-empty-state svg,
.gmao-empty-state .empty-icon {
  width: 48px;
  height: 48px;
  color: hsl(var(--muted-foreground));
  opacity: 0.5;
}
.gmao-empty-state h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}
.gmao-empty-state p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 24rem;
}

/* ============================================
   GMAO SPINNER — Indicador de carga
   ============================================ */
.gmao-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2.5px solid hsl(var(--muted-foreground) / 0.25);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: gmao-spin 0.7s linear infinite;
}
@keyframes gmao-spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   ESTILOS WIZARD - CREACIÓN DE ARTÍCULO INVENTARIO
   ============================================ */

/* Drag & Drop Zone */
.drag-drop-zone {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drag-drop-zone:hover {
    border-color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.02);
}

.drag-drop-zone.drag-over {
    border-color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.08);
    transform: scale(1.01);
}

.drag-drop-zone.active {
    border-color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.12);
}

/* Lista de Archivos Adjuntos */
.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--border-ui);
    border-radius: var(--radius-xl);
    transition: var(--transition-ui);
}

.file-item:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.file-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.file-item-icon.pdf { background: #FEF2F2; color: #EF4444; }
.file-item-icon.image { background: #F0FDF4; color: #10B981; }
.file-item-icon.cad { background: #EFF6FF; color: #3B82F6; }
.file-item-icon.default { background: #F8FAFC; color: #64748B; }

.file-item-details {
    flex: 1;
    min-width: 0;
}

.file-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-item-remove {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-ui);
    flex-shrink: 0;
}

.file-item-remove:hover {
    background: #FEF2F2;
    color: #EF4444;
}

/* Animaciones del Wizard */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   VARIANTES ADICIONALES DE GMAO BTN
   ============================================ */
.gmao-btn.success {
  background: #10b981;
  color: white;
  border: none;
}
.gmao-btn.success:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.3);
}

.gmao-btn.warning {
  background: #f59e0b;
  color: white;
  border: none;
}
.gmao-btn.warning:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.3);
}

.gmao-btn.subtle {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.gmao-btn.subtle:hover {
  background: #e2e8f0;
  color: #1e293b;
  box-shadow: none;
}

.gmao-btn.success-subtle {
  background: var(--action-success-bg);
  color: var(--action-success-text);
  border: 1px solid var(--action-success-border);
}
.gmao-btn.success-subtle:hover {
  background: #dcfce7;
  box-shadow: none;
}

.gmao-btn.danger-subtle {
  background: var(--action-danger-bg);
  color: var(--action-danger-text);
  border: 1px solid var(--action-danger-border);
}
.gmao-btn.danger-subtle:hover {
  background: #fee2e2;
  box-shadow: none;
}

/* Assignment keeps its actions reachable in narrow panels and reduced viewport heights. */
#wo-assign-modal {
  box-sizing: border-box;
  block-size: 100vh;
  block-size: 100dvh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

#wo-assign-modal .wo-assign-dialog {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-block-size: 100%;
  overflow: hidden;
}

#wo-assign-modal .wo-assign-dialog > h3,
#wo-assign-modal .wo-assign-dialog > p {
  flex-shrink: 0;
}

#wo-assign-modal #assign-form-mount,
#wo-assign-modal .wo-assign-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#wo-assign-modal .wo-assign-fields {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-padding-block: 0.5rem;
}

.wo-assign-form {
  min-width: 0;
  container-type: inline-size;
}

.wo-assign-form .gmao-input {
  min-height: 44px;
  font-size: 1rem;
}

.wo-assign-form .gmao-btn {
  min-width: 0;
  min-height: 44px;
  align-items: center;
  padding: 0.625rem 1rem;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.wo-assign-form [id$="-clear-tech"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.wo-assign-form .wo-assign-results {
  position: relative;
  max-height: min(15rem, 35dvh);
  overscroll-behavior-y: contain;
}

.wo-assign-actions {
  display: grid;
  flex-shrink: 0;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-ui);
}

.wo-assign-primary-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wo-assign-actions .gmao-btn {
  width: 100%;
}


/* Use the form's width so the shared inline panel also adapts correctly. */
@container (min-width: 24rem) {
  .wo-assign-primary-actions {
    flex-direction: row-reverse;
  }

  .wo-assign-actions .gmao-btn {
    width: auto;
  }

  .wo-assign-form .gmao-input {
    font-size: 0.875rem;
  }
}

/* Preserve room for the scrollable fields when a keyboard or landscape reduces height. */
@media (max-height: 480px) {
  #wo-assign-modal .wo-assign-dialog {
    padding: 1rem;
  }

  #wo-assign-modal #wo-assign-description {
    margin-bottom: 0.75rem;
  }

  #wo-assign-modal .wo-assign-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    gap: 0.5rem;
  }

  #wo-assign-modal .wo-assign-primary-actions {
    flex-direction: row-reverse;
  }

  #wo-assign-modal .wo-assign-primary-actions .gmao-btn {
    flex: 1;
    padding-inline: 0.75rem;
  }

  #wo-assign-modal .wo-assign-primary-actions .primary {
    flex: 2;
  }

}

@media (max-height: 360px) and (max-width: 480px) {
  #wo-assign-modal #wo-assign-description {
    display: none;
  }
}

/* Responsive para el modal wizard en móvil */
@media (max-width: 767px) {
    #create-inventory-item-modal {
        padding: 0 !important;
    }
    
    #create-inventory-item-modal > div {
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
    
    #create-inventory-item-modal .p-8 {
        padding: 1rem !important;
    }
    
    #create-inventory-item-modal h2 {
        font-size: 1.25rem !important;
    }
    
    #create-inventory-item-modal .grid-cols-1.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    #create-inventory-item-modal .grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Drag & Drop zone en móvil */
    #wizard-drag-drop-zone {
        padding: 2rem 1rem !important;
    }
    
    #wizard-drag-drop-zone svg {
        width: 32px !important;
        height: 32px !important;
    }
}

/* =============================================
   🛞 Utilidad: Ocultar scrollbar (Carruseles)
   ============================================= */
/* Chrome, Safari y Opera */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
/* IE, Edge y Firefox */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* =============================================
   🪡 Scrollbar horizontal "hilo fino" estilo Notion
   Solo visible al hover, ultra sutil
   ============================================= */
.gmao-scrollbar-x::-webkit-scrollbar {
    height: 5px;
}
.gmao-scrollbar-x::-webkit-scrollbar-track {
    background: transparent;
}
.gmao-scrollbar-x::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 9999px;
    transition: background-color 0.3s ease;
}
.gmao-scrollbar-x:hover::-webkit-scrollbar-thumb {
    background: #e2e8f0;
}
.gmao-scrollbar-x::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}
.gmao-scrollbar-x {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
.gmao-scrollbar-x:hover {
    scrollbar-color: #e2e8f0 transparent;
}
/* =============================================
   🪡 Scrollbar vertical "hilo fino" estilo Notion
   ============================================= */
.gmao-scrollbar-y::-webkit-scrollbar {
    width: 5px;
}
.gmao-scrollbar-y::-webkit-scrollbar-track {
    background: transparent;
}
.gmao-scrollbar-y::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 9999px;
    transition: background-color 0.3s ease;
}
.gmao-scrollbar-y:hover::-webkit-scrollbar-thumb {
    background: #e2e8f0;
}
.gmao-scrollbar-y::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Validación de órdenes y firmas de compras. */
.gmao-validation-settings {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #dbe3ef;
    border-radius: 1rem;
    background: #fff;
    color: #334155;
    font-size: .8rem;
}
.gmao-validation-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.gmao-validation-choice { display: inline-flex; align-items: center; gap: .45rem; font-size: .75rem; cursor: pointer; padding: .35rem 0; }
.gmao-checkbox { width: 1rem; height: 1rem; accent-color: #2563eb; flex: 0 0 auto; }
.gmao-bulk-close { color: #475569; padding: .375rem .625rem; font-size: .75rem; font-weight: 700; display: inline-flex; align-items: center; gap: .375rem; }
.gmao-bulk-close:hover { background: #f1f5f9; }
.gmao-bulk-actions { gap: .5rem; }
.gmao-bulk-action-options { flex-wrap: wrap; }
.gmao-list-select-all { margin-right: .5rem; vertical-align: middle; }
.gmao-validation-result { margin-top: .6rem; white-space: normal; overflow-wrap: anywhere; }
.gmao-validation-warning { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; padding: .7rem; border-radius: .6rem; margin: .6rem 0; }
.gmao-validation-note { padding: .7rem 1rem; color: #475569; font-size: .8rem; }
.gmao-validation-reasons { list-style: disc; margin: .5rem 0 .5rem 1.2rem; }
.gmao-validation-secondary { background: #e2e8f0; color: #334155; }
.gmao-validation-dialog { width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; margin: auto; padding: 1.5rem; border: 1px solid #cbd5e1; border-radius: 1rem; color: #334155; }
.gmao-validation-dialog::backdrop { background: #0f172a66; }
.gmao-validation-dialog h2,
.gmao-validation-settings h2 { font-size: 1.1rem; font-weight: 750; margin: 0 0 .5rem; }
.gmao-validation-dialog p { margin: .75rem 0 1.25rem; line-height: 1.6; }
.gmao-validation-settings p { margin: .5rem 0; line-height: 1.5; }
.gmao-validation-form { display: grid; gap: 1rem; margin-top: 1rem; }
.gmao-validation-form fieldset { border: 1px solid #e2e8f0; padding: 1rem; border-radius: .75rem; }
.gmao-validation-form legend { font-weight: 700; padding: 0 .35rem; }
.gmao-validation-people { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; max-height: 15rem; overflow-y: auto; }
.gmao-validation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem; margin-top: .75rem; }
.gmao-validation-field { display: grid; gap: .4rem; margin: .75rem 0; font-size: .8rem; font-weight: 600; }
.gmao-validation-field select { width: 100%; padding: .65rem; min-height: 2.5rem; }
.gmao-purchase-signature-badge { border: 1px solid #bfdbfe; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: .65rem; font-weight: 700; padding: .3rem .5rem; white-space: nowrap; cursor: pointer; }
.gmao-bulk-close[hidden], .gmao-validation-dialog button[hidden], .gmao-validation-grid[hidden], .gmao-validation-warning[hidden],
.gmao-validation-note[hidden], .gmao-validation-settings[hidden], .gmao-purchase-signature-badge[hidden] { display: none !important; }
.gmao-bulk-close:disabled, .gmao-validation-dialog button:disabled { opacity: .5; cursor: not-allowed; }

/* La revisión respeta el ocultado de acciones y formularios decidido por el JS. */
:is([data-review-panel], [data-workflow-controls], [data-workflow-initial-actions], #production-signatures-view, #work-order-review-view, #validation-settings, #work-order-decision-dialog, #ceco-form, #ceco-detail) [hidden], [data-workflow-status][hidden] {
    display: none !important;
}

/* La bandeja ocupa el espacio real de la app; cada columna conserva su posición. */
#main-app:is([data-active-view="production-signatures"], [data-active-view="work-order-review"]) #content-area,
.gmao-production-inbox { overflow-anchor: none; }
.gmao-production-list-panel { display: flex; flex-direction: column; gap: .75rem; min-height: 0; }
.gmao-production-inbox [data-production-list] { max-height: 18rem; overflow-y: auto; overscroll-behavior-y: contain; }
.gmao-production-detail { min-height: 22rem; scroll-margin-top: 4rem; }
.gmao-production-detail-header { position: sticky; top: 0; z-index: 10; border-radius: .75rem .75rem 0 0; }
.gmao-production-inbox [data-production-actions] { flex-direction: row; flex-wrap: wrap; gap: .5rem; }
.gmao-production-inbox [data-production-action] { min-height: 2.25rem; height: auto; padding: .5rem .75rem; font-size: .75rem; }
.gmao-production-inbox [data-review-panel] { margin-top: 1rem; padding-top: 1rem; }
.gmao-production-inbox [data-review-panel] > * + * { margin-top: 1rem; }
@media (max-width: 767px) {
    #main-app:is([data-active-view="production-signatures"], [data-active-view="work-order-review"]) #content-area {
        padding-top: calc(3.5rem + env(safe-area-inset-top, 0px)) !important;
    }
}
@media (min-width: 768px) {
    .gmao-production-detail { scroll-margin-top: .75rem; }
}
@media (min-width: 1024px) {
    #main-app:is([data-active-view="production-signatures"], [data-active-view="work-order-review"]) #content-area {
        overflow: clip !important;
    }
    .gmao-production-inbox { flex: 1; height: 100%; min-height: 0; overflow: hidden; contain: layout paint; }
    .gmao-production-inbox .gmao-production-layout { flex: 1; min-height: 0; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.7fr); }
    .gmao-production-inbox.gmao-production-detail-only .gmao-production-layout { grid-template-columns: minmax(0, 1fr); }
    .gmao-production-inbox [data-inbox-list] { overflow: hidden; }
    .gmao-production-inbox [data-production-list] { flex: 1; min-height: 0; max-height: none; }
    .gmao-production-inbox [data-production-empty] { flex: 1; min-height: 0; }
    .gmao-production-detail { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
}
/* Selección de la OT abierta y de las personas responsables de validar. */
#production-signatures-view [data-production-list] > button[aria-current="true"] {
    border-color: #93c5fd;
    background: #eff6ff;
    box-shadow: inset 3px 0 0 #3b82f6;
}
#production-signatures-view [data-production-list] > button[aria-current="true"] > span:first-child {
    background: #dbeafe;
    color: #2563eb;
}
#validation-settings label:has(> .gmao-checkbox:checked),
#ceco-validator-people label:has(> .gmao-checkbox:checked) {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}
