:root {
    --primary-color: #222;
    --secondary-color: #286090;
    --accent-color: #b3e5fc;
    --success-color: #43a047;
    --warning-color: #ffe082;
    --info-color: #5bc0de;
    --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 .welcome {
    font-size: 0.9em;
    margin-right: 8px;
    white-space: nowrap;
  }

  .header .logout {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.9em;
    margin-left: 6px;
    transition: opacity 0.2s;
  }

  .header .logout:hover {
    opacity: 0.8;
  }

  .header .garage {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1em;
    white-space: nowrap;
  }

  .header .garage img {
    height: 24px;
    width: 24px;
    margin-right: 6px;
    object-fit: contain;
  }
  /* Theme dropdown in side menu */
  .theme-dropdown {
    position: relative;
    margin: 4px 12px 8px 12px;
    flex-shrink: 0; /* Prevent dropdown from shrinking */
  }

  .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;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
  }

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

  .topbar .top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .topbar .top-actions button,
  .add-job-btn {
    background: var(--warning-color);
    color: #444;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95em;
    min-height: 40px;
    white-space: nowrap;
  }

  .topbar .top-actions button:last-child,
  .add-job-btn {
    background: var(--success-color);
    color: #fff;
  }

  .topbar .top-actions button:hover,
  .add-job-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  .add-job-btn {
    margin-bottom: 16px;
    align-self: flex-end;
  }

  /* Enhanced table styling — matches invoice.css for theme parity */
  .table-container {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    /* Enhanced mobile scrolling */
    -webkit-overflow-scrolling: touch;
  }

  .jobs-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--theme-surface);
    font-size: 0.95em;
    min-width: 800px;
    transition: background-color 0.3s ease;
  }

  .jobs-table th,
  .jobs-table td {
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
  }

  .jobs-table th {
    background: var(--table-header-bg);
    color: var(--theme-text);
    font-weight: 600;
    border-bottom: 2px solid var(--theme-border);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color 0.3s ease;
  }

  .jobs-table td {
    color: var(--theme-text);
    border-bottom: 1px solid var(--theme-border);
    transition: color 0.3s ease;
  }

  .jobs-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
  }

  .jobs-table tbody tr:hover {
    background: var(--table-bg);
  }

  .jobs-table td a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
  }

  .jobs-table td a:hover {
    text-decoration: underline;
  }

  .jobs-table td .edit-link {
    color: var(--secondary-color);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
  }

  .jobs-table td .edit-link:hover {
    background: var(--table-bg);
    text-decoration: none;
  }

  .jobs-table tr:last-child td {
    border-bottom: none;
  }

  /* Status indicators — rgba overlays + theme vars, safe in both light and dark mode */
  .status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    text-align: center;
    min-width: 60px;
    display: inline-block;
    white-space: nowrap;
  }

  .status.pending {
    background: rgba(255, 193, 7, 0.1);
    color: #f57c00;
    border: 1px solid rgba(255, 193, 7, 0.3);
  }

  .status.in-progress {
    background: rgba(33, 150, 243, 0.1);
    color: #1976d2;
    border: 1px solid rgba(33, 150, 243, 0.3);
  }

  .status.completed {
    background: rgba(67, 160, 71, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(67, 160, 71, 0.3);
  }

  /* 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 */
  
  /* Large tablets and small desktops */
  @media (max-width: 1024px) {
    .container {
      margin: 16px auto;
      padding: 20px;
      width: calc(100% - 24px);
    }
    
    .header-title-center {
      font-size: 1.1em;
    }
    
    .side-menu {
      width: 280px;
      max-width: 80vw;
    }
  }

@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
    min-height: 56px;
  }
  
  .header .logo {
    font-size: 1.2em;
    margin-right: 12px;
  }
  .header-title-center {
    font-size: 1em;
  }
    
    .header .welcome {
      font-size: 0.85em;
    }
    
    .header .garage {
      font-size: 0.9em;
    }
    
    .container {
      margin: 12px auto;
      padding: 16px;
      width: calc(100% - 16px);
      border-radius: 6px;
    }
    
    .topbar {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
    }
    
    .topbar h2 {
      font-size: 1.3em;
    }
    
    .add-job-btn {
      align-self: stretch;
      margin-bottom: 12px;
    }
    
    .jobs-table {
      font-size: 0.9em;
    }
    
    .jobs-table th,
    .jobs-table td {
      padding: 10px 8px;
    }
    
    .side-menu {
      width: 300px;
      max-width: 85vw;
    }
  }

  /* Mobile phones */
  @media (max-width: 480px) {
    body {
      font-size: 14px;
    }
    
    .header {
      padding: 8px 12px;
      min-height: 52px;
    }
    
    .header .logo {
      font-size: 1.1em;
      margin-right: 8px;
    }

    .header-title-center {
      font-size: 0.9em;
      letter-spacing: 0.2px;
    }
    
    .header .welcome {
      display: none;
    }
    
    .header .garage {
      font-size: 0.85em;
    }
    
    .header .garage img {
      height: 20px;
      width: 20px;
    }
    
    .burger {
      width: 40px;
      height: 40px;
      margin-left: 8px;
    }
    
    .container {
      margin: 8px auto;
      padding: 12px;
      width: calc(100% - 12px);
      border-radius: 4px;
    }
    
    .topbar h2 {
      font-size: 1.2em;
    }
    
    .topbar .top-actions {
      width: 100%;
    }
    
    .topbar .top-actions button {
      flex: 1;
      font-size: 0.9em;
      padding: 8px 12px;
    }
    
    .add-job-btn {
      font-size: 0.95em;
      padding: 12px 16px;
    }
    
    .jobs-table {
      font-size: 0.85em;
      min-width: 700px;
    }
    
    .jobs-table th,
    .jobs-table td {
      padding: 8px 6px;
    }
    
    .side-menu {
      width: 280px;
      max-width: 90vw;
      /* Enhanced mobile scrolling */
      height: calc(100vh - env(safe-area-inset-top));
      height: calc(100dvh - env(safe-area-inset-top));
    }
    
    .side-menu .side-links {
      /* Extra padding for mobile scrolling */
      padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    .side-menu .side-link {
      padding: 12px 14px;
      font-size: 0.95em;
    }
    
    .footer {
      padding: 16px 12px;
      font-size: 0.85em;
    }
    
    .footer a {
      display: inline-block;
      margin: 4px 6px;
    }
  }

  /* Very small phones */
  @media (max-width: 360px) {
    .header-title-center {
      font-size: 0.8em;
    }
    
    .side-menu {
      width: 260px;
      max-width: 95vw;
    }
    
    .container {
      padding: 10px;
      width: calc(100% - 8px);
    }
    
    .jobs-table {
      min-width: 650px;
    }
  }

  /* iOS specific fixes for menu scrolling */
  @supports (-webkit-touch-callout: none) {
    .side-menu {
      /* Fix for iOS Safari viewport units */
      height: -webkit-fill-available;
    }
    
    /* Prevent bounce scrolling on body when menu is open */
    body.menu-open {
      position: fixed;
      width: 100%;
      overflow: hidden;
    }
  }

  /* Print styles */
  @media print {
    .header,
    .burger,
    .side-menu,
    .side-menu-backdrop,
    .footer,
    .add-job-btn,
    .topbar .top-actions {
      display: none !important;
    }
    
    .container {
      margin: 0;
      padding: 0;
      box-shadow: none;
      max-width: none;
      width: 100%;
    }
    
    .jobs-table {
      font-size: 12px;
    }
  }

  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .header,
    .side-menu,
    .footer {
      border: 1px solid;
    }
    
    .jobs-table th,
    .jobs-table td {
      border: 1px solid;
    }
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
