/* =======================================================
   COMPONENTS — Tarjetas blancas planas con sombra suave,
   botones pill, inputs pill, badges, modal, toast, tabla.
   Estilo "Forest Gold" (sidebar oscuro + main claro + mostaza).
   ======================================================= */

/* ===== Card ===== */
.nm-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}
.nm-card--flat { box-shadow: var(--shadow-sm); }
.nm-card--sunk { background: var(--color-surface-sunk); box-shadow: none; }
.nm-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.nm-card__head h3 { font-size: var(--fs-lg); }
.nm-card__head-sub { font-size: var(--fs-xs); color: var(--color-text-muted); }

/* ===== Stat card ===== */
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.stat-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card__icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: rgba(217, 168, 50, 0.14);
  color: var(--color-accent);
}
.stat-card__icon--success { background: rgba(29, 176, 135, 0.14);  color: var(--color-success); }
.stat-card__icon--warning { background: rgba(230, 162, 60, 0.14);  color: var(--color-warning); }
.stat-card__icon--info    { background: rgba(61, 125, 204, 0.14);  color: var(--color-info); }

.stat-card__label {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}
.stat-card__value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  color: var(--color-text-strong);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-card__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.stat-card__delta--up   { background: var(--color-success-soft); color: var(--color-success); }
.stat-card__delta--down { background: var(--color-danger-soft);  color: var(--color-danger); }
.stat-card__delta--flat { background: var(--color-surface-sunk); color: var(--color-text-muted); }

/* ===== Botones (pill) ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--color-sidebar-bg);
  box-shadow: 0 4px 12px rgba(40, 60, 55, 0.18);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: #fff;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
  border: 0;
}
.btn:hover {
  background: var(--color-sidebar-bg-deep);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(40, 60, 55, 0.26);
}
.btn:active { transform: translateY(0); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.30); }
.btn:disabled, .btn.is-disabled { opacity: 0.55; pointer-events: none; }

.btn--primary {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--glow-accent);
}
.btn--primary:hover {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--glow-accent-strong);
  transform: translateY(-1px);
}
.btn--primary:active { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.20); }

.btn--ghost { background: transparent; box-shadow: none; color: var(--color-text-strong); }
.btn--ghost:hover { background: rgba(40, 60, 55, 0.06); box-shadow: none; color: var(--color-text-strong); transform: none; }

/* .btn--secondary queda como alias del default (mismo verde oscuro) por compat */
.btn--secondary { background: var(--color-sidebar-bg); color: #fff; }
.btn--secondary:hover { background: var(--color-sidebar-bg-deep); color: #fff; }
.btn--secondary:active { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.30); }

.btn--outline {
  background: var(--color-surface);
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
  color: var(--color-text-strong);
}
.btn--outline:hover {
  background: var(--color-surface);
  box-shadow: inset 0 0 0 1px var(--color-accent);
  color: var(--color-accent-ink);
  transform: translateY(-1px);
}

.btn--danger { color: var(--color-danger); }
.btn--block { width: 100%; }
.btn--lg { padding: var(--space-4) var(--space-6); font-size: var(--fs-md); }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--fs-xs); }

/* ===== Inputs (pill blancos con sombra suave) ===== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field__hint  { font-size: var(--fs-xs); color: var(--color-text-muted); }
.field__error { font-size: var(--fs-xs); color: var(--color-danger); }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--color-surface-sunk);
  box-shadow: inset 0 1px 3px rgba(40, 60, 55, 0.08);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  font-size: var(--fs-sm);
  color: var(--color-text-strong);
  transition: box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.textarea,
textarea.input { border-radius: var(--radius-lg); min-height: 120px; resize: vertical; padding: var(--space-4) var(--space-5); line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: inset 0 1px 3px rgba(40, 60, 55, 0.06), var(--ring-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-dim); }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7C78' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-5) center;
  padding-right: var(--space-10);
}

/* Input con icono (search) */
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon__icon {
  position: absolute;
  left: var(--space-5);
  color: var(--color-text-muted);
  pointer-events: none;
  display: grid; place-items: center;
}
.input-icon .input { padding-left: calc(var(--space-10) + 4px); }

/* Switch */
.switch {
  position: relative;
  width: 46px; height: 26px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-sink);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.switch__dot {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch.is-on { background: var(--color-accent); }
.switch.is-on .switch__dot { transform: translateX(20px); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  background: var(--color-surface-sunk);
  color: var(--color-text);
  white-space: nowrap;
}
.badge--success { background: var(--color-success-soft); color: var(--color-success); }
.badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-soft);    color: var(--color-info); }
.badge--accent  { background: var(--color-accent); color: #fff; }
.badge--success-strong { background: rgba(25, 135, 84, 0.16);  color: #14653f; }
.badge--dark           { background: rgba(61, 68, 81, 0.14);   color: #3d4451; }
.badge__dot {
  /* Punto decorativo de los badges desactivado a petición: los badges de estatus
     se muestran sin el punto de la izquierda. */
  display: none;
}

/* ===== Tabla custom ===== */
.nm-table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-3);
  /* sin overflow:hidden — necesario para que el sticky del thead funcione con el scroll de la página */
}
.nm-table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-4);
  flex-wrap: wrap;
}
.nm-table-toolbar .input-icon { flex: 1; min-width: 220px; }

.nm-table-scroll {
  width: 100%;
  border-radius: var(--radius-md);
  /* Scroll interno (X + Y) en todos los tamaños: la tabla nunca hace scrollear
     la página completa. El thead queda sticky al top de este container. */
  overflow: auto;
  max-height: 65vh;
  -webkit-overflow-scrolling: touch;
}
.nm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.nm-table thead th {
  text-align: left;
  font-weight: var(--fw-semi);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: var(--space-4);
  background: var(--color-surface-sunk);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  /* Sticky: el header queda fijo al top del container scrolleable de la tabla
     (que ahora siempre tiene scroll interno con max-height). */
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--color-border);
}
.nm-table thead th:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: 0; }
.nm-table thead th:last-child  { border-top-right-radius: var(--radius-md); border-bottom-right-radius: 0; }
.nm-table thead th[data-sort] .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
}
.nm-table thead th[data-sort].is-sort-asc  .sort-arrow { opacity: 1; }
.nm-table thead th[data-sort].is-sort-desc .sort-arrow { opacity: 1; transform: rotate(180deg); }

.nm-table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
.nm-table tbody tr:last-child td { border-bottom: 0; }
.nm-table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.nm-table tbody tr:hover { background: var(--color-surface-sunk); }

.nm-table-empty {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}

.nm-table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-3) var(--space-2);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.nm-table-pagination__pages { display: flex; gap: var(--space-2); }
.nm-table-pagination__btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  display: grid; place-items: center;
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
  color: var(--color-text);
  transition: box-shadow var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nm-table-pagination__btn:hover:not(:disabled) { color: var(--color-accent-ink); }
.nm-table-pagination__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.nm-table-pagination__btn.is-active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--glow-accent);
}

/* ===== Avatar (con anillo dorado opcional) ===== */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: var(--fw-semi);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar--ring {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 28, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* z-index muy alto para que SIEMPRE quede sobre cualquier drawer/sidebar */
  z-index: calc(var(--z-modal) + 20);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* Modal centrado con position:fixed + translate(-50%, -50%).
   Fixed se ancla DIRECTO al viewport, no al backdrop ni a ningún padre.
   Garantiza centrado real independiente de scroll, transformaciones o
   problemas del padre. */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: calc(100vw - var(--space-8));
  max-width: var(--modal-max-w, 520px);
  max-height: calc(100vh - var(--space-8));
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translate(-50%, -50%) scale(0.97);
  transition: transform var(--dur-base) var(--ease-out);
  overflow: hidden;
  /* z-index aún más alto que el backdrop del modal y que cualquier drawer */
  z-index: calc(var(--z-modal) + 21);
}
.modal-backdrop.is-open ~ .modal,
.modal-backdrop.is-open .modal { transform: translate(-50%, -50%) scale(1); }

/* En mobile, oculta el drawer mientras hay modal abierto para evitar capas
   apiladas y mejorar performance del blur */
@media (max-width: 720px) {
  body.has-modal-open .drawer-side,
  body.has-modal-open .drawer-side-backdrop { visibility: hidden; }
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-8) var(--space-3);
  flex-shrink: 0;
}
.modal__body {
  padding: 0 var(--space-8) var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  /* scrollbar más sutil dentro del modal */
  scrollbar-width: thin;
}
.modal__close {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: var(--color-sidebar-bg);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out);
}
.modal__close:hover { background: var(--color-sidebar-bg-deep); }
.modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-8);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
  flex-wrap: wrap;
}
/* Si solo hay un botón en las acciones, lo centramos */
.modal__actions > .btn:only-child { margin-inline: auto; }

/* Mobile: padding más ajustado y botones que se apilan ocupando todo el ancho
   para no desbordar el modal cuando los labels son largos. */
@media (max-width: 640px) {
  .modal-backdrop { padding: var(--space-2); }
  .modal__head    { padding: var(--space-5) var(--space-5) var(--space-3); }
  .modal__body    { padding: 0 var(--space-5) var(--space-5); }
  .modal__actions {
    padding: var(--space-3) var(--space-5);
    flex-direction: column-reverse;
  }
  .modal__actions > .btn {
    width: 100%;
    white-space: normal;
  }
  .modal__actions > .btn:only-child { margin-inline: 0; }
}

/* ===== Toast ===== */
.toast-stack {
  position: fixed;
  /* Arriba a la derecha, justo debajo de la campana del topbar — abajo
     chocaban con el globo del chat IA flotante */
  top: 76px;
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 400;
  pointer-events: none;
}
.toast {
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  min-width: 280px;
  max-width: 420px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  pointer-events: auto;
  animation: nm-fade-in var(--dur-base) var(--ease-out);
}
.toast__icon {
  width: 24px; height: 24px;
  flex-shrink: 0;
  color: var(--color-accent);
}
.toast--success .toast__icon { color: var(--color-success); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--danger  .toast__icon { color: var(--color-danger); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: var(--fw-semi); color: var(--color-text-strong); font-size: var(--fs-sm); }
.toast__msg   { font-size: var(--fs-xs); color: var(--color-text-muted); }

/* ===== Spinner ===== */
.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(40, 60, 55, 0.18);
  border-top-color: var(--color-accent);
  animation: nm-spin 0.7s linear infinite;
}
.spinner--lg { width: 38px; height: 38px; border-width: 4px; }

/* ===== Loader (anillo cónico animado con blur) — para modales de carga ===== */
.loader {
  height: 80px;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 50%;
  box-sizing: border-box;
  position: relative;
  mask: conic-gradient(#000 0 0) content-box exclude, conic-gradient(#000 0 0);
  -webkit-mask: conic-gradient(#000 0 0) content-box exclude, conic-gradient(#000 0 0);
  filter: blur(12px);
}
.loader::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-conic-gradient(#0000 0 5%, var(--color-sidebar-bg), #0000 20% 50%);
  animation: l2 1.5s linear infinite;
}
@keyframes l2 {
  to { rotate: 1turn; }
}

/* ===== Modal compacto (loading + alert) ===== */
.modal--alert {
  width: 380px;
  max-width: 380px;
  text-align: center;
}
.modal--alert .modal__body { padding: var(--space-8) var(--space-6) var(--space-6); }
.modal--alert .modal__actions { justify-content: center; }
.modal__icon {
  width: 72px; height: 72px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  display: grid; place-items: center;
}
.modal__icon--success { background: var(--color-success-soft); color: var(--color-success); }
.modal__icon--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.modal__icon--danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.modal__icon--info    { background: var(--color-info-soft);    color: var(--color-info); }
.modal__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--color-text-strong);
  margin: 0 0 var(--space-2);
}
.modal__message {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Modal de loading (sin cerrar, solo loader + texto) */
.modal--loading {
  width: 280px;
  max-width: 280px;
  text-align: center;
  padding: var(--space-8) var(--space-6);
}
.modal--loading .loader { margin: 0 auto var(--space-5); }
.modal--loading .modal__message { font-weight: var(--fw-semi); color: var(--color-text-strong); }

/* ===== Tabs ===== */
.tabs {
  display: inline-flex;
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  padding: 4px;
  gap: 4px;
}
.tabs__item {
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.tabs__item:hover { color: var(--color-text-strong); }
.tabs__item.is-active {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--glow-accent);
}

/* ===== Chart wrapper ===== */
.chart-box {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.chart-box canvas { width: 100% !important; height: auto !important; }

/* ===== Drawer lateral (detalle) ===== */
.drawer-side-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 30, 28, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.drawer-side-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer-side {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 520px;
  max-width: 100vw;
  background: var(--color-surface);
  box-shadow: -20px 0 60px rgba(20, 30, 28, 0.25);
  z-index: calc(var(--z-modal) + 1);
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.drawer-side.is-open { transform: translateX(0); }
.drawer-side__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.drawer-side__head h3 { font-size: var(--fs-xl); }
.drawer-side__head-sub { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.drawer-side__close {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-surface-sunk);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.drawer-side__close:hover { color: var(--color-text-strong); }
.drawer-side__body { flex: 1; overflow-y: auto; padding: var(--space-6); }
.drawer-side__foot {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: var(--space-3);
}

/* Drawer ampliado para vista de acciones del cliente */
.drawer-side--wide { width: 680px; }
/* En mobile fuerza ancho completo (anula también el width: 520px del .drawer-side base) */
@media (max-width: 720px) {
  .drawer-side,
  .drawer-side--wide {
    width: 100vw;
    max-width: 100vw;
  }
}

/* Encabezado de cliente dentro del drawer */
.drawer-client-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface-sunk);
  margin-bottom: var(--space-5);
}
.drawer-client-head__main { flex: 1; min-width: 0; }
.drawer-client-head__name { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--color-text-strong); margin: 0; }
.drawer-client-head__meta { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }
.drawer-client-head__saldo {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--color-accent-ink);
  font-family: var(--font-mono);
  text-align: right;
  flex-shrink: 0;
}
/* Mobile: el header de cliente apila vertical para que no se cramps el contenido */
@media (max-width: 520px) {
  .drawer-client-head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .drawer-client-head__saldo {
    text-align: left;
    font-size: var(--fs-lg);
    align-self: stretch;
  }
}

/* Secciones de acciones */
.action-section { margin-bottom: var(--space-6); }
.action-section__title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 var(--space-3);
  padding: 0 var(--space-1);
}
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
@media (max-width: 520px) { .action-grid { grid-template-columns: repeat(2, 1fr); } }

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text-strong);
  text-align: center;
  cursor: pointer;
  /* funciona como <a> y como <button> */
  font: inherit;
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.action-card:hover {
  text-decoration: none;
  border-color: var(--color-accent);
  background: var(--color-surface-sunk);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.action-card__icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(217, 168, 50, 0.14);
  color: var(--color-accent);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.action-card:hover .action-card__icon {
  background: var(--color-accent);
  color: #fff;
}
.action-card--success .action-card__icon { background: rgba(29, 176, 135, 0.14);  color: var(--color-success); }
.action-card--success:hover .action-card__icon { background: var(--color-success); color: #fff; }
.action-card--info    .action-card__icon { background: rgba(61, 125, 204, 0.14);  color: var(--color-info); }
.action-card--info:hover .action-card__icon    { background: var(--color-info);    color: #fff; }
.action-card--warning .action-card__icon { background: rgba(230, 162, 60, 0.14);  color: var(--color-warning); }
.action-card--warning:hover .action-card__icon { background: var(--color-warning); color: #fff; }
.action-card--danger  .action-card__icon { background: rgba(192, 38, 63, 0.14);   color: var(--color-danger); }
.action-card--danger:hover .action-card__icon  { background: var(--color-danger);  color: #fff; }
.action-card__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  line-height: 1.3;
}

/* Stack de balance cards (Cuentas y saldos) */
.balance-stack { display: flex; flex-direction: column; gap: var(--space-3); }

.balance-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.balance-card__head {
  text-align: center;
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--color-text-strong);
  background: var(--color-surface-sunk);
  border-bottom: 1px solid var(--color-border);
}
.balance-card__split {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: stretch;
}
.balance-card__col {
  padding: var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}
.balance-card__divider {
  background: var(--color-border);
  width: 1px;
  align-self: stretch;
  margin: var(--space-3) 0;
}
.balance-card__label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--fw-semi);
}
.balance-card__value {
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  color: var(--color-text-strong);
  line-height: 1.2;
  word-break: break-word;
}
.balance-card__currency {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
  margin-left: 4px;
}

/* Footer destructivo del drawer */
.drawer-danger-zone {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.btn--danger-solid {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger-solid:hover { background: #9a1e33; color: #fff; }

/* Pares clave/valor para drawer */
.kv-list { display: flex; flex-direction: column; gap: var(--space-3); }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-label { font-size: var(--fs-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; }
.kv-value { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--color-text-strong); text-align: right; word-break: break-word; }

/* ===== Filter chips (toolbar) ===== */
.chip-group {
  display: inline-flex;
  background: var(--color-surface-sunk);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
}
/* En mobile permite que los chips envuelvan en varias líneas para no cortarse */
@media (max-width: 640px) {
  .chip-group {
    flex-wrap: wrap;
    overflow-x: visible;
    border-radius: var(--radius-lg);
  }
}
.chip {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  color: var(--color-text-muted);
  cursor: pointer;
  background: transparent;
  border: 0;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--color-text-strong); }
.chip.is-active {
  background: var(--color-sidebar-bg);
  color: #fff;
}

/* Botón acción de tabla (compacto) */
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  background: var(--color-sidebar-bg);
  color: #fff;
  border: 0;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.row-action:hover { background: var(--color-sidebar-bg-deep); }
.row-action--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.row-action--ghost:hover { color: var(--color-accent-ink); background: rgba(40, 60, 55, 0.06); }

/* ===== Activity list ===== */
.activity { display: flex; flex-direction: column; }
.activity__item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.activity__item:last-child { border-bottom: 0; }
.activity__icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: rgba(217, 168, 50, 0.14);
  display: grid; place-items: center;
  color: var(--color-accent);
  flex-shrink: 0;
}
.activity__body { flex: 1; min-width: 0; }
.activity__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--color-text-strong); }
.activity__meta  { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: 2px; }

/* ===== Celda editable inline (Ejecutivo / Estatus en tabla) ===== */
.cell-edit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px 8px 2px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
}
.cell-edit:hover { background: rgba(217, 168, 50, 0.12); }
.cell-edit__pencil {
  opacity: 0;
  font-size: 11px;
  color: var(--color-accent);
  transition: opacity var(--dur-fast) var(--ease-out);
  user-select: none;
}
.cell-edit:hover .cell-edit__pencil { opacity: 1; }

/* ===== Celda telefónica (número + botones WhatsApp/Marcar) ===== */
.cell-phone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.cell-phone__num {
  color: var(--color-text);
  white-space: nowrap;
  font-size: var(--fs-sm);
}
.cell-phone__actions {
  display: flex;
  gap: 6px;
}
.cell-phone__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.cell-phone__btn--wa  { background: rgba(37, 211, 102, 0.14); color: #128c7e; }
.cell-phone__btn--wa:hover  { background: #25d366; color: #fff; transform: translateY(-1px); }
.cell-phone__btn--tel { background: rgba(61, 125, 204, 0.14); color: #1e5fbf; }
.cell-phone__btn--tel:hover { background: #1e5fbf; color: #fff; transform: translateY(-1px); }

/* ===== Acciones de formulario (botones al final de un form standalone) ===== */
.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}
@media (max-width: 640px) {
  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .form-actions > .btn,
  .form-actions > a.btn {
    width: 100%;
    white-space: normal;
    text-align: center;
    justify-content: center;
  }
}

/* ===== Link/botón en celda de tabla (estilo pill mostaza) ===== */
.cell-link {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(217, 168, 50, 0.12);
  color: var(--color-accent-ink);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: var(--fw-semi);
  font-size: var(--fs-xs);
  border: 0;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.cell-link:hover {
  background: rgba(217, 168, 50, 0.24);
  transform: translateY(-1px);
}
