      * {
        font-family: 'Roboto', system-ui, -apple-system, sans-serif;
      }

      #invoicePreview * {
        font-size: 13px !important;
      }

      #invoicePreview h1,
      #invoicePreview h2,
      #invoicePreview h3,
      #invoicePreview h4,
      #invoicePreview h5,
      #invoicePreview h6 {
        font-weight: bold;
        font-size: 13px !important;
      }

      #invoicePreview .company-name {
        font-size: 16px !important;
      }

      #invoicePreview .invoice-title {
        font-size: 16px !important;
      }

      #invoicePreview .invoice-title {
        font-size: 16px !important;
      }

      body {
        background: #f8fafc;
        min-height: 100vh;
        font-family: 'Inter', 'Roboto', system-ui, sans-serif;
      }

      body.loaded {
        opacity: 1;
      }

      #seoIntro {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
      }

      #seoIntro .seo-copy {
        max-width: 1120px;
        display: grid;
        grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
        gap: 1.25rem;
        align-items: center;
      }

      #seoIntro .seo-lead {
        max-width: 720px;
      }

      #seoIntro .seo-kicker {
        color: #2563eb;
        font-size: 0.8rem;
        font-weight: 700;
        letter-spacing: 0;
        margin-bottom: 0.45rem;
        text-transform: uppercase;
      }

      #seoIntro .seo-trust-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 1rem;
      }

      #seoIntro .seo-trust-row span {
        background: #eff6ff;
        border: 1px solid #bfdbfe;
        border-radius: 999px;
        color: #1d4ed8;
        font-size: 0.78rem;
        font-weight: 600;
        padding: 0.35rem 0.65rem;
      }

      #seoIntro .seo-card {
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        background: #ffffff;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
      }

      #seoIntro .seo-mini-card {
        background: #f8fafc;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.85rem;
      }

      #seoIntro .seo-feature-list {
        display: grid;
        gap: 0.45rem;
        list-style: none;
        margin: 0;
        padding: 0;
      }

      #seoIntro .seo-feature-list li {
        color: #374151;
        font-size: 0.875rem;
        line-height: 1.45;
        padding-left: 1.35rem;
        position: relative;
      }

      #seoIntro .seo-feature-list li::before {
        content: "";
        background: #2563eb;
        border-radius: 999px;
        height: 0.42rem;
        left: 0.25rem;
        position: absolute;
        top: 0.55rem;
        width: 0.42rem;
      }

      @media (max-width: 768px) {
        #seoIntro .seo-copy {
          grid-template-columns: 1fr;
        }
      }

      .editable {
        cursor: text;
        transition: all 0.2s ease;
        border-radius: 4px;
        padding: 2px 4px;
        margin: -2px -4px;
      }

      .editable:hover {
        background-color: rgba(37, 99, 235, 0.05);
      }

      .editable:focus {
        outline: 2px solid #2563eb;
        background-color: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        color: #111827 !important;
      }

      .table-header-white {
        color: #111827 !important;
        background: white !important;
      }

      .items-heading {
        color: white !important;
      }

      .items-heading i {
        color: white !important;
      }

      .table-header-white:focus {
        color: #111827 !important;
        background-color: #f9fafb !important;
        outline: 2px solid #2563eb !important;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
      }

      .table-header-white:hover {
        color: #111827 !important;
        background-color: #f9fafb !important;
      }

      .invoice-preview {
        background: white;
        border-radius: 16px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
      }

      .sidebar {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border-right: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        border-radius: 0 16px 16px 0;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex-shrink: 0;
      }

      .glass-card {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      }

      .glass-card:hover {
        background: rgba(255, 255, 255, 0.95);
        border-color: rgba(37, 99, 235, 0.2);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
      }

      .btn {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        font-weight: 500;
        border-radius: 12px;
        backdrop-filter: blur(10px);
      }

      .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      }

      .btn:active {
        transform: translateY(0);
      }

      .template-option {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
        position: relative;
      }

      .template-option:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
      }

      .template-option.active {
        border-color: #2563eb !important;
        background: rgba(37, 99, 235, 0.08) !important;
        box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
        transform: translateY(-2px);
      }

      .template-option.active::before {
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        background: linear-gradient(135deg, #2563eb, #3b82f6);
        border-radius: 14px;
        z-index: -1;
        opacity: 0.1;
      }


      .currency-symbol {
        min-width: auto;
        text-align: left;
        padding-right: 0;
      }



      .items-table {
        border-collapse: separate;
        border-spacing: 0;
        width: 100%;
        table-layout: fixed;
        max-width: 100%;
      }

      /* Prevent table overflow */
      .items-table th,
      .items-table td {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 0;
      }

      /* PDF table optimization */
      .items-table {
        white-space: nowrap;
      }

      .items-table th,
      .items-table td {
        white-space: nowrap;
        overflow: visible;
        padding: 8px 12px;
      }

      .items-table th:first-child,
      .items-table td:first-child {
        white-space: normal;
        word-wrap: break-word;
        padding: 8px 12px;
      }

      /* Dynamic column widths based on visible columns */
      .items-table th:first-child,
      .items-table td:first-child {
        width: 50%;
        min-width: 0;
      }

      .items-table th:nth-child(2),
      .items-table td:nth-child(2) {
        width: 15%;
        min-width: 0;
        padding: 8px 8px 8px 12px;
      }

      .items-table th:nth-child(3),
      .items-table td:nth-child(3) {
        width: 20%;
        min-width: 0;
        padding: 8px 8px 8px 12px;
      }

      .items-table th:nth-last-child(2),
      .items-table td:nth-last-child(2) {
        width: 20%;
        min-width: 0;
      }

      .items-table th:last-child,
      .items-table td:last-child {
        width: 5%;
        min-width: 0;
      }

      /* Adjust widths when optional columns are visible */
      .items-table th.tax-column,
      .items-table td.tax-column,
      .items-table th.discount-column,
      .items-table td.discount-column,
      .items-table th.shipping-column,
      .items-table td.shipping-column {
        width: 9%;
        min-width: 0;
        padding: 8px 12px;
      }

      /* Ensure input fields in optional columns are properly sized */
      .tax-column input,
      .discount-column input,
      .shipping-column input,
      .items-table td:nth-child(2) input,
      .items-table td:nth-child(3) input,
      .items-table td:nth-last-child(2) input {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 72px !important;
        box-sizing: border-box !important;
        text-align: left !important;
        font-size: 12px !important;
      }

      .tax-column input,
      .discount-column input,
      .shipping-column input {
        max-width: 48px !important;
      }

      /* When optional columns are shown, adjust main columns */
      body[data-tax-mode="per_item_fixed"] .items-table th:first-child,
      body[data-tax-mode="per_item_percentage"] .items-table th:first-child,
      body[data-discount-mode="per_item_fixed"] .items-table th:first-child,
      body[data-discount-mode="per_item_percentage"] .items-table th:first-child,
      body[data-shipping-mode="per_item_fixed"] .items-table th:first-child,
      body[data-shipping-mode="per_item_percentage"] .items-table th:first-child,
      body[data-tax-mode="per_item_fixed"] .items-table td:first-child,
      body[data-tax-mode="per_item_percentage"] .items-table td:first-child,
      body[data-discount-mode="per_item_fixed"] .items-table td:first-child,
      body[data-discount-mode="per_item_percentage"] .items-table td:first-child,
      body[data-shipping-mode="per_item_fixed"] .items-table td:first-child,
      body[data-shipping-mode="per_item_percentage"] .items-table td:first-child {
        width: 32%;
      }

      body[data-tax-mode="per_item_fixed"] .items-table th:nth-child(2),
      body[data-tax-mode="per_item_percentage"] .items-table th:nth-child(2),
      body[data-discount-mode="per_item_fixed"] .items-table th:nth-child(2),
      body[data-discount-mode="per_item_percentage"] .items-table th:nth-child(2),
      body[data-shipping-mode="per_item_fixed"] .items-table th:nth-child(2),
      body[data-shipping-mode="per_item_percentage"] .items-table th:nth-child(2),
      body[data-tax-mode="per_item_fixed"] .items-table td:nth-child(2),
      body[data-tax-mode="per_item_percentage"] .items-table td:nth-child(2),
      body[data-discount-mode="per_item_fixed"] .items-table td:nth-child(2),
      body[data-discount-mode="per_item_percentage"] .items-table td:nth-child(2),
      body[data-shipping-mode="per_item_fixed"] .items-table td:nth-child(2),
      body[data-shipping-mode="per_item_percentage"] .items-table td:nth-child(2) {
        width: 9%;
      }

      body[data-tax-mode="per_item_fixed"] .items-table th:nth-child(3),
      body[data-tax-mode="per_item_percentage"] .items-table th:nth-child(3),
      body[data-discount-mode="per_item_fixed"] .items-table th:nth-child(3),
      body[data-discount-mode="per_item_percentage"] .items-table th:nth-child(3),
      body[data-shipping-mode="per_item_fixed"] .items-table th:nth-child(3),
      body[data-shipping-mode="per_item_percentage"] .items-table th:nth-child(3),
      body[data-tax-mode="per_item_fixed"] .items-table td:nth-child(3),
      body[data-tax-mode="per_item_percentage"] .items-table td:nth-child(3),
      body[data-discount-mode="per_item_fixed"] .items-table td:nth-child(3),
      body[data-discount-mode="per_item_percentage"] .items-table td:nth-child(3),
      body[data-shipping-mode="per_item_fixed"] .items-table td:nth-child(3),
      body[data-shipping-mode="per_item_percentage"] .items-table td:nth-child(3) {
        width: 14%;
      }

      /* PDF specific table optimizations */
      @media print {
        .items-table {
          font-size: 10px !important;
          table-layout: fixed !important;
        }

        .items-table th,
        .items-table td {
          padding: 4px 2px !important;
          font-size: 10px !important;
          line-height: 1.2 !important;
        }

        .items-table th:first-child,
        .items-table td:first-child {
          width: 40% !important;
        }

        .items-table .tax-column,
        .items-table .discount-column,
        .items-table .shipping-column {
          width: 10% !important;
          min-width: 0 !important;
        }

        .items-table input {
          font-size: 9px !important;
          padding: 1px !important;
        }
      }

      .items-table thead tr {
        background: white !important;
      }

      .items-table th {
        background: white !important;
        font-weight: 600;
        color: #111827;
        border-bottom: 2px solid #e5e7eb;
      }

      .item-row-even {
        background-color: #f9fafb !important;
      }

      .item-row-odd {
        background-color: #ffffff !important;
      }

      .summary-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        overflow: hidden;
        word-wrap: break-word;
        min-height: 24px;
        padding: 2px 0;
      }

      .summary-value {
        flex-shrink: 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 120px;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 2px;
      }

      .summary-label {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-right: 8px;
        text-align: left;
      }

      /* Ensure input fields in summary don't cause overflow */
      .summary-value input {
        max-width: 60px !important;
        min-width: 40px !important;
        font-size: 11px !important;
        padding: 1px 2px !important;
        text-align: right !important;
      }

      /* Better spacing for summary elements */
      .summary-value>* {
        flex-shrink: 0;
      }

      /* Hide input fields and calculation symbols in print view */
      @media print {
        .hide-in-pdf {
          display: none !important;
          visibility: hidden !important;
        }

        /* Ensure summary section is properly formatted in print */
        .summary-value {
          max-width: none !important;
          justify-content: flex-end !important;
        }

        .summary-row {
          padding: 1px 0 !important;
        }
      }

      .mobile-menu {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
      }

      .mobile-menu.open {
        transform: translateX(0);
      }

      .fade-in {
        animation: fadeIn 0.3s ease-in-out;
      }

      @keyframes fadeIn {
        from {
          opacity: 0;
          transform: translateY(10px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .slide-up {
        animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
      }

      @keyframes slideUp {
        from {
          opacity: 0;
          transform: translateY(20px) scale(0.95);
        }

        to {
          opacity: 1;
          transform: translateY(0) scale(1);
        }
      }

      /* Enhanced loading states */
      .loading {
        position: relative;
        overflow: hidden;
      }

      .loading::after {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
        animation: shimmer 1.5s infinite;
      }

      @keyframes shimmer {
        0% {
          left: -100%;
        }

        100% {
          left: 100%;
        }
      }

      @keyframes spin {
        from {
          transform: rotate(0deg);
        }

        to {
          transform: rotate(360deg);
        }
      }

      .animate-spin {
        animation: spin 1s linear infinite;
      }

      .signature-pad {
        border: 2px dashed #d1d5db;
        border-radius: 8px;
      }

      .toast {
        position: fixed;
        top: 20px;
        right: 20px;
        background: white;
        border-left: 4px solid #10b981;
        padding: 16px 20px;
        border-radius: 8px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        transform: translateX(400px);
        opacity: 0;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      }

      .toast.show {
        transform: translateX(0);
        opacity: 1;
      }

      .toast.error {
        border-left-color: #ef4444;
      }

      .toast.warning {
        border-left-color: #f59e0b;
      }

      /* Invoice Header Linking */
      .invoice-header-container {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        width: 100%;
        gap: 1rem;
      }

      .invoice-header-container.items-start {
        align-items: flex-start !important;
      }

      .company-section {
        flex: 1;
        min-width: 0;
      }

      .invoice-section {
        flex-shrink: 0;
        text-align: right;
      }

      @media (max-width: 640px) {
        .invoice-header-container {
          flex-direction: column;
          gap: 1.5rem;
        }

        .invoice-section {
          text-align: left;
        }

        .invoice-preview {
          padding: 1rem !important;
          margin: 0.5rem !important;
          border-radius: 8px !important;
        }

        .flex.flex-col.md\:flex-row {
          flex-direction: column !important;
          gap: 1rem !important;
        }

        .flex.flex-col.lg\:flex-row {
          flex-direction: column !important;
          gap: 1rem !important;
        }

        .w-full.lg\:w-80 {
          width: 100% !important;
          max-width: 100% !important;
        }

        .items-table {
          font-size: 11px !important;
        }

        .items-table th,
        .items-table td {
          padding: 4px 2px !important;
          font-size: 11px !important;
        }

        .items-table input {
          font-size: 10px !important;
          padding: 2px !important;
          width: 60px !important;
          min-width: 60px !important;
          max-width: 60px !important;
        }

        .summary-row {
          font-size: 11px !important;
        }

        .border.border-gray-200.rounded-lg {
          margin: 0.5rem 0 !important;
        }
      }

      /* Mobile overlay */
      .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
      }

      .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
      }

      /* Enhanced Mobile Sidebar */
      @media (max-width: 768px) {
        .sidebar {
          position: fixed;
          left: -100%;
          top: 0;
          height: 100vh;
          height: 100dvh;
          z-index: 200;
          transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
          width: 320px;
          max-width: 85vw;
          background: rgba(255, 255, 255, 0.98);
          backdrop-filter: blur(20px);
          border-right: none;
          box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
          padding: 1.5rem;
          overflow-y: auto;
        }

        .sidebar.open {
          left: 0 !important;
          transform: translateX(0) !important;
        }

        .sidebar-toggle-btn {
          display: none !important;
        }

        .main-content {
          padding: 0.5rem !important;
        }

        .flex-1 {
          padding: 0.5rem !important;
        }

        .max-w-full {
          padding: 0 !important;
        }

        .pdf-container {
          padding: 0.5rem !important;
          max-width: 100% !important;
        }
      }

      /* Desktop sidebar toggle */
      @media (min-width: 769px) {
        .sidebar.collapsed {
          width: 64px !important;
          min-width: 64px;
          padding-left: 0.75rem !important;
          padding-right: 0.75rem !important;
          overflow: visible;
        }

        .sidebar.collapsed .sidebar-tabs,
        .sidebar.collapsed h3,
        .sidebar.collapsed .space-y-2,
        .sidebar.collapsed h2 {
          display: none !important;
        }

        .sidebar.collapsed>.flex:first-child {
          justify-content: center;
          margin-bottom: 0 !important;
          padding-bottom: 0;
          border-bottom: 0;
        }

        .sidebar.collapsed>.flex:first-child>.flex {
          display: none !important;
        }

        .sidebar.collapsed .sidebar-toggle-btn {
          display: flex !important;
          opacity: 1;
          visibility: visible;
        }

        .main-content {
          transition: all 0.3s ease;
        }
      }

      /* Prevent clicks on main content when sidebar is open */
      body.sidebar-open .main-content {
        pointer-events: none;
      }

      body.sidebar-open .sidebar {
        pointer-events: auto;
      }

      body.sidebar-open .mobile-overlay {
        opacity: 1;
        visibility: visible;
      }

      /* Ensure mobile menu button is always visible */
      .mobile-menu-btn {
        position: relative;
        z-index: 250;
      }

      /* Fix header on mobile */
      .header {
        position: relative;
        z-index: 100;
      }

      /* Improve touch targets */
      .glass-card button,
      .template-option,
      .mobile-btn {
        min-height: 48px;
        padding: 12px 16px;
      }

      /* Better dropdown positioning on mobile */
      @media (max-width: 768px) {
        .dropdown {
          position: absolute !important;
          top: 100% !important;
          left: 0 !important;
          right: auto !important;
          width: 100% !important;
          min-width: 200px !important;
          max-height: 60vh !important;
          overflow-y: auto !important;
          z-index: 9999 !important;
        }

        /* Mobile editable improvements */
        .editable {
          min-height: 32px !important;
          padding: 4px 6px !important;
          font-size: 12px !important;
        }

        .editable:focus {
          font-size: 14px !important;
          padding: 6px 8px !important;
        }

        /* Mobile input improvements */
        input[type="date"] {
          font-size: 12px !important;
          padding: 4px !important;
          min-width: 100px !important;
          width: 100px !important;
        }

        /* Mobile button improvements */
        #addItemBtn {
          font-size: 12px !important;
          padding: 8px 12px !important;
        }
      }

      .overlay {
        display: none;
      }

      .glass-card {
        min-height: 48px;
      }

      button {
        min-height: 48px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
      }

      .btn-primary,
      .btn-secondary {
        min-height: 48px !important;
        padding: 0.875rem 1.25rem !important;
      }

      .control-btn {
        min-height: 44px !important;
        padding: 0.75rem 1rem !important;
      }

      .template-option {
        min-height: 80px;
        touch-action: manipulation;
      }

      input[type="color"] {
        width: 48px;
        height: 48px;
        border-radius: 12px;
      }

      .template-option,
      .glass-card button,
      button {
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
      }

      button:focus-visible,
      .template-option:focus-visible,
      input:focus-visible {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
      }

      /* Tablet Optimizations */
      @media (min-width: 769px) and (max-width: 1024px) {
        .sidebar {
          width: 300px;
          background: rgba(255, 255, 255, 0.96);
        }
      }

      /* Desktop Enhancements */
      @media (min-width: 1025px) {
        .sidebar {
          width: 340px;
          background: rgba(255, 255, 255, 0.95);
        }

        .sidebar:hover {
          background: rgba(255, 255, 255, 0.98);
          box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
        }
      }

      /* Hide Add Item Button in PDF/Print */
      .pdf-hide {
        display: none !important;
      }

      .print-hide {
        display: none !important;
      }

      /* Logo Position Buttons */
      .logo-position-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px;
        border: 2px solid #e5e7eb;
        border-radius: 8px;
        background: white;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 12px;
        font-weight: 500;
        color: #6b7280;
      }

      .logo-position-btn:hover {
        border-color: #2563eb;
        background: #f8fafc;
      }

      .logo-position-btn.active {
        border-color: #2563eb;
        background: #eff6ff;
        color: #2563eb;
      }

      .logo-position-btn .w-3 {
        transition: background-color 0.2s ease;
      }

      .logo-position-btn.active .w-3 {
        background-color: #2563eb;
      }

      #logoSection {
        margin-top: 0.45rem;
      }

      #logoSection .logo-tools-card {
        margin-left: 0;
      }

      #logoSection .logo-upload-dropzone {
        background: rgba(248, 250, 252, 0.72);
      }

      #logoSection .logo-upload-dropzone .w-12 {
        height: 2.65rem;
        margin-bottom: 0.6rem;
        width: 2.65rem;
      }

      #logoSection .logo-upload-dropzone p {
        margin-bottom: 0.75rem !important;
      }

      #logoSection .logo-control-group {
        border-top: 1px solid #e5e7eb;
        margin-top: 0.85rem;
        padding-top: 0.85rem;
      }

      /* Logo Size Buttons */
      .logo-size-btn {
        border-color: #e5e7eb;
        background: white;
        color: #6b7280;
        transition: all 0.2s ease;
        min-width: 50px;
        white-space: nowrap;
        font-size: 11px;
        padding: 4px 8px;
      }

      .logo-size-btn:hover {
        border-color: #2563eb;
        background: #f8fafc;
      }

      .logo-size-btn.active {
        border-color: #2563eb;
        background: #2563eb;
        color: white;
      }

      /* Logo Draggable */
      .logo-draggable {
        cursor: move;
        user-select: none;
      }

      .logo-draggable:hover {
        opacity: 0.8;
      }

      /* Fix signature section positioning */
      #signatureSection {
        position: relative;
        z-index: 10;
        margin-top: 0.5rem;
      }

      #signatureSection .glass-card {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(16px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
      }

      /* Ensure proper stacking order */
      .sidebar .space-y-2>* {
        position: static;
        z-index: auto;
      }

      /* Sticky sidebar + tabbed panels */
      .sidebar-sticky {
        position: sticky;
        top: 0.75rem;
        height: calc(100vh - 96px);
        margin-top: 0.75rem;
        overflow: hidden;
        display: flex;
        flex-direction: column;
      }

      .sidebar>.flex:first-child {
        margin-bottom: 1rem !important;
        padding-bottom: 0.85rem;
        border-bottom: 1px solid rgba(226, 232, 240, 0.9);
      }

      @media (min-width: 769px) {

        .mobile-nav-wrapper,
        .mobile-bottom-nav-bar,
        .mobile-controls-sheet {
          display: none !important;
        }

        body {
          padding-bottom: 0 !important;
        }
      }

      .sidebar-tabs {
        display: flex;
        flex: 1;
        flex-direction: column;
        margin-bottom: 0;
        min-height: 0;
      }

      .sidebar-tabs input[type="radio"] {
        position: absolute;
        opacity: 0;
        pointer-events: none;
      }

      .sidebar-tab-buttons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        background: rgba(255, 255, 255, 0.8);
        border: 1px solid rgba(226, 232, 240, 0.9);
        border-radius: 12px;
        padding: 0.5rem;
        margin-bottom: 1rem;
      }

      .sidebar-tab-btn {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.85rem;
        color: #374151;
        transition: background 0.15s ease, color 0.15s ease;
      }

      #sidebarTabQuick:checked~.sidebar-tab-buttons label[for="sidebarTabQuick"],
      #sidebarTabBrand:checked~.sidebar-tab-buttons label[for="sidebarTabBrand"],
      #sidebarTabTemplates:checked~.sidebar-tab-buttons label[for="sidebarTabTemplates"] {
        background: #111827;
        color: #ffffff;
      }

      .sidebar-tab-panel {
        display: none;
        overflow: auto;
        padding: 0.15rem 0.25rem 0 0;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
        scrollbar-gutter: stable;
      }

      .sidebar-tab-panel>.mb-6 {
        margin-bottom: 0 !important;
      }

      .sidebar-tab-panel h3 {
        margin-bottom: 0.85rem !important;
        line-height: 1.2;
      }

      .sidebar .space-y-2>*+* {
        margin-top: 0.65rem !important;
      }

      .sidebar .glass-card {
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
      }

      #sidebarTabQuick:checked~.sidebar-panel-quick,
      #sidebarTabBrand:checked~.sidebar-panel-brand,
      #sidebarTabTemplates:checked~.sidebar-panel-templates {
        display: block;
      }

      @media print {
        @page {
          margin: 0;
          size: A4;
        }

        html,
        body {
          height: auto !important;
          overflow: visible !important;
        }

        /* Ensure date inputs have proper width in print */
        .invoice-date-input {
          min-width: 96px !important;
          width: 96px !important;
          text-align: right !important;
        }

        * {
          -webkit-print-color-adjust: exact !important;
          print-color-adjust: exact !important;
        }

        body {
          background: white !important;
          margin: 0 !important;
          padding: 0 !important;
          font-family: 'Roboto', system-ui, sans-serif !important;
          height: auto !important;
          min-height: auto !important;
        }

        .header,
        .sidebar,
        .mobile-controls,
        .mobile-menu-btn,
        .no-print,
        .overlay,
        .pdf-hide,
        .print-hide,
        button,
        .remove-item,
        i.ri-arrow-left-s-line,
        i.ri-arrow-right-s-line,
        .ri-arrow-left-s-line,
        .ri-arrow-right-s-line {
          display: none !important;
          visibility: hidden !important;
          opacity: 0 !important;
          height: 0 !important;
          width: 0 !important;
          margin: 0 !important;
          padding: 0 !important;
        }

        .main-content {
          display: block !important;
          flex-direction: column !important;
          margin: 0 !important;
          padding: 0 !important;
          height: auto !important;
        }

        .flex-1 {
          padding: 0 !important;
          flex: none !important;
          height: auto !important;
          min-height: auto !important;
        }

        .max-w-6xl,
        .max-w-full {
          max-width: none !important;
          margin: 0 !important;
          padding: 0 !important;
        }

        .px-8 {
          padding-left: 0 !important;
          padding-right: 0 !important;
        }

        .invoice-preview {
          box-shadow: none !important;
          border: 1px solid rgba(229, 231, 235, 0.95) !important;
          margin: 0 auto !important;
          padding: 8mm !important;
          border-radius: 12px !important;
          min-height: 297mm !important;
          height: auto !important;
          width: 210mm !important;
          max-width: 210mm !important;
          background: white !important;
          font-size: 13px !important;
          line-height: 1.3 !important;
          page-break-inside: auto !important;
          overflow: visible !important;
          position: static !important;
          transform: none !important;
        }

        .invoice-preview * {
          font-size: 13px !important;
          line-height: 1.3 !important;
        }

        .invoice-preview .company-name {
          font-size: 14px !important;
        }

        .invoice-preview .invoice-title {
          font-size: 16px !important;
        }

        .flex.flex-col.md\:flex-row {
          display: flex !important;
          flex-direction: row !important;
          justify-content: space-between !important;
          align-items: flex-start !important;
        }

        .flex-1 {
          flex: 1 !important;
          text-align: left !important;
        }

        .text-right {
          text-align: right !important;
          flex: none !important;
          min-width: 200px !important;
        }

        .flex.flex-col.lg\:flex-row {
          display: flex !important;
          flex-direction: row !important;
          gap: 1.5rem !important;
        }

        .w-full.lg\:w-80 {
          width: 280px !important;
          max-width: 280px !important;
          flex-shrink: 0 !important;
          min-width: 280px !important;
        }

        .overflow-x-auto {
          overflow: visible !important;
        }

        .items-table {
          border-collapse: collapse !important;
          width: 100% !important;
          table-layout: fixed !important;
          margin-bottom: 0 !important;
        }

        .items-table th:first-child,
        .items-table td:first-child {
          width: 40% !important;
          min-width: 0 !important;
        }

        .items-table th:nth-child(2),
        .items-table td:nth-child(2) {
          width: 10% !important;
          min-width: 0 !important;
        }

        .items-table th:nth-child(3),
        .items-table td:nth-child(3) {
          width: 15% !important;
          min-width: 0 !important;
        }

        .items-table th:nth-last-child(2),
        .items-table td:nth-last-child(2) {
          width: 20% !important;
          min-width: 0 !important;
        }

        .items-table th:last-child,
        .items-table td:last-child {
          display: none !important;
        }

        .items-table th,
        .items-table td {
          border: 1px solid #e5e7eb !important;
          padding: 4px 6px !important;
          font-size: 10px !important;
          word-wrap: break-word !important;
          overflow-wrap: break-word !important;
          vertical-align: top !important;
          text-overflow: ellipsis !important;
          overflow: hidden !important;
        }

        .remove-item {
          display: none !important;
        }

        .items-table thead tr {
          background: #111827 !important;
        }

        .items-table th {
          background: #111827 !important;
          color: white !important;
          font-weight: 600 !important;
          font-size: 10px !important;
        }

        .item-row-even {
          background-color: #f9fafb !important;
        }

        .item-row-odd {
          background-color: #ffffff !important;
        }

        /* PDF specific layout fixes */
        .border-b-2.border-gray-900 {
          margin-bottom: 15px !important;
          padding-bottom: 10px !important;
        }

        .mb-6 {
          margin-bottom: 15px !important;
        }

        .mb-8 {
          margin-bottom: 20px !important;
        }

        .p-4,
        .p-3 {
          padding: 8px !important;
        }

        .space-y-1>*+* {
          margin-top: 3px !important;
        }

        .space-y-2>*+* {
          margin-top: 6px !important;
        }

        /* Signature area */
        #signatureArea {
          margin-top: 20px !important;
          page-break-inside: avoid !important;
        }

        /* Summary section adjustments */
        .summary-row {
          padding: 3px 0 !important;
        }

        /* Hide add item button and other controls */
        #addItemBtn,
        .pdf-hide,
        .print-hide,
        .no-print,
        .hide-in-pdf,
        button,
        .remove-item,
        [class*="arrow"],
        i[class*="arrow"] {
          display: none !important;
          visibility: hidden !important;
          width: 0 !important;
          height: 0 !important;
          margin: 0 !important;
          padding: 0 !important;
        }

        /* Ensure summary values are properly aligned in print */
        .summary-row {
          display: flex !important;
          justify-content: space-between !important;
          align-items: center !important;
          padding: 2px 0 !important;
        }

        .summary-value {
          text-align: right !important;
          white-space: nowrap !important;
        }

        .summary-label {
          text-align: left !important;
          flex: 1 !important;
        }

        /* Hide inactive summary rows in PDF */
        #discountRow[style*="display: none"],
        #shippingRow[style*="display: none"],
        #taxRow[style*="display: none"],
        .summary-row[style*="display: none"] {
          display: none !important;
          visibility: hidden !important;
          height: 0 !important;
          margin: 0 !important;
          padding: 0 !important;
          overflow: hidden !important;
        }

        /* Force hide when modes are none */
        body[data-discount-mode="none"] #discountRow,
        body[data-shipping-mode="none"] #shippingRow,
        body[data-tax-mode="none"] #taxRow {
          display: none !important;
        }

        /* Prevent table overflow */
        .border.border-gray-200.rounded-lg {
          border: 1px solid #e5e7eb !important;
          border-radius: 8px !important;
          overflow: hidden !important;
          margin-bottom: 10px !important;
        }

        /* Compact spacing for many items */
        .items-table tbody tr {
          height: auto !important;
          min-height: 20px !important;
        }

        .items-table tbody td {
          padding: 3px 4px !important;
          vertical-align: top !important;
          line-height: 1.1 !important;
        }

        /* Responsive font sizing based on content */
        .items-table tbody tr:nth-child(n+8) td {
          font-size: 9px !important;
          padding: 2px 3px !important;
        }

        .items-table tbody tr:nth-child(n+12) td {
          font-size: 8px !important;
          padding: 1px 2px !important;
        }

        #invoice-container,
        .pdf-container {
          max-width: 210mm !important;
          width: 210mm !important;
          margin: 0 auto !important;
          padding: 0 !important;
          overflow: visible !important;
        }
      }

      body.pdf-capture-mode .remove-item,
      body.pdf-capture-mode .resize-handle,
      body.pdf-capture-mode #addItemBtn,
      body.pdf-capture-mode .hide-in-pdf,
      body.pdf-capture-mode .pdf-hide,
      body.pdf-capture-mode .print-hide {
        display: none !important;
      }

      body.pdf-capture-mode #invoicePreview {
        animation: none !important;
        box-shadow: none !important;
        background: #ffffff !important;
        border-radius: 16px !important;
        box-sizing: border-box !important;
        min-height: 297mm !important;
        opacity: 1 !important;
        overflow: visible !important;
        padding: 8mm !important;
        transform: none !important;
        width: 210mm !important;
        max-width: 210mm !important;
      }

      body.pdf-capture-mode #invoice-container,
      body.pdf-capture-mode .pdf-container {
        width: 210mm !important;
        max-width: 210mm !important;
        margin: 0 auto !important;
        overflow: visible !important;
      }

      body.pdf-capture-mode #invoicePreview .invoice-header-container,
      body.pdf-capture-mode #invoicePreview .flex.flex-col.md\:flex-row,
      body.pdf-capture-mode #invoicePreview .flex.flex-col.lg\:flex-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
      }

      body.pdf-capture-mode #invoicePreview .invoice-header-container {
        justify-content: space-between !important;
      }

      body.pdf-capture-mode #invoicePreview .invoice-section {
        text-align: right !important;
      }

      body.pdf-capture-mode #invoicePreview .w-full.lg\:w-80 {
        width: 20rem !important;
      }

      body.pdf-capture-mode #invoicePreview .overflow-x-auto {
        overflow: visible !important;
      }

      body.pdf-capture-mode #invoicePreview .editable,
      body.pdf-capture-mode #invoicePreview .editable:hover,
      body.pdf-capture-mode #invoicePreview .editable:focus,
      body.pdf-capture-mode #invoicePreview [contenteditable="true"],
      body.pdf-capture-mode #invoicePreview [contenteditable="true"]:hover,
      body.pdf-capture-mode #invoicePreview [contenteditable="true"]:focus {
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
      }

      body.pdf-capture-mode #invoicePreview input {
        appearance: none !important;
        -webkit-appearance: none !important;
        -webkit-text-fill-color: #111827 !important;
        background: transparent !important;
        color: #111827 !important;
        height: auto !important;
        line-height: 1.35 !important;
        min-height: 18px !important;
        opacity: 1 !important;
        overflow: visible !important;
        padding: 0 !important;
        box-shadow: none !important;
        outline: none !important;
      }

      body.pdf-capture-mode #invoicePreview .invoice-date-input {
        min-width: 112px !important;
        width: 112px !important;
      }

      body.pdf-capture-mode .items-table th:last-child,
      body.pdf-capture-mode .items-table td:last-child {
        display: none !important;
      }

      @media (min-width: 769px) {
        body[data-tax-mode="none"][data-discount-mode="none"][data-shipping-mode="none"] .items-table {
          min-width: 0 !important;
          width: 100% !important;
        }

        body[data-tax-mode="none"][data-discount-mode="none"][data-shipping-mode="none"] .overflow-x-auto {
          overflow-x: hidden !important;
        }
      }

      .header {
        background: rgb(255, 255, 255);
        color: #374151;
        padding: 1rem 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        position: sticky;
        top: 0;
        z-index: 100;
        border-bottom: 1px solid #dadada;
      }

      .header-content {
        max-width: auto;
        margin: 0 auto;
        padding: 0 5rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .logo-section {
        display: flex;
        align-items: center !important;
        gap: 0.75rem;
      }

      .sidebar-toggle-btn {
        background: #f8fafc;
        border: 1px solid #e5e7eb;
        color: #374151;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 18px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      }

      .sidebar-toggle-btn:hover {
        background: #2563eb;
        color: white;
        border-color: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
      }

      .sidebar-toggle-btn:active {
        transform: translateY(0);
      }

      .sidebar-toggle-btn.active {
        background: #2563eb;
        color: white;
        border-color: #2563eb;
      }

      .logo {
        background: #2563eb;
        color: white;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: left !important;
        justify-content: left !important;
        font-weight: 700;
        font-size: 1.25rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      }

      .app-title {
        font-size: 1.5rem;
        font-weight: 600;
        letter-spacing: -0.025em;
      }

      .header-actions {
        display: flex;
        gap: 0.75rem;
        align-items: center;
      }

      .mobile-menu-btn {
        display: none;
        background: #2563eb;
        border: none;
        color: white;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 18px;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
      }

      .mobile-menu-btn:hover {
        background: #1e40af;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
      }

      .mobile-menu-btn:active {
        transform: translateY(0);
      }

      .btn-primary {
        background: #2563eb;
        color: white;
        border: none;
        padding: 0.75rem 1.25rem;
        border-radius: 8px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
        font-size: 14px;
        min-height: 44px;
        box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
      }

      .btn-primary:hover {
        background: #1e40af;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
      }

      .btn-primary:active {
        transform: translateY(0);
      }

      .btn-secondary {
        background: white;
        color: #374151;
        border: 1px solid #e5e7eb;
        padding: 0.75rem 1.25rem;
        border-radius: 8px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
        font-size: 14px;
        min-height: 44px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      }

      .btn-secondary:hover {
        background: #f8fafc;
        border-color: #2563eb;
        color: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      }

      .btn-secondary:active {
        transform: translateY(0);
      }

      .control-panel {
        background: rgba(237, 237, 237, 0.95);
        backdrop-filter: blur(10px);
        border-radius: 12px;
        padding: 0.8rem;
        display: flex;
        gap: 0.8rem;
        align-items: center;
        border: 1px solid rgba(226, 232, 240, 0.8);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
      }

      .control-btn {
        background: white;
        border: 1px solid #e5e7eb;
        color: #374151;
        padding: 0.625rem 1rem;
        border-radius: 8px;
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
        font-weight: 500;
        min-height: 40px;
        width: 116px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
      }

      .control-btn:hover {
        background: #f8fafc;
        border-color: #2563eb;
        color: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
      }

      .control-btn:active {
        transform: translateY(0);
      }

      .dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.75rem;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        min-width: 280px;
        max-height: 400px;
        overflow-y: auto;
        z-index: 9999;
        display: none;
        margin-top: 0.5rem;
      }

      .dropdown.show {
        display: block;
        animation: slideDown 0.2s ease;
      }

      @keyframes slideDown {
        from {
          opacity: 0;
          transform: translateY(-10px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .dropdown-item {
        padding: 0.75rem 1rem;
        border-radius: 6px;
        cursor: pointer;
        color: #374151;
        font-size: 0.9rem;
        font-weight: 500;
        transition: all 0.2s ease;
        min-height: 44px;
        display: flex;
        align-items: center;
      }

      .dropdown-item:hover {
        background: #f3f4f6;
        color: #2563eb;
        transform: translateX(2px);
      }

      .currency-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
      }

      .currency-flag {
        font-size: 1rem;
        line-height: 1;
        flex: 0 0 auto;
      }

      .currency-info {
        display: flex;
        flex-direction: column;
      }

      .currency-name {
        font-weight: 500;
      }

      .currency-code {
        font-size: 0.75rem;
        color: #6b7280;
      }

      .mobile-controls {
        display: none;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(226, 232, 240, 0.8);
        padding: 1rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        overflow: visible;
        position: sticky;
        top: 0;
        z-index: 250;
      }

      /* Mobile bottom nav + controls sheet */
      .mobile-bottom-nav {
        display: none;
      }

      .mobile-nav-wrapper input[type="radio"] {
        position: absolute;
        opacity: 0;
        pointer-events: none;
      }

      .mobile-bottom-nav-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 400;
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid rgba(226, 232, 240, 0.9);
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
        padding: 0.5rem 0.75rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
      }

      .mobile-bottom-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        padding: 0.5rem 0.25rem;
        border-radius: 12px;
        font-weight: 600;
        color: #374151;
        user-select: none;
        cursor: pointer;
      }

      .mobile-bottom-nav-btn i {
        font-size: 1.1rem;
      }

      .mobile-bottom-nav-btn span {
        font-size: 0.75rem;
      }

      .mobile-controls-sheet {
        position: sticky;
        top: 0;
        z-index: 600;
        overflow: visible;
      }

      .desktop-controls {
        position: sticky;
        top: 0;
        z-index: 600;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(226, 232, 240, 0.9);
      }

      .desktop-controls-inner {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0.75rem 1rem;
      }

      .desktop-controls-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
      }

      .desktop-controls-row>.relative {
        width: 116px;
      }

      .desktop-controls-row>.relative:has(#currencyBtn) {
        width: 116px;
      }

      .desktop-controls-row>.relative .control-btn {
        width: 100%;
      }

      .desktop-controls-spacer {
        flex: 1;
        min-width: 1rem;
      }

      .desktop-export-actions {
        display: flex;
        gap: 0.5rem;
        margin-left: auto;
        margin-right: 2.5rem;
      }

      @media (max-width: 1100px) {
        .desktop-export-actions {
          margin-right: 0;
        }
      }

      @media (max-width: 768px) {
        .desktop-controls {
          display: none !important;
        }
      }

      @media (max-width: 768px) {
        .mobile-nav-wrapper {
          display: block;
        }

        /* Keep content above bottom nav */
        body {
          padding-bottom: 76px;
        }

        /* Turn controls into a top sheet controlled by nav */
        .mobile-controls {
          display: block !important;
        }

        /* Default: show actions */
        .mobile-controls .sheet-actions,
        .mobile-controls .sheet-charges {
          display: none;
        }

        #mobileNavActions:checked~.mobile-controls-sheet .mobile-controls .sheet-actions {
          display: flex;
        }

        #mobileNavCharges:checked~.mobile-controls-sheet .mobile-controls .sheet-charges {
          display: flex;
        }

        #mobileNavSettings:checked~.mobile-controls-sheet .mobile-controls {
          display: none !important;
        }

        /* Highlight active nav */
        #mobileNavActions:checked~.mobile-bottom-nav-bar label[for="mobileNavActions"],
        #mobileNavCharges:checked~.mobile-bottom-nav-bar label[for="mobileNavCharges"],
        #mobileNavSettings:checked~.mobile-bottom-nav-bar label[for="mobileNavSettings"] {
          background: #111827;
          color: #ffffff;
        }
      }

      .mobile-btn-row {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        justify-content: center;
      }

      .mobile-btn-row>.relative {
        flex: 1 1 0;
        min-width: 0;
      }

      .mobile-btn-row:last-child {
        margin-bottom: 0;
      }

      .mobile-btn {
        flex: 1;
        min-width: 0;
        background: white;
        color: #2563eb;
        border: 1px solid #e5e7eb;
        padding: 0.875rem 1rem;
        border-radius: 8px;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        transition: all 0.2s ease;
        font-size: 0.875rem;
        min-height: 48px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
      }

      .mobile-btn:hover {
        background: #f8fafc;
        border-color: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
      }

      .mobile-btn:active {
        transform: translateY(0);
      }

      .mobile-btn.primary {
        background: #2563eb;
        color: white;
        border-color: #2563eb;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
      }

      .mobile-btn.primary:hover {
        background: #1e40af;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
      }

      .mobile-btn.primary:active {
        transform: translateY(0);
      }

      @media (min-width: 769px) {
        .control-panel {
          display: flex !important;
        }

        .mobile-controls {
          display: block !important;
        }

        .mobile-menu-btn {
          display: none !important;
        }

        .mobile-btn-row {
          justify-content: flex-start;
          flex-wrap: wrap;
          max-width: 1100px;
          margin-left: auto;
          margin-right: auto;
        }

        .mobile-btn {
          flex: 0 0 auto;
          min-width: 140px;
        }
      }

      #currencyBtn,
      #mobileCurrencyBtn {
        white-space: nowrap;
        overflow: hidden;
      }

      @media (max-width: 768px) {
        .mobile-menu-btn {
          display: flex !important;
        }

        .header-actions>.btn-primary,
        .header-actions>.btn-secondary,
        .control-panel {
          display: none !important;
        }

        .mobile-controls {
          display: block !important;
        }

        .app-title {
          font-size: 1.25rem;
        }

        .sidebar {
          z-index: 200;
        }

        .header-content {
          padding: 0 1rem;
        }

        .logo-section {
          flex: 1;
        }

        .sidebar-toggle-btn {
          display: none !important;
        }

        /* Mobile invoice preview improvements */
        .invoice-preview {
          font-size: 12px !important;
          line-height: 1.4 !important;
        }

        .invoice-preview * {
          font-size: 12px !important;
        }

        .invoice-preview .company-name {
          font-size: 14px !important;
        }

        .invoice-preview .invoice-title {
          font-size: 14px !important;
        }

        /* Mobile table improvements */
        .overflow-x-auto {
          overflow-x: scroll !important;
          -webkit-overflow-scrolling: touch !important;
        }

        .items-table {
          min-width: 600px !important;
        }

        /* Mobile summary section */
        .border.border-gray-200.rounded-lg {
          width: 100% !important;
          margin: 1rem 0 !important;
        }

        /* Mobile summary row improvements */
        .summary-row {
          font-size: 11px !important;
          padding: 4px 0 !important;
        }

        .summary-value {
          max-width: 100px !important;
          font-size: 11px !important;
        }

        .summary-label {
          font-size: 11px !important;
          margin-right: 4px !important;
        }

        /* Hide calculation elements on mobile for cleaner view */
        .hide-in-pdf {
          display: none !important;
        }

        /* Mobile dropdown fix */
        .mobile-controls .dropdown {
          position: absolute !important;
          top: 100% !important;
          left: 0 !important;
          right: 0 !important;
          width: 100% !important;
          max-width: none !important;
          z-index: 99999 !important;
          margin-top: 0.5rem !important;
        }

        .mobile-btn-row .relative {
          position: relative !important;
          overflow: visible !important;
        }
      }

      /* Invoice Preview Container Fixes */
      .invoice-preview {
        max-width: 210mm;
        min-height: 297mm;
        width: min(100%, 210mm);
        overflow: visible;
        box-sizing: border-box;
      }

      .invoice-date-input {
        font-variant-numeric: tabular-nums;
      }

      /* PDF Container Optimization */
      .pdf-container {
        max-width: 210mm;
        width: 100%;
        min-height: auto;
        padding: 0;
        box-sizing: border-box;
        font-family: 'Inter', system-ui, sans-serif;
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: transparent;
        margin: 0 auto;
        overflow-x: auto;
      }

      /* PDF generation temporary styles */
      .pdf-generating {
        width: 210mm !important;
        max-width: 210mm !important;
        padding: 15mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
        background: #ffffff !important;
        border-radius: 0 !important;
        box-shadow: none !important;
      }

      .pdf-generating .items-table {
        table-layout: fixed !important;
        width: 100% !important;
        font-size: 11px !important;
      }

      .page-break {
        page-break-before: always;
      }

      .no-break {
        page-break-inside: avoid;
      }

      /* Main content layout fixes */
      .main-content {
        overflow-x: hidden;
        width: 100%;
      }

      .flex-1 {
        min-width: 0;
        overflow-x: hidden;
        width: 100%;
      }

      /* Responsive table container */
      .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }

      /* Ensure inputs don't cause overflow */
      .items-table input {
        max-width: 100%;
        box-sizing: border-box;
      }

      /* Invoice container responsive fixes */
      #invoice-container {
        max-width: 210mm;
        overflow-x: visible;
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto;
      }

      @media print {
        .pdf-container {
          max-width: none !important;
          width: 100% !important;
          margin: 0 !important;
          padding: 0 !important;
          overflow: visible !important;
          height: auto !important;
          min-height: auto !important;
        }

        #invoice-container {
          max-width: none !important;
          overflow: visible !important;
          height: auto !important;
          margin: 0 !important;
          padding: 0 !important;
        }

        .invoice-preview {
          max-width: none;
          overflow: visible;
        }

        #invoice-container {
          max-width: none;
          overflow: visible;
        }
      }

      /* Professional Footer Styles */
      footer {
        background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
      }

      footer a {
        position: relative;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 0.5rem 0.75rem;
        border-radius: 6px;
      }

      footer a:hover {
        background: rgba(37, 99, 235, 0.1);
        transform: translateY(-1px);
      }

      footer a::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 50%;
        width: 0;
        height: 2px;
        background: #2563eb;
        transition: all 0.3s ease;
        transform: translateX(-50%);
      }

      footer a:hover::after {
        width: 80%;
      }

      /* Mobile Footer Styles */
      @media (max-width: 768px) {
        footer {
          padding: 1rem 0;
        }

        footer .max-w-6xl {
          padding: 0 1rem;
        }

        footer a {
          padding: 0.75rem 0.5rem;
          font-size: 0.875rem;
          text-align: center;
          min-height: 44px;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        footer .flex-wrap {
          gap: 0.5rem;
          justify-content: center;
        }

        footer .text-center p {
          font-size: 0.875rem;
          line-height: 1.5;
        }
      }

      /* Tablet Footer Styles */
      @media (min-width: 769px) and (max-width: 1024px) {
        footer a {
          padding: 0.625rem 1rem;
          font-size: 0.9rem;
        }

        footer .flex-wrap {
          gap: 1.5rem;
        }
      }

      /* Desktop Footer Enhancements */
      @media (min-width: 1025px) {
        footer {
          background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #ffffff 100%);
        }

        footer a {
          padding: 0.75rem 1.25rem;
          font-weight: 500;
        }

        footer .flex-wrap {
          gap: 2rem;
        }
      }

      /* Print Styles for Footer */
      @media print {
        footer {
          display: none !important;
        }
      }

      /* ================================================================
   MOBILE RESPONSIVE UPGRADE
   All rules below are additive — zero desktop layout changes
   ================================================================ */

      /* ── Header: mobile sidebar toggle button ── */
      .mobile-header-toggle {
        display: none;
        /* hidden on desktop */
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        min-height: 42px !important;
        border-radius: 10px;
        border: 1.5px solid #e5e7eb;
        background: #f8fafc;
        color: #374151;
        cursor: pointer;
        font-size: 20px;
        transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
      }

      .mobile-header-toggle:hover,
      .mobile-header-toggle:focus-visible {
        background: #111827;
        color: #ffffff;
        border-color: #111827;
        box-shadow: 0 4px 14px rgba(17, 24, 39, 0.22);
        outline: none;
      }

      .mobile-header-toggle:active {
        transform: scale(0.95);
      }

      .mobile-header-toggle[aria-expanded="true"] {
        background: #111827;
        color: #ffffff;
        border-color: #111827;
        box-shadow: 0 4px 14px rgba(17, 24, 39, 0.22);
      }

      /* Show only on mobile */
      @media (max-width: 768px) {
        .mobile-header-toggle {
          display: flex !important;
        }

        /* Header layout on mobile */
        .header-content {
          padding: 0 1rem !important;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 0.75rem;
        }

        .logo-section {
          flex: 1;
          min-width: 0;
        }

        .logo-img {
          height: 46px !important;
        }
      }

      /* ── Mobile Control Panel (sticky bottom bar) ── */
      .mobile-control-panel {
        display: none;
        /* hidden on desktop */
      }

      @media (max-width: 768px) {

        /* Show the new control panel */
        .mobile-control-panel {
          display: flex !important;
          position: fixed;
          bottom: 0;
          left: 0;
          right: 0;
          z-index: 500;
          align-items: center;
          gap: 0.5rem;
          padding: 0.65rem 0.875rem;
          padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
          background: rgba(255, 255, 255, 0.97);
          backdrop-filter: blur(24px);
          -webkit-backdrop-filter: blur(24px);
          border-top: 1px solid rgba(226, 232, 240, 0.95);
          box-shadow:
            0 -4px 24px rgba(0, 0, 0, 0.08),
            0 -1px 0 rgba(226, 232, 240, 0.5);
        }

        /* Hide the old mobile bottom nav bar — new panel replaces it */
        .mobile-bottom-nav-bar,
        .mobile-nav-wrapper {
          display: none !important;
        }

        /* Body bottom padding to clear the control panel */
        body {
          padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
        }
      }

      /* ── MCP: Individual Buttons ── */
      .mcp-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 0.5rem 0.4rem;
        min-height: 52px !important;
        min-width: 0;
        border: 1.5px solid #e5e7eb;
        border-radius: 12px;
        background: #ffffff;
        color: #374151;
        font-size: 0.7rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        white-space: nowrap;
        line-height: 1;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
        flex: 1;
        letter-spacing: 0.01em;
      }

      .mcp-btn i {
        font-size: 1.2rem;
        line-height: 1;
      }

      .mcp-btn span {
        font-size: 0.68rem;
        font-weight: 600;
      }

      .mcp-btn:active {
        transform: scale(0.95);
      }

      /* New button */
      .mcp-new {
        color: #374151;
        border-color: #e5e7eb;
        background: #f8fafc;
      }

      .mcp-new:hover,
      .mcp-new:focus-visible {
        background: #f1f5f9;
        border-color: #94a3b8;
        color: #111827;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        outline: none;
      }

      /* Export PDF — primary action, most prominent */
      .mcp-primary {
        flex: 1.6;
        /* takes more space */
        background: #111827;
        color: #ffffff;
        border-color: #111827;
        box-shadow: 0 2px 10px rgba(17, 24, 39, 0.25);
        font-size: 0.72rem;
      }

      .mcp-primary:hover,
      .mcp-primary:focus-visible {
        background: #1e293b;
        border-color: #1e293b;
        box-shadow: 0 4px 16px rgba(17, 24, 39, 0.35);
        outline: none;
      }

      .mcp-primary i {
        font-size: 1.3rem;
      }

      /* Options button */
      .mcp-options {
        color: #374151;
        border-color: #e5e7eb;
      }

      .mcp-options:hover,
      .mcp-options:focus-visible {
        background: #f1f5f9;
        border-color: #94a3b8;
        color: #111827;
        outline: none;
      }

      .mcp-options.active {
        background: #111827;
        color: #ffffff;
        border-color: #111827;
        box-shadow: 0 2px 10px rgba(17, 24, 39, 0.22);
      }

      /* ── MCP: Options Wrapper ── */
      .mcp-options-wrapper {
        position: relative;
        flex: 1;
        display: flex;
      }

      .mcp-options-wrapper .mcp-btn {
        width: 100%;
      }

      /* ── MCP: Upward Dropdown ── */
      .mcp-dropdown {
        position: absolute;
        bottom: calc(100% + 8px);
        right: 0;
        min-width: 210px;
        background: #ffffff;
        border: 1px solid rgba(226, 232, 240, 0.9);
        border-radius: 16px;
        box-shadow:
          0 20px 60px rgba(0, 0, 0, 0.15),
          0 8px 24px rgba(0, 0, 0, 0.08),
          0 0 0 1px rgba(255, 255, 255, 0.5) inset;
        overflow: hidden;
        z-index: 600;

        /* Hidden state */
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px) scale(0.96);
        transform-origin: bottom right;
        transition:
          opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
          transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
          visibility 0.2s;
        pointer-events: none;
      }

      .mcp-dropdown.show {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
      }

      /* Dropdown header label */
      .mcp-dropdown-header {
        font-size: 0.7rem;
        font-weight: 700;
        color: #9ca3af;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        padding: 0.7rem 1rem 0.4rem;
        border-bottom: 1px solid #f1f5f9;
        user-select: none;
      }

      /* ── MCP: Dropdown Items ── */
      .mcp-dropdown-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        padding: 0.75rem 1rem;
        background: transparent;
        border: none;
        border-radius: 0;
        color: #111827;
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        text-align: left;
        min-height: 48px !important;
        transition: background 0.15s ease, color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
      }

      .mcp-dropdown-item:hover,
      .mcp-dropdown-item:focus-visible {
        background: #f8fafc;
        color: #111827;
        outline: none;
      }

      .mcp-dropdown-item:active {
        background: #f1f5f9;
      }

      .mcp-item-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: #f1f5f9;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 0.95rem;
        color: #374151;
        transition: background 0.15s ease;
      }

      .mcp-dropdown-item:hover .mcp-item-icon {
        background: #e2e8f0;
      }

      .mcp-item-label {
        flex: 1;
        font-size: 0.875rem;
        font-weight: 500;
      }

      .mcp-item-arrow {
        font-size: 1.1rem;
        color: #d1d5db;
        flex-shrink: 0;
      }

      .mcp-divider {
        height: 1px;
        background: #f1f5f9;
        margin: 0.2rem 0;
        border: none;
      }

      /* ── Responsive Invoice Preview (mobile) ── */
      @media (max-width: 768px) {

        /* Main content area padding */
        .flex-1.p-6 {
          padding: 0.75rem 0.5rem !important;
        }

        .max-w-full.mx-auto.px-8 {
          padding-left: 0.25rem !important;
          padding-right: 0.25rem !important;
          max-width: 100% !important;
        }

        /* Invoice card itself */
        #invoicePreview {
          padding: 1rem 0.75rem !important;
          border-radius: 10px !important;
          min-height: auto !important;
        }

        /* Invoice header stacks on mobile */
        .invoice-header-container {
          flex-direction: column !important;
          gap: 1rem !important;
        }

        .invoice-section {
          text-align: right !important;
          width: 100% !important;
        }

        /* Bill To / Ship To section */
        .flex.flex-col.md\:flex-row {
          flex-direction: column !important;
          gap: 1rem !important;
        }

        /* Bottom section (notes + summary) */
        .flex.flex-col.lg\:flex-row {
          flex-direction: column !important;
          gap: 1rem !important;
        }

        /* Summary panel full width on mobile */
        .w-full.lg\:w-80 {
          width: 100% !important;
          max-width: 100% !important;
          min-width: 0 !important;
        }

        /* Table horizontal scroll */
        .overflow-x-auto {
          overflow-x: scroll !important;
          -webkit-overflow-scrolling: touch !important;
          border-radius: 8px;
        }

        .items-table {
          min-width: 560px !important;
        }

        /* Add item button */
        #addItemBtn {
          font-size: 12px !important;
          padding: 8px 12px !important;
          min-height: 40px !important;
        }
      }

      /* ── Responsive SEO Intro ── */
      @media (max-width: 640px) {
        #seoIntro .seo-copy {
          grid-template-columns: 1fr !important;
          gap: 1rem !important;
        }

        #seoIntro .max-w-6xl {
          padding-left: 1rem;
          padding-right: 1rem;
        }
      }

      /* ── Desktop: Hide mobile-only elements ── */
      @media (min-width: 769px) {
        .mobile-control-panel {
          display: none !important;
        }

        .mobile-header-toggle {
          display: none !important;
        }
      }

      /* ================================================================
   CRITICAL OVERRIDES — must be last to win specificity
   Fixing sidebar toggle and Options dropdowns
   ================================================================ */
      @media (max-width: 768px) {

        /* 1. Mobile Sidebar Fixes */
        .sidebar {
          position: fixed !important;
          top: 0 !important;
          left: 0 !important;
          bottom: 0 !important;
          width: 280px !important;
          max-width: 85vw !important;
          height: 100% !important;
          z-index: 9999 !important;
          transform: translateX(-100%) !important;
          transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
          background: white !important;
          display: block !important;
          visibility: visible !important;
          opacity: 1 !important;
        }

        .sidebar.open {
          transform: translateX(0) !important;
        }

        /* 2. Hide old bottom nav completely */
        .mobile-bottom-nav-bar,
        .mobile-nav-wrapper {
          display: none !important;
        }

        /* 3. Visually hide the old mobile controls without display:none 
        so the JS-driven dropdowns inside them can still be shown */
        .mobile-controls-sheet,
        .mobile-controls,
        .mobile-controls .mobile-btn-row,
        .mobile-controls .relative,
        .desktop-controls,
        .desktop-controls-inner,
        .desktop-controls-row,
        .desktop-controls-row>.relative {
          position: fixed !important;
          top: 0 !important;
          left: 0 !important;
          width: 0 !important;
          height: 0 !important;
          padding: 0 !important;
          margin: 0 !important;
          border: none !important;
          visibility: hidden !important;
          pointer-events: none !important;
          z-index: 10000 !important;
          background: transparent !important;
          box-shadow: none !important;
          overflow: visible !important;
          display: block !important;
          /* Override the old display:none */
          backdrop-filter: none !important;
          /* Fix containing block for fixed children */
          -webkit-backdrop-filter: none !important;
          transform: none !important;
        }

        /* 4. Ensure the new panel is always on top */
        .mobile-control-panel {
          display: flex !important;
          z-index: 9000 !important;
        }

        /* 5. Make dropdowns visible and styled as centered modals on mobile */
        .mobile-controls .dropdown,
        .desktop-controls .dropdown {
          visibility: visible !important;
          position: fixed !important;
          top: 50% !important;
          left: 50% !important;
          transform: translate(-50%, -50%) !important;
          width: 90vw !important;
          max-width: 350px !important;
          background: white !important;
          z-index: 10001 !important;
          box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
          pointer-events: auto !important;
          border-radius: 12px !important;
          display: none !important;
          /* overridden by .show */
          padding: 8px !important;
        }

        .mobile-controls .dropdown .dropdown-item,
        .desktop-controls .dropdown .dropdown-item {
          color: #111827 !important;
          /* Ensure text is dark and professional */
          font-size: 15px !important;
          padding: 12px 16px !important;
          border-radius: 8px !important;
        }

        .mobile-controls .dropdown .dropdown-item:hover,
        .desktop-controls .dropdown .dropdown-item:hover {
          background-color: #f3f4f6 !important;
          color: #2563eb !important;
        }

        .mobile-controls .dropdown.show,
        .desktop-controls .dropdown.show {
          display: block !important;
          animation: modalPop 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
        }

        /* Add a backdrop when dropdown is shown */
        body.modal-open::after {
          content: '';
          position: fixed;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background: rgba(0, 0, 0, 0.5);
          z-index: 10000;
        }

        @keyframes modalPop {
          from {
            opacity: 0;
            transform: translate(-50%, -45%);
          }

          to {
            opacity: 1;
            transform: translate(-50%, -50%);
          }
        }
      }