* {
  box-sizing: border-box;
  font-family: Calibri, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
  background-color: #e9ecf0;
  margin: 10px;
  color: #000;
}
.sheet-wrapper {
  background: #ffffff;
  padding: 14px;
  border: 1px solid #888;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-width: 1460px;
  margin: 0 auto;
}

/* Barra superior de sesión para el usuario común / admin */
.user-session-bar {
  background: #002060;
  color: #fff;
  padding: 6px 12px;
  margin-bottom: 10px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
}
.user-session-bar a {
  color: #ffc000;
  text-decoration: none;
  font-weight: bold;
  margin-left: 10px;
}

/* Barra de Alerta de Carpeta No Vinculada */
.folder-alert-bar {
  padding: 8px 14px;
  margin-bottom: 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}
.folder-alert-bar.unlinked {
  background-color: #fef3c7;
  border: 1.5px solid #f59e0b;
  color: #92400e;
}
.folder-alert-bar.linked {
  background-color: #ecfdf5;
  border: 1.5px solid #10b981;
  color: #065f46;
}
.btn-link-folder {
  background: #002060;
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}
.btn-link-folder:hover {
  background: #082d7c;
}

/* Panel Superior */
.top-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid #ccc;
}

.header-left {
  display: grid;
  grid-template-columns: 120px 240px;
  row-gap: 5px;
  align-items: center;
  font-size: 15px;
  font-weight: bold;
}
.lbl-orden { color: #000; cursor: pointer; user-select: none; }
.lbl-customer { color: #d66000; cursor: pointer; user-select: none; }
.lbl-order { color: #c00000; cursor: pointer; user-select: none; }
.lbl-cases { color: #c00000; cursor: pointer; user-select: none; }

.box-val {
  border: 1.5px solid #000;
  padding: 3px 8px;
  min-height: 28px;
  background: #fff;
  display: flex;
  align-items: center;
  font-size: 14px;
  cursor: text;
}
.box-val.text-right {
  justify-content: flex-end;
}
.box-val.totals {
  font-size: 17px;
  font-weight: bold;
}

.header-center {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  position: relative;
}
.form-row {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.form-row label {
  font-size: 13px;
  font-weight: bold;
  color: #c00000;
  width: 95px;
  cursor: pointer;
  user-select: none;
}
.form-row input, .form-row select {
  border: 1.5px solid #000;
  padding: 4px 6px;
  font-weight: bold;
  font-size: 13px;
}

/* Autocomplete Dropdown para Customer */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 101px;
  width: 320px;
  max-height: 220px;
  overflow-y: auto;
  background: #ffffff;
  border: 2px solid #002060;
  border-top: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  z-index: 1000;
  display: none;
}
.autocomplete-item {
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}
.autocomplete-item:hover, .autocomplete-item.active {
  background-color: #002060;
  color: #ffffff;
}
.autocomplete-item strong {
  color: #d66000;
}
.autocomplete-item:hover strong, .autocomplete-item.active strong {
  color: #ffc000;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Botones estilo Excel */
.btn-action {
  background: #ffffff;
  border: 2px solid #444;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  min-height: 52px;
  box-shadow: 1px 2px 3px rgba(0,0,0,0.15);
  transition: all 0.15s ease;
  color: #000;
}
.btn-action:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}
.btn-action:active {
  transform: translateY(1px);
}
.btn-action.btn-item {
  background: #002060;
  color: #ffffff;
  border-color: #001540;
}
.btn-action.btn-item:hover {
  background: #082d7c;
}
.btn-action.btn-mic {
  background: #2e7d32;
  color: #ffffff;
  border-color: #1b5e20;
}
.btn-action.btn-mic:hover {
  background: #388e3c;
}
.btn-action.btn-mic.listening {
  background: #c00000 !important;
  border-color: #800000 !important;
  animation: pulseMic 0.8s infinite alternate;
}
@keyframes pulseMic {
  from { transform: scale(1); box-shadow: 0 0 5px rgba(255,0,0,0.5); }
  to { transform: scale(1.05); box-shadow: 0 0 15px rgba(255,0,0,0.9); }
}
.btn-action.btn-red {
  background: #c00000;
  color: #ffffff;
  border-color: #800000;
}
.btn-action.btn-red:hover {
  background: #9d0000;
}
.btn-action.btn-export {
  background: #107c41;
  color: #ffffff;
  border-color: #0b592e;
}
.btn-action.btn-export:hover {
  background: #148e4b;
}

/* Panel del Asistente Ultrarrápido */
.voice-assistant-panel {
  background: #f8fafc;
  border: 2px solid #2e7d32;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voice-assistant-panel.listening {
  border-color: #c00000;
  background: #fff8f8;
}
.voice-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.voice-title {
  font-size: 13.5px;
  font-weight: bold;
  color: #1b5e20;
  display: flex;
  align-items: center;
  gap: 6px;
}
.voice-assistant-panel.listening .voice-title {
  color: #b71c1c;
}
.badge-info {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.assistant-bubble {
  background: #ffffff;
  border: 1.5px solid #002060;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: bold;
  color: #002060;
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-live-bubble {
  background: #f1f5f9;
  border: 1px dashed #64748b;
  padding: 5px 10px;
  font-size: 13px;
  min-height: 28px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  color: #0f172a;
  font-family: Consolas, 'Courier New', monospace;
}
.flow-steps-tracker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
  margin-top: 2px;
}
.step-pill {
  background: #e2e8f0;
  padding: 4px 8px;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  color: #475569;
}
.step-pill.current {
  background: #002060;
  color: #ffffff;
  border-color: #001540;
}
.step-pill.done {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

/* Contenedor de la Cuadrícula */
.grid-container {
  overflow-x: auto;
  max-height: 520px;
  border: 1px solid #7f7f7f;
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
th, td {
  border: 1px solid #7f7f7f;
  padding: 3px 4px;
  white-space: nowrap;
}
th {
  background-color: #d9d9d9;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: bold;
}
th.th-line {
  background-color: #555555;
  color: #ffffff;
  width: 40px;
}
th.th-blue {
  background-color: #002060;
  color: #ffffff;
}
th.th-yellow {
  background-color: #ffc000;
  color: #002060;
}
th.th-dates {
  background-color: #ffc000;
  color: #002060;
}
th.th-cyan {
  background-color: #00b0f0;
  color: #000000;
}

td input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 11.5px;
  padding: 1px;
  font-family: inherit;
}
td input:focus {
  outline: 2px solid #002060;
  background: #ffffe0;
}
.text-center { text-align: center; }
.text-right { text-align: right; }
.col-lin-num {
  background-color: #f1f5f9;
  font-weight: bold;
  color: #334155;
  text-align: center;
  user-select: none;
}
.row-deleted {
  background-color: #ffe4e4 !important;
  color: #a00000;
  font-weight: bold;
}
.row-deleted input {
  display: none;
}

/* Notas */
.notes-box {
  margin-top: 12px;
  padding: 10px;
  background: #fafafa;
  border: 1px solid #aaa;
}
.notes-box h4 {
  margin: 0 0 6px 0;
  color: #002060;
  cursor: pointer;
  user-select: none;
}
.notes-box textarea {
  width: 100%;
  height: 80px;
  border: 1.5px solid #444;
  padding: 6px;
  font-size: 13px;
}

/* Modal emergente */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: #fff;
  border: 2px solid #002060;
  padding: 18px;
  width: 760px;
  max-width: 95%;
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.modal-content h3 {
  margin: 0 0 12px 0;
  color: #002060;
  border-bottom: 2px solid #ffc000;
  padding-bottom: 5px;
}
.modal-group {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
}
.modal-group label {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 3px;
  cursor: pointer;
  user-select: none;
}
.modal-group input {
  border: 1px solid #666;
  padding: 5px 7px;
  font-size: 13px;
}
.modal-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-row-4 {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 6px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 15px;
}