  :root {
    --primary-color: #222;
    --secondary-color: #286090;
    --accent-color: #b3e5fc;
    --success-color: #43a047;
    --warning-color: #ffe082;
    --info-color: #5bc0de;
    --danger-color: #dc3545;
    --background-color: #f5f5f5;
    --container-bg: #fff;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #e2e8f0;
    --table-bg: #f8fafd;
    --table-header-bg: #e3eaf5;
    --table-border: #e2e8f0;
    
    /* Theme colors */
    --theme-bg: var(--background-color);
    --theme-surface: var(--container-bg);
    --theme-text: var(--text-primary);
    --theme-text-secondary: var(--text-secondary);
    --theme-border: var(--border-color);
    
    /* Responsive breakpoints */
    --mobile-sm: 480px;
    --mobile-md: 768px;
    --tablet: 1024px;
    --desktop: 1200px;
  }

  /* Dark theme variables */
  [data-theme="dark"] {
    --primary-color: #1a1a1a;
    --background-color: #121212;
    --container-bg: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --table-bg: #2a2a2a;
    --table-header-bg: #333333;
    --table-border: #404040;
    --accent-color: #81d4fa;
    --secondary-color: #3498db;
    
    /* Update theme colors for dark mode */
    --theme-bg: var(--background-color);
    --theme-surface: var(--container-bg);
    --theme-text: var(--text-primary);
    --theme-text-secondary: var(--text-secondary);
    --theme-border: var(--border-color);
  }

  /* Reset and base styles */
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html, body {
    height: 100%;
    margin: 0;
    padding: 0;
  }

  body {
    background: var(--theme-bg);
    color: var(--theme-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
  }

  /* Enhanced header with better responsive behavior */
  .header {
    background: var(--primary-color);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    position: relative;
    min-height: 60px;
    flex-wrap: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  .header .logo {
    display: flex;
    align-items: center;
    font-size: 1.4em;
    font-weight: 600;
    flex: 0 0 auto;
    margin-right: 16px;
  }

  .header .logo img {
    height: 132px;
    width: 132px;
    margin-right: 8px;
    object-fit: contain;
  }

  .header-title-center {
    flex: 1 1 0;
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--accent-color);
    margin: 0;
    z-index: 1;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header .right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
  }
.header .back-link,
.header .back-link:link,
.header .back-link:visited,
.header .back-link:active {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  font-size: 0.95em;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: background 0.2s, transform 0.15s;
}
.header .back-link:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(-2px);
  color: #fff;
}
.header .back-link:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}
.header .back-link .arrow {
  font-size: 1.1em;
  line-height: 1;
}

  .side-menu .side-header {
    background: #204d74;
    padding: 20px 18px 16px 18px;
    font-size: 1.1em;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .side-menu .side-header img {
    height: 28px;
    width: 28px;
    object-fit: contain;
  }

  .business-name {
    font-size: 0.9em;
    color: var(--accent-color);
    padding: 0 18px 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 8px;
    font-weight: 500;
  }

  .side-menu .side-links {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
    min-height: 0;
    padding-bottom: 20px;
  }

  .side-menu .side-link {
    color: #fff;
    text-decoration: none;
    padding: 14px 16px;
    font-size: 1em;
    border-radius: 6px;
    margin: 1px 0;
    font-weight: 500;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    word-break: break-word;
    min-height: 44px;
    flex-shrink: 0;
  }

  .side-menu .side-link.active,
  .side-menu .side-link:hover,
  .side-menu .side-link:focus {
    background: #204d74;
    outline: none;
  }

  /* Theme dropdown in side menu */
  .theme-dropdown {
    position: relative;
    margin: 4px 12px 8px 12px;
    flex-shrink: 0;
  }

  .theme-toggle {
    color: #fff;
    text-decoration: none;
    padding: 14px 16px;
    font-size: 1em;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
  }

  .theme-toggle:hover,
  .theme-toggle:focus {
    background: #204d74;
    outline: none;
  }

  .theme-toggle .arrow {
    transition: transform 0.2s ease;
    font-size: 0.8em;
  }

  .theme-toggle.active .arrow {
    transform: rotate(180deg);
  }

  .theme-options {
    display: none;
    background: #1a4a6b;
    border-radius: 6px;
    margin-top: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  .theme-options.show {
    display: block;
    animation: slideDown 0.2s ease;
  }

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

  .theme-option {
    color: #fff;
    text-decoration: none;
    padding: 12px 20px;
    font-size: 0.95em;
    font-weight: 500;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    min-height: 40px;
  }

  .theme-option:hover,
  .theme-option:focus {
    background: #204d74;
    outline: none;
  }

  .theme-option.active {
    background: #204d74;
    position: relative;
  }

  .theme-option.active::after {
    content: '✓';
    margin-left: auto;
    font-weight: bold;
    color: var(--accent-color);
  }

  .theme-icon {
    font-size: 1.1em;
    width: 16px;
    text-align: center;
  }

  /* Enhanced container */
  .container {
    max-width: var(--desktop);
    margin: 24px auto;
    background: var(--theme-surface);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 24px;
    min-height: 60vh;
    flex: 1 0 auto;
    width: calc(100% - 32px);
    transition: background-color 0.3s ease;
  }

  /* Form styling */
  .form-header {
    margin-bottom: 32px;
    border-bottom: 2px solid var(--theme-border);
    padding-bottom: 16px;
  }

  .form-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: var(--theme-text);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .form-section {
    margin-bottom: 32px;
  }

  .form-section h3 {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--theme-text);
    margin: 0 0 16px 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border);
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--theme-text);
    font-size: 0.95em;
  }

  .form-input,
  .form-select,
  .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 0.95em;
    transition: border-color 0.2s;
    font-family: inherit;
  }

  .form-textarea {
    resize: vertical;
    min-height: 100px;
  }

  .form-input:focus,
  .form-select:focus,
  .form-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(40, 96, 144, 0.1);
  }

  /* Items table */
  .items-section {
    margin-bottom: 24px;
  }

  .items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
  }

  .items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--table-bg);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
  }

  .items-table th,
  .items-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--table-border);
  }

  .items-table th {
    background: var(--table-header-bg);
    font-weight: 600;
    color: var(--theme-text);
  }

  .items-table td {
    color: var(--theme-text);
  }

  .items-table input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--theme-border);
    border-radius: 4px;
    background: var(--theme-surface);
    color: var(--theme-text);
  }

  .items-table .quantity-input,
  .items-table .price-input {
    width: 80px;
  }

  .items-table .remove-btn {
    background: var(--danger-color);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
  }

  .items-table .remove-btn:hover {
    background: #c62828;
  }

  .add-item-btn {
    background: var(--success-color);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
  }

  .add-item-btn:hover {
    background: #2e7d32;
  }

  /* Totals section */
  .totals-section {
    background: var(--table-bg);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
  }

  .totals-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    max-width: 400px;
    margin-left: auto;
  }

  .total-row {
    display: contents;
  }

  .total-label {
    text-align: right;
    font-weight: 500;
    color: var(--theme-text);
  }

  .total-value {
    text-align: right;
    font-weight: 600;
    color: var(--secondary-color);
    min-width: 100px;
  }

  .total-row.grand-total .total-label,
  .total-row.grand-total .total-value {
    font-size: 1.2em;
    padding-top: 12px;
    border-top: 2px solid var(--theme-border);
  }

  /* Action buttons */
  .form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 24px;
    border-top: 2px solid var(--theme-border);
  }

  .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
  }

  .btn-primary {
    background: var(--secondary-color);
    color: #fff;
  }

  .btn-primary:hover {
    background: #1e5490;
    transform: translateY(-1px);
  }

  .btn-success {
    background: var(--success-color);
    color: #fff;
  }

  .btn-success:hover {
    background: #2e7d32;
    transform: translateY(-1px);
  }

  .btn-info {
    background: var(--info-color);
    color: #fff;
  }

  .btn-info:hover {
    background: #31b0d5;
    transform: translateY(-1px);
  }

  .btn-warning {
    background: #ff9800;
    color: #fff;
  }

  .btn-warning:hover {
    background: #f57c00;
    transform: translateY(-1px);
  }

  .btn-secondary {
    background: rgba(0, 0, 0, 0.1);
    color: var(--theme-text);
    border: 1px solid var(--theme-border);
  }

  .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.15);
  }

  /* Status message */
  .status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: #fff;
    font-weight: 600;
    animation: fadeInOut 4s ease;
    z-index: 1000;
    max-width: 300px;
  }

  .status-message.success {
    background: var(--success-color);
  }

  .status-message.error {
    background: var(--danger-color);
  }

  .status-message.info {
    background: var(--info-color);
  }

  @keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-20px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
  }

  /* Loading overlay */
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
  }

  .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  .loading-text {
    margin-left: 15px;
    color: #fff;
    font-weight: 600;
  }

  /* Enhanced footer */
  .footer {
    background: var(--primary-color);
    color: var(--accent-color);
    font-size: 0.9em;
    text-align: center;
    padding: 20px 16px;
    margin-top: auto;
    letter-spacing: 0.3px;
    border-top: 1px solid #2c5070;
    width: 100%;
  }

  .footer a {
    color: var(--accent-color);
    text-decoration: none;
    margin: 0 8px;
    font-weight: 500;
    transition: opacity 0.2s;
  }

  .footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
  }

  .footer .sep {
    color: #4fc3f7;
    font-weight: 700;
    margin: 0 8px;
  }

  /* Responsive Design */
  @media (max-width: 768px) {
    .container {
      margin: 12px auto;
      padding: 16px;
      width: calc(100% - 16px);
    }

    .form-grid {
      grid-template-columns: 1fr;
    }

    .form-actions {
      justify-content: stretch;
    }

    .btn {
      width: 100%;
      justify-content: center;
    }

    .items-table {
      font-size: 0.9em;
    }

    .items-table th,
    .items-table td {
      padding: 8px 6px;
    }

    .items-table .quantity-input,
    .items-table .price-input {
      width: 60px;
    }
  }

  @media (max-width: 480px) {
    .header-title-center {
      font-size: 1em;
    }

    .form-header h2 {
      font-size: 1.3em;
    }

    .form-section h3 {
      font-size: 1.1em;
    }

    .items-table {
      font-size: 0.85em;
    }

    .totals-grid {
      font-size: 0.9em;
    }
  }
/* Customer autocomplete */
.autocomplete-wrap { position: relative; }
.customer-suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  margin: 4px 0 0; padding: 0; list-style: none;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #d0d7de);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  max-height: 280px; overflow-y: auto;
  z-index: 9999;
}
.customer-suggestion {
  padding: 10px 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid var(--border-color, #eee);
}
.customer-suggestion:last-child { border-bottom: none; }
.customer-suggestion:hover,
.customer-suggestion.active { background: var(--hover-bg, #f3f6fa); }
.customer-suggestion .cs-name { font-weight: 600; color: var(--text-primary, #111); }
.customer-suggestion .cs-meta { font-size: 12px; color: var(--text-muted, #666); }
.customer-suggestions-empty {
  padding: 10px 12px; color: var(--text-muted, #666);
  font-style: italic; font-size: 13px;
}
