/* ══════════════════════════════════════════════════════════════
   ElenisOrders — Dashboard CSS
   Tema oscuro coherente con livechat.css (WhatsApp dark)
   ══════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg:           #111B21;
  --surface:      #202C33;
  --surface2:     #182229;
  --border:       #2A3942;
  --text:         #E9EDEF;
  --text-muted:   #8696A0;
  --green:        #25D366;
  --green-dim:    #1A5E3A;
  --yellow:       #F0C040;
  --yellow-dim:   #4A3800;
  --red:          #EF4444;
  --red-dim:      #4A1010;
  --blue:         #3B82F6;
  --blue-dim:     #1A2C55;
  --gray:         #6B7280;
  --gray-dim:     #1E262B;
}

.conversation-tools { padding: 12px 18px 6px; background: var(--surface2); border-bottom: 1px solid var(--border); }
.conversation-search { display: flex; gap: 8px; max-width: 620px; margin-bottom: 10px; }
.conversation-search input { flex: 1; min-width: 180px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.stage2-conv-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.conversation-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--text-muted); font-size: 12px; margin-top: 5px; }
.conversation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}
.conversation-actions .btn-action {
  width: auto;
  max-width: max-content;
  flex: 0 0 auto;
  white-space: nowrap;
}
.conversation-take { margin-left: 0; }
.unread-count { min-width: 22px; height: 22px; padding: 2px 7px; border-radius: 999px; background: var(--green); color: #071b10; font-weight: 700; text-align: center; }
.conversation-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px; border-top: 1px solid var(--border); }
.conversation-notice { padding: 10px 18px; }
.conversation-notice.error { color: #fecaca; background: var(--red-dim); }
@media (max-width: 640px) {
  .stage2-conv-row { align-items: flex-start; flex-wrap: wrap; }
  .conversation-meta { gap: 5px; }
  .conversation-actions {
    flex: 1 0 100%;
    margin-left: 60px;
    margin-top: -4px;
  }
}

/* ── Reset base (ya definido en livechat.css; seguro duplicar) ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Layout principal del dashboard ────────────────────────── */
.dash-root {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.dash-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.dash-topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.dash-topbar-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Barra de navegación entre módulos ───────────────────────── */
.dash-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.dash-nav::-webkit-scrollbar { display: none; }

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.dash-nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.dash-nav-item.active {
  background: rgba(37, 211, 102, 0.12);
  color: var(--green);
}
.dash-nav-icon  { font-size: 14px; line-height: 1; }
.dash-nav-label { font-size: 12px; }
.dash-nav-count { min-width:22px; height:22px; display:inline-grid; place-items:center; margin-left:auto; padding:0 6px; border-radius:999px; background:#dc3545; color:#fff; font-size:.7rem; font-weight:750; }
.escalation-page { overflow-y:auto; }
.escalation-filters { padding:16px 20px 0; }
.escalation-list { display:grid; gap:12px; padding:18px 20px; }
.escalation-card { display:grid; grid-template-columns:minmax(0,1fr) minmax(190px,.34fr) auto; gap:18px; align-items:start; padding:18px; border:1px solid var(--border); border-radius:14px; background:#fff; box-shadow:0 4px 16px rgba(23,43,77,.05); }
.escalation-customer { display:flex; align-items:center; gap:10px; }
.escalation-customer strong,.escalation-customer small { display:block; }
.escalation-customer small { margin-top:2px; color:var(--text-muted); font-size:.74rem; }
.escalation-question { margin:14px 0 0; color:var(--text); font-size:.94rem; line-height:1.5; overflow-wrap:anywhere; }
.escalation-answer { margin-top:13px; padding:11px 13px; border-radius:10px; background:#f3f7ff; }
.escalation-answer span { color:var(--brand); font-size:.7rem; font-weight:750; text-transform:uppercase; }
.escalation-answer p { margin:4px 0 0; line-height:1.45; }
.escalation-meta { display:grid; gap:8px; color:var(--text-muted); font-size:.76rem; }
.escalation-meta .badge { width:fit-content; }
.escalation-meta span { display:flex; align-items:center; gap:6px; }
.escalation-actions { display:flex; flex-direction:column; gap:8px; min-width:130px; }
@media (max-width: 920px) { .escalation-card { grid-template-columns:1fr auto; } .escalation-meta { grid-column:1; } .escalation-actions { grid-column:2; grid-row:1 / span 2; } }
@media (max-width: 620px) { .escalation-card { grid-template-columns:1fr; } .escalation-meta,.escalation-actions { grid-column:1; grid-row:auto; } .escalation-actions { flex-direction:row; flex-wrap:wrap; } }

/* ── Filtros / tabs ──────────────────────────────────────────── */
.dash-filters {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.dash-filters::-webkit-scrollbar { display: none; }
.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-btn:hover { background: var(--border); color: var(--text); }
.filter-btn.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ── Lista scrollable ────────────────────────────────────────── */
.dash-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.dash-list::-webkit-scrollbar { width: 4px; }
.dash-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Tarjeta de pedido ───────────────────────────────────────── */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 6px 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.order-card:hover { border-color: var(--green); }
.order-card.selected { border-color: var(--green); background: var(--surface2); }

.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.order-label { font-weight: 600; font-size: 15px; color: var(--text); }
.order-total { font-weight: 600; font-size: 14px; color: var(--green); }

.order-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.order-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.order-customer { font-size: 13px; color: var(--text-muted); }

/* ── Badge de estado / tipo ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-pending         { background: var(--yellow-dim); color: var(--yellow);  border: 1px solid #7a6000; }
.badge-confirmed       { background: var(--blue-dim);   color: var(--blue);    border: 1px solid #1e4080; }
.badge-preparing       { background: #1A2C40;            color: #60A5FA;        border: 1px solid #1e3a60; }
.badge-readyforpickup  { background: #1A3040;            color: #38BDF8;        border: 1px solid #0e4060; }
.badge-outfordelivery  { background: #1A2C40;            color: #818CF8;        border: 1px solid #2e2e80; }
.badge-delivered       { background: var(--green-dim);  color: var(--green);   border: 1px solid #0f4022; }
.badge-cancelled       { background: var(--red-dim);    color: var(--red);     border: 1px solid #6a1010; }
/* Conversaciones */
.badge-active          { background: var(--green-dim);  color: var(--green);   border: 1px solid #0f4022; }
.badge-escalated       { background: var(--yellow-dim); color: var(--yellow);  border: 1px solid #7a6000; }
.badge-handledbyhuman  { background: var(--blue-dim);   color: var(--blue);    border: 1px solid #1e4080; }
.badge-closed          { background: var(--gray-dim);   color: var(--gray);    border: 1px solid #2a3040; }
/* Tipo de transacción */
.badge-servicebooking  { background: #2A1A40;            color: #C084FC;        border: 1px solid #5a2a80; }
.badge-mixedorder      { background: #1A2C40;            color: #38BDF8;        border: 1px solid #0e4060; }
.badge-productorder    { background: var(--gray-dim);   color: var(--gray);    border: 1px solid #2a3040; }
.badge-origin-whatsapp { background:#e7f8ef; color:#167344; border:1px solid #a7e4c3; }
.badge-origin-manual   { background:#eef2ff; color:#4338ca; border:1px solid #c7d2fe; }
.order-origin-inline   { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:7px 0 12px; font-size:13px; color:#6b7280; }
/* IsAdHoc */
.badge-adhoc           { background: #2A1A40;            color: #C084FC;        border: 1px solid #5a2a80; }

/* ── Panel de detalle (overlay) ──────────────────────────────── */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
@media (min-width: 640px) {
  .detail-overlay { align-items: center; }
}
.detail-panel {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 600px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 640px) {
  .detail-panel {
    border-radius: 16px;
    max-height: 80dvh;
  }
}
.detail-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.detail-header-title { font-size: 16px; font-weight: 600; flex: 1; }
.detail-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.detail-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Secciones dentro del detalle ────────────────────────────── */
.detail-section { margin-bottom: 16px; }
.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 8px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label { color: var(--text-muted); flex-shrink: 0; }
.detail-row-value { color: var(--text); text-align: right; }

/* ── Ítems de pedido ─────────────────────────────────────────── */
.order-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.order-item-row:last-child { border-bottom: none; }
.order-item-qty {
  background: var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 1px 7px;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.order-item-name { flex: 1; color: var(--text); }
.order-item-note { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.order-item-price { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ── Historial de estados ────────────────────────────────────── */
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.history-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Botones de acción ───────────────────────────────────────── */
.btn-action {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-action:disabled { opacity: 0.4; cursor: default; }
.btn-action:hover:not(:disabled) { opacity: 0.85; }
.btn-primary   { background: var(--green); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-dim); }
.btn-close-panel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 6px;
}
.btn-close-panel:hover { background: var(--border); }

/* ── Fila de conversación (estilo WhatsApp) ──────────────────── */
.conv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.conv-row:hover { background: var(--surface2); }
.conv-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #2A3942;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  text-transform: uppercase;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-name { font-size: 15px; font-weight: 600; color: var(--text); }
.conv-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.conv-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.conv-preview {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.conv-preview.escalated { color: var(--yellow); }

/* ── Estado vacío ────────────────────────────────────────────── */
.dash-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.dash-empty-icon { font-size: 48px; margin-bottom: 12px; }
.dash-empty h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.dash-empty p { font-size: 13px; }

/* ── Loading spinner ─────────────────────────────────────────── */
.dash-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
}
.dash-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: dspin 0.8s linear infinite;
}
@keyframes dspin { to { transform: rotate(360deg); } }

/* ── Mensaje de acción (feedback) ────────────────────────────── */
.action-msg {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
  align-self: center;
}
.action-msg.ok  { color: var(--green); }
.action-msg.err { color: var(--red); }

/* ── Error card ──────────────────────────────────────────────── */
.dash-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
}
.dash-error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.dash-error-card .icon { font-size: 42px; margin-bottom: 12px; }
.dash-error-card h2 { font-size: 17px; color: var(--text); margin-bottom: 8px; }
.dash-error-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── Tarjeta de admin (categorías / knowledge / reglas) ───────── */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 6px 12px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.15s;
}
.admin-card:hover { border-color: var(--green); }
.admin-card-body  { flex: 1; min-width: 0; }
.admin-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}
.admin-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.admin-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.admin-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Badge activo / inactivo ─────────────────────────────────── */
.badge-active-on  { background: var(--green-dim); color: var(--green); border: 1px solid #0f4022; }
.badge-active-off { background: var(--gray-dim);  color: var(--gray);  border: 1px solid #2a3040; }

/* ── Badge stock (catálogo) ──────────────────────────────────── */
.badge-stock-ok  { background: var(--blue-dim);  color: var(--blue);  border: 1px solid #1e4080; }
.badge-stock-out { background: var(--red-dim);   color: var(--red);   border: 1px solid #6a1010; }

/* ── Botones pequeños ────────────────────────────────────────── */
.btn-sm {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-sm:hover:not(:disabled) { opacity: 0.8; }
.btn-sm:disabled { opacity: 0.4; cursor: default; }
.btn-sm-edit   { background: var(--border); color: var(--text); }
.btn-sm-danger { background: var(--red-dim); color: var(--red); }
.btn-sm-toggle { background: var(--gray-dim); color: var(--text-muted); }

/* ── Formulario en panel (create / edit) ─────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus  { border-color: var(--green); }
.form-textarea      { resize: vertical; min-height: 80px; }
.form-select option { background: var(--surface); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.form-toggle-label { font-size: 13px; color: var(--text); }

/* ── Confirmación de borrado inline ──────────────────────────── */
.confirm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 8px;
  margin: 6px 12px;
  font-size: 13px;
  color: var(--red);
  flex-wrap: wrap;
}
.confirm-row span { flex: 1; }

/* ── Topbar con botón de acción ──────────────────────────────── */
.dash-topbar-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.dash-topbar-btn:hover { opacity: 0.85; }
.dash-topbar-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Buscador inline en filtros (catálogo) ───────────────────── */
.menu-search {
  flex: 1;
  min-width: 120px;
  max-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.menu-search:focus       { border-color: var(--green); }
.menu-search::placeholder { color: var(--text-muted); }

/* ── Clientes — tags editables ───────────────────────────────── */
.customer-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}
.customer-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid #1e4080;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.customer-tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}
.customer-tag-remove:hover { opacity: 1; }
.tag-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.tag-add-btn {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag-add-btn:hover { opacity: 0.8; }

/* ── Secciones de Tienda y Configuración ─────────────────────── */
.settings-section {
  margin: 12px 16px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.settings-section:last-child { margin-bottom: 16px; }

.settings-section-title {
  padding: 9px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.settings-section-body { padding: 16px; }

/* fila de dato de solo lectura */
.settings-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.settings-info-row:last-child { border-bottom: none; }
.settings-info-row span:first-child { color: var(--text-muted); font-size: 12px; }
.settings-info-row span:last-child  { color: var(--text); font-weight: 500; }

/* ── Botón de cancelar/rechazar ──────────────────────────── */
.btn-cancel { background: #2A1A10; color: #F87171; border: 1px solid #6a2020; }

/* ── Agenda — pill de pendientes en topbar ───────────────── */
.agenda-pending-pill {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid #7a6000;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Agenda — badge de count en tab ─────────────────────── */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 14px;
  margin-left: 4px;
  vertical-align: middle;
}
.filter-btn.active .tab-count { background: rgba(0,0,0,0.2); }

/* ── Agenda — tarjeta de cita ────────────────────────────── */
.agenda-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 12px;
  margin: 4px 12px;
  overflow: hidden;
  transition: border-color 0.15s;
  cursor: default;
}
.agenda-card:hover         { border-color: var(--green); }
.agenda-card.selected      { border-color: var(--green); background: var(--surface2); }

/* Acento de color izquierdo según estado */
.agenda-card.status-pending   { border-left-color: var(--yellow); }
.agenda-card.status-confirmed { border-left-color: var(--blue); }
.agenda-card.status-completed { border-left-color: var(--green); }
.agenda-card.status-rejected,
.agenda-card.status-cancelled { border-left-color: var(--red); }
.agenda-card.status-noshow    { border-left-color: var(--gray); }

/* Área principal clickeable */
.agenda-card-main {
  display: flex;
  align-items: stretch;
  padding: 12px 16px;
  cursor: pointer;
  gap: 0;
}

/* Columna de hora — prominente */
.agenda-time {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 60px;
  padding-right: 14px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.agenda-time-start {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.agenda-time-end {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1;
}

/* Cuerpo de la tarjeta */
.agenda-card-body {
  flex: 1;
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.agenda-customer {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-service {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-phone {
  font-size: 12px;
  color: var(--text-muted);
}
.agenda-notes {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

/* Acciones inline (confirmar/rechazar en Pending) */
.agenda-card-actions {
  padding: 0 16px 12px;
  display: flex;
  gap: 8px;
}

/* Formulario inline de rechazo */
.agenda-reject-form {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Agenda — separador de fecha entre grupos ────────────── */
.agenda-date-sep {
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.agenda-date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Orders — fecha agendada en tarjeta de ServiceBooking ── */
.order-scheduled {
  font-size: 12px;
  color: var(--blue);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   Dashboard Home — /
   ══════════════════════════════════════════════════════════════ */

/* Área scrollable que contiene las secciones de widgets */
.dash-home-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.dash-home-scroll::-webkit-scrollbar { width: 4px; }
.dash-home-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Encabezado de sección */
.dash-home-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin: 16px 0 8px;
}
.dash-home-section-title:first-child { margin-top: 0; }

/* Grid de stat-cards: auto-fill con mínimo 140px */
.dash-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

/* Tarjeta de estadística */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s;
  text-decoration: none;
  color: inherit;
}
.stat-card[href]:hover { border-color: var(--green); cursor: pointer; }

/* Variantes de color */
.stat-card-green  { border-left: 3px solid var(--green); }
.stat-card-blue   { border-left: 3px solid var(--blue); }
.stat-card-alert  { border-left: 3px solid var(--yellow); background: color-mix(in srgb, var(--yellow-dim) 60%, var(--surface)); }
.stat-card-dim    { opacity: 0.6; }

/* stat-card que ocupa 2 columnas en pantallas anchas */
@media (min-width: 600px) {
  .stat-card-wide { grid-column: span 2; }
}

/* Contenido de la tarjeta */
.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-card-green  .stat-card-value { color: var(--green); }
.stat-card-blue   .stat-card-value { color: var(--blue); }
.stat-card-alert  .stat-card-value { color: var(--yellow); }

.stat-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.stat-card-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Pie de página con timestamp */
.dash-home-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg, #0f1117);
  color: var(--text, #f4f4f5);
}
.login-card {
  width: min(92vw, 380px);
  padding: 32px;
  border: 1px solid var(--border, #2a3040);
  border-radius: 14px;
  background: var(--surface, #171a22);
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.login-card h1 { margin: 0 0 4px; }
.login-subtitle { color: var(--text-muted, #9ca3af); margin: 0 0 24px; }
.login-field { display: grid; gap: 8px; margin-bottom: 16px; }
.login-field input {
  width: 100%; box-sizing: border-box; padding: 11px 12px;
  border: 1px solid var(--border, #2a3040); border-radius: 8px;
  background: var(--surface2, #202532); color: inherit;
}
.login-button {
  width: 100%; padding: 11px 14px; border: 0; border-radius: 8px;
  background: var(--green, #3ddc84); color: #07120b; font-weight: 700; cursor: pointer;
}
.login-button:disabled { opacity: .6; cursor: wait; }
.login-error { margin-bottom: 14px; color: #f87171; font-size: .92rem; }
.dash-login-link { display: inline-block; margin-top: 18px; color: var(--green, #3ddc84); }

/* Dashboard operativo — Etapa 4 */
.dashboard-toolbar {
  min-height: 72px;
  height: auto;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}
.dashboard-toolbar > div:first-child { min-width: 220px; }
.dashboard-period {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dashboard-period label { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.dashboard-period select,
.dashboard-period input,
.dashboard-list-tools select,
.dashboard-search input {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  padding: 8px 10px;
}
.dashboard-content { padding: 18px; }
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}
.dashboard-kpis button.stat-card {
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dashboard-operational-content { display: grid; gap: 18px; }
.dashboard-domain-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}
.dashboard-section-heading,
.dashboard-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.dashboard-section-heading h2,
.dashboard-panel-heading h3 { margin: 2px 0 4px; color: var(--text); }
.dashboard-section-heading h2 { font-size: 20px; }
.dashboard-panel-heading h3 { font-size: 16px; }
.dashboard-section-heading p,
.dashboard-panel-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.dashboard-section-kicker {
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.dashboard-section-link,
.dashboard-panel-heading a,
.dashboard-request-preview-actions a {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.dashboard-section-link { flex-shrink: 0; margin-top: 5px; }
.dashboard-domain-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dashboard-domain-kpis .stat-card { min-width: 0; }
.dashboard-domain-kpis button.stat-card {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dashboard-section-empty,
.dashboard-capability-empty {
  margin-top: 14px;
  border: 1px dashed var(--border);
  border-radius: 11px;
  background: var(--surface2);
  color: var(--text-muted);
  padding: 14px;
  font-size: 13px;
}
.dashboard-capability-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.dashboard-capability-empty i { color: var(--brand); font-size: 24px; }
.dashboard-capability-empty strong,
.dashboard-capability-empty span { display: block; }
.dashboard-capability-empty span { margin-top: 2px; }
.dashboard-operational-panel {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.dashboard-panel-heading {
  align-items: center;
  margin: 0;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.dashboard-request-preview-list { display: grid; }
.dashboard-request-preview-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(170px, .8fr) minmax(120px, auto);
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.dashboard-request-preview-row:last-child { border-bottom: 0; }
.dashboard-request-preview-row:hover { background: var(--surface2); }
.dashboard-request-preview-main,
.dashboard-request-preview-meta,
.dashboard-request-preview-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dashboard-request-preview-main strong { font-size: 13px; }
.dashboard-request-preview-main p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.dashboard-request-preview-meta { color: var(--text-muted); font-size: 12px; }
.dashboard-request-preview-meta .badge { align-self: flex-start; }
.dashboard-request-preview-actions { align-items: flex-end; }
.dashboard-poll-notice { border-radius: 10px; }
.dashboard-list-error { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.dashboard-orders-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.dashboard-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.dashboard-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 11px 14px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.dashboard-tab span {
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface2);
  font-size: 11px;
}
.dashboard-tab.active { color: var(--green); border-bottom-color: var(--green); }
.dashboard-list-tools {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  flex-wrap: wrap;
}
.dashboard-search { display: flex; flex: 1; min-width: min(100%, 300px); }
.dashboard-search input { flex: 1; min-width: 0; border-radius: 8px 0 0 8px; }
.dashboard-search button,
.dashboard-pagination button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}
.dashboard-search button { border-radius: 0 8px 8px 0; }
.dashboard-order-list { display: grid; }
.dashboard-order-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(170px, 1fr) minmax(140px, .8fr) minmax(170px, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.dashboard-order-row:last-child { border-bottom: 0; }
.dashboard-order-row:hover { background: var(--surface2); }
.dashboard-order-main,
.dashboard-order-state,
.dashboard-order-meta,
.dashboard-order-links { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dashboard-order-main span,
.dashboard-order-meta span,
.dashboard-order-links span { color: var(--text-muted); font-size: 12px; }
.dashboard-order-number,
.dashboard-order-links a { color: var(--green); text-decoration: none; font-weight: 700; }
.dashboard-order-state { align-items: flex-start; }
.status-badge,
.payment-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface2);
}
.status-pending, .payment-badge.pending { color: var(--yellow); }
.status-confirmed, .status-preparing, .status-outfordelivery { color: var(--blue); }
.status-readyforpickup, .status-delivered, .payment-badge.paid { color: var(--green); }
.payment-badge.neutral { color: var(--text-muted); }
.status-cancelled { color: var(--text-muted); }
.dashboard-list-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.dashboard-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
.dashboard-pagination button { border-radius: 8px; }
.dashboard-pagination button:disabled { opacity: .4; cursor: default; }

@media (max-width: 820px) {
  .dashboard-period { margin-left: 0; width: 100%; }
  .dashboard-domain-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-request-preview-row { grid-template-columns: minmax(0, 1fr) auto; }
  .dashboard-request-preview-actions { grid-column: 2; grid-row: 1 / span 2; }
  .dashboard-order-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .dashboard-content { padding: 10px; }
  .dashboard-period select { flex: 1; }
  .dashboard-period input { width: calc(50% - 4px); }
  .dashboard-domain-section { padding: 14px; }
  .dashboard-section-heading,
  .dashboard-panel-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .dashboard-domain-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-domain-kpis .stat-card { min-height: 116px; padding: 13px; }
  .dashboard-domain-kpis .stat-card-value { font-size: 24px; }
  .dashboard-request-preview-row { grid-template-columns: 1fr; }
  .dashboard-request-preview-actions { grid-column: 1; grid-row: auto; align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .dashboard-order-row { grid-template-columns: 1fr; }
  .dashboard-order-state { flex-direction: row; flex-wrap: wrap; }
  .dashboard-pagination { justify-content: center; flex-wrap: wrap; }
}

/* ===========================================================================
   Elenis ecosystem UI — visual alignment with ElenisAdmin / Skote
   ========================================================================== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface2: #f8faff;
  --border: #e6ebf2;
  --text: #172b4d;
  --text-muted: #6b7a90;
  --brand: #3d73e8;
  --brand-dark: #2859c7;
  --green: #3d73e8;
  --green-dim: #edf3ff;
  --yellow: #a76b00;
  --yellow-dim: #fff7df;
  --red: #c53b4b;
  --red-dim: #fff0f1;
  --blue: #3d73e8;
  --blue-dim: #edf3ff;
  --gray: #6b7a90;
  --gray-dim: #f1f4f8;
  --success: #138a55;
  --success-soft: #ecfdf4;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(23, 43, 77, .06);
  --sidebar-width: 250px;
  --sidebar-compact-width: 76px;
  --topbar-height: 78px;
}

html, body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(61, 115, 232, .28);
  outline-offset: 2px;
}

.orders-shell { display: flex; min-height: 100dvh; background: var(--bg); }
.orders-sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  min-height: 100dvh;
  background: linear-gradient(180deg, #102b69 0%, #21114f 100%);
  color: #dbe5f2;
  position: sticky;
  top: 0;
  z-index: 40;
  transition: width .2s ease, flex-basis .2s ease, transform .2s ease;
}
.sidebar-inner { height: 100dvh; padding: 24px 16px 16px; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 42px;
  margin: 0 8px 34px;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  object-fit: contain;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(7, 29, 75, .4);
}
.brand-copy { line-height: 1.15; white-space: nowrap; }
.brand-copy strong { display: block; font-size: 1.08rem; }
.brand-copy small { display: block; margin-top: 3px; color: #a9bee7; font-size: .75rem; }

.dash-nav { display: grid; align-content: start; gap: 5px; padding: 0; background: transparent; border: 0; overflow: visible; }
.dash-nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #b9c8e5;
  font-size: .9rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.dash-nav-item:hover, .dash-nav-item.active { background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; }
.dash-nav-icon { width: 22px; flex: 0 0 22px; font-size: 1.25rem; line-height: 1; text-align: center; }
.dash-nav-label { overflow: hidden; font-size: .88rem; white-space: nowrap; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); }
.dash-nav-user { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 5px 8px 13px; overflow: hidden; }
.user-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(79, 131, 244, .28); color: #fff; font-weight: 750; }
.user-copy { min-width: 0; line-height: 1.25; white-space: nowrap; }
.user-copy strong, .user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; }
.user-copy strong { color: #fff; font-size: .82rem; }
.user-copy small { margin-top: 2px; color: #9eb1d1; font-size: .72rem; }
.sidebar-footer form { margin: 0; }
.logout-button { width: 100%; }

.orders-main { flex: 1; min-width: 0; min-height: 100dvh; }
.orders-global-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(18px, 3vw, 42px);
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.sidebar-toggle { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 40px; border: 0; border-radius: 10px; background: transparent; color: #30415d; cursor: pointer; }
.sidebar-toggle:hover { background: #edf3ff; color: var(--brand); }
.sidebar-toggle i { font-size: 1.55rem; }
.orders-topbar-title { min-width: 0; line-height: 1.25; }
.orders-topbar-title strong { display: block; font-size: 1.08rem; }
.eyebrow { display: block; color: var(--text-muted); font-size: .65rem; font-weight: 750; letter-spacing: .16em; }
.role-badge { margin-left: auto; padding: 5px 11px; border-radius: 999px; background: #edf3ff; color: #285bc6; font-size: .76rem; font-weight: 650; white-space: nowrap; }
.orders-content { min-height: calc(100dvh - var(--topbar-height)); min-width: 0; }
.orders-content > .screen-center { min-height: calc(100dvh - var(--topbar-height)); }
.sidebar-backdrop { display: none; }

body.sidebar-collapsed .orders-sidebar { width: var(--sidebar-compact-width); flex-basis: var(--sidebar-compact-width); }
body.sidebar-collapsed .sidebar-inner { padding-inline: 10px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; margin-inline: 0; }
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .dash-nav-label,
body.sidebar-collapsed .user-copy { display: none; }
body.sidebar-collapsed .dash-nav-item { justify-content: center; padding-inline: 8px; }
body.sidebar-collapsed .dash-nav-user { justify-content: center; padding-inline: 0; }

.dash-root { height: calc(100dvh - var(--topbar-height)); min-height: 560px; background: var(--bg); color: var(--text); }
.dash-root.agenda-root { height: auto; min-height: calc(100dvh - var(--topbar-height)); overflow: visible; }
.agenda-root .dash-list { flex: none; overflow: visible; }
.dash-topbar { min-height: 74px; height: auto; padding: 14px clamp(18px, 3vw, 34px); gap: 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dash-topbar-title { color: var(--text); font-size: 1.18rem; font-weight: 750; letter-spacing: -.015em; }
.dash-topbar-sub { color: var(--text-muted); }
.dash-list { padding: 16px clamp(12px, 2vw, 24px) 24px; }
.dash-filters { padding: 10px clamp(18px, 3vw, 34px); gap: 7px; background: var(--surface); border-bottom: 1px solid var(--border); }
.filter-btn { min-height: 36px; padding: 6px 14px; border-color: #d5deea; color: #52637d; background: #fff; font-weight: 600; }
.filter-btn:hover { background: #edf3ff; border-color: #c9d9f7; color: var(--brand); }
.filter-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.order-card, .admin-card, .agenda-card, .settings-section, .dashboard-orders-panel, .stat-card, .detail-section {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.order-card, .admin-card, .agenda-card { margin: 7px 0; border-radius: var(--radius); }
.order-card:hover, .admin-card:hover, .agenda-card:hover { border-color: #b8cdf7; box-shadow: 0 12px 28px rgba(23, 43, 77, .1); }
.order-card.selected { border-color: var(--brand); background: #f7faff; }
.order-total, .dashboard-order-number, .dashboard-order-links a, .info-title { color: var(--brand); }

.btn-action, .dash-topbar-btn, .button, .btn { min-height: 38px; border-radius: 9px; font-weight: 650; transition: background .15s, color .15s, border-color .15s, transform .15s; }
.btn-action:hover:not(:disabled), .dash-topbar-btn:hover:not(:disabled) { opacity: 1; transform: translateY(-1px); }
.btn-primary, .dash-topbar-btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover:not(:disabled), .dash-topbar-btn:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-secondary { background: #edf2f8; color: #30415d; border: 1px solid #dce4ef; }
.btn-secondary:hover:not(:disabled) { background: #e3eaf3; }
.btn-danger { background: #fff0f1; color: var(--red); border-color: #ffd6da; }

.form-input, .form-textarea, .form-select, .form-control,
.dashboard-period select, .dashboard-period input, .dashboard-list-tools select, .dashboard-search input {
  border-color: #d5deea;
  background: #fff;
  color: var(--text);
  border-radius: 9px;
}
.form-input:focus, .form-textarea:focus, .form-select:focus, .form-control:focus,
.dashboard-period select:focus, .dashboard-period input:focus, .dashboard-list-tools select:focus, .dashboard-search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(61, 115, 232, .12);
}
.form-label { color: #30415d; }
.form-toggle-row { background: #f8faff; border-color: var(--border); }

.detail-overlay { background: rgba(16, 31, 59, .5); backdrop-filter: blur(3px); }
.detail-panel { background: #fff; border-color: var(--border); box-shadow: 0 24px 70px rgba(23, 43, 77, .22); }
.detail-header, .detail-footer { background: #fff; border-color: var(--border); }
.detail-row, .order-item-row, .info-row { border-color: var(--border); }
.detail-row-value, .order-item-name, .info-value { color: var(--text); }
.detail-row-label, .order-item-note, .order-item-price, .info-label { color: var(--text-muted); }

.badge, .status-badge, .payment-badge { border-color: transparent; text-transform: none; letter-spacing: 0; }
.badge-delivered, .badge-active, .status-readyforpickup, .status-delivered, .payment-badge.paid { background: var(--success-soft); color: var(--success); border-color: #c8f1d9; }
.badge-pending, .badge-escalated, .status-pending, .payment-badge.pending { background: #fff7df; color: var(--yellow); border-color: #f1dfaa; }
.badge-cancelled { background: #fff0f1; color: var(--red); border-color: #ffd6da; }
.badge-confirmed, .badge-preparing, .badge-outfordelivery, .badge-handledbyhuman { background: #edf3ff; color: var(--brand); border-color: #d8e5ff; }
.badge-closed, .badge-productorder { background: #f1f4f8; color: #52637d; border-color: #e0e6ee; }

.dash-loading, .dash-error, .dash-empty { color: var(--text-muted); }
.dash-error-card, .error-card { background: #fff; border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }
.dash-error-card h2, .error-card h2 { color: var(--text); }
.dash-error-card p, .error-card p { color: var(--text-muted); }
.dash-spinner, .spinner { border-color: #dce6f8; border-top-color: var(--brand); }

.dashboard-page { min-height: calc(100dvh - var(--topbar-height)); padding: clamp(20px, 3vw, 36px); background: var(--bg); }
.dashboard-main { max-width: 1180px; margin: 0 auto; }
.dashboard-main > h1 { margin: 0 0 24px; font-size: clamp(1.55rem, 2.5vw, 2.15rem); letter-spacing: -.025em; }
.dashboard-main .detail-section { padding: 21px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
.alert { padding: 12px 15px; border: 1px solid transparent; border-radius: 10px; margin: 0 0 16px; }
.alert-danger { background: #fff1f2; color: #a52b3c; border-color: #ffd9de; }
.alert-success { background: #ecfdf4; color: #167344; border-color: #c8f1d9; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.action-msg { margin: 10px clamp(18px, 3vw, 34px) 0; padding: 10px 13px; border: 1px solid transparent; border-radius: 10px; font-size: .86rem; }
.action-msg.ok, .topbar-feedback.ok { color: #167344; }
.action-msg.ok { background: #ecfdf4; border-color: #c8f1d9; }
.action-msg.err, .topbar-feedback.err { color: #a52b3c; }
.action-msg.err { background: #fff1f2; border-color: #ffd9de; }
.topbar-feedback { font-size: .8rem; font-weight: 650; }

.login-page { min-height: 100dvh; padding: 24px; background: linear-gradient(135deg, #eef4ff, #f8f6ff); color: var(--text); }
.login-card { padding: 34px; background: #fff; border-color: var(--border); box-shadow: 0 18px 50px rgba(23, 43, 77, .13); }
.login-card h1 { color: var(--text); letter-spacing: -.025em; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .eyebrow { margin-bottom: 3px; }
.auth-brand h1 { font-size: 1.55rem; }
.login-subtitle { color: var(--text-muted); }
.login-field label { color: #30415d; font-size: .84rem; font-weight: 650; }
.login-field small { color: var(--text-muted); }
.login-field input { background: #fff; border-color: #d5deea; color: var(--text); }
.login-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(61, 115, 232, .12); }
.login-button { background: var(--brand); color: #fff; }
.login-button:hover { background: var(--brand-dark); }
.ui-form-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 12px; }
.ui-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.section-action { margin-top: 12px; }
.btn-icon-action { width: 38px; min-width: 38px; padding: 0; }
.btn-icon-action i, .dash-empty-icon i, .dash-topbar-title i { font-size: 1.25em; vertical-align: -.12em; }
.dash-empty-icon i { font-size: 2.4rem; }

/* Constructor de pedido manual. Mantiene el formulario separado de la página
   para que pueda convertirse en el editor compartido de la siguiente etapa. */
.order-composer-panel { max-width: 860px; width: min(96vw, 860px); max-height: 92dvh; }
.detail-header-actions { display:flex; align-items:center; gap:8px; }
.order-readonly-value { min-height:40px; padding:9px 11px; border:1px solid #e5e7eb; border-radius:8px; background:#f8fafc; color:#374151; }
.order-line-unavailable { display:block; margin-top:4px; color:#b91c1c; font-weight:600; }
.order-edit-block-reason { margin-top:10px; font-size:12px; line-height:1.4; color:#6b7280; }
.order-edit-confirmation { position:fixed; inset:0; z-index:110; display:grid; place-items:center; padding:20px; background:rgba(15,23,42,.52); }
.order-edit-confirmation-card { width:min(100%, 500px); padding:22px; border-radius:14px; background:#fff; box-shadow:0 18px 48px rgba(15,23,42,.25); }
.order-edit-confirmation-card h3 { margin:0 0 12px; font-size:18px; color:#111827; }
.order-edit-confirmation-card p { margin:0 0 12px; line-height:1.5; color:#374151; }
.order-edit-confirmation-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
.booking-cancellation-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: clamp(12px, 3vw, 28px);
  background: rgba(16, 31, 59, .58);
  backdrop-filter: blur(3px);
}

/* ETAPA 3: identidad y operación compartidas */
.customer-identity { display:flex; flex-direction:column; min-width:0; gap:2px; }
.customer-identity-name { color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.customer-identity-phone { color:var(--text-muted); font-size:.78rem; font-weight:500; white-space:nowrap; }
.customer-identity-inline { flex-direction:row; align-items:baseline; flex-wrap:wrap; gap:5px; }
.customer-identity-inline .customer-identity-phone::before { content:"\00b7"; margin-right:5px; color:var(--text-muted); }
.order-card-identity { display:flex; align-items:baseline; min-width:0; gap:8px; flex-wrap:wrap; }
.order-detail-badges { display:flex; gap:6px; margin-top:4px; flex-wrap:wrap; }
.order-total-row { font-size:1rem; }
.payment-pending-section { border:1px solid #f59e0b; background:#fffbeb; }
.payment-proof-row, .payment-review-actions { gap:8px; align-items:center; flex-wrap:wrap; }
.payment-review-actions { display:flex; margin-top:10px; }
.payment-review-actions .form-input { min-width:210px; flex:1; }
.payment-analysis-box { margin:8px 0 12px; padding:11px 12px; border:1px solid; border-radius:10px; font-size:.88rem; }
.payment-analysis-box.analysis-pending { border-color:#93c5fd; background:#eff6ff; color:#1e3a5f; }
.payment-analysis-box.analysis-preapproved { border-color:#86efac; background:#f0fdf4; color:#14532d; }
.payment-analysis-box.analysis-review, .payment-analysis-box.analysis-unavailable { border-color:#fcd34d; background:#fffbeb; color:#713f12; }
.payment-analysis-heading { font-weight:700; margin-bottom:4px; }
.payment-analysis-box p { margin:0 0 7px; line-height:1.4; }
.payment-analysis-box small { display:block; margin-top:7px; font-weight:600; }
.payment-analysis-amounts { display:flex; gap:8px 20px; flex-wrap:wrap; }
.payment-analysis-amounts span { display:flex; gap:5px; flex-wrap:wrap; }

.business-hours-editor { border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.business-hours-header, .business-hours-row { display:grid; grid-template-columns:minmax(100px,1.1fr) minmax(100px,.8fr) minmax(110px,1fr) minmax(110px,1fr); align-items:center; gap:12px; padding:10px 12px; }
.business-hours-header { background:var(--surface2); color:var(--text-muted); font-size:.75rem; font-weight:700; text-transform:uppercase; }
.business-hours-row + .business-hours-row { border-top:1px solid var(--border); }
.business-hours-row .form-input { min-width:0; }
.business-hours-toggle { display:flex; align-items:center; gap:7px; color:var(--text-muted); font-size:.82rem; }
.business-hours-toggle input, .payment-method-toggle input, .form-toggle-row input { width:18px; height:18px; accent-color:var(--green); }
.form-help { margin:0 0 10px; color:var(--text-muted); font-size:.8rem; }
.settings-page-list { padding-bottom:24px; }
.settings-section-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.settings-section-heading .btn-action { flex:0 0 auto; }
.push-device-settings { width:100%; }
.push-settings-combined { padding:0; }
.push-settings-subsection { min-width:0; }
.push-settings-subsection + .push-settings-subsection { border-top:1px solid var(--border); }
.push-settings-subsection-title { padding:16px 16px 0; color:var(--text); font-size:.92rem; font-weight:750; }
.push-settings-subsection-body { padding:16px; }
.push-device-loading { display:flex; align-items:center; gap:12px; color:var(--text-muted); min-height:48px; }
.push-device-loading .dash-spinner { width:24px; height:24px; flex:0 0 auto; }
.push-device-summary { display:grid; grid-template-columns:48px minmax(0,1fr); gap:14px; align-items:center; }
.push-device-icon { width:48px; height:48px; border-radius:14px; display:grid; place-items:center; background:#edf2f8; color:var(--text-muted); }
.push-device-icon i { font-size:1.45rem; }
.push-device-icon.active { background:#e8f8ef; color:#167344; }
.push-device-icon.blocked,.push-device-icon.error { background:#fff1f2; color:#a52b3c; }
.push-device-status { font-size:1rem; font-weight:750; color:var(--text); }
.push-device-summary p { margin:4px 0 0; color:var(--text-muted); line-height:1.5; }
.push-device-permission { display:inline-block; margin-top:7px; color:var(--text-muted); font-size:.78rem; font-weight:650; }
.push-device-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:18px; }
.push-settings-intro { margin-top:0; }
.push-settings-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.push-settings-grid .form-toggle-row { margin:0; min-height:48px; }
.push-severity-settings { margin:18px 0 0; padding:14px; border:1px solid var(--border); border-radius:11px; }
.push-severity-settings legend { padding:0 7px; font-size:.82rem; font-weight:700; color:var(--text-muted); }
.push-severity-settings:disabled { opacity:.58; }
.scheduling-reminder-grid { display:grid; gap:12px; }
.scheduling-reminder-row { display:grid; grid-template-columns:minmax(160px,1fr) minmax(120px,.65fr) minmax(190px,1fr); gap:16px; align-items:center; padding:14px; border:1px solid var(--border); border-radius:11px; background:var(--surface2); }
.scheduling-reminder-enabled { display:flex; align-items:center; gap:8px; color:var(--text); font-size:.86rem; }
.scheduling-reminder-enabled input { width:18px; height:18px; accent-color:var(--green); }
.scheduling-reminder-row .form-group { margin:0; }
.booking-confirmation { font-size:.76rem; font-weight:650; }
.booking-confirmation.confirmed { color:var(--success); }
.booking-confirmation.unconfirmed { color:var(--text-muted); }
@media (max-width: 600px) {
  .settings-section-heading { align-items:stretch; flex-direction:column; }
  .settings-section-heading .btn-action { width:100%; }
  .push-settings-grid { grid-template-columns:1fr; }
  .push-device-actions .btn-action { width:100%; min-height:44px; }
  .scheduling-reminder-row { grid-template-columns:1fr; gap:10px; }
}
.settings-readonly-grid, .settings-label-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 20px; }
.settings-toggle-first { border-top:0; padding-top:0; }
.payment-method-list { display:grid; gap:0; }
.payment-method-row { padding:12px 0; border-top:1px solid var(--border); }
.payment-method-row:first-child { padding-top:0; border-top:0; }
.payment-method-toggle { display:flex; align-items:center; gap:8px; margin-bottom:8px; }

.users-grid { margin:16px; border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--surface); }
.users-grid-header, .users-grid-row { display:grid; grid-template-columns:minmax(110px,.9fr) minmax(135px,1.1fr) minmax(105px,.8fr) minmax(125px,1fr) minmax(105px,.8fr) minmax(140px,1fr) minmax(260px,1.6fr); align-items:center; gap:12px; padding:12px 14px; }
.users-grid-header { background:var(--surface2); color:var(--text-muted); font-size:.72rem; font-weight:750; text-transform:uppercase; }
.users-grid-row + .users-grid-row { border-top:1px solid var(--border); }
.users-grid-row > div { min-width:0; overflow-wrap:anywhere; }
.users-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.users-password-note { display:block; margin-top:4px; color:var(--yellow); }
.user-form-modal { width:min(620px,calc(100vw - 28px)); }
.user-form-actions { justify-content:flex-end; }
.temporary-password { display:block; margin:14px 0; padding:12px; border-radius:8px; background:var(--surface2); font-size:1rem; overflow-wrap:anywhere; }

.confirmation-overlay { position:fixed; inset:0; z-index:1300; display:grid; place-items:center; padding:16px; background:rgba(15,23,42,.58); }
.confirmation-dialog { width:min(460px,100%); max-height:calc(100dvh - 32px); overflow:auto; padding:22px; border:1px solid var(--border); border-radius:14px; background:var(--surface); box-shadow:0 24px 70px rgba(0,0,0,.3); }
.confirmation-dialog h2 { margin:0 0 10px; font-size:1.15rem; }
.confirmation-dialog p { margin:0; color:var(--text-muted); line-height:1.5; }
.confirmation-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; flex-wrap:wrap; }
.order-editor-overlay { z-index:1200; }

@media (max-width:1100px) {
  .users-grid-header { display:none; }
  .users-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; border:0; background:transparent; overflow:visible; }
  .users-grid-row { display:flex; flex-direction:column; align-items:stretch; gap:8px; border:1px solid var(--border); border-radius:10px; background:var(--surface); }
  .users-grid-row + .users-grid-row { border-top:1px solid var(--border); }
  .users-grid-row > div { display:grid; grid-template-columns:115px minmax(0,1fr); gap:8px; }
  .users-grid-row > div::before { content:attr(data-label); color:var(--text-muted); font-size:.74rem; font-weight:700; }
  .users-actions { justify-content:flex-start; }
}

@media (max-width:700px) {
  .business-hours-header { display:none; }
  .business-hours-row { grid-template-columns:1fr 1fr; gap:8px; }
  .business-hours-row strong { grid-column:1; }
  .business-hours-toggle { grid-column:2; justify-self:end; }
  .business-hours-row .form-input { width:100%; }
  .settings-readonly-grid, .settings-label-grid, .users-grid { grid-template-columns:1fr; }
  .users-grid { margin:10px; }
  .detail-header-actions { align-items:flex-end; }
  .confirmation-actions .btn-action { flex:1 1 170px; justify-content:center; }
}
.booking-cancellation-dialog {
  width: min(100%, 560px);
  max-height: calc(100dvh - clamp(24px, 6vw, 56px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 43, 77, .28);
}
.booking-cancellation-body { min-height: 0; }
.booking-cancellation-summary {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8faff;
}
.booking-cancellation-summary-row {
  display: grid;
  grid-template-columns: minmax(90px, .7fr) minmax(0, 1.6fr);
  gap: 12px;
  padding: 6px 0;
  font-size: .84rem;
}
.booking-cancellation-summary-row span { color: var(--text-muted); }
.booking-cancellation-summary-row strong { color: var(--text); overflow-wrap: anywhere; }
.booking-cancellation-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
}
.booking-cancellation-option + .booking-cancellation-option {
  border-top: 1px solid var(--border);
}
.booking-cancellation-option input { margin-top: 3px; }
.booking-cancellation-option small { color: var(--text-muted); }
.order-composer-body.escalation-answer-form { gap: 10px; }
.escalation-answer-form .booking-cancellation-summary { margin-bottom: 0; }
.escalation-answer-field { width: 100%; min-width: 0; margin: 0; }
.escalation-answer-input {
  display: block;
  width: 100%;
  min-height: 120px;
  max-height: min(260px, 40dvh);
  box-sizing: border-box;
  line-height: 1.45;
  resize: vertical;
}
.order-composer-subtitle { margin-top: 3px; color: var(--text-muted); font-size: .78rem; }
.order-composer-body { display: grid; gap: 16px; padding: 18px 22px; background: #f7f9fc; }
.order-composer-section { padding: 17px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(23, 43, 77, .04); }
.order-notify-option { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid #d8e5ff; border-radius: 10px; background: #f5f8ff; cursor: pointer; }
.order-notify-option.disabled { border-color: var(--border); background: #f7f8fa; cursor: default; opacity: .72; }
.order-notify-option input { margin-top: 3px; }
.order-notify-option strong, .order-notify-option small { display: block; }
.order-notify-option strong { color: var(--text); font-size: .86rem; }
.order-notify-option small { margin-top: 2px; color: var(--text-muted); font-size: .74rem; }
.order-product-search { margin-bottom: 10px; }
.order-product-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 230px; overflow-y: auto; padding-right: 2px; }
.order-product-choice { min-height: 64px; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); text-align: left; cursor: pointer; }
.order-product-choice:hover:not(:disabled) { border-color: #a9c3f6; background: #f7faff; }
.order-product-choice:disabled { opacity: .55; cursor: default; }
.order-product-choice span, .order-product-choice strong, .order-product-choice small { display: block; }
.order-product-choice strong { font-size: .86rem; }
.order-product-choice small { margin-top: 3px; color: var(--text-muted); font-size: .7rem; }
.order-product-choice-price { flex: 0 0 auto; color: var(--brand); font-size: .82rem; font-weight: 700; text-align: right; }
.order-composer-empty { grid-column: 1 / -1; padding: 20px; color: var(--text-muted); font-size: .82rem; text-align: center; }
.order-draft-lines { display: grid; gap: 10px; margin-top: 14px; }
.order-draft-line { padding: 14px; border: 1px solid var(--border); border-radius: 11px; background: #fbfcfe; }
.order-draft-line-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.order-draft-line-header strong, .order-draft-line-header small { display: block; }
.order-draft-line-header strong { color: var(--text); font-size: .92rem; }
.order-draft-line-header small { margin-top: 2px; color: var(--text-muted); font-size: .72rem; }
.order-quantity-control { width: fit-content; display: grid; grid-template-columns: 34px 42px 34px; align-items: center; margin-bottom: 12px; border: 1px solid #d5deea; border-radius: 9px; overflow: hidden; background: #fff; }
.order-quantity-control button { height: 32px; border: 0; background: #edf3ff; color: var(--brand); font-size: 1rem; cursor: pointer; }
.order-quantity-control span { text-align: center; font-size: .84rem; font-weight: 700; }
.order-option-group { margin: 10px 0 12px; }
.required-mark { color: var(--red); }
.order-option-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.order-option-check { display: flex; gap: 8px; align-items: center; padding: 8px 9px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: .8rem; cursor: pointer; }
.order-option-check small { margin-left: 4px; color: var(--brand); font-weight: 650; }
.order-field-help { display: block; margin-top: 5px; color: var(--text-muted); font-size: .72rem; }
.order-rule-note { padding: 9px 11px; border-radius: 8px; background: #f1f4f8; color: var(--text-muted); font-size: .76rem; }
.order-validation-summary { display: grid; gap: 4px; margin: 0; }
.order-composer-footer { align-items: center; }
.order-server-authority { margin-left: auto; color: var(--text-muted); font-size: .72rem; }

/* Live chat receives the same light surfaces while retaining its message layout. */
.chat-wrapper { width: calc(100% - 32px); max-width: 1320px; height: calc(100dvh - var(--topbar-height) - 32px); margin: 16px auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-header, .input-area { background: #fff; border-color: var(--border); }
.header-name { color: var(--text); }
.header-phone, .header-status { color: var(--text-muted); }
.header-avatar, .btn-send, .btn-take, .btn-take-full { background: var(--brand); }
.btn-icon { color: var(--text-muted); }
.btn-icon:hover { background: #edf3ff; color: var(--brand); }
.status-banner { background: #fff7df; border-color: #f1dfaa; }
.status-banner span { color: var(--yellow); }
.messages-area { background-color: #f5f7fb; background-image: radial-gradient(rgba(61, 115, 232, .055) 1px, transparent 1px); background-size: 20px 20px; }
.date-divider span, .msg-row.system .bubble { background: #fff; color: var(--text-muted); border-color: var(--border); box-shadow: 0 2px 8px rgba(23, 43, 77, .05); }
.msg-row.from-customer .bubble { background: #fff; border-color: #fff; color: var(--text); box-shadow: 0 3px 12px rgba(23, 43, 77, .08); }
.msg-row.from-ai .bubble { background: #edf3ff; border-color: #edf3ff; color: var(--text); }
.msg-row.from-operator .bubble { background: #3d73e8; border-color: #3d73e8; color: #fff; }
.msg-row.from-ai .bubble-role { color: var(--brand); }
.msg-row.from-operator .bubble-role, .msg-row.from-operator .bubble-time { color: #dce8ff; }
.input-box { background: #f5f7fb; border: 1px solid #d5deea; color: var(--text); }
.input-box:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(61, 115, 232, .12); }
.locked-overlay, .info-panel { background: #f8faff; border-color: var(--border); }

@media (max-width: 767px) {
  :root { --topbar-height: 64px; }
  .orders-sidebar { position: fixed; left: 0; transform: translateX(-100%); width: min(86vw, 280px); min-height: 100dvh; }
  .sidebar-inner { height: 100dvh; }
  .orders-main { width: 100%; }
  .orders-global-topbar { padding: 0 14px; }
  .role-badge { display: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(16, 31, 59, .48); }
  body.sidebar-mobile-open { overflow: hidden; }
  body.sidebar-mobile-open .orders-sidebar { transform: translateX(0); }
  body.sidebar-mobile-open .sidebar-backdrop { display: block; }
  body.sidebar-collapsed .orders-sidebar { width: min(86vw, 280px); }
  body.sidebar-collapsed .sidebar-inner { padding: 24px 16px 16px; }
  body.sidebar-collapsed .sidebar-brand { justify-content: flex-start; margin-inline: 8px; }
  body.sidebar-collapsed .brand-copy,
  body.sidebar-collapsed .dash-nav-label,
  body.sidebar-collapsed .user-copy { display: block; }
  body.sidebar-collapsed .dash-nav-item { justify-content: flex-start; padding-inline: 13px; }
  body.sidebar-collapsed .dash-nav-user { justify-content: flex-start; padding-inline: 8px; }
  .dash-root { height: auto; min-height: calc(100dvh - var(--topbar-height)); }
  .dash-topbar { align-items: flex-start; flex-wrap: wrap; }
  .dash-topbar .dash-topbar-btn, .dash-topbar > .btn-action { margin-left: auto; }
  .dash-list { overflow: visible; }
  .detail-panel { max-height: 92dvh; }
  .chat-wrapper { width: 100%; height: calc(100dvh - var(--topbar-height)); margin: 0; border: 0; border-radius: 0; overflow-y: auto; }
  .chat-column { height: min(72dvh, 680px); min-height: 480px; }
  .info-panel { background: #f8faff; border-color: var(--border); }
  .ui-form-grid { grid-template-columns: 1fr; }
  .order-composer-panel { width: 100%; max-height: 94dvh; }
  .booking-cancellation-modal { place-items: end center; padding: 10px; }
  .booking-cancellation-dialog { width: 100%; max-height: calc(100dvh - 20px); border-radius: 14px; }
  .booking-cancellation-summary-row { grid-template-columns: 1fr; gap: 2px; }
  .order-composer-body { padding: 14px; }
  .order-composer-section { padding: 13px; }
  .order-product-picker, .order-option-list { grid-template-columns: 1fr; }
  .order-server-authority { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
/* Agenda mensual */
.calendar-shell{margin:16px;background:var(--surface);border:1px solid var(--border);border-radius:12px;overflow:hidden}
.calendar-toolbar{display:flex;align-items:center;gap:8px;padding:12px;border-bottom:1px solid var(--border)}
.calendar-toolbar h2{font-size:17px;text-transform:capitalize;margin:0 auto 0 0}
.calendar-weekdays,.calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}
.calendar-weekdays div{padding:8px;text-align:center;font-size:11px;font-weight:700;color:var(--text-muted);border-bottom:1px solid var(--border)}
.calendar-day{min-height:105px;padding:7px;border:0;border-right:1px solid var(--border);border-bottom:1px solid var(--border);background:transparent;text-align:left;color:inherit;cursor:pointer;overflow:hidden}
.calendar-day:hover,.calendar-day.selected{background:var(--surface-2)}.calendar-day.outside{opacity:.42}
.calendar-day-number{display:block;font-weight:700;margin-bottom:5px}.calendar-event{display:block;padding:3px 5px;margin:2px 0;border-radius:4px;background:var(--green-dim);font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.calendar-event.status-pending{border-left:3px solid var(--yellow)}.calendar-event.status-confirmed{border-left:3px solid var(--blue)}.calendar-event.status-completed{border-left:3px solid var(--green)}.calendar-event.status-rejected,.calendar-event.status-cancelled{border-left:3px solid var(--red)}.calendar-event.status-noshow{border-left:3px solid var(--gray)}
.calendar-more{font-size:10px;color:var(--text-muted)}.calendar-day-detail{padding:14px}.calendar-day-detail h3{margin:0 0 10px;text-transform:capitalize}
.calendar-detail-event{width:100%;display:flex;gap:10px;align-items:center;padding:9px;border:0;border-top:1px solid var(--border);background:transparent;color:inherit;text-align:left;cursor:pointer}.calendar-detail-event span:nth-child(2){flex:1}
.request-page{overflow-y:auto}.request-list{display:grid;gap:12px;padding:18px 20px}.request-card{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.38fr) auto;gap:18px;align-items:start;padding:18px;border:1px solid var(--border);border-radius:14px;background:#fff;box-shadow:0 4px 16px rgba(23,43,77,.05)}.request-identity{display:flex;align-items:center;gap:10px}.request-identity strong,.request-identity small{display:block}.request-identity small{margin-top:2px;color:var(--text-muted);font-size:.74rem}.request-service{display:flex;align-items:center;gap:7px;margin-top:14px;color:var(--text);font-weight:700}.request-description{margin:9px 0 0;color:var(--text-muted);font-size:.86rem;line-height:1.45;overflow-wrap:anywhere}.request-meta{display:grid;gap:9px;color:var(--text-muted);font-size:.77rem}.request-meta .badge{width:fit-content}.request-meta span{display:flex;align-items:center;gap:6px}.request-actions{display:flex;flex-direction:column;gap:8px;min-width:135px}.request-detail-panel{max-width:660px}.request-detail-description{margin-top:13px;padding:12px;border-radius:10px;background:var(--surface2)}.request-detail-description span{color:var(--text-muted);font-size:.72rem;font-weight:700;text-transform:uppercase}.request-detail-description p{margin:5px 0 0;line-height:1.5;overflow-wrap:anywhere}.request-no-booking{margin:0;color:var(--text-muted)}.request-id-value{max-width:300px;overflow-wrap:anywhere}.request-detail-footer{gap:10px;justify-content:space-between}.request-status-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
@media(max-width:920px){.request-card{grid-template-columns:1fr auto}.request-meta{grid-column:1}.request-actions{grid-column:2;grid-row:1 / span 2}}
@media(max-width:620px){.request-list{padding:14px}.request-card{grid-template-columns:1fr}.request-meta,.request-actions{grid-column:1;grid-row:auto}.request-actions{flex-direction:row;flex-wrap:wrap}.request-detail-footer{align-items:stretch;flex-direction:column}.request-status-actions{justify-content:flex-start}.request-id-value{max-width:180px}}

/* Notificaciones externas (solo lectura) */
.notification-page { overflow-y: auto; }
.notification-error { display: flex; align-items: center; gap: 10px; margin: 16px 20px 0; }
.notification-error .conversation-notice { flex: 1; margin: 0; }
.notification-list { display: grid; gap: 12px; padding: 18px 20px; }
.notification-card { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: 0 4px 16px rgba(23,43,77,.05); }
.notification-card-heading, .notification-card-footer, .notification-card-meta, .notification-detail-title-row, .notification-delivery-heading { display: flex; align-items: center; gap: 10px; }
.notification-card-heading { justify-content: space-between; }
.notification-card-heading time { color: var(--text-muted); font-size: .76rem; white-space: nowrap; }
.notification-card h2, .notification-detail-title { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.notification-card h2 { font-size: 1rem; }
.notification-preview { display: -webkit-box; margin: 0; overflow: hidden; color: var(--text-muted); font-size: .86rem; line-height: 1.5; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.notification-card-footer { justify-content: space-between; }
.notification-card-meta { min-width: 0; flex-wrap: wrap; color: var(--text-muted); font-size: .77rem; }
.notification-card-meta > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-severity, .notification-status { display: inline-flex; width: fit-content; align-items: center; gap: 5px; border-radius: 999px; font-size: .7rem; font-weight: 750; line-height: 1; white-space: nowrap; }
.notification-severity { padding: 6px 9px; }
.notification-status { padding: 5px 8px; }
.notification-severity-info { background: #eaf2ff; color: #285da8; }
.notification-severity-warning { background: #fff2d6; color: #9a5b00; }
.notification-severity-critical { background: #ffe8e8; color: #b42318; }
.notification-status-pending { background: #eef2f7; color: #53627a; }
.notification-status-sent { background: #e4f7ed; color: #16734a; }
.notification-status-partial { background: #fff2d6; color: #8a5504; }
.notification-status-failed { background: #ffe8e8; color: #b42318; }
.notification-status-unknown { background: #f2eaff; color: #6841a5; }
.notification-detail-panel { width: min(760px, calc(100vw - 28px)); max-width: 760px; max-height: 92dvh; }
.notification-detail-body { display: grid; gap: 14px; }
.notification-detail-title-row { justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.notification-detail-title { font-size: 1.12rem; }
.notification-message { margin: 10px 0 0; color: var(--text); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.notification-break-value { overflow-wrap: anywhere; }
.notification-metadata { max-height: 300px; margin: 0; padding: 13px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; background: #f7f9fc; color: var(--text); font: .78rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.notification-no-deliveries { margin: 0; color: var(--text-muted); }
.notification-delivery-list { display: grid; gap: 10px; }
.notification-delivery-card { padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfe; }
.notification-delivery-heading { justify-content: space-between; }
.notification-delivery-heading strong { color: var(--text); font-size: .86rem; }
.notification-destination { margin-top: 5px; color: var(--text-muted); font-size: .8rem; overflow-wrap: anywhere; }
.notification-delivery-facts { display: grid; grid-template-columns: .55fr 1fr 1fr; gap: 10px; margin: 12px 0 0; }
.notification-delivery-facts div { min-width: 0; }
.notification-delivery-facts dt { color: var(--text-muted); font-size: .68rem; font-weight: 700; text-transform: uppercase; }
.notification-delivery-facts dd { margin: 3px 0 0; color: var(--text); font-size: .77rem; overflow-wrap: anywhere; }
.notification-delivery-error { display: grid; gap: 3px; margin-top: 10px; padding: 9px 10px; border-radius: 8px; background: #fff0f0; color: #9f241c; font-size: .75rem; overflow-wrap: anywhere; }
.notification-detail-error { display: grid; justify-items: start; gap: 10px; }
.notification-detail-error .conversation-notice { margin: 0; }

/* Ajustes móviles quirúrgicos: áreas táctiles, viewport y contención de scroll. */
html, body { max-width: 100%; overflow-x: hidden; }
@supports (overflow: clip) {
  html, body { overflow-x: clip; }
}

/* livechat.css comparte este nombre con los botones generales. */
.btn-action { width: auto; }
.info-panel .btn-action { width: 100%; }

@media (min-width: 768px) and (max-width: 1024px), (pointer: coarse) {
  .sidebar-toggle,
  .btn-icon,
  .btn-close-panel,
  .btn-icon-action {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .btn-action,
  .dash-topbar-btn,
  .button,
  .btn,
  .btn-sm,
  .filter-btn,
  .tag-add-btn,
  .btn-take {
    min-height: 44px;
  }
  .form-input,
  .form-textarea,
  .form-select,
  .form-control,
  .login-field input,
  .conversation-search input,
  .menu-search,
  .input-box,
  .dashboard-period select {
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  :root { --topbar-height: calc(64px + env(safe-area-inset-top)); }

  .orders-global-topbar {
    padding-top: env(safe-area-inset-top);
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .sidebar-inner,
  body.sidebar-collapsed .sidebar-inner {
    padding-top: max(24px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .sidebar-toggle,
  .btn-icon,
  .btn-close-panel,
  .btn-icon-action {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .sidebar-toggle { flex-basis: 44px; }
  .btn-action,
  .dash-topbar-btn,
  .button,
  .btn,
  .btn-sm,
  .filter-btn,
  .tag-add-btn,
  .btn-take {
    min-height: 44px;
  }

  .form-input,
  .form-textarea,
  .form-select,
  .form-control,
  .login-field input,
  .conversation-search input,
  .menu-search,
  .input-box,
  .dashboard-period select {
    font-size: 16px;
  }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .tag-input-row { align-items: stretch; flex-wrap: wrap; }
  .tag-input-row .form-input { min-width: 0; flex: 1 1 180px; }
  .tag-add-btn { flex: 1 1 auto; }

  .login-page {
    min-height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .login-card { width: min(100%, 380px); padding: 24px; }

  .conversation-actions {
    margin-left: 0;
    padding-left: 60px;
  }
  .admin-card { align-items: flex-start; flex-wrap: wrap; }
  .admin-card-actions { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .admin-card-actions .btn-sm { flex: 1 1 120px; }

  .detail-panel,
  .order-composer-panel,
  .notification-detail-panel {
    max-height: calc(100dvh - env(safe-area-inset-top));
  }
  .detail-header,
  .detail-body,
  .detail-footer {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .detail-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .confirmation-overlay,
  .order-edit-confirmation,
  .booking-cancellation-modal {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }
  .confirmation-dialog,
  .order-edit-confirmation-card,
  .booking-cancellation-dialog { max-width: 100%; }

  .order-quantity-control { grid-template-columns: 44px 48px 44px; }
  .order-quantity-control button { height: 44px; }

  .chat-wrapper { overscroll-behavior: contain; }
  .chat-column { height: 100%; min-height: 0; flex: 0 0 100%; }
  .messages-area { min-height: 0; overscroll-behavior: contain; }
  .status-banner { gap: 8px; flex-wrap: wrap; }
  .input-area {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }
}

.elenis-reconnect {
  position: fixed;
  z-index: 10020;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 14px;
  color: #102b69;
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  border: 1px solid rgba(16, 43, 105, .18);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .16);
  pointer-events: none;
  transform: translateX(-50%);
}

.elenis-reconnect.is-visible { display: flex; }

.elenis-reconnect-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(16, 43, 105, .2);
  border-top-color: #102b69;
  border-radius: 50%;
  animation: elenis-reconnect-spin .8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .elenis-reconnect-spinner { animation-duration: 1.6s; }
}

@media (max-width: 620px) {
  .notification-list { padding: 14px; }
  .notification-card-heading { align-items: flex-start; }
  .notification-card-footer { align-items: stretch; flex-direction: column; }
  .notification-card-footer .btn-action { justify-content: center; }
  .notification-error { align-items: stretch; flex-direction: column; margin: 14px; }
  .notification-delivery-facts { grid-template-columns: 1fr; }
  .notification-detail-panel { width: 100%; max-height: 94dvh; }
}
@media(max-width:760px){.calendar-day{min-height:72px;padding:4px}.calendar-event{font-size:0}.calendar-event:before{content:'•';font-size:14px}.calendar-weekdays div{font-size:9px}}
