<!DOCTYPE html>
<html lang="es" data-theme="industrial">
<head>
  <script>/*pos_theme_early*/(function(){var t=localStorage.getItem("pos_theme")||"industrial";document.documentElement.setAttribute("data-theme",t);})()</script>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Facturación CFDI — Nexus Autoparts POS</title>
  <link rel="stylesheet" href="/pos/static/css/tokens.css" />

  <style>
    /* =========================================================================
       BASE RESET & SHELL
       ========================================================================= */

    *, *::before, *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html, body {
      height: 100%;
    }

    body {
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      color: var(--color-text-primary);
      background-color: var(--color-bg-base);
      transition: background-color var(--duration-normal) var(--ease-in-out),
                  color var(--duration-normal) var(--ease-in-out);
      overflow: hidden;
    }

    [data-theme="modern"] body {
      background-color: var(--color-bg-base);
      background-image: radial-gradient(
        circle,
        var(--dot-grid-color) 1px,
        transparent 1px
      );
      background-size: var(--dot-grid-size) var(--dot-grid-size);
    }

    /* =========================================================================
       THEME SWITCHER BAR
       ========================================================================= */

    .theme-bar {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: var(--z-toast);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 var(--space-5);
      background: var(--color-bg-overlay);
      border-bottom: 1px solid var(--color-border);
      backdrop-filter: blur(10px);
      height: 36px;
    }

    [data-theme="industrial"] .theme-bar {
      background: rgba(13, 13, 13, 0.95);
      border-bottom-color: var(--color-primary-muted);
    }

    .theme-bar__left {
      display: flex;
      align-items: center;
      gap: var(--space-3);
    }

    .theme-bar__store {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-primary);
      font-size: 0.75rem;
      letter-spacing: var(--tracking-widest);
      text-transform: uppercase;
      color: var(--color-text-accent);
    }

    .theme-bar__dot {
      width: 6px;
      height: 6px;
      background: var(--color-success);
      border-radius: var(--radius-full);
      box-shadow: 0 0 6px var(--color-success);
      animation: blink 2.5s ease-in-out infinite;
    }

    @keyframes blink {
      0%, 100% { opacity: 1; }
      50%       { opacity: 0.35; }
    }

    .theme-bar__sep {
      width: 1px;
      height: 16px;
      background: var(--color-border);
    }

    .theme-bar__label {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
    }

    .theme-bar__right {
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

    .theme-btn {
      display: inline-flex;
      align-items: center;
      gap: var(--space-1);
      padding: 2px var(--space-3);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-full);
      background: transparent;
      color: var(--color-text-secondary);
      font-family: var(--font-body);
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      cursor: pointer;
      transition: var(--transition-fast);
      letter-spacing: var(--tracking-wide);
    }

    .theme-btn:hover {
      border-color: var(--color-primary);
      color: var(--color-primary);
    }

    .theme-btn.is-active {
      background: var(--color-primary);
      border-color: var(--color-primary);
      color: var(--color-text-inverse);
    }

    .theme-btn__swatch {
      width: 8px;
      height: 8px;
      border-radius: var(--radius-full);
    }

    .theme-btn--industrial .theme-btn__swatch { background: #F5A623; }
    .theme-btn--modern    .theme-btn__swatch  { background: #FF6B35; }

    /* =========================================================================
       APP LAYOUT
       ========================================================================= */

    .app-shell {
      display: flex;
      height: 100vh;
      padding-top: 36px;
    }

    /* =========================================================================
       SIDEBAR
       ========================================================================= */

    .sidebar {
      width: 260px;
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      background: var(--color-bg-elevated);
      border-right: 1px solid var(--color-border);
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }

    .sidebar::-webkit-scrollbar       { width: 4px; }
    .sidebar::-webkit-scrollbar-track { background: var(--scrollbar-track); }
    .sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }

    /* Brand */

    .sidebar__brand {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      padding: var(--space-4) var(--space-4) var(--space-3);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    .brand-logo {
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--color-primary);
      color: var(--color-text-inverse);
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-primary);
      font-size: 1.125rem;
      letter-spacing: -0.04em;
      flex-shrink: 0;
    }

    [data-theme="industrial"] .brand-logo {
      clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
    }

    [data-theme="modern"] .brand-logo {
      border-radius: var(--radius-md);
    }

    .brand-name__primary {
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-primary);
      font-size: 0.9375rem;
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
      color: var(--color-text-primary);
      line-height: 1;
    }

    .brand-name__sub {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      letter-spacing: var(--tracking-wider);
      text-transform: uppercase;
      margin-top: 2px;
    }

    /* Navigation */

    .sidebar__nav {
      flex: 1;
      padding: var(--space-3) 0;
    }

    .nav-section-label {
      padding: var(--space-3) var(--space-4) var(--space-1);
      font-size: 0.6875rem;
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-widest);
      text-transform: uppercase;
      color: var(--color-text-muted);
    }

    .nav-item {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      padding: var(--space-2) var(--space-4);
      color: var(--color-text-secondary);
      text-decoration: none;
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-regular);
      border-left: 3px solid transparent;
      transition: var(--transition-fast);
      cursor: pointer;
    }

    .nav-item:hover {
      background: var(--color-surface-2);
      color: var(--color-text-primary);
    }

    .nav-item.is-active {
      background: var(--color-primary-muted);
      color: var(--color-primary);
      border-left-color: var(--color-primary);
      font-weight: var(--font-weight-semibold);
    }

    .nav-item__icon {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      opacity: 0.7;
    }

    .nav-item.is-active .nav-item__icon {
      opacity: 1;
    }

    /* Sidebar footer */

    .sidebar__footer {
      padding: var(--space-3) var(--space-4);
      border-top: 1px solid var(--color-border);
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

    .sidebar__user-avatar {
      width: 28px;
      height: 28px;
      border-radius: var(--radius-full);
      background: var(--color-primary);
      color: var(--color-text-inverse);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: var(--text-caption);
      font-weight: var(--font-weight-bold);
      flex-shrink: 0;
    }

    .sidebar__user-info { flex: 1; overflow: hidden; }

    .sidebar__user-name {
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-semibold);
      color: var(--color-text-primary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .sidebar__user-role {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
    }

    /* =========================================================================
       MAIN CONTENT
       ========================================================================= */

    .main {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-width: 0;
    }

    /* ---- Page Header ---- */

    .page-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: var(--space-4) var(--space-6);
      background: var(--color-bg-elevated);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    [data-theme="industrial"] .page-header {
      background: var(--color-surface-1);
    }

    .page-header__title-group { display: flex; flex-direction: column; gap: 2px; }

    .page-header__eyebrow {
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-widest);
      text-transform: uppercase;
      color: var(--color-text-muted);
    }

    .page-header__title {
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-primary);
      font-size: var(--text-h4);
      letter-spacing: var(--heading-tracking-h4);
      color: var(--color-text-primary);
      line-height: 1.2;
    }

    [data-theme="industrial"] .page-header__title {
      text-transform: uppercase;
    }

    .page-header__actions {
      display: flex;
      align-items: center;
      gap: var(--space-3);
    }

    /* ---- Summary Cards ---- */

    .summary-strip {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: var(--space-4);
      padding: var(--space-4) var(--space-6);
      background: var(--color-bg-base);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    [data-theme="modern"] .summary-strip {
      background: transparent;
    }

    .summary-card {
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-lg);
      padding: var(--space-4) var(--space-5);
      display: flex;
      align-items: flex-start;
      gap: var(--space-3);
      box-shadow: var(--shadow-sm);
      transition: var(--transition-normal);
    }

    .summary-card:hover {
      box-shadow: var(--shadow-md);
      border-color: var(--color-border-strong);
    }

    [data-theme="industrial"] .summary-card {
      border-left: 3px solid var(--color-primary);
    }

    [data-theme="modern"] .summary-card {
      background: var(--color-bg-overlay);
    }

    .summary-card__icon {
      width: 38px;
      height: 38px;
      border-radius: var(--radius-md);
      background: var(--color-primary-muted);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .summary-card__icon svg {
      width: 20px;
      height: 20px;
      stroke: var(--color-primary);
      fill: none;
      stroke-width: 1.75;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .summary-card__icon--money    { background: rgba(34,197,94,.12); }
    .summary-card__icon--money svg { stroke: var(--color-success); }
    .summary-card__icon--pending   { background: rgba(234,179,8,.12); }
    .summary-card__icon--pending svg { stroke: var(--color-warning); }
    .summary-card__icon--cancelled { background: rgba(239,68,68,.12); }
    .summary-card__icon--cancelled svg { stroke: var(--color-error); }

    .summary-card__body { flex: 1; min-width: 0; }

    .summary-card__label {
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-wider);
      text-transform: uppercase;
      color: var(--color-text-muted);
      margin-bottom: var(--space-1);
    }

    .summary-card__value {
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-primary);
      font-size: 1.5rem;
      color: var(--color-text-primary);
      line-height: 1.1;
    }

    .summary-card__sub {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      margin-top: 2px;
    }

    .summary-card__delta {
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      margin-top: 2px;
    }

    .summary-card__delta--up   { color: var(--color-success); }
    .summary-card__delta--down { color: var(--color-error); }

    /* ---- Tabs Row ---- */

    .tabs-row {
      display: flex;
      align-items: stretch;
      gap: 0;
      padding: 0 var(--space-6);
      background: var(--color-bg-elevated);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .tabs-row::-webkit-scrollbar { display: none; }

    [data-theme="industrial"] .tabs-row {
      background: var(--color-surface-1);
    }

    .tab-btn {
      display: inline-flex;
      align-items: center;
      gap: var(--space-2);
      padding: var(--space-3) var(--space-4);
      border: none;
      border-bottom: 2px solid transparent;
      background: transparent;
      color: var(--color-text-muted);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-semibold);
      cursor: pointer;
      white-space: nowrap;
      transition: var(--transition-fast);
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
      position: relative;
    }

    .tab-btn:hover {
      color: var(--color-text-primary);
      background: var(--color-surface-2);
    }

    .tab-btn.is-active {
      color: var(--color-primary);
      border-bottom-color: var(--color-primary);
    }

    .tab-btn__badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 18px;
      height: 18px;
      padding: 0 var(--space-1);
      border-radius: var(--radius-full);
      background: var(--color-primary-muted);
      color: var(--color-primary);
      font-size: 0.6875rem;
      font-weight: var(--font-weight-bold);
    }

    .tab-btn.is-active .tab-btn__badge {
      background: var(--color-primary);
      color: var(--color-text-inverse);
    }

    .tab-btn__badge--warn {
      background: rgba(234,179,8,.15);
      color: var(--color-warning);
    }

    .tab-btn.is-active .tab-btn__badge--warn {
      background: var(--color-warning);
      color: #000;
    }

    /* ---- Tab Panels ---- */

    .tab-panels {
      flex: 1;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }

    .tab-panels::-webkit-scrollbar       { width: 6px; }
    .tab-panels::-webkit-scrollbar-track { background: var(--scrollbar-track); }
    .tab-panels::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }

    .tab-panel {
      display: none;
      padding: var(--space-5) var(--space-6);
    }

    .tab-panel.is-active {
      display: block;
    }

    /* =========================================================================
       TOOLBAR (search, filters, actions)
       ========================================================================= */

    .toolbar {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      margin-bottom: var(--space-4);
      flex-wrap: wrap;
    }

    .search-box {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      padding: 0 var(--space-3);
      height: 36px;
      flex: 1;
      min-width: 200px;
      max-width: 320px;
      transition: var(--transition-fast);
    }

    .search-box:focus-within {
      border-color: var(--color-border-focus);
      box-shadow: var(--shadow-accent);
    }

    .search-box svg {
      width: 15px;
      height: 15px;
      stroke: var(--color-text-muted);
      fill: none;
      stroke-width: 2;
      stroke-linecap: round;
      flex-shrink: 0;
    }

    .search-box input {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      color: var(--color-text-primary);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
    }

    .search-box input::placeholder {
      color: var(--color-text-muted);
    }

    .select-filter {
      height: 36px;
      padding: 0 var(--space-3);
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      color: var(--color-text-secondary);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      cursor: pointer;
      outline: none;
      transition: var(--transition-fast);
    }

    .select-filter:focus {
      border-color: var(--color-border-focus);
      box-shadow: var(--shadow-accent);
    }

    .date-range {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      padding: 0 var(--space-3);
      height: 36px;
      font-size: var(--text-body-sm);
      color: var(--color-text-secondary);
      cursor: pointer;
      transition: var(--transition-fast);
      white-space: nowrap;
    }

    .date-range:hover {
      border-color: var(--color-border-strong);
    }

    .date-range svg {
      width: 14px;
      height: 14px;
      stroke: var(--color-text-muted);
      fill: none;
      stroke-width: 2;
      stroke-linecap: round;
      flex-shrink: 0;
    }

    .toolbar__spacer { flex: 1; }

    /* =========================================================================
       BUTTONS
       ========================================================================= */

    .btn {
      display: inline-flex;
      align-items: center;
      gap: var(--space-2);
      padding: 0 var(--space-4);
      height: 36px;
      border-radius: var(--radius-md);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-wide);
      cursor: pointer;
      border: 1px solid transparent;
      transition: var(--transition-fast);
      text-decoration: none;
      white-space: nowrap;
    }

    .btn svg {
      width: 15px;
      height: 15px;
      stroke: currentColor;
      fill: none;
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
      flex-shrink: 0;
    }

    .btn--primary {
      background: var(--btn-primary-bg);
      color: var(--btn-primary-text);
      border-color: var(--btn-primary-border);
    }

    .btn--primary:hover {
      background: var(--btn-primary-bg-hover);
    }

    .btn--secondary {
      background: var(--btn-secondary-bg);
      color: var(--btn-secondary-text);
      border-color: var(--btn-secondary-border);
    }

    .btn--secondary:hover {
      background: var(--btn-secondary-bg-hover);
    }

    .btn--ghost {
      background: var(--btn-ghost-bg);
      color: var(--btn-ghost-text);
      border-color: var(--btn-ghost-border);
    }

    .btn--ghost:hover {
      background: var(--color-surface-2);
      border-color: var(--color-border-strong);
      color: var(--color-text-primary);
    }

    .btn--sm {
      height: 28px;
      padding: 0 var(--space-3);
      font-size: var(--text-caption);
    }

    .btn--danger {
      background: rgba(239,68,68,.1);
      color: var(--color-error);
      border-color: rgba(239,68,68,.25);
    }

    .btn--danger:hover {
      background: rgba(239,68,68,.2);
    }

    /* =========================================================================
       DATA TABLE
       ========================================================================= */

    .table-wrapper {
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      box-shadow: var(--shadow-sm);
    }

    [data-theme="modern"] .table-wrapper {
      background: var(--color-bg-overlay);
    }

    .data-table {
      width: 100%;
      border-collapse: collapse;
      font-size: var(--text-body-sm);
    }

    .data-table thead {
      background: var(--color-surface-2);
      border-bottom: 1px solid var(--color-border);
    }

    [data-theme="industrial"] .data-table thead {
      background: var(--color-surface-3);
    }

    .data-table th {
      padding: var(--space-3) var(--space-4);
      text-align: left;
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-wider);
      text-transform: uppercase;
      color: var(--color-text-muted);
      white-space: nowrap;
    }

    .data-table th:first-child { padding-left: var(--space-5); }
    .data-table th:last-child  { padding-right: var(--space-5); }

    .data-table tbody tr {
      border-bottom: 1px solid var(--color-border);
      transition: background var(--duration-fast) var(--ease-in-out);
    }

    .data-table tbody tr:last-child {
      border-bottom: none;
    }

    .data-table tbody tr:hover {
      background: var(--color-surface-2);
    }

    .data-table td {
      padding: var(--space-3) var(--space-4);
      color: var(--color-text-secondary);
      vertical-align: middle;
    }

    .data-table td:first-child { padding-left: var(--space-5); }
    .data-table td:last-child  { padding-right: var(--space-5); }

    .data-table .td--primary {
      color: var(--color-text-primary);
      font-weight: var(--font-weight-semibold);
    }

    .data-table .td--mono {
      font-family: var(--font-mono);
      font-size: 0.8125rem;
      color: var(--color-text-accent);
    }

    .data-table .td--amount {
      font-family: var(--font-mono);
      font-size: 0.8125rem;
      color: var(--color-text-primary);
      font-weight: var(--font-weight-semibold);
      text-align: right;
    }

    /* =========================================================================
       BADGES / STATUS PILLS
       ========================================================================= */

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px var(--space-2);
      border-radius: var(--radius-full);
      font-size: 0.6875rem;
      font-weight: var(--font-weight-bold);
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
      white-space: nowrap;
    }

    .badge::before {
      content: '';
      width: 5px;
      height: 5px;
      border-radius: var(--radius-full);
      background: currentColor;
      flex-shrink: 0;
    }

    /* CFDI-specific statuses */
    .badge--timbrada {
      background: rgba(34, 197, 94, 0.15);
      color: var(--color-success);
    }

    .badge--pendiente {
      background: rgba(234, 179, 8, 0.15);
      color: var(--color-warning);
    }

    .badge--cancelada {
      background: rgba(239, 68, 68, 0.15);
      color: var(--color-error);
    }

    .badge--ppd {
      background: rgba(99, 102, 241, 0.15);
      color: #818cf8;
    }

    .badge--proceso {
      background: var(--color-primary-muted);
      color: var(--color-primary);
    }

    .badge--aceptada {
      background: rgba(34, 197, 94, 0.15);
      color: var(--color-success);
    }

    .badge--rechazada {
      background: rgba(239, 68, 68, 0.15);
      color: var(--color-error);
    }

    .badge--vigente {
      background: rgba(34, 197, 94, 0.15);
      color: var(--color-success);
    }

    .badge--por-vencer {
      background: rgba(234, 179, 8, 0.15);
      color: var(--color-warning);
    }

    /* =========================================================================
       TABLE FOOTER / PAGINATION ROW
       ========================================================================= */

    .table-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: var(--space-3) var(--space-5);
      border-top: 1px solid var(--color-border);
      background: var(--color-surface-1);
      font-size: var(--text-caption);
      color: var(--color-text-muted);
    }

    .pagination {
      display: flex;
      align-items: center;
      gap: var(--space-1);
    }

    .page-btn {
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm);
      background: transparent;
      color: var(--color-text-secondary);
      font-size: var(--text-caption);
      font-family: var(--font-body);
      cursor: pointer;
      transition: var(--transition-fast);
    }

    .page-btn:hover {
      border-color: var(--color-primary);
      color: var(--color-primary);
    }

    .page-btn.is-active {
      background: var(--color-primary);
      border-color: var(--color-primary);
      color: var(--color-text-inverse);
      font-weight: var(--font-weight-bold);
    }

    /* =========================================================================
       CANCELLATION CARDS (Tab Cancelaciones)
       ========================================================================= */

    .cancel-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: var(--space-4);
    }

    .cancel-card {
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-lg);
      padding: var(--space-4) var(--space-5);
      box-shadow: var(--shadow-sm);
      transition: var(--transition-normal);
      position: relative;
      overflow: hidden;
    }

    [data-theme="modern"] .cancel-card {
      background: var(--color-bg-overlay);
    }

    .cancel-card::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 4px;
    }

    .cancel-card--proceso::before   { background: var(--color-primary); }
    .cancel-card--aceptada::before  { background: var(--color-success); }
    .cancel-card--rechazada::before { background: var(--color-error); }

    .cancel-card:hover {
      box-shadow: var(--shadow-md);
      transform: translateY(-1px);
    }

    .cancel-card__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: var(--space-3);
    }

    .cancel-card__folio {
      font-family: var(--font-mono);
      font-size: 0.875rem;
      font-weight: var(--font-weight-semibold);
      color: var(--color-text-accent);
    }

    .cancel-card__body {
      display: flex;
      flex-direction: column;
      gap: var(--space-2);
    }

    .cancel-card__row {
      display: flex;
      align-items: flex-start;
      gap: var(--space-2);
    }

    .cancel-card__row-label {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wide);
      font-weight: var(--font-weight-semibold);
      min-width: 80px;
      flex-shrink: 0;
      padding-top: 1px;
    }

    .cancel-card__row-value {
      font-size: var(--text-body-sm);
      color: var(--color-text-secondary);
      line-height: var(--leading-caption);
    }

    .cancel-card__footer {
      margin-top: var(--space-3);
      padding-top: var(--space-3);
      border-top: 1px solid var(--color-border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    /* =========================================================================
       CONFIG FORM (Tab Configuración CFDI)
       ========================================================================= */

    .config-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: var(--space-5);
    }

    .config-section {
      background: var(--color-bg-elevated);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      box-shadow: var(--shadow-sm);
    }

    [data-theme="modern"] .config-section {
      background: var(--color-bg-overlay);
    }

    [data-theme="industrial"] .config-section {
      border-left: 3px solid var(--color-primary);
    }

    .config-section__header {
      padding: var(--space-4) var(--space-5);
      border-bottom: 1px solid var(--color-border);
      background: var(--color-surface-2);
      display: flex;
      align-items: center;
      gap: var(--space-3);
    }

    [data-theme="industrial"] .config-section__header {
      background: var(--color-surface-3);
    }

    .config-section__header svg {
      width: 18px;
      height: 18px;
      stroke: var(--color-primary);
      fill: none;
      stroke-width: 1.75;
      stroke-linecap: round;
      stroke-linejoin: round;
      flex-shrink: 0;
    }

    .config-section__title {
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-secondary);
      font-size: var(--text-body-sm);
      letter-spacing: var(--tracking-wider);
      text-transform: uppercase;
      color: var(--color-text-secondary);
      flex: 1;
    }

    .config-section__body {
      padding: var(--space-5);
    }

    .form-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: var(--space-4);
    }

    .form-field {
      display: flex;
      flex-direction: column;
      gap: var(--space-1);
    }

    .form-field--span2 {
      grid-column: span 2;
    }

    .form-label {
      font-size: var(--text-caption);
      font-weight: var(--font-weight-semibold);
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
      color: var(--color-text-muted);
    }

    .form-input {
      height: 36px;
      padding: 0 var(--space-3);
      background: var(--color-bg-base);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      color: var(--color-text-primary);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      outline: none;
      transition: var(--transition-fast);
    }

    .form-input:focus {
      border-color: var(--color-border-focus);
      box-shadow: var(--shadow-accent);
    }

    .form-select {
      height: 36px;
      padding: 0 var(--space-3);
      background: var(--color-bg-base);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      color: var(--color-text-primary);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      outline: none;
      cursor: pointer;
      transition: var(--transition-fast);
    }

    .form-select:focus {
      border-color: var(--color-border-focus);
      box-shadow: var(--shadow-accent);
    }

    .form-hint {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
    }

    .cert-status {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      padding: var(--space-3) var(--space-4);
      background: var(--color-surface-2);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md);
      margin-bottom: var(--space-4);
    }

    [data-theme="industrial"] .cert-status {
      background: var(--color-surface-3);
    }

    .cert-status__icon {
      width: 36px;
      height: 36px;
      border-radius: var(--radius-md);
      background: rgba(34,197,94,.12);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .cert-status__icon svg {
      width: 20px;
      height: 20px;
      stroke: var(--color-success);
      fill: none;
      stroke-width: 1.75;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .cert-status__info { flex: 1; }

    .cert-status__name {
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-semibold);
      color: var(--color-text-primary);
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

    .cert-status__detail {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      margin-top: 2px;
    }

    /* Section headings */

    .section-heading {
      display: flex;
      align-items: center;
      gap: var(--space-3);
      margin-bottom: var(--space-4);
    }

    .section-heading__title {
      font-family: var(--font-heading);
      font-weight: var(--heading-weight-secondary);
      font-size: var(--text-h6);
      letter-spacing: var(--heading-tracking-h6);
      text-transform: uppercase;
      color: var(--color-text-secondary);
      white-space: nowrap;
    }

    .section-heading__line {
      flex: 1;
      height: 1px;
      background: var(--color-border);
    }

    /* =========================================================================
       RESPONSIVE
       ========================================================================= */

    @media (max-width: 1200px) {
      .config-grid {
        grid-template-columns: 1fr;
      }

      .config-section[style*="span 2"] {
        grid-column: span 1;
      }
    }

    @media (max-width: 1024px) {
      .summary-strip {
        grid-template-columns: repeat(2, 1fr);
      }

      .sidebar {
        width: 60px;
        overflow: visible;
      }

      .brand-name, .nav-item span, .sidebar__user-info,
      .nav-section-label { display: none; }

      .nav-item {
        justify-content: center;
        padding: var(--space-3);
        border-left: none;
        border-bottom: 2px solid transparent;
      }

      .nav-item.is-active {
        border-left: none;
        border-bottom-color: var(--color-primary);
      }
    }

    @media (max-width: 768px) {
      .summary-strip {
        grid-template-columns: repeat(2, 1fr);
        padding: var(--space-3) var(--space-4);
        gap: var(--space-3);
      }

      .page-header { padding: var(--space-3) var(--space-4); }
      .tabs-row    { padding: 0 var(--space-4); }
      .tab-panel   { padding: var(--space-4); }
      .toolbar     { gap: var(--space-2); }
      .search-box  { max-width: 100%; }

      .page-header__actions { display: none; }
      .form-grid { grid-template-columns: 1fr; }
      .form-field--span2 { grid-column: span 1; }
    }
  </style>
</head>

<body>

  <!-- =========================================================================
       THEME SWITCHER BAR
       ========================================================================= -->

  <header class="theme-bar" role="banner">
    <div class="theme-bar__left">
      <div class="theme-bar__store">
        <span class="theme-bar__dot"></span>
        Nexus Autoparts
      </div>
      <div class="theme-bar__sep"></div>
      <span class="theme-bar__label">Sucursal Centro &mdash; Usuario: H. García</span>
      <div class="theme-bar__sep"></div>
      <span class="theme-bar__label" id="live-clock">--:--:--</span>
    </div>
    <div class="theme-bar__right">
      <span class="theme-bar__label">Tema:</span>
      <button class="theme-btn theme-btn--industrial is-active" data-theme-target="industrial" onclick="setTheme('industrial')">
        <span class="theme-btn__swatch"></span>
        Industrial
      </button>
      <button class="theme-btn theme-btn--modern" data-theme-target="modern" onclick="setTheme('modern')">
        <span class="theme-btn__swatch"></span>
        Moderno
      </button>
    </div>
  </header>

  <!-- =========================================================================
       APP SHELL
       ========================================================================= -->

  <div class="app-shell">

    <!-- -----------------------------------------------------------------------
         SIDEBAR NAVIGATION
         ----------------------------------------------------------------------- -->

    <aside class="sidebar" role="navigation" aria-label="Navegación principal">

      <!-- Brand -->
      <div class="sidebar__brand">
        <div class="brand-logo">NA</div>
        <div class="brand-name">
          <span class="brand-name__primary">Nexus</span>
          <span class="brand-name__sub">Autoparts POS</span>
        </div>
      </div>

      <!-- Nav -->
      <nav class="sidebar__nav">

        <div class="nav-section-label">Principal</div>

        <a class="nav-item" href="/pos/dashboard">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <rect x="3" y="3" width="7" height="7"/>
            <rect x="14" y="3" width="7" height="7"/>
            <rect x="14" y="14" width="7" height="7"/>
            <rect x="3" y="14" width="7" height="7"/>
          </svg>
          <span>Dashboard</span>
        </a>

        <a class="nav-item" href="/pos/sale">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <rect x="2" y="3" width="20" height="14" rx="2"/>
            <path d="M8 21h8M12 17v4"/>
          </svg>
          <span>POS</span>
        </a>

        <a class="nav-item" href="/pos/catalog">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
          </svg>
          <span>Catálogo</span>
        </a>

        <a class="nav-item" href="/pos/inventory">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
            <polyline points="3.27 6.96 12 12.01 20.73 6.96"/>
            <line x1="12" y1="22.08" x2="12" y2="12"/>
          </svg>
          <span>Inventario</span>
        </a>

        <div class="nav-section-label">Gestión</div>

        <a class="nav-item" href="/pos/customers">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
            <circle cx="9" cy="7" r="4"/>
            <path d="M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/>
          </svg>
          <span>Clientes</span>
        </a>

        <a class="nav-item is-active" href="/pos/invoicing" aria-current="page">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
            <polyline points="14 2 14 8 20 8"/>
            <line x1="16" y1="13" x2="8" y2="13"/>
            <line x1="16" y1="17" x2="8" y2="17"/>
            <polyline points="10 9 9 9 8 9"/>
          </svg>
          <span>Facturación</span>
        </a>

        <a class="nav-item" href="/pos/accounting">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <line x1="12" y1="1" x2="12" y2="23"/>
            <path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
          </svg>
          <span>Contabilidad</span>
        </a>

        <a class="nav-item" href="/pos/reports">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <line x1="18" y1="20" x2="18" y2="10"/>
            <line x1="12" y1="20" x2="12" y2="4"/>
            <line x1="6"  y1="20" x2="6"  y2="14"/>
          </svg>
          <span>Reportes</span>
        </a>

        <div class="nav-section-label">Sistema</div>

        <a class="nav-item" href="/pos/config">
          <svg class="nav-item__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
            <circle cx="12" cy="12" r="3"/>
            <path d="M19.07 4.93a10 10 0 0 1 0 14.14M4.93 4.93a10 10 0 0 0 0 14.14"/>
          </svg>
          <span>Configuración</span>
        </a>

      </nav>

      <!-- Footer user -->
      <div class="sidebar__footer">
        <div class="sidebar__user-avatar">HG</div>
        <div class="sidebar__user-info">
          <div class="sidebar__user-name">Hugo García</div>
          <div class="sidebar__user-role">Administrador</div>
        </div>
      </div>

    </aside>

    <!-- -----------------------------------------------------------------------
         MAIN CONTENT
         ----------------------------------------------------------------------- -->

    <main class="main" role="main">

      <!-- Page Header -->
      <div class="page-header">
        <div class="page-header__title-group">
          <span class="page-header__eyebrow">Gestión</span>
          <h1 class="page-header__title">Facturación CFDI</h1>
        </div>
        <div class="page-header__actions">
          <button class="btn btn--ghost">
            <svg viewBox="0 0 24 24">
              <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
              <polyline points="7 10 12 15 17 10"/>
              <line x1="12" y1="15" x2="12" y2="3"/>
            </svg>
            Exportar
          </button>
          <button class="btn btn--secondary">
            <svg viewBox="0 0 24 24">
              <path d="M9 14l-4-4 4-4"/>
              <path d="M5 10h11a4 4 0 0 1 0 8h-1"/>
            </svg>
            Nota de Crédito
          </button>
          <button class="btn btn--primary">
            <svg viewBox="0 0 24 24">
              <line x1="12" y1="5" x2="12" y2="19"/>
              <line x1="5" y1="12" x2="19" y2="12"/>
            </svg>
            Nueva Factura
          </button>
        </div>
      </div>

      <!-- Summary Cards -->
      <div class="summary-strip">

        <div class="summary-card">
          <div class="summary-card__icon">
            <svg viewBox="0 0 24 24">
              <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
              <polyline points="14 2 14 8 20 8"/>
              <line x1="16" y1="13" x2="8" y2="13"/>
              <line x1="16" y1="17" x2="8" y2="17"/>
            </svg>
          </div>
          <div class="summary-card__body">
            <div class="summary-card__label">Facturas del Mes</div>
            <div class="summary-card__value">247</div>
            <div class="summary-card__delta summary-card__delta--up">+18 vs mes anterior</div>
          </div>
        </div>

        <div class="summary-card">
          <div class="summary-card__icon summary-card__icon--money">
            <svg viewBox="0 0 24 24">
              <line x1="12" y1="1" x2="12" y2="23"/>
              <path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
            </svg>
          </div>
          <div class="summary-card__body">
            <div class="summary-card__label">Monto Facturado</div>
            <div class="summary-card__value">$842,190</div>
            <div class="summary-card__sub">MXN · Mes en curso</div>
          </div>
        </div>

        <div class="summary-card">
          <div class="summary-card__icon summary-card__icon--pending">
            <svg viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="10"/>
              <polyline points="12 6 12 12 16 14"/>
            </svg>
          </div>
          <div class="summary-card__body">
            <div class="summary-card__label">Pendientes de Pago</div>
            <div class="summary-card__value">34</div>
            <div class="summary-card__delta summary-card__delta--down">$156,400.00 MXN</div>
          </div>
        </div>

        <div class="summary-card">
          <div class="summary-card__icon summary-card__icon--cancelled">
            <svg viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="10"/>
              <line x1="15" y1="9" x2="9" y2="15"/>
              <line x1="9" y1="9" x2="15" y2="15"/>
            </svg>
          </div>
          <div class="summary-card__body">
            <div class="summary-card__label">Canceladas</div>
            <div class="summary-card__value">6</div>
            <div class="summary-card__sub">Este mes</div>
          </div>
        </div>

      </div>

      <!-- Tabs Row -->
      <div class="tabs-row" role="tablist" aria-label="Módulos de Facturación">
        <button class="tab-btn is-active" role="tab" aria-selected="true"  aria-controls="panel-facturas"     id="tab-facturas"     onclick="switchTab('facturas')">
          Facturas <span class="tab-btn__badge">247</span>
        </button>
        <button class="tab-btn" role="tab" aria-selected="false" aria-controls="panel-notas"        id="tab-notas"        onclick="switchTab('notas')">
          Notas de Crédito <span class="tab-btn__badge">8</span>
        </button>
        <button class="tab-btn" role="tab" aria-selected="false" aria-controls="panel-complementos" id="tab-complementos" onclick="switchTab('complementos')">
          Complementos de Pago <span class="tab-btn__badge">12</span>
        </button>
        <button class="tab-btn" role="tab" aria-selected="false" aria-controls="panel-cancelaciones" id="tab-cancelaciones" onclick="switchTab('cancelaciones')">
          Cancelaciones <span class="tab-btn__badge tab-btn__badge--warn">6</span>
        </button>
        <button class="tab-btn" role="tab" aria-selected="false" aria-controls="panel-config"       id="tab-config"       onclick="switchTab('config')">
          Configuración CFDI
        </button>
      </div>

      <!-- Tab Panels -->
      <div class="tab-panels" id="tab-panels">

        <!-- =================================================================
             TAB 1 — FACTURAS
             ================================================================= -->
        <div class="tab-panel is-active" id="panel-facturas" role="tabpanel" aria-labelledby="tab-facturas">

          <div class="toolbar">
            <div class="search-box">
              <svg viewBox="0 0 24 24" stroke-linecap="round">
                <circle cx="11" cy="11" r="8"/>
                <line x1="21" y1="21" x2="16.65" y2="16.65"/>
              </svg>
              <input type="text" placeholder="Buscar folio, RFC, cliente…" />
            </div>

            <div class="date-range">
              <svg viewBox="0 0 24 24">
                <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
                <line x1="16" y1="2" x2="16" y2="6"/>
                <line x1="8" y1="2" x2="8" y2="6"/>
                <line x1="3" y1="10" x2="21" y2="10"/>
              </svg>
              01 Mar 2026 — 31 Mar 2026
            </div>

            <select class="select-filter" aria-label="Filtrar por estatus">
              <option value="">Todas</option>
              <option value="timbrada">Timbradas</option>
              <option value="pendiente">Pendientes</option>
              <option value="cancelada">Canceladas</option>
              <option value="ppd">PPD</option>
            </select>

            <div class="toolbar__spacer"></div>

            <button class="btn btn--ghost">
              <svg viewBox="0 0 24 24">
                <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
                <polyline points="7 10 12 15 17 10"/>
                <line x1="12" y1="15" x2="12" y2="3"/>
              </svg>
              Exportar CSV
            </button>
          </div>

          <div class="table-wrapper">
            <table class="data-table">
              <thead>
                <tr>
                  <th>Folio</th>
                  <th>Serie</th>
                  <th>Cliente</th>
                  <th>RFC</th>
                  <th style="text-align:right;">Subtotal</th>
                  <th style="text-align:right;">IVA</th>
                  <th style="text-align:right;">Total</th>
                  <th>Uso CFDI</th>
                  <th>Estatus</th>
                  <th>Acciones</th>
                </tr>
              </thead>
              <tbody>

                <tr>
                  <td class="td--mono">NAP-001289</td>
                  <td class="td--primary">A</td>
                  <td class="td--primary">Taller Mecánico Ramírez</td>
                  <td class="td--mono">TMR8402156HJ</td>
                  <td class="td--amount">$3,450.00</td>
                  <td class="td--amount">$552.00</td>
                  <td class="td--amount">$4,002.00</td>
                  <td style="font-size:var(--text-caption);">G03 Gastos en general</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NAP-001288</td>
                  <td class="td--primary">A</td>
                  <td class="td--primary">Distribuidora Automotriz del Norte SA de CV</td>
                  <td class="td--mono">DAN950312AB7</td>
                  <td class="td--amount">$18,760.00</td>
                  <td class="td--amount">$3,001.60</td>
                  <td class="td--amount">$21,761.60</td>
                  <td style="font-size:var(--text-caption);">G01 Adquisición de mercancias</td>
                  <td><span class="badge badge--ppd">PPD</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NAP-001287</td>
                  <td class="td--primary">A</td>
                  <td class="td--primary">Flotillas Logísticas Monterrey</td>
                  <td class="td--mono">FLM8710234KL9</td>
                  <td class="td--amount">$7,890.00</td>
                  <td class="td--amount">$1,262.40</td>
                  <td class="td--amount">$9,152.40</td>
                  <td style="font-size:var(--text-caption);">G03 Gastos en general</td>
                  <td><span class="badge badge--pendiente">Pendiente</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NAP-001286</td>
                  <td class="td--primary">B</td>
                  <td class="td--primary">Servicio Exprés Autopartes</td>
                  <td class="td--mono">SEA020819PP3</td>
                  <td class="td--amount">$1,120.00</td>
                  <td class="td--amount">$179.20</td>
                  <td class="td--amount">$1,299.20</td>
                  <td style="font-size:var(--text-caption);">G03 Gastos en general</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NAP-001285</td>
                  <td class="td--primary">A</td>
                  <td class="td--primary">Refaccionaria El Piston SC</td>
                  <td class="td--mono">REP9305077HG5</td>
                  <td class="td--amount">$5,300.00</td>
                  <td class="td--amount">$848.00</td>
                  <td class="td--amount">$6,148.00</td>
                  <td style="font-size:var(--text-caption);">G01 Adquisición de mercancias</td>
                  <td><span class="badge badge--cancelada">Cancelada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NAP-001284</td>
                  <td class="td--primary">B</td>
                  <td class="td--primary">Grupo Automotriz Torres e Hijos</td>
                  <td class="td--mono">GAT7612098DF2</td>
                  <td class="td--amount">$32,450.00</td>
                  <td class="td--amount">$5,192.00</td>
                  <td class="td--amount">$37,642.00</td>
                  <td style="font-size:var(--text-caption);">G01 Adquisición de mercancias</td>
                  <td><span class="badge badge--ppd">PPD</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

              </tbody>
            </table>

            <div class="table-footer">
              <span>Mostrando 1–6 de 247 facturas</span>
              <div class="pagination">
                <button class="page-btn" aria-label="Página anterior">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="15 18 9 12 15 6"/>
                  </svg>
                </button>
                <button class="page-btn is-active">1</button>
                <button class="page-btn">2</button>
                <button class="page-btn">3</button>
                <span style="color:var(--color-text-muted);padding:0 4px;">…</span>
                <button class="page-btn">42</button>
                <button class="page-btn" aria-label="Página siguiente">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="9 18 15 12 9 6"/>
                  </svg>
                </button>
              </div>
            </div>

          </div>
        </div><!-- /panel-facturas -->

        <!-- =================================================================
             TAB 2 — NOTAS DE CRÉDITO
             ================================================================= -->
        <div class="tab-panel" id="panel-notas" role="tabpanel" aria-labelledby="tab-notas">

          <div class="toolbar">
            <div class="search-box">
              <svg viewBox="0 0 24 24" stroke-linecap="round">
                <circle cx="11" cy="11" r="8"/>
                <line x1="21" y1="21" x2="16.65" y2="16.65"/>
              </svg>
              <input type="text" placeholder="Buscar nota de crédito…" />
            </div>
            <div class="toolbar__spacer"></div>
            <button class="btn btn--ghost">
              <svg viewBox="0 0 24 24">
                <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
                <polyline points="7 10 12 15 17 10"/>
                <line x1="12" y1="15" x2="12" y2="3"/>
              </svg>
              Exportar
            </button>
            <button class="btn btn--primary">
              <svg viewBox="0 0 24 24">
                <line x1="12" y1="5" x2="12" y2="19"/>
                <line x1="5" y1="12" x2="19" y2="12"/>
              </svg>
              Nueva Nota de Crédito
            </button>
          </div>

          <div class="table-wrapper">
            <table class="data-table">
              <thead>
                <tr>
                  <th>Folio NC</th>
                  <th>Factura Relacionada</th>
                  <th>Cliente</th>
                  <th>Motivo</th>
                  <th style="text-align:right;">Monto</th>
                  <th>Estatus</th>
                  <th>Acciones</th>
                </tr>
              </thead>
              <tbody>

                <tr>
                  <td class="td--mono">NC-000041</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001240</td>
                  <td class="td--primary">Taller Mecánico Ramírez</td>
                  <td>Devolución de mercancía defectuosa</td>
                  <td class="td--amount">$1,160.00</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NC-000040</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001215</td>
                  <td class="td--primary">Flotillas Logísticas Monterrey</td>
                  <td>Descuento comercial por volumen</td>
                  <td class="td--amount">$3,450.00</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NC-000039</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001198</td>
                  <td class="td--primary">Distribuidora Automotriz del Norte SA de CV</td>
                  <td>Error en precio unitario</td>
                  <td class="td--amount">$870.40</td>
                  <td><span class="badge badge--pendiente">Pendiente</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NC-000038</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001172</td>
                  <td class="td--primary">Grupo Automotriz Torres e Hijos</td>
                  <td>Devolución parcial de pedido</td>
                  <td class="td--amount">$8,120.00</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">NC-000037</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001154</td>
                  <td class="td--primary">Servicio Exprés Autopartes</td>
                  <td>Producto no solicitado enviado por error</td>
                  <td class="td--amount">$580.00</td>
                  <td><span class="badge badge--cancelada">Cancelada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">PDF</button>
                    </div>
                  </td>
                </tr>

              </tbody>
            </table>

            <div class="table-footer">
              <span>Mostrando 1–5 de 8 notas de crédito</span>
              <div class="pagination">
                <button class="page-btn" aria-label="Anterior">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
                </button>
                <button class="page-btn is-active">1</button>
                <button class="page-btn">2</button>
                <button class="page-btn" aria-label="Siguiente">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
                </button>
              </div>
            </div>
          </div>
        </div><!-- /panel-notas -->

        <!-- =================================================================
             TAB 3 — COMPLEMENTOS DE PAGO
             ================================================================= -->
        <div class="tab-panel" id="panel-complementos" role="tabpanel" aria-labelledby="tab-complementos">

          <div class="toolbar">
            <div class="search-box">
              <svg viewBox="0 0 24 24" stroke-linecap="round">
                <circle cx="11" cy="11" r="8"/>
                <line x1="21" y1="21" x2="16.65" y2="16.65"/>
              </svg>
              <input type="text" placeholder="Buscar complemento de pago…" />
            </div>
            <select class="select-filter" aria-label="Método de pago">
              <option value="">Todos los métodos</option>
              <option value="03">03 Transferencia electrónica</option>
              <option value="04">04 Tarjeta de crédito</option>
              <option value="28">28 Tarjeta de débito</option>
              <option value="01">01 Efectivo</option>
              <option value="99">99 Por definir</option>
            </select>
            <div class="toolbar__spacer"></div>
            <button class="btn btn--primary">
              <svg viewBox="0 0 24 24">
                <line x1="12" y1="5" x2="12" y2="19"/>
                <line x1="5" y1="12" x2="19" y2="12"/>
              </svg>
              Nuevo Complemento
            </button>
          </div>

          <div class="table-wrapper">
            <table class="data-table">
              <thead>
                <tr>
                  <th>Folio CP</th>
                  <th>Facturas</th>
                  <th>Cliente</th>
                  <th style="text-align:right;">Monto Pagado</th>
                  <th>Método Pago</th>
                  <th>Fecha</th>
                  <th>Estatus</th>
                  <th>Acciones</th>
                </tr>
              </thead>
              <tbody>

                <tr>
                  <td class="td--mono">CP-000072</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001271</td>
                  <td class="td--primary">Distribuidora Automotriz del Norte SA de CV</td>
                  <td class="td--amount">$21,761.60</td>
                  <td style="font-size:var(--text-caption);">03 Transferencia SPEI</td>
                  <td>28/03/2026</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">CP-000071</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001260, NAP-001261</td>
                  <td class="td--primary">Grupo Automotriz Torres e Hijos</td>
                  <td class="td--amount">$56,800.00</td>
                  <td style="font-size:var(--text-caption);">04 Tarjeta de crédito</td>
                  <td>26/03/2026</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">CP-000070</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001244</td>
                  <td class="td--primary">Flotillas Logísticas Monterrey</td>
                  <td class="td--amount">$9,152.40</td>
                  <td style="font-size:var(--text-caption);">03 Transferencia SPEI</td>
                  <td>24/03/2026</td>
                  <td><span class="badge badge--pendiente">Pendiente</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">CP-000069</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001230</td>
                  <td class="td--primary">Taller Mecánico Ramírez</td>
                  <td class="td--amount">$4,002.00</td>
                  <td style="font-size:var(--text-caption);">01 Efectivo</td>
                  <td>22/03/2026</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

                <tr>
                  <td class="td--mono">CP-000068</td>
                  <td class="td--mono" style="color:var(--color-text-accent);">NAP-001218, NAP-001225</td>
                  <td class="td--primary">Refaccionaria El Piston SC</td>
                  <td class="td--amount">$18,444.00</td>
                  <td style="font-size:var(--text-caption);">28 Tarjeta de débito</td>
                  <td>20/03/2026</td>
                  <td><span class="badge badge--timbrada">Timbrada</span></td>
                  <td>
                    <div style="display:flex;gap:4px;">
                      <button class="btn btn--ghost btn--sm">Ver</button>
                      <button class="btn btn--ghost btn--sm">XML</button>
                    </div>
                  </td>
                </tr>

              </tbody>
            </table>

            <div class="table-footer">
              <span>Mostrando 1–5 de 12 complementos de pago</span>
              <div class="pagination">
                <button class="page-btn" aria-label="Anterior">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
                </button>
                <button class="page-btn is-active">1</button>
                <button class="page-btn">2</button>
                <button class="page-btn">3</button>
                <button class="page-btn" aria-label="Siguiente">
                  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
                </button>
              </div>
            </div>
          </div>
        </div><!-- /panel-complementos -->

        <!-- =================================================================
             TAB 4 — CANCELACIONES
             ================================================================= -->
        <div class="tab-panel" id="panel-cancelaciones" role="tabpanel" aria-labelledby="tab-cancelaciones">

          <div class="section-heading">
            <span class="section-heading__title">Solicitudes de Cancelación SAT — Marzo 2026</span>
            <span class="section-heading__line"></span>
            <button class="btn btn--ghost btn--sm">
              <svg viewBox="0 0 24 24">
                <polyline points="23 4 23 10 17 10"/>
                <path d="M20.49 15a9 9 0 1 1-.38-4.93"/>
              </svg>
              Actualizar estatus
            </button>
          </div>

          <div class="cancel-grid">

            <div class="cancel-card cancel-card--proceso">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001290</span>
                <span class="badge badge--proceso">En proceso</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Flotillas Logísticas Monterrey</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">FLM8710234KL9</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">02 — Comprobante emitido con errores sin relación</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$9,152.40 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Solicitada: 31/03/2026 08:20</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

            <div class="cancel-card cancel-card--proceso">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001285</span>
                <span class="badge badge--proceso">En proceso</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Refaccionaria El Piston SC</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">REP9305077HG5</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">01 — Comprobante emitido con errores con relación</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$6,148.00 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Solicitada: 30/03/2026 11:42</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

            <div class="cancel-card cancel-card--aceptada">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001260</span>
                <span class="badge badge--aceptada">Aceptada SAT</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Servicio Exprés Autopartes</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">SEA020819PP3</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">02 — Comprobante emitido con errores sin relación</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$2,320.00 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Aceptada: 28/03/2026 09:15</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

            <div class="cancel-card cancel-card--aceptada">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001210</span>
                <span class="badge badge--aceptada">Aceptada SAT</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Grupo Automotriz Torres e Hijos</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">GAT7612098DF2</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">04 — Operación nominativa relacionada en factura global</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$14,900.00 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Aceptada: 21/03/2026 10:05</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

            <div class="cancel-card cancel-card--rechazada">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001243</span>
                <span class="badge badge--rechazada">Rechazada SAT</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Taller Mecánico Ramírez</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">TMR8402156HJ</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">03 — No se llevó a cabo la operación</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$4,560.00 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Rechazada: 25/03/2026 16:30</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

            <div class="cancel-card cancel-card--rechazada">
              <div class="cancel-card__header">
                <span class="cancel-card__folio">NAP-001198</span>
                <span class="badge badge--rechazada">Rechazada SAT</span>
              </div>
              <div class="cancel-card__body">
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Cliente</span>
                  <span class="cancel-card__row-value">Distribuidora Automotriz del Norte SA de CV</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">RFC</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-size:0.8rem;">DAN950312AB7</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Motivo</span>
                  <span class="cancel-card__row-value">01 — Comprobante emitido con errores con relación</span>
                </div>
                <div class="cancel-card__row">
                  <span class="cancel-card__row-label">Monto</span>
                  <span class="cancel-card__row-value" style="font-family:var(--font-mono);font-weight:600;color:var(--color-text-primary);">$31,248.00 MXN</span>
                </div>
              </div>
              <div class="cancel-card__footer">
                <span style="font-size:var(--text-caption);color:var(--color-text-muted);">Rechazada: 18/03/2026 14:45</span>
                <button class="btn btn--ghost btn--sm">Ver detalle</button>
              </div>
            </div>

          </div>
        </div><!-- /panel-cancelaciones -->

        <!-- =================================================================
             TAB 5 — CONFIGURACIÓN CFDI
             ================================================================= -->
        <div class="tab-panel" id="panel-config" role="tabpanel" aria-labelledby="tab-config">

          <div class="config-grid">

            <!-- DATOS FISCALES DEL EMISOR -->
            <div class="config-section">
              <div class="config-section__header">
                <svg viewBox="0 0 24 24">
                  <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
                  <polyline points="9 22 9 12 15 12 15 22"/>
                </svg>
                <span class="config-section__title">Datos Fiscales del Emisor</span>
              </div>
              <div class="config-section__body">
                <div class="form-grid">

                  <div class="form-field">
                    <label class="form-label" for="rfc-emisor">RFC Emisor</label>
                    <input class="form-input" id="rfc-emisor" type="text" value="NAP960714JK3" style="font-family:var(--font-mono);" />
                    <span class="form-hint">RFC registrado ante el SAT</span>
                  </div>

                  <div class="form-field">
                    <label class="form-label" for="cp-fiscal">C.P. Fiscal</label>
                    <input class="form-input" id="cp-fiscal" type="text" value="64000" />
                    <span class="form-hint">Código postal del domicilio fiscal</span>
                  </div>

                  <div class="form-field form-field--span2">
                    <label class="form-label" for="razon-social">Razón Social</label>
                    <input class="form-input" id="razon-social" type="text" value="NEXUS AUTOPARTES SA DE CV" />
                  </div>

                  <div class="form-field form-field--span2">
                    <label class="form-label" for="regimen-fiscal">Régimen Fiscal</label>
                    <select class="form-select" id="regimen-fiscal">
                      <option selected>601 — General de Ley Personas Morales</option>
                      <option>603 — Personas Morales con Fines no Lucrativos</option>
                      <option>605 — Sueldos y Salarios e Ingresos Asimilados a Salarios</option>
                      <option>612 — Personas Físicas con Actividades Empresariales</option>
                      <option>621 — Incorporación Fiscal</option>
                      <option>626 — Régimen Simplificado de Confianza</option>
                    </select>
                    <span class="form-hint">Régimen del emisor según el SAT</span>
                  </div>

                </div>

                <div style="margin-top:var(--space-4);display:flex;justify-content:flex-end;gap:var(--space-3);">
                  <button class="btn btn--ghost">Cancelar</button>
                  <button class="btn btn--primary">
                    <svg viewBox="0 0 24 24">
                      <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>
                      <polyline points="17 21 17 13 7 13 7 21"/>
                      <polyline points="7 3 7 8 15 8"/>
                    </svg>
                    Guardar Datos
                  </button>
                </div>
              </div>
            </div>

            <!-- CERTIFICADO DE SELLO DIGITAL -->
            <div class="config-section">
              <div class="config-section__header">
                <svg viewBox="0 0 24 24">
                  <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
                  <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
                </svg>
                <span class="config-section__title">Certificado de Sello Digital (CSD)</span>
              </div>
              <div class="config-section__body">

                <div class="cert-status">
                  <div class="cert-status__icon">
                    <svg viewBox="0 0 24 24">
                      <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
                      <polyline points="22 4 12 14.01 9 11.01"/>
                    </svg>
                  </div>
                  <div class="cert-status__info">
                    <div class="cert-status__name">
                      CSD Activo &nbsp;<span class="badge badge--vigente">Vigente</span>
                    </div>
                    <div class="cert-status__detail">
                      No. Certificado: 20001000000300022779 &nbsp;·&nbsp; Vence: 14/07/2026
                    </div>
                  </div>
                  <button class="btn btn--ghost btn--sm">Ver</button>
                </div>

                <div class="form-grid">
                  <div class="form-field">
                    <label class="form-label">Archivo .cer</label>
                    <button class="btn btn--secondary" style="width:100%;justify-content:center;">
                      <svg viewBox="0 0 24 24">
                        <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
                        <polyline points="17 8 12 3 7 8"/>
                        <line x1="12" y1="3" x2="12" y2="15"/>
                      </svg>
                      Subir certificado .cer
                    </button>
                    <span class="form-hint">Certificado público del SAT</span>
                  </div>

                  <div class="form-field">
                    <label class="form-label">Archivo .key</label>
                    <button class="btn btn--secondary" style="width:100%;justify-content:center;">
                      <svg viewBox="0 0 24 24">
                        <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
                        <polyline points="17 8 12 3 7 8"/>
                        <line x1="12" y1="3" x2="12" y2="15"/>
                      </svg>
                      Subir llave privada .key
                    </button>
                    <span class="form-hint">Llave privada del CSD</span>
                  </div>

                  <div class="form-field form-field--span2">
                    <label class="form-label" for="contrasena-csd">Contraseña del CSD</label>
                    <input class="form-input" id="contrasena-csd" type="password" placeholder="Contraseña de la llave privada" />
                    <span class="form-hint">Contraseña asignada al generar el CSD en el SAT</span>
                  </div>
                </div>

                <div style="margin-top:var(--space-4);display:flex;justify-content:flex-end;gap:var(--space-3);">
                  <button class="btn btn--ghost">Cancelar</button>
                  <button class="btn btn--primary">
                    <svg viewBox="0 0 24 24">
                      <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
                      <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
                    </svg>
                    Actualizar CSD
                  </button>
                </div>
              </div>
            </div>

            <!-- CONFIGURACIÓN DE SERIES — full width -->
            <div class="config-section" style="grid-column: span 2;">
              <div class="config-section__header">
                <svg viewBox="0 0 24 24">
                  <line x1="8" y1="6" x2="21" y2="6"/>
                  <line x1="8" y1="12" x2="21" y2="12"/>
                  <line x1="8" y1="18" x2="21" y2="18"/>
                  <line x1="3" y1="6" x2="3.01" y2="6"/>
                  <line x1="3" y1="12" x2="3.01" y2="12"/>
                  <line x1="3" y1="18" x2="3.01" y2="18"/>
                </svg>
                <span class="config-section__title">Configuración de Series de Folios</span>
                <button class="btn btn--ghost btn--sm">
                  <svg viewBox="0 0 24 24">
                    <line x1="12" y1="5" x2="12" y2="19"/>
                    <line x1="5" y1="12" x2="19" y2="12"/>
                  </svg>
                  Agregar Serie
                </button>
              </div>
              <div class="config-section__body" style="padding:0;">
                <table class="data-table">
                  <thead>
                    <tr>
                      <th>Serie</th>
                      <th>Descripción</th>
                      <th>Folio Actual</th>
                      <th>Folio Inicial</th>
                      <th>Tipo CFDI</th>
                      <th style="text-align:center;">Predeterminada</th>
                      <th>Estatus</th>
                      <th>Acciones</th>
                    </tr>
                  </thead>
                  <tbody>

                    <tr>
                      <td style="font-family:var(--font-mono);font-size:1.1rem;font-weight:700;color:var(--color-text-accent);padding-left:var(--space-5);">A</td>
                      <td class="td--primary">Factura estándar — Sucursal Centro</td>
                      <td class="td--mono">001290</td>
                      <td class="td--mono">001001</td>
                      <td><span class="badge badge--timbrada">I — Ingreso</span></td>
                      <td style="text-align:center;">
                        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--color-success)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                          <polyline points="20 6 9 17 4 12"/>
                        </svg>
                      </td>
                      <td><span class="badge badge--vigente">Activa</span></td>
                      <td>
                        <button class="btn btn--ghost btn--sm">Editar</button>
                      </td>
                    </tr>

                    <tr>
                      <td style="font-family:var(--font-mono);font-size:1.1rem;font-weight:700;color:var(--color-text-accent);padding-left:var(--space-5);">B</td>
                      <td class="td--primary">Factura mayoreo — Clientes corporativos</td>
                      <td class="td--mono">000042</td>
                      <td class="td--mono">000001</td>
                      <td><span class="badge badge--timbrada">I — Ingreso</span></td>
                      <td style="text-align:center;color:var(--color-text-muted);">—</td>
                      <td><span class="badge badge--vigente">Activa</span></td>
                      <td>
                        <button class="btn btn--ghost btn--sm">Editar</button>
                      </td>
                    </tr>

                    <tr>
                      <td style="font-family:var(--font-mono);font-size:1.1rem;font-weight:700;color:var(--color-text-accent);padding-left:var(--space-5);">NC</td>
                      <td class="td--primary">Notas de crédito</td>
                      <td class="td--mono">000041</td>
                      <td class="td--mono">000001</td>
                      <td><span class="badge badge--pendiente">E — Egreso</span></td>
                      <td style="text-align:center;color:var(--color-text-muted);">—</td>
                      <td><span class="badge badge--vigente">Activa</span></td>
                      <td>
                        <button class="btn btn--ghost btn--sm">Editar</button>
                      </td>
                    </tr>

                    <tr>
                      <td style="font-family:var(--font-mono);font-size:1.1rem;font-weight:700;color:var(--color-text-accent);padding-left:var(--space-5);">CP</td>
                      <td class="td--primary">Complementos de pago</td>
                      <td class="td--mono">000072</td>
                      <td class="td--mono">000001</td>
                      <td><span class="badge badge--ppd">P — Pago</span></td>
                      <td style="text-align:center;color:var(--color-text-muted);">—</td>
                      <td><span class="badge badge--vigente">Activa</span></td>
                      <td>
                        <button class="btn btn--ghost btn--sm">Editar</button>
                      </td>
                    </tr>

                    <tr>
                      <td style="font-family:var(--font-mono);font-size:1.1rem;font-weight:700;color:var(--color-text-accent);padding-left:var(--space-5);">T</td>
                      <td class="td--primary">Traslados — Remisiones fiscales</td>
                      <td class="td--mono">000018</td>
                      <td class="td--mono">000001</td>
                      <td><span class="badge badge--cancelada">T — Traslado</span></td>
                      <td style="text-align:center;color:var(--color-text-muted);">—</td>
                      <td><span class="badge badge--por-vencer">Inactiva</span></td>
                      <td>
                        <div style="display:flex;gap:4px;">
                          <button class="btn btn--ghost btn--sm">Editar</button>
                          <button class="btn btn--danger btn--sm">Activar</button>
                        </div>
                      </td>
                    </tr>

                  </tbody>
                </table>
              </div>
            </div>

          </div>
        </div><!-- /panel-config -->

      </div><!-- /tab-panels -->

    </main>

  </div><!-- /app-shell -->

  <!-- =========================================================================
       MODAL: DETALLE CFDI + XML PREVIEW
       ========================================================================= -->
  <div class="modal-overlay" id="modalDetalleOverlay" style="display:none; position:fixed; inset:0; z-index:var(--z-modal); background:var(--overlay-backdrop); display:none; align-items:center; justify-content:center;">
    <div class="modal-card" style="background:var(--color-bg-elevated); border:1px solid var(--color-border); border-radius:var(--radius-lg); width:720px; max-width:95vw; max-height:90vh; overflow:auto; box-shadow:var(--shadow-xl);">
      <div style="display:flex; align-items:center; justify-content:space-between; padding:var(--space-5) var(--space-6); border-bottom:1px solid var(--color-border);">
        <div>
          <div style="font-family:var(--font-heading); font-size:var(--text-h5); font-weight:var(--heading-weight-primary); color:var(--color-text-primary);">Detalle de Factura</div>
          <div style="font-size:var(--text-caption); color:var(--color-text-muted); margin-top:2px;">NAP-001289 — Timbrada</div>
        </div>
        <button onclick="document.getElementById('modalDetalleOverlay').style.display='none'" style="background:none; border:none; color:var(--color-text-muted); font-size:1.4rem; cursor:pointer; padding:var(--space-2);">✕</button>
      </div>
      <div style="padding:var(--space-5) var(--space-6);">
        <div style="display:grid; grid-template-columns:1fr 1fr; gap:var(--space-4); margin-bottom:var(--space-6);">
          <div>
            <div style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); margin-bottom:var(--space-1);">Emisor</div>
            <div style="font-weight:var(--font-weight-semibold);">Nexus Autoparts SA de CV</div>
            <div style="font-family:var(--font-mono); font-size:var(--text-body-sm); color:var(--color-text-secondary);">NAP960714JK3</div>
          </div>
          <div>
            <div style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); margin-bottom:var(--space-1);">Receptor</div>
            <div style="font-weight:var(--font-weight-semibold);">Taller Mecánico Rodríguez</div>
            <div style="font-family:var(--font-mono); font-size:var(--text-body-sm); color:var(--color-text-secondary);">TMR8402156HJ</div>
          </div>
          <div>
            <div style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); margin-bottom:var(--space-1);">UUID</div>
            <div style="font-family:var(--font-mono); font-size:var(--text-caption); color:var(--color-text-accent); word-break:break-all;">6ba7b810-9dad-11d1-80b4-00c04fd430c8</div>
          </div>
          <div>
            <div style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); margin-bottom:var(--space-1);">Total</div>
            <div style="font-family:var(--font-mono); font-size:var(--text-h4); font-weight:var(--font-weight-bold); color:var(--color-text-primary);">$4,002.00</div>
          </div>
        </div>
        <!-- XML Preview -->
        <div style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); margin-bottom:var(--space-2);">Vista previa XML</div>
        <pre style="background:var(--color-surface-3); border:1px solid var(--color-border); border-radius:var(--radius-md); padding:var(--space-4); font-family:var(--font-mono); font-size:11px; color:var(--color-text-secondary); overflow-x:auto; max-height:200px; line-height:1.6;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4"
  Version="4.0" Serie="A" Folio="001289"
  Fecha="2026-03-31T14:22:00" FormaPago="01"
  SubTotal="3450.00" Moneda="MXN"
  Total="4002.00" TipoDeComprobante="I"
  MetodoPago="PUE" LugarExpedicion="64000"&gt;
  &lt;cfdi:Emisor Rfc="NAP960714JK3"
    Nombre="Nexus Autoparts SA de CV"
    RegimenFiscal="601"/&gt;
  &lt;cfdi:Receptor Rfc="TMR8402156HJ"
    Nombre="Taller Mecánico Rodríguez"
    UsoCFDI="G03" DomicilioFiscalReceptor="64000"
    RegimenFiscalReceptor="612"/&gt;
  &lt;cfdi:Conceptos&gt;
    &lt;cfdi:Concepto ClaveProdServ="25174800"
      Cantidad="4" ClaveUnidad="H87"
      Descripcion="Balatas delanteras TRW"
      ValorUnitario="485.00" Importe="1940.00"/&gt;
  &lt;/cfdi:Conceptos&gt;
&lt;/cfdi:Comprobante&gt;</pre>
      </div>
      <div style="display:flex; gap:var(--space-3); justify-content:flex-end; padding:var(--space-4) var(--space-6); border-top:1px solid var(--color-border);">
        <button style="padding:var(--space-2) var(--space-5); border:1px solid var(--color-border); border-radius:var(--radius-md); background:transparent; color:var(--color-text-primary); cursor:pointer; font-family:var(--font-body); font-size:var(--text-body-sm);">Descargar XML</button>
        <button style="padding:var(--space-2) var(--space-5); border:1px solid var(--color-border); border-radius:var(--radius-md); background:transparent; color:var(--color-text-primary); cursor:pointer; font-family:var(--font-body); font-size:var(--text-body-sm);">Descargar PDF</button>
        <button style="padding:var(--space-2) var(--space-5); border:1px solid var(--btn-danger-bg); border-radius:var(--radius-md); background:var(--btn-danger-bg); color:var(--btn-danger-text); cursor:pointer; font-family:var(--font-body); font-size:var(--text-body-sm); font-weight:var(--font-weight-semibold);" onclick="document.getElementById('modalDetalleOverlay').style.display='none'; document.getElementById('modalCancelOverlay').style.display='flex';">Cancelar CFDI</button>
      </div>
    </div>
  </div>

  <!-- =========================================================================
       MODAL: CANCELACIÓN CFDI — Selector Motivo SAT
       ========================================================================= -->
  <div class="modal-overlay" id="modalCancelOverlay" style="display:none; position:fixed; inset:0; z-index:var(--z-modal); background:var(--overlay-backdrop); display:none; align-items:center; justify-content:center;">
    <div class="modal-card" style="background:var(--color-bg-elevated); border:1px solid var(--color-border); border-radius:var(--radius-lg); width:520px; max-width:95vw; box-shadow:var(--shadow-xl);">
      <div style="display:flex; align-items:center; gap:var(--space-3); padding:var(--space-5) var(--space-6); border-bottom:1px solid var(--color-border);">
        <div style="width:40px; height:40px; border-radius:var(--radius-full); background:rgba(239,68,68,0.12); display:flex; align-items:center; justify-content:center; flex-shrink:0;">
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="var(--color-error)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
        </div>
        <div>
          <div style="font-family:var(--font-heading); font-size:var(--text-h5); font-weight:var(--heading-weight-primary); color:var(--color-text-primary);">Cancelar CFDI</div>
          <div style="font-size:var(--text-caption); color:var(--color-text-muted);">NAP-001289 — $4,002.00 MXN</div>
        </div>
        <button onclick="document.getElementById('modalCancelOverlay').style.display='none'" style="background:none; border:none; color:var(--color-text-muted); font-size:1.4rem; cursor:pointer; padding:var(--space-2); margin-left:auto;">✕</button>
      </div>
      <div style="padding:var(--space-5) var(--space-6);">
        <div style="font-size:var(--text-body-sm); font-weight:var(--font-weight-semibold); color:var(--color-text-primary); margin-bottom:var(--space-3);">Motivo de cancelación (SAT)</div>
        <div style="display:flex; flex-direction:column; gap:var(--space-2);">
          <label style="display:flex; align-items:flex-start; gap:var(--space-3); padding:var(--space-3) var(--space-4); border:1px solid var(--color-border); border-radius:var(--radius-md); cursor:pointer; transition:var(--transition-fast);" onmouseover="this.style.borderColor='var(--color-primary)'" onmouseout="this.style.borderColor='var(--color-border)'">
            <input type="radio" name="motivo-sat" value="01" style="margin-top:3px; accent-color:var(--color-primary);" checked>
            <div>
              <div style="font-weight:var(--font-weight-semibold); font-size:var(--text-body-sm);">01 — Comprobante emitido con errores con relación</div>
              <div style="font-size:var(--text-caption); color:var(--color-text-muted);">Se sustituirá por otro CFDI. Requiere UUID de reemplazo.</div>
            </div>
          </label>
          <label style="display:flex; align-items:flex-start; gap:var(--space-3); padding:var(--space-3) var(--space-4); border:1px solid var(--color-border); border-radius:var(--radius-md); cursor:pointer; transition:var(--transition-fast);" onmouseover="this.style.borderColor='var(--color-primary)'" onmouseout="this.style.borderColor='var(--color-border)'">
            <input type="radio" name="motivo-sat" value="02" style="margin-top:3px; accent-color:var(--color-primary);">
            <div>
              <div style="font-weight:var(--font-weight-semibold); font-size:var(--text-body-sm);">02 — Comprobante emitido con errores sin relación</div>
              <div style="font-size:var(--text-caption); color:var(--color-text-muted);">No se sustituirá por otro CFDI.</div>
            </div>
          </label>
          <label style="display:flex; align-items:flex-start; gap:var(--space-3); padding:var(--space-3) var(--space-4); border:1px solid var(--color-border); border-radius:var(--radius-md); cursor:pointer; transition:var(--transition-fast);" onmouseover="this.style.borderColor='var(--color-primary)'" onmouseout="this.style.borderColor='var(--color-border)'">
            <input type="radio" name="motivo-sat" value="03" style="margin-top:3px; accent-color:var(--color-primary);">
            <div>
              <div style="font-weight:var(--font-weight-semibold); font-size:var(--text-body-sm);">03 — No se llevó a cabo la operación</div>
              <div style="font-size:var(--text-caption); color:var(--color-text-muted);">La operación que amparó el CFDI no se realizó.</div>
            </div>
          </label>
          <label style="display:flex; align-items:flex-start; gap:var(--space-3); padding:var(--space-3) var(--space-4); border:1px solid var(--color-border); border-radius:var(--radius-md); cursor:pointer; transition:var(--transition-fast);" onmouseover="this.style.borderColor='var(--color-primary)'" onmouseout="this.style.borderColor='var(--color-border)'">
            <input type="radio" name="motivo-sat" value="04" style="margin-top:3px; accent-color:var(--color-primary);">
            <div>
              <div style="font-weight:var(--font-weight-semibold); font-size:var(--text-body-sm);">04 — Operación nominativa relacionada en una factura global</div>
              <div style="font-size:var(--text-caption); color:var(--color-text-muted);">Cancelar cuando la operación se desglosó en una factura global.</div>
            </div>
          </label>
        </div>
        <!-- UUID de reemplazo (solo para motivo 01) -->
        <div style="margin-top:var(--space-4);">
          <label style="font-size:var(--text-caption); color:var(--color-text-muted); text-transform:uppercase; letter-spacing:var(--tracking-widest); display:block; margin-bottom:var(--space-1);">UUID de CFDI sustituto (motivo 01)</label>
          <input type="text" placeholder="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" style="width:100%; padding:var(--space-2) var(--space-3); border:1px solid var(--color-border); border-radius:var(--radius-md); background:var(--color-surface-2); color:var(--color-text-primary); font-family:var(--font-mono); font-size:var(--text-body-sm);">
        </div>
      </div>
      <div style="display:flex; gap:var(--space-3); justify-content:flex-end; padding:var(--space-4) var(--space-6); border-top:1px solid var(--color-border);">
        <button onclick="document.getElementById('modalCancelOverlay').style.display='none'" style="padding:var(--space-2) var(--space-5); border:1px solid var(--color-border); border-radius:var(--radius-md); background:transparent; color:var(--color-text-primary); cursor:pointer; font-family:var(--font-body); font-size:var(--text-body-sm);">Cancelar</button>
        <button onclick="document.getElementById('modalCancelOverlay').style.display='none'" style="padding:var(--space-2) var(--space-5); border:1px solid var(--btn-danger-bg); border-radius:var(--radius-md); background:var(--btn-danger-bg); color:var(--btn-danger-text); cursor:pointer; font-family:var(--font-body); font-size:var(--text-body-sm); font-weight:var(--font-weight-semibold);">Solicitar Cancelación SAT</button>
      </div>
    </div>
  </div>

  <script src="/pos/static/js/app-init.js"></script>
  <script src="/pos/static/js/sidebar.js"></script>
  <script src="/pos/static/js/invoicing.js"></script>

</body>
</html>
