/* ============================================================
   Pacmotion — Design tokens & global styles
   ============================================================ */

:root {
  --color-primary:       #337AB7;  /* Azul clásico corporativo de Ace Admin */
  --color-primary-dark:  #286090;  /* Tono más oscuro para estados hover o active */
  --color-secondary:     #7C8EB5;  /* Gris azulado secundario */
  --color-bg:            #E4E6E9;  /* Fondo general gris muy suave típico de dashboards */
  --color-surface:       #FFFFFF;  /* Superficies de tarjetas y contenedores (Blanco) */
  --color-sidebar:       #242A30;  /* Sidebar oscuro elegante (o puedes usar #3A4248) */
  --color-sidebar-text:  #ABBAC3;  /* Texto claro para la barra lateral oscura */
  --color-sidebar-active:#438EB9;  /* Azul brillante característico para elementos activos en el menú */
  --color-text:          #393939;  /* Texto principal oscuro pero no negro absoluto */
  --color-text-muted:    #666666;  /* Texto secundario o descriptivo */
  --color-border:        #DCE2E6;  /* Bordes sutiles y limpios */
  --color-success:       #87B87F;  /* Verde distintivo estilo Ace */
  --color-warning:       #FFB752;  /* Naranja / Amarillo de alerta clásico */
  --color-error:         #D15B47;  /* Rojo terracota / error clásico del template */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius:        8px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }

/* ============================================================
   Layout shell
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-height);
}
.sidebar-brand img { width: 32px; height: 32px; object-fit: contain; }
.sidebar-brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-sidebar-active);
  letter-spacing: .02em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Section headers (root items with no route) */
.sidebar-section-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--space-4) var(--space-2) var(--space-1);
}

/* Child nav items */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-item i { font-size: 1rem; flex-shrink: 0; }
.sidebar-item:hover,
.sidebar-item.active {
  background: rgba(255,255,255,.10);
  color: var(--color-sidebar-active);
}
.sidebar-item.active { font-weight: 600; }

/* Dashboard (root item WITH a route — no group label) */
.sidebar-item-root {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: var(--space-1);
}
.sidebar-item-root i { font-size: 1rem; flex-shrink: 0; }
.sidebar-item-root:hover,
.sidebar-item-root.active {
  background: rgba(255,255,255,.10);
  color: var(--color-sidebar-active);
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name  { font-size: .8rem; font-weight: 600; color: var(--color-sidebar-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: .7rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-empty-note { padding: 12px 8px; font-size: .8rem; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  z-index: 90;
}
.topbar-menu-toggle {
  display: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  padding: var(--space-2);
}
.topbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: .8rem;
}
.topbar-breadcrumb a { color: var(--color-text-muted); }
.topbar-breadcrumb a:hover { color: var(--color-primary); }
.topbar-breadcrumb .sep { color: var(--color-border); }
.topbar-breadcrumb .current { color: var(--color-text); font-weight: 500; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topbar-actions form { margin: 0; }
.topbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  font-size: 1rem;
  transition: background .15s, color .15s;
}
.topbar-icon-btn:hover { background: var(--color-bg); color: var(--color-text); }

/* ============================================================
   Main content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.page-body {
  flex: 1;
  padding: var(--space-6);
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card-title { font-weight: 600; font-size: .9rem; }
.card-body  { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .875rem;
  padding: 8px 16px;
  line-height: 1;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-bg); color: var(--color-primary); }
.btn-success   { background: var(--color-success); color: #fff; padding: 6px 12px; }
.btn-success:hover { filter: brightness(.92); }
.btn-warning   { background: var(--color-warning); color: #fff; }
.btn-warning:hover { filter: brightness(.92); }
.btn-danger    { background: var(--color-error); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-ghost     { background: transparent; color: var(--color-text-muted); padding: 6px 12px; }
.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--color-text); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   Forms
   ============================================================ */
.form-label {
  display: block;
  font-weight: 500;
  font-size: .875rem;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: .875rem;
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(42,109,255,.15);
}
.form-control::placeholder { color: var(--color-text-muted); }
.form-group { margin-bottom: var(--space-4); }
.form-text  { font-size: .75rem; color: var(--color-text-muted); margin-top: var(--space-1); }
.form-error { font-size: .75rem; color: var(--color-error);     margin-top: var(--space-1); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   Tables
   ============================================================ */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .875rem;
  margin: 0;
}
.table thead tr {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.table th {
  padding: var(--space-3) var(--space-3);
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}
.table td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-bg); }
.table .text-right, .table .text-end { text-align: right; }
.table .text-center { text-align: center; }

/* ============================================================
   Badges / Status
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-error   { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-gray    { background: #F1F5F9; color: #475569; }

/* ============================================================
   Messages / Alerts
   ============================================================ */
.messages { padding: 0 var(--space-6); margin-top: var(--space-4); }
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: var(--space-3);
  border: 1px solid transparent;
}
.alert-success { background: #D1FAE5; border-color: #6EE7B7; color: #065F46; }
.alert-warning { background: #FEF3C7; border-color: #FCD34D; color: #92400E; }
.alert-error, .alert-danger { background: #FEE2E2; border-color: #FCA5A5; color: #991B1B; }
.alert-info    { background: #DBEAFE; border-color: #93C5FD; color: #1E40AF; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: center;
  padding: var(--space-4) 0;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 var(--space-2);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  transition: all .15s;
}
.page-link:hover  { background: var(--color-bg); color: var(--color-primary); }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   Footer
   ============================================================ */
.page-footer {
  margin-top: var(--space-8);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: .75rem;
  color: var(--color-text-muted);
}

/* ============================================================
   Overlay for mobile
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }
  .topbar { left: 0; }
  .topbar-menu-toggle { display: flex; }

  .page-body { padding: var(--space-4); }
}

@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Utilities
   ============================================================ */
.d-flex     { display: flex; }
.d-grid     { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-sm  { font-size: .8rem; }
.text-xs  { font-size: .75rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1   { margin-top: var(--space-1); }
.mt-2   { margin-top: var(--space-2); }
.mt-3   { margin-top: var(--space-3); }
.mt-4   { margin-top: var(--space-4); }
.mb-0   { margin-bottom: 0; }
.mb-1   { margin-bottom: var(--space-1); }
.mb-4   { margin-bottom: var(--space-4); }
.mb-6   { margin-bottom: var(--space-6); }
.mb-8   { margin-bottom: var(--space-8); }
.mt-5   { margin-top: var(--space-5); }
.mb-5   { margin-bottom: var(--space-5); }
.p-0    { padding: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-inline { display: inline; }
.link-primary { color: var(--color-primary); }
.ml-1  { margin-left: var(--space-1); }
.col-span-full { grid-column: 1 / -1; }
.mw-480 { max-width: 480px; }
.mw-560 { max-width: 560px; }
.mw-640 { max-width: 640px; }
.mnw-280 { min-width: 280px; }
details summary { cursor: pointer; }
pre { white-space: pre-wrap; }

/* ============================================================
   SelectWithCreate — sentinel option styling
   ============================================================ */
option.qc-sentinel-opt {
  color: var(--color-primary);
  font-style: italic;
  border-top: 1px solid var(--color-border);
}

/* ============================================================
   Quick-create modal
   ============================================================ */
.qc-modal-overlay {
  display: none;           /* hidden by default */
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.qc-modal-overlay.qc-open {
  display: flex;           /* only shown when JS adds this class */
}
.qc-modal {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
.qc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.qc-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.qc-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.qc-modal-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.qc-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.qc-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.qc-field {
  margin-bottom: 14px;
}
.qc-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 4px;
}
.qc-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: var(--color-error);
  font-size: 0.8125rem;
}
.qc-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}
@keyframes qc-spin { to { transform: rotate(360deg); } }
.qc-spin { display: inline-block; animation: qc-spin 0.8s linear infinite; }

/* ============================================================
   Card body variants
   ============================================================ */
.card-body-sm      { padding: 16px; }
.card-body-compact { padding: 12px 20px; }
.card-body-flush   { padding: 0; }

/* ============================================================
   Detail page layout
   ============================================================ */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}

/* Uppercase small label used in detail views */
.detail-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 2px;
}

/* Horizontal divider within a card */
.section-divider {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-bottom: 12px;
}
.section-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ============================================================
   Totals rows (detail + form summary)
   ============================================================ */
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .875rem;
}
.totals-row-grand {
  border-top: 2px solid var(--color-border);
  margin-top: 4px;
  padding-top: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* NCF info block (invoice detail) */
.ncf-label-sm  { font-size: .75rem; color: var(--color-text-muted); margin-bottom: 2px; }
.ncf-monospace { font-size: 1rem; font-weight: 700; font-family: monospace; letter-spacing: .05em; margin-bottom: 12px; }

/* Badge variant sized for page titles */
.badge-title { font-size: .75rem; vertical-align: middle; margin-left: 6px; }
/* Extra-small badge (direction labels etc.) */
.badge-xs { font-size: .65rem; }

/* ============================================================
   Dashboard stat cards
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card-body {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon-blue  { background: #DBEAFE; color: var(--color-primary); }
.stat-icon-green { background: #D1FAE5; color: var(--color-success); }
.stat-icon-amber { background: #FEF3C7; color: var(--color-warning); }
.stat-icon-gray  { background: #F1F5F9; color: var(--color-secondary); }
.stat-value { font-size: 1.5rem; font-weight: 700; }

/* ============================================================
   Form enhancements
   ============================================================ */
.form-hint {
  font-size: .75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  display: block;
}
.required { color: var(--color-error); }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}
/* Inside a .form-row, form-groups need no bottom margin */
.form-row .form-group { margin-bottom: 0; }

.form-control-readonly {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: default;
}

/* Checkbox-inline row (inventory settings) */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-row .form-label { margin: 0; cursor: pointer; }

/* ============================================================
   Empty table state
   ============================================================ */
.table-empty { text-align: center; padding: 40px; color: var(--color-text-muted); }
.table-empty i { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ============================================================
   Invoice form line items
   ============================================================ */
.line-row td { padding: 6px 4px; vertical-align: middle; }
.line-row .form-control { padding: 5px 8px; }
.line-itbis,
.line-total { text-align: right; font-weight: 600; min-width: 100px; padding-right: 8px; }
#lines-table { margin: 0; }
#lines-table tfoot td { background: var(--color-bg); font-weight: 600; padding: 8px; }
#lines-table .col-product  { width: 200px; }
#lines-table .col-qty      { width: 80px; }
#lines-table .col-price    { width: 100px; }
#lines-table .col-currency { width: 90px; }
#lines-table .col-rate     { width: 90px; }
#lines-table .col-itbis    { width: 100px; }
#lines-table .col-bs       { width: 70px; }
#lines-table .col-discount { width: 90px; }
#lines-table .col-itbis-amt{ width: 100px; }
#lines-table .col-total    { width: 110px; }
#lines-table .col-del      { width: 40px; }
.totals-box { min-width: 280px; }

/* Section sub-header within a card */
.card-section-head {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-bottom: 12px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}

/* ============================================================
   Form-row column templates (named grids)
   ============================================================ */
/* 4-col: wide first + three equal  (invoice header rows, transaction row-1) */
.form-row-h4 { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
/* 5-col equal (transaction row-2) */
.form-row-5  { grid-template-columns: repeat(5, 1fr); gap: 12px; }
/* 4-col equal */
.form-row-4  { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
/* 3-col with wide middle (product id row-1) */
.form-row-m3 { grid-template-columns: 1fr 2fr 1fr; gap: 12px; margin-bottom: 16px; }
/* 3-col wide first + 2 equal (product pricing row-2) */
.form-row-w3 { grid-template-columns: 1fr 1fr 2fr; gap: 12px; }
/* 2-col wide first (ecf section) */
.form-row-w1 { grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 16px; }
/* 2-col wide second (buyer section) */
.form-row-w2 { grid-template-columns: 1fr 2fr; gap: 12px; }
/* 5-col wide first (product detail) */
.form-row-p5 { grid-template-columns: 1fr 2fr 1fr 1fr 1fr; gap: 16px; }
/* 5-col equal (transaction detail) */
.form-row-d5 { grid-template-columns: 2fr repeat(4, 1fr); gap: 16px; }
/* Company identity grid: narrow + wide */
.form-row-co { grid-template-columns: 1fr 2fr; gap: 16px; }
/* Logo picker: auto + 1fr */
.form-row-logo { grid-template-columns: auto 1fr; gap: 24px; align-items: center; }

/* ============================================================
   Company settings — logo
   ============================================================ */
.logo-preview {
  max-height: 80px;
  max-width: 200px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px;
  background: #fff;
}
.logo-placeholder {
  width: 120px;
  height: 60px;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: .75rem;
}

/* ============================================================
   Login page
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-card { width: 100%; max-width: 400px; padding: 40px; }
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}
.login-brand img { width: 40px; }
.login-brand-name { font-size: 1.25rem; font-weight: 700; color: var(--color-text); }
.login-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* ============================================================
   Service orders — timer buttons (P9-FE-003/004; P16-FE-001)
   Darker shades than .btn-success / .btn-danger so white text meets
   WCAG 2.1 AA (#047857 5.5:1, #B91C1C 6.5:1).
   ============================================================ */
.btn-timer-start { background: #047857; color: #fff; }
.btn-timer-start:hover { background: #065F46; color: #fff; }
.btn-timer-stop  { background: #B91C1C; color: #fff; }
.btn-timer-stop:hover  { background: #991B1B; color: #fff; }
.timer-elapsed { font-variant-numeric: tabular-nums; margin-left: 6px; }
.text-nowrap { white-space: nowrap; }
.service-title { font-size: 1.05rem; margin-bottom: 2px; }

/* Service order page on the operations engine (P16-FE-001, D-044).
   Reuses the .opr-* tabs, KPI cards, entry forms and timer buttons. */
.svc-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.svc-running-list { list-style: none; margin: 4px 0 0; padding: 0; }
.svc-running-list li { font-size: .8125rem; white-space: nowrap; }
.svc-running-list .timer-elapsed { margin-left: 2px; font-weight: 600; }
.svc-timer-cell form { display: inline-block; }
.svc-timer-cell .btn { min-width: 96px; justify-content: center; }
.svc-my-timer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.svc-my-timer .timer-elapsed { font-weight: 700; color: #047857; }
.svc-manual-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 767px) {
  /* Task table → stacked cards; Start / Stop become full-width touch targets. */
  .svc-task-table thead { display: none; }
  .svc-task-table, .svc-task-table tbody, .svc-task-table tr, .svc-task-table td { display: block; width: 100%; }
  .svc-task-table tr { border-bottom: 1px solid var(--color-border); padding: 10px 12px; }
  .svc-task-table td { border: 0; padding: 4px 0; text-align: left !important; }
  .svc-task-table td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 96px;
    font-size: .75rem;
    color: var(--color-text-muted);
  }
  .svc-task-table td.svc-task-name { font-size: 1rem; font-weight: 600; }
  .svc-task-table td.table-empty { text-align: center !important; }
  .svc-timer-cell form, .svc-timer-cell .btn,
  .svc-complete-cell form, .svc-complete-cell .btn { display: flex; width: 100%; }
  .svc-timer-cell .btn, .svc-complete-cell .btn { min-height: 48px; font-size: 1rem; justify-content: center; }
  .svc-my-timer { justify-content: flex-start; }
}

/* ============================================================
   Operations — tasks, timers, materials, costs (P12-FE-001)
   Colours reuse the badge palette (all pairs >= 4.5:1).
   ============================================================ */
/* Task status badge: <span class="badge opr-st opr-st-{{ status|lower|slugify }}"> */
.opr-st                { background: #F1F5F9; color: #475569; }
.opr-st-no-iniciada    { background: #F1F5F9; color: #334155; }
.opr-st-en-progreso    { background: #DBEAFE; color: #1E40AF; }
.opr-st-completada     { background: #D1FAE5; color: #065F46; }
.opr-st-detenida       { background: #FEF3C7; color: #92400E; }
.opr-st-cancelada      { background: #FEE2E2; color: #991B1B; }

/* Filter bar (task list) */
.opr-filters {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 12px;
  align-items: end;
}
.opr-filters .form-group { margin-bottom: 0; }
.opr-filters .form-label { font-size: .75rem; margin-bottom: 4px; color: var(--color-text-muted); }
.opr-filters-row2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}
.opr-filters-row2 .opr-filter-actions { margin-left: auto; display: flex; gap: 8px; }
.opr-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opr-check input { width: 16px; height: 16px; }

/* Due-date highlighting */
.opr-overdue  { color: #B91C1C; font-weight: 600; }
.opr-due-soon { color: #92400E; font-weight: 600; }
.opr-row-done td { color: var(--color-text-muted); }

/* Visible keyboard focus on operations controls */
.opr-tab:focus-visible,
.opr-check input:focus-visible,
.btn-timer-start:focus-visible,
.btn-timer-stop:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

/* KPI cards (task detail) */
.opr-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.opr-kpi { padding: 12px 16px; }
.opr-kpi-label { font-size: .75rem; color: var(--color-text-muted); margin-bottom: 2px; }
.opr-kpi-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.opr-kpi-sub   { font-size: .75rem; color: var(--color-text-muted); }
.opr-kpi-total { border-color: var(--color-primary); }
.opr-progress {
  height: 6px;
  border-radius: 9999px;
  background: #E2E8F0;
  margin-top: 6px;
  overflow: hidden;
}
.opr-progress-bar { height: 100%; background: var(--color-primary); border-radius: 9999px; }
.opr-progress-over .opr-progress-bar { background: #B91C1C; }

/* Timer panel (task detail) */
.opr-timer-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.opr-timer-panel.is-running { border-color: #047857; background: #F0FDF4; }
.opr-timer-clock {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-left: 0;
}
.opr-btn-lg { padding: 14px 24px; font-size: 1rem; min-height: 48px; justify-content: center; }
.opr-status-form { display: flex; gap: 8px; align-items: center; }
.opr-status-form .form-control { min-width: 160px; }

/* Tabs (progressively enhanced: sections stay visible without JS) */
.opr-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.opr-tab {
  padding: 10px 16px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.opr-tab:hover { color: var(--color-text); }
.opr-tab[aria-selected="true"] { color: var(--color-primary-dark); border-bottom-color: var(--color-primary); }
.opr-tabs[hidden] { display: none; }
.opr-tabpanel[hidden] { display: none; }

/* Inline entry forms under the tables */
.opr-entry-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}
.opr-entry-form .form-group { margin-bottom: 0; }
.opr-entry-form .opr-form-wide { grid-column: span 2; }
.opr-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Running timer cards ("Mis cronómetros") */
.opr-timer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}
.opr-timer-card {
  border: 1px solid #047857;
  background: #F0FDF4;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.opr-timer-card .opr-timer-clock { font-size: 1.75rem; }
.opr-timer-card form .btn { width: 100%; justify-content: center; }
.opr-empty { padding: 32px 16px; text-align: center; color: var(--color-text-muted); }
.opr-empty i { font-size: 1.75rem; display: block; margin-bottom: 6px; }

@media (max-width: 1100px) {
  .opr-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .opr-filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .opr-page .page-actions { flex-wrap: wrap; width: 100%; }
  .opr-filters { grid-template-columns: 1fr; }
  .opr-filters-row2 .opr-filter-actions { margin-left: 0; width: 100%; }
  .opr-filters-row2 .opr-filter-actions .btn { flex: 1; justify-content: center; }
  .opr-kpis { grid-template-columns: 1fr 1fr; }
  .opr-kpis .opr-kpi-total { grid-column: 1 / -1; }
  .opr-timer-panel { flex-direction: column; align-items: stretch; text-align: center; }
  .opr-timer-panel form, .opr-timer-panel .btn { width: 100%; }
  .opr-status-form { flex-wrap: wrap; }
  .opr-status-form .form-control, .opr-status-form .btn { width: 100%; justify-content: center; }
  .opr-entry-form { grid-template-columns: 1fr; }
  .opr-entry-form .opr-form-wide { grid-column: auto; }
  .opr-form-actions .btn { flex: 1; justify-content: center; }
  .opr-timer-grid { grid-template-columns: 1fr; padding: 12px; }
  .opr-hide-sm { display: none; }
  .opr-page .form-row-w1 { grid-template-columns: 1fr; }
}

/* ============================================================
   Sales order flow — quotation order screen, CPO summary (P12-FE-003)
   Author    : David Rodríguez
   Company   : Pacmotion Engineering
   Date      : 2026-10-10
   Revision  : 1.0
   ============================================================ */
/* Extra document status badges (components/doc_status_badge.html) */
.badge-closed { background: #E2E8F0; color: #1E293B; }
.badge-legacy { background: #EDE9FE; color: #5B21B6; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.d-block { display: block; }
.qo-table [hidden], .qo-invoice-card [hidden], #cpo-summary-form [hidden] { display: none !important; }

/* Action bars that may hold several buttons: wrap instead of overflowing */
.doc-actions { flex-wrap: wrap; justify-content: flex-end; }

/* Tables of the sales order pages: scroll horizontally on small screens */
.sof-table { min-width: 560px; }
.sof-table .sof-desc { min-width: 180px; }
.sof-table tbody th { font-weight: 500; color: var(--color-text); text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--color-border); }
.sof-open { color: #92400E; }
.sof-done { color: #065F46; white-space: nowrap; }

/* Informational / warning notes inside cards */
.sof-note { margin: var(--space-3) var(--space-4); }
.sof-note-warn { color: #92400E; }
.sof-subsection { border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.sof-subsection-title { padding: 0 var(--space-4) var(--space-2); }
.sof-compare { min-width: 420px; }

/* Quotation order screen */
.qo-table { min-width: 760px; }
.qo-col-check { width: 44px; text-align: center; }
.qo-col-check input[type="checkbox"],
.order-line-include { width: 18px; height: 18px; cursor: pointer; accent-color: var(--color-primary); }
.qo-col-qty { width: 140px; }
.qo-col-qty .form-control { min-width: 110px; }
.qo-desc-label { cursor: pointer; display: block; }
.qo-row-off td:not(.qo-col-check) { color: var(--color-text-muted); }
.qo-row-off .order-line-qty { background: var(--color-bg); }
.qo-row-error { background: #FEF2F2; }
.qo-line-total { white-space: nowrap; }
.form-control.is-invalid,
.form-control.qo-over { border-color: #B91C1C; box-shadow: 0 0 0 3px rgba(185,28,28,.12); }
.qo-invoice-card-active { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(42,109,255,.15); }
.qo-table input:focus-visible,
.sof-switch-input:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; }

/* "Resumir orden" switch (native checkbox with role="switch") */
.sof-switch { display: flex; align-items: center; gap: var(--space-3); }
.sof-switch-input {
  appearance: none; -webkit-appearance: none;
  position: relative; flex-shrink: 0;
  width: 42px; height: 24px; margin: 0;
  border-radius: 9999px;
  background: #64748B;
  cursor: pointer;
  transition: background .15s;
}
.sof-switch-input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.sof-switch-input:checked { background: var(--color-primary); }
.sof-switch-input:checked::after { transform: translateX(18px); }
.sof-switch-label { font-weight: 600; cursor: pointer; }

@media (max-width: 640px) {
  .doc-actions { justify-content: flex-start; width: 100%; }
  .doc-actions .btn, .doc-actions form { flex: 1 1 auto; }
  .doc-actions form .btn { width: 100%; justify-content: center; }
  .sof-confirm-actions { flex-direction: column-reverse; }
  .sof-confirm-actions .btn { width: 100%; justify-content: center; }
}
@media print {
  .sof-table, .qo-table { min-width: 0; }
}

/* ============================================================
   Error pages — 403 (P13-FE-001)
   ============================================================ */
.error-standalone { width: 100%; padding: 0 16px; }
.error-card { max-width: 560px; margin: 48px auto; }
.error-card .card-body { padding: 40px 32px; }
.error-code {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
@media (max-width: 767px) {
  .error-card { margin: 24px auto; }
  .error-card .card-body { padding: 28px 16px; }
  .error-card .btn { width: 100%; justify-content: center; }
}
