/* CSS Variables for theming */
    :root {
      /* Light mode */
      --bg-primary: #ffffff;
      --bg-secondary: #f8fafc;
      --bg-tertiary: #f1f5f9;
      --bg-sidebar: #ffffff;
      --bg-input: #ffffff;
      --bg-auto: #f8fafc;
      --bg-table-header: #f8fafc;
      --bg-table-row: #ffffff;
      --bg-table-row-hover: #f1f5f9;
      --text-primary: #0f172a;
      --text-secondary: #475569;
      --text-tertiary: #64748b;
      --text-inverse: #ffffff;
      --border-light: #e2e8f0;
      --border-input: #e2e8f0;
      --border-focus: #0f172a;
      --border-error: #ef4444;
      --accent: #0f172a;
      --accent-light: #f1f5f9;
      --shadow: rgba(0, 0, 0, 0.02);
      --status-bg: #f8fafc;
      --status-border: #e2e8f0;
      --nav-hover: #f1f5f9;
      --floating-label-bg: #ffffff;
      --sidebar-width: 240px;
      --header-height: 64px;
      --table-border: #e2e8f0;
      /* custom dropdown extras */
      --dropdown-bg: #ffffff;
      --dropdown-hover: #f1f5f9;
      --dropdown-border: #e2e8f0;
    }

    /* Dark mode */
    [data-theme="dark"] {
      --bg-primary: #0f172a;
      --bg-secondary: #1e293b;
      --bg-tertiary: #334155;
      --bg-sidebar: #1e293b;
      --bg-input: #1e293b;
      --bg-auto: #334155;
      --bg-table-header: #1e293b;
      --bg-table-row: #0f172a;
      --bg-table-row-hover: #1e293b;
      --text-primary: #f1f5f9;
      --text-secondary: #cbd5e1;
      --text-tertiary: #94a3b8;
      --text-inverse: #0f172a;
      --border-light: #334155;
      --border-input: #475569;
      --border-focus: #94a3b8;
      --border-error: #f87171;
      --accent: #94a3b8;
      --accent-light: #334155;
      --shadow: rgba(0, 0, 0, 0.3);
      --status-bg: #1e293b;
      --status-border: #334155;
      --nav-hover: #334155;
      --floating-label-bg: #1e293b;
      --table-border: #334155;
      --dropdown-bg: #1e293b;
      --dropdown-hover: #334155;
      --dropdown-border: #475569;
    }

    /* Custom scrollbar */
    ::-webkit-scrollbar {
      width: 3px;
      height: 3px;
    }

    ::-webkit-scrollbar-track {
      background: #f5f5f7cc;
    }

    ::-webkit-scrollbar-thumb {
      background-color: #999;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      background: var(--bg-secondary);
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      line-height: 1.5;
      min-height: 100vh;
      transition: background-color 0.2s ease;
    }

    /* Dashboard layout */
    .dashboard {
      display: flex;
      min-height: 100vh;
    }

    /* Sidebar */
    .sidebar {
      width: var(--sidebar-width);
      background: var(--bg-sidebar);
      border-right: 1px solid var(--border-light);
      padding: 2rem 1rem;
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      overflow-y: auto;
      transition: background-color 0.2s ease, border-color 0.2s ease;
    }

    .company-logo {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0 1rem;
      margin-bottom: 2.5rem;
    }

    .logo-icon {
      font-size: 2rem;
      color: var(--accent);
    }

    .company-name {
      font-weight: 600;
      font-size: 1.1rem;
      color: var(--text-primary);
      letter-spacing: -0.02em;
    }

    .nav-vertical {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

    .nav-item {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.75rem 1rem;
      border-radius: 12px;
      color: var(--text-secondary);
      font-size: 0.9rem;
      font-weight: 480;
      cursor: pointer;
      transition: all 0.2s ease;
      border: none;
      background: transparent;
      width: 100%;
      text-align: left;
      text-decoration: none;
    }

    .nav-item i {
      font-size: 1.25rem;
    }

    .nav-item:hover {
      background: var(--nav-hover);
      color: var(--text-primary);
    }

    .nav-item.active {
      background: var(--accent-light);
      color: var(--text-primary);
      font-weight: 500;
    }

    /* Main content */
    .main-content {
      flex: 1;
      margin-left: var(--sidebar-width);
      min-height: 100vh;
      background: var(--bg-primary);
      transition: background-color 0.2s ease;
    }

    /* Top bar - no search on other pages */
    .top-bar {
      height: var(--header-height);
      border-bottom: 1px solid var(--border-light);
      display: flex;
      align-items: center;
      justify-content: flex-end;
      padding: 0 2rem;
      background: var(--bg-primary);
      transition: background-color 0.2s ease, border-color 0.2s ease;
    }

    /* Theme toggle - icons only */
    .theme-toggle {
      display: flex;
      align-items: center;
      gap: 0.25rem;
      background: var(--bg-tertiary);
      padding: 0.25rem;
      border-radius: 40px;
      border: 1px solid var(--border-input);
    }

    .theme-btn {
      background: transparent;
      border: none;
      padding: 0.5rem 1rem;
      border-radius: 30px;
      font-size: 1.1rem;
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .theme-btn i {
      font-size: 1.2rem;
    }

    .theme-btn.active {
      background: var(--bg-primary);
      color: var(--text-primary);
      box-shadow: 0 2px 4px var(--shadow);
    }

    /* Content area */
    .content-area {
      padding: 2rem;
      max-width: 800px;
      margin: 0 auto;
    }

    /* Page title */
    .page-title {
      font-size: 2rem;
      font-weight: 500;
      color: var(--text-primary);
      margin-bottom: 2rem;
    }

    /* Floating label styles */
    .field-group {
      position: relative;
      margin-bottom: 1.5rem;
    }

    .field-group.floating {
      margin-top: 0.5rem;
    }

    .field-group.floating input,
    .field-group.floating select,
    .field-group.floating textarea {
      width: 100%;
      padding: 1rem 1rem;
      border: 1px solid var(--border-input);
      border-radius: 12px;
      font-size: 0.9rem;
      background: var(--bg-input);
      color: var(--text-primary);
      font-family: inherit;
      transition: all 0.2s ease;
      line-height: 1.2;
    }

    /* keep native select style but we'll overlay custom ones */
    .field-group.floating select {
      padding: 1rem 1rem;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234b5c6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 1rem center;
      background-size: 0.9rem;
      background-color: var(--bg-input);
    }

    [data-theme="dark"] .field-group.floating select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    }

    .field-group.floating label {
      position: absolute;
      left: 1rem;
      top: 50%;
      transform: translateY(-50%);
      background: transparent;
      padding: 0 0.25rem;
      color: var(--text-tertiary);
      font-size: 0.9rem;
      font-weight: normal;
      text-transform: none;
      letter-spacing: normal;
      transition: all 0.2s ease;
      pointer-events: none;
      border-radius: 4px;
      line-height: 1;
      z-index: 1;
    }

    .field-group.floating textarea~label {
      top: 1.2rem;
      transform: none;
    }

    .field-group.floating.focused label,
    .field-group.floating.filled label {
      top: 0;
      transform: translateY(-50%);
      font-size: 0.6rem;
      font-weight: 400;
      color: var(--text-secondary);
      background: var(--floating-label-bg);
      padding: 0.2rem 0.5rem;
      border: 1px solid var(--border-input);
      border-radius: 30px;
    }

    .field-group.floating input:focus,
    .field-group.floating select:focus,
    .field-group.floating textarea:focus {
      outline: none;
      border-color: var(--border-focus);
    }

    .field-hint {
      font-size: 0.65rem;
      color: var(--text-tertiary);
      margin-top: 0.2rem;
      display: block;
      margin-left: 0.5rem;
    }

    /* --- CUSTOM DROPDOWN (replaces native select, same width & rounded) --- */
    .custom-select-wrapper {
      position: relative;
      width: 100%;
    }

    .custom-select-trigger {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      padding: 1rem 1rem;
      border: 1px solid var(--border-input);
      border-radius: 12px;
      background: var(--bg-input);
      color: var(--text-primary);
      font-size: 0.9rem;
      line-height: 1.2;
      cursor: pointer;
      transition: border-color 0.2s ease;
    }

    .custom-select-trigger i {
      color: var(--text-tertiary);
      font-size: 1.1rem;
      transition: transform 0.2s ease;
    }

    .custom-select-trigger.open i {
      transform: rotate(180deg);
    }

    .custom-options {
      position: absolute;
      top: calc(100% + 4px);
      left: 0;
      width: 100%;
      background: var(--dropdown-bg);
      border: 1px solid var(--dropdown-border);
      border-radius: 12px;
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
      z-index: 100;
      max-height: 250px;
      overflow-y: auto;
      display: none;
      padding: 0.25rem 0;
    }

    .custom-options.show {
      display: block;
    }

    .custom-option {
      padding: 0.8rem 1rem;
      font-size: 0.9rem;
      color: var(--text-primary);
      cursor: pointer;
      transition: background 0.1s ease;
    }

    .custom-option:hover {
      background: var(--dropdown-hover);
    }

    .custom-option.selected {
      background: var(--accent-light);
      font-weight: 500;
    }

    /* hide the native select visually but keep it functional */
    select.custom-select-hidden {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      border: 0;
    }

    /* Error styling for custom dropdown trigger */
    .custom-select-trigger.error-border {
      border-color: var(--border-error) !important;
    }

    /* Radio groups */
    .radio-group {
      display: flex;
      gap: 1.5rem;
      margin: 1rem 0;
    }

    .radio-label {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      font-size: 0.85rem;
      text-transform: none;
      letter-spacing: normal;
      color: var(--text-primary);
      font-weight: normal;
    }

    .radio-label input[type="radio"] {
      width: auto;
      margin-right: 0.25rem;
      accent-color: var(--accent);
    }

    .section-title {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 1rem;
      padding-bottom: 0.3rem;
      border-bottom: 1px solid var(--border-light);
    }

    .dynamic-fields,
    .order-type-container,
    .message-container {
      margin-top: 0.5rem;
      padding-top: 0.5rem;
      border-top: 1px solid var(--border-light);
    }

    .field-row {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      margin-bottom: 1rem;
    }

    .field-row .field-group {
      flex: 1 1 calc(50% - 0.5rem);
      min-width: 150px;
      margin-bottom: 0;
    }

    .field-row.three-cols .field-group {
      flex: 1 1 calc(33.333% - 0.75rem);
    }

    .connection-type {
      display: flex;
      gap: 1.5rem;
      margin: 1rem 0 0.5rem;
      padding: 0.5rem 0;
    }

    .connection-label {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      font-size: 0.85rem;
      color: var(--text-primary);
    }

    .connection-label input[type="radio"] {
      width: auto;
      accent-color: var(--accent);
    }

    .error-border {
      border-color: var(--border-error) !important;
    }

    .hidden {
      display: none;
    }

    .status {
      background: var(--status-bg);
      border-radius: 40px;
      padding: 0.7rem 1.2rem;
      margin: 1.5rem 0 1.2rem;
      font-size: 0.8rem;
      color: var(--text-secondary);
      border: 1px solid var(--status-border);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .send-btn {
      width: 100%;
      background: var(--accent);
      color: var(--text-inverse);
      border: none;
      padding: 0.85rem;
      border-radius: 40px;
      font-size: 0.85rem;
      font-weight: 480;
      letter-spacing: 0.2px;
      cursor: pointer;
      transition: opacity 0.2s ease;
      text-transform: lowercase;
    }

    .send-btn:hover {
      opacity: 0.85;
    }

    .send-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .auto-field {
      background-color: var(--bg-auto) !important;
    }

    #total {
      font-weight: 600;
      background-color: var(--bg-input) !important;
      cursor: text;
    }

    #total.editable {
      background-color: var(--bg-input) !important;
    }

    /* Responsive */
    @media (max-width: 768px) {
      .sidebar {
        width: 72px;
        padding: 2rem 0.5rem;
      }

      .company-name,
      .nav-item span:not(.nav-item i) {
        display: none;
      }

      .company-logo {
        justify-content: center;
        padding: 0;
      }

      .nav-item {
        justify-content: center;
        padding: 0.75rem;
      }

      .nav-item i {
        font-size: 1.5rem;
      }

      .main-content {
        margin-left: 72px;
      }

      .top-bar {
        padding: 0 1rem;
      }
    }

    @media (max-width: 640px) {
      .field-row {
        flex-direction: column;
      }

      .field-row .field-group {
        flex: 1 1 100%;
      }

      .content-area {
        padding: 1rem;
      }
    }