/* ===================================================================
   Design tokens — derived from the Importadora Patzi logo:
   navy #0C4779, teal #17A9C6, red #D31034 (sampled from source PNG).
   Navy + teal carry the interface; red is held back for danger/destructive
   actions only, per brand direction. Action-teal is a darkened variant of
   the brand teal (6.3:1 on white) — the bright brand teal itself fails
   AA as a text/button color (2.8:1) so it stays decorative/atmospheric.
   =================================================================== */
:root {
  --font-sans: 'Inter', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --color-canvas: #f2f6f9;
  --color-surface: #ffffff;
  --color-surface-alt: #fbfcfd;
  --color-surface-sunken: #eaf1f6;
  --color-border: #d7e1e9;
  --color-border-strong: #b9cad6;

  --color-text: #142433;
  --color-text-muted: #57707f;
  --color-text-on-brand: #ffffff;

  --color-brand: #0c4779;
  --color-brand-deep: #082e4d;
  --color-heading: #0c4779;
  --color-teal: #17a9c6;
  --color-teal-tint: #e4f5f9;
  --color-teal-tint-strong: #dcf0f5;
  --color-summary-border: #c8e6ee;
  --color-action: #0a697d;
  --color-action-text: #0a697d;
  --color-action-text-hover: #084f5e;
  --color-action-deep: #084f5e;
  --color-focus-ring: rgba(10, 105, 125, 0.15);
  --color-danger: #d31034;
  --color-danger-text: #d31034;
  --color-danger-deep: #a80c29;
  --color-danger-tint: #fcecef;
  --color-danger-tint-strong: #f8d7de;
  --color-warning-bg: #fdf1d2;
  --color-warning-text: #7a5c00;
  --color-warning-border: #f3dfa0;
  --color-info-bg: #e4f5f9;
  --color-info-text: #0a697d;
  --color-info-border: #b8dce6;
  --color-success-bg: #dcf3e4;
  --color-success-text: #146c3b;
  --color-success-border: #b8e2c6;

  --shadow-sm: 0 1px 2px rgba(12, 71, 121, 0.07), 0 1px 1px rgba(12, 71, 121, 0.04);
  --shadow-md: 0 2px 4px rgba(12, 71, 121, 0.06), 0 10px 24px rgba(12, 71, 121, 0.12);

  --radius: 10px;
  --radius-sm: 7px;
}

/* ---------- Modo noche ----------
   Se activa con html[data-theme="dark"] (ver partials/head.ejs + theme-toggle).
   Excluido a proposito en paginas con body.doc-body (cotizacion/documento del
   cliente): esos documentos deben imprimirse/entregarse siempre en claro. */
html[data-theme="dark"] body:not(.doc-body) {
  --color-canvas: #0d141c;
  --color-surface: #1b2733;
  --color-surface-alt: #202e3b;
  --color-surface-sunken: #16212c;
  --color-border: #2a3947;
  --color-border-strong: #3d4f60;

  --color-text: #e7eef4;
  --color-text-muted: #9fb2c1;

  --color-heading: #17a9c6;
  --color-teal-tint: #12313a;
  --color-teal-tint-strong: #163c47;
  --color-summary-border: #1f4a54;
  --color-action-text: #17a9c6;
  --color-action-text-hover: #5cc9df;
  --color-focus-ring: rgba(23, 169, 198, 0.25);
  --color-danger-text: #ff6b6b;
  --color-danger-tint: #3a1017;
  --color-danger-tint-strong: #4a1620;
  --color-warning-bg: #3a2f0f;
  --color-warning-text: #f0cf70;
  --color-warning-border: #5c4a1a;
  --color-info-bg: #12313a;
  --color-info-text: #5cc9df;
  --color-info-border: #1f4a54;
  --color-success-bg: #103b24;
  --color-success-text: #6fe0a8;
  --color-success-border: #1c5c3c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-canvas);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-action-text); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--color-action-text-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--color-teal);
  outline-offset: 2px;
}

/* ---------- App shell: sidebar de navegacion (todas las paginas) ---------- */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.app-sidebar {
  width: 228px; flex-shrink: 0; background: var(--color-brand); color: var(--color-text-on-brand);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.app-sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; color: var(--color-text-on-brand); font-size: 13.5px; padding: 0 10px 20px; line-height: 1.25; }
.app-sidebar .brand:hover { text-decoration: none; }
.brand-logo { height: 32px; width: auto; display: block; flex-shrink: 0; }
.app-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.app-nav a.side-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: #cfe4ee; font-size: 14px; font-weight: 500; position: relative;
}
.app-nav a.side-item svg { flex-shrink: 0; }
.app-nav a.side-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.app-nav a.side-item.active { background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 700; }

.app-sidebar-footer { border-top: 1px solid rgba(255, 255, 255, 0.15); margin-top: 14px; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.app-sidebar-footer .nav-username { color: #aac4dc; font-size: 12.5px; margin: 0; }
.app-sidebar-footer .theme-toggle-btn { margin-left: 0; }
.icon-btn.side-item {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: transparent; color: #cfe4ee; cursor: pointer; padding: 0;
  transition: background-color 0.15s ease;
}
.icon-btn.side-item:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.app-main { flex: 1; min-width: 0; }

/* El menu hamburguesa (boton, panel deslizante, fondo oscuro) solo existe
   visualmente en movil (ver @media max-width:720px mas abajo). En
   escritorio y tablet, ".mobile-nav-drawer" se vuelve "display:contents"
   para que ".app-nav" y ".app-sidebar-footer" sigan siendo hijos directos
   del flex de ".app-sidebar", exactamente como antes de agregar el drawer. */
.mobile-menu-toggle, .mobile-menu-close, .mobile-nav-backdrop { display: none; }
.mobile-nav-drawer { display: contents; }

/* Tablet: la barra completa colapsa a una franja de solo iconos, con
   tooltip al pasar el mouse (data-label), en vez de textos completos. */
@media (min-width: 721px) and (max-width: 1023px) {
  .app-sidebar { width: 68px; padding: 20px 10px; align-items: center; }
  .app-sidebar .brand span, .app-nav a.side-item span, .app-sidebar-footer .nav-username { display: none; }
  .app-sidebar .brand { padding: 0 0 20px; justify-content: center; }
  .app-nav a.side-item { justify-content: center; padding: 11px; }
  .side-item[data-label]:hover::after {
    content: attr(data-label);
    position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--color-brand-deep); color: #fff; font-size: 12.5px; font-weight: 600;
    padding: 6px 10px; border-radius: 6px; white-space: nowrap; box-shadow: var(--shadow-md);
    pointer-events: none; z-index: 30;
  }
  .app-sidebar-footer { flex-direction: column; gap: 10px; }
  .icon-btn.side-item { position: relative; }
}

/* Movil: barra superior angosta (logo + boton hamburguesa arriba a la
   derecha) y el menu completo se abre como panel deslizante desde la
   derecha, con fondo oscuro detras para cerrar tocando afuera. */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; min-height: 0; }
  .app-sidebar {
    width: 100%; flex-direction: row; flex-wrap: nowrap; align-items: center;
    justify-content: space-between; padding: 12px 16px;
  }
  .app-sidebar .brand { padding: 0; }

  .mobile-menu-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm); border: none;
    background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; flex-shrink: 0;
  }
  .mobile-menu-toggle:hover { background: rgba(255, 255, 255, 0.18); }

  .mobile-nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(4, 20, 36, 0.55);
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 999;
  }
  .mobile-nav-backdrop.open { opacity: 1; pointer-events: auto; }

  .mobile-nav-drawer {
    display: flex; flex-direction: column; position: fixed; top: 0; right: 0; bottom: 0;
    width: min(280px, 82vw); background: var(--color-brand); padding: 18px 16px;
    transform: translateX(100%); transition: transform 0.25s ease; z-index: 1000;
    overflow-y: auto; box-shadow: -8px 0 24px rgba(4, 20, 36, 0.35);
  }
  .mobile-nav-drawer.open { transform: translateX(0); }

  .mobile-menu-close {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer;
    align-self: flex-end; margin-bottom: 10px; flex-shrink: 0;
  }
  .mobile-menu-close:hover { background: rgba(255, 255, 255, 0.18); }

  .mobile-nav-drawer .app-nav { flex-direction: column; }
  .mobile-nav-drawer .app-sidebar-footer { flex-wrap: wrap; }
}

.theme-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid transparent;
  background: transparent; color: inherit; cursor: pointer; padding: 0; margin-left: 14px;
  transition: background-color 0.15s ease;
}
.theme-toggle-btn:hover { background: rgba(255, 255, 255, 0.12); }
.login-box .theme-toggle-btn { color: var(--color-text-muted); }
.login-box .theme-toggle-btn:hover { background: var(--color-surface-sunken); }
.icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 20px;
}

h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 16px; color: var(--color-text); }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 14px; color: var(--color-heading); letter-spacing: -0.01em; }
h3 { font-size: 0.8rem; margin: 0 0 8px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px;
  flex-wrap: wrap; gap: 12px;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.field-span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
}

label { display: block; font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }

input[type=text], input[type=number], input[type=date], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--color-surface); color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-action-text); box-shadow: 0 0 0 3px var(--color-focus-ring);
}
input:disabled { background: var(--color-surface-sunken); color: var(--color-text-muted); font-weight: 600; cursor: not-allowed; }
textarea { resize: vertical; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--color-action); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-action-deep); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.btn-secondary { background: var(--color-surface); color: var(--color-action-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-teal-tint); border-color: var(--color-action-text); text-decoration: none; }
.btn-secondary:active { background: var(--color-teal-tint-strong); }

.btn-danger { background: var(--color-surface); color: var(--color-danger-text); border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-tint); text-decoration: none; }
.btn-danger:active { background: var(--color-danger-tint-strong); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th, table td { padding: 9px 10px; border-bottom: 1px solid var(--color-border); text-align: left; }
table th { background: var(--color-surface-sunken); color: var(--color-text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
table tbody tr:hover { background: var(--color-teal-tint); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---------- Columna de acciones: botones apilados en vertical ---------- */
.actions-stack { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.actions-stack > a.btn, .actions-stack > form { display: block; width: 100%; margin: 0; }
.actions-stack > form > .btn { display: block; width: 100%; text-align: center; }
/* Fila superior (Ver + Editar uno al lado del otro), mismo ancho total que
   los botones apilados debajo ya que comparten el mismo contenedor padre. */
.actions-stack .actions-row { display: flex; gap: 6px; }
.actions-stack .actions-row > a.btn { flex: 1; margin: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; }
.badge-borrador { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.badge-procesando { background: var(--color-info-bg); color: var(--color-info-text); border-color: var(--color-info-border); }
.badge-finalizado { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.badge-vencimiento-por_vencer { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); margin-top: 4px; }
.badge-vencimiento-vencida { background: var(--color-danger-tint); color: var(--color-danger-text); border-color: var(--color-danger-tint-strong); margin-top: 4px; }
a.badge-vencimiento-por_vencer, a.badge-vencimiento-vencida { text-decoration: none; cursor: pointer; }
a.badge-vencimiento-por_vencer:hover, a.badge-vencimiento-vencida:hover { filter: brightness(1.08); text-decoration: none; }
span.badge-vencimiento-por_vencer, span.badge-vencimiento-vencida { cursor: default; opacity: 0.85; }
.role-badge-super_admin { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.role-badge-moderador { background: var(--color-info-bg); color: var(--color-info-text); border-color: var(--color-info-border); }
.role-badge-visualizador { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }

.card-success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success-text); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--color-brand-deep) 0%, var(--color-brand) 55%, var(--color-action-deep) 100%);
}
.login-box {
  background: var(--color-surface); padding: 38px 34px 32px; border-radius: 14px; width: 350px;
  box-shadow: 0 24px 60px rgba(4, 20, 36, 0.35), 0 2px 8px rgba(4, 20, 36, 0.2);
  position: relative;
}
.login-box .theme-toggle-btn { position: absolute; top: 14px; right: 14px; margin-left: 0; }
.login-logo { display: block; height: 64px; width: auto; margin: 4px auto 14px; }
.login-box h1 { text-align: center; color: var(--color-heading); margin-bottom: 4px; }
.login-box .sub { text-align: center; color: var(--color-text-muted); font-size: 13px; margin-bottom: 22px; }
.error-msg { background: var(--color-danger-tint); color: var(--color-danger-text); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.login-magic-email-input { width: 100%; }

/* ---------- Boton flotante de WhatsApp ---------- */
.whatsapp-fab {
  position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px; border-radius: 50%;
  background: #25d366; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(4, 20, 36, 0.35); z-index: 500; transition: transform 0.15s, background 0.15s;
}
.whatsapp-fab:hover { transform: scale(1.06); background: #1ebe57; }
.whatsapp-fab svg { width: 28px; height: 28px; }
.whatsapp-fab-disabled { background: var(--color-border-strong); color: var(--color-text-muted); cursor: not-allowed; pointer-events: none; }

/* ---------- Biblioteca de archivos ---------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.file-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px; background: var(--color-surface-alt); display: flex; flex-direction: column; gap: 8px; }
.file-thumb { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); background: var(--color-surface-sunken); display: block; }
.file-card-body { flex: 1; }
.file-card-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-heading); }
.file-card-pick { cursor: pointer; transition: border-color .15s, transform .1s; }
.file-card-pick:hover { border-color: var(--color-action); }

.modal-overlay { position: fixed; inset: 0; background: rgba(4, 20, 36, 0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: var(--color-surface); border-radius: 14px; max-width: 760px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(4, 20, 36, 0.35); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--color-border); }
.modal-header h3 { margin: 0; color: var(--color-heading); }
.modal-body { padding: 16px 20px; overflow-y: auto; }

/* ---------- Quote form / items ---------- */
.item-row { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--color-surface-alt); position: relative; }
.item-row .remove-item { position: absolute; top: 10px; right: 10px; }
.item-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); }

.summary-box { background: var(--color-teal-tint); border: 1px solid var(--color-summary-border); border-radius: var(--radius); padding: 14px 18px; }
.summary-box .row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 13.5px; }
.summary-box .row.total { font-size: 16px; font-weight: 700; color: var(--color-heading); border-top: 1px solid var(--color-summary-border); margin-top: 6px; padding-top: 10px; }
.summary-box .sum-value { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.3; }
.summary-box .sum-value-secondary { font-size: 11.5px; font-weight: 500; color: var(--color-text-muted); }
.summary-box .row.total .sum-value-secondary { font-size: 12.5px; font-weight: 600; }

.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }

.search-box { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-box input { flex: 1; min-width: 200px; }
.search-box .per-page-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.search-box .per-page-field select { width: auto; padding: 8px 10px; }

/* ---------- Tablas anchas: scroll horizontal duplicado arriba ---------- */
.table-scroll-top { overflow-x: auto; overflow-y: hidden; height: 14px; }
.table-scroll-top > div { height: 1px; }
.table-scroll-wrap { overflow-x: auto; }

/* ---------- Paginacion ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--color-text-muted); }
.pagination .btn:disabled { visibility: hidden; }

/* ---------- Buscador de clientes (autocompletar) ---------- */
.client-search { position: relative; margin-bottom: 20px; }
.client-search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; z-index: 20;
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-height: 260px; overflow-y: auto;
}
.client-search-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: none; cursor: pointer; font-family: inherit;
  border-bottom: 1px solid var(--color-border);
}
.client-search-item:last-child { border-bottom: none; }
.client-search-item:hover, .client-search-item:focus-visible { background: var(--color-teal-tint); outline: none; }
.client-search-item-nombre { font-size: 14px; font-weight: 600; color: var(--color-text); }
.client-search-item-detalle { font-size: 12px; color: var(--color-text-muted); }
.client-search-empty { padding: 10px 12px; font-size: 12.5px; color: var(--color-text-muted); }

/* ---------- Interruptor de moneda (Bs / USD) ---------- */
.currency-toggle {
  display: inline-flex; align-items: center; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); overflow: hidden;
}
.currency-toggle-btn, a.currency-toggle-btn {
  padding: 9px 14px; font-size: 13px; font-weight: 600; font-family: inherit; color: var(--color-text-muted);
  background: var(--color-surface); border: none; cursor: pointer; text-decoration: none; line-height: 1;
}
.currency-toggle-btn:not(:last-child) { border-right: 1px solid var(--color-border-strong); }
.currency-toggle-btn:hover { background: var(--color-teal-tint); text-decoration: none; }
.currency-toggle-btn.active { background: var(--color-action); color: #fff; }
.currency-toggle-btn.active:hover { background: var(--color-action-deep); }

/* ---------- Semaforo de liberacion (solo pedidos Finalizados) ---------- */
.liberacion-semaforo { display: inline-flex; gap: 7px; align-items: center; }
.liberacion-dot {
  width: 18px; height: 18px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.liberacion-dot.liberacion-rojo { background: #d31034; color: #d31034; }
.liberacion-dot.liberacion-amarillo { background: #f0b400; color: #f0b400; }
.liberacion-dot.liberacion-verde { background: #1b8a4f; color: #1b8a4f; }
.liberacion-dot:hover:not(:disabled) { transform: scale(1.15); }
.liberacion-dot.active {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--color-surface), 0 0 0 4px currentColor;
}
.liberacion-dot:disabled { opacity: 0.25; cursor: not-allowed; filter: grayscale(70%); }
.liberacion-dot:disabled:hover { transform: none; }

.helptext { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; max-width: 75ch; }
.nav-username { color: #aac4dc; font-size: 13px; margin-right: 6px; }

/* ---------- Dashboard ---------- */
.stat-grid { margin-bottom: 20px; }
.stat-tile { margin-bottom: 0; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.stat-label { font-size: 12px; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--color-text); letter-spacing: -0.01em; }
.stat-value-accent { color: var(--color-heading); }
.chart-box { position: relative; height: 320px; }
.chart-box-sm { height: 260px; }
@media (max-width: 720px) {
  .chart-box { height: 260px; }
  .chart-box-sm { height: 220px; }
}

/* ---------- Panel: tarjeta principal con total + tendencia ---------- */
.dash-hero { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; align-items: stretch; }
.dash-hero-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) {
  .dash-hero { grid-template-columns: 1fr; }
}

.chart-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.chart-card-total .value { font-size: 1.4rem; font-weight: 700; color: var(--color-heading); letter-spacing: -0.01em; text-align: right; }

.stat-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; width: fit-content; }
.stat-trend-up { background: var(--color-success-bg); color: var(--color-success-text); }
.stat-trend-down { background: var(--color-danger-tint); color: var(--color-danger-text); }
.stat-trend-flat { background: var(--color-surface-sunken); color: var(--color-text-muted); }
.stat-tile-hero { background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-action) 100%); border-color: transparent; }
.stat-tile-hero .stat-label, .stat-tile-hero .stat-value { color: #fff; }
.stat-tile-hero .stat-trend-up, .stat-tile-hero .stat-trend-down, .stat-tile-hero .stat-trend-flat { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* ---------- Panel: dona con leyenda ---------- */
.donut-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { flex: 1; color: var(--color-text); }
.donut-legend-value { font-weight: 700; color: var(--color-text); }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.donut-center .pct { font-size: 1.3rem; font-weight: 800; color: var(--color-heading); display: block; line-height: 1; }
.donut-center .lbl { font-size: 10.5px; color: var(--color-text-muted); }
@media (max-width: 720px) {
  .donut-panel { grid-template-columns: 1fr; }
}

/* ---------- Client-facing quote (web + PDF) ---------- */
.print-view {
  max-width: 900px; margin: 0 auto; background: var(--color-surface); padding: 32px 36px;
}
.print-view .header { display: flex; justify-content: space-between; border-bottom: 3px solid var(--color-brand); padding-bottom: 14px; margin-bottom: 20px; }
.print-view .header h1 { color: var(--color-brand); margin: 0; font-size: 1.4rem; }
.header-brand { display: flex; align-items: center; gap: 14px; }
.quote-logo { height: 56px; width: auto; }
.print-view .cond { font-size: 12px; color: var(--color-text-muted); white-space: pre-line; max-width: 75ch; }
.print-view .quote-footer { color: var(--color-text-muted); font-size: 13px; }
.print-toolbar { max-width: 900px; margin: 0 auto 12px; display: flex; gap: 10px; justify-content: flex-end; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-view { padding: 0; }
}
