    :root {
      --bg: #0f172a;
      --panel: #111827;
      --card: #ffffff;
      --muted: #64748b;
      --text: #0f172a;
      --line: #e2e8f0;
      --brand: #0f3a68;
      --brand-2: #1d4ed8;
      --green: #15803d;
      --amber: #b45309;
      --red: #b91c1c;
      --soft: #f8fafc;
      --gold: #caa74a;
    }


    html,
    body {
      max-width: 100%;
      overflow-x: hidden;
    }


    .layout,
    .main,
    .card,
    .dashboard-support-grid,
    .dashboard-lower-grid,
    .dashboard-card-grid {
      min-width: 0;
    }


    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      font-family: Arial, Helvetica, sans-serif;
      background: #0b1220;
      color: #e2e8f0;
    }


    .hidden {
      display: none !important;
    }


    .login-wrap {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: linear-gradient(135deg, #0f172a, #1e293b);
    }

    .login-card {
      width: min(520px, 100%);
      background: #111827;
      color: #e2e8f0;
      border: 1px solid #1f2937;
      border-radius: 16px;
      box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
      padding: 28px;
    }

    .login-card h1 {
      margin: 0 0 8px;
      font-size: 30px;
    }

    .subtitle {
      color: var(--muted);
      margin: 0 0 22px;
    }

    .grid {
      display: grid;
      gap: 14px;
    }

    .grid-2 {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .grid-4 {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    label {
      display: block;
      margin: 8px 0 6px;
      font-weight: 700;
      font-size: 12px;
      letter-spacing: .04em;
      text-transform: uppercase;
      color: #94a3b8;
    }



    input,
    select,
    textarea,
    button {
      font: inherit;
    }

    input,
    select,
    textarea {
      width: 100%;
      padding: 10px 12px;
      border: 1px solid #334155;
      border-radius: 10px;
      background: #0f172a;
      color: #e2e8f0;
    }

    [id^="contacts_"] {
      margin-top: 8px;
      padding-left: 12px;
      border-left: 2px solid #1f2937;
    }

    textarea {
      min-height: 86px;
      resize: vertical;
    }

    button {
      border: none;
      border-radius: 10px;
      padding: 10px 14px;
      cursor: pointer;
      font-weight: 700;
    }

    .btn-primary {
      background: #caa74a;
      color: #0b1220;
    }

    .btn-primary:hover {
      background: #e0b95a;
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    }


    .btn-ghost {
      background: transparent;
      border: 1px solid #334155;
      color: #cbd5e1;
    }

    .btn-danger,
    .btn-warning {
      background: transparent;
      color: #94a3b8;
      border: 1px solid transparent;
    }

    .btn-warning:hover,
    .btn-danger:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #e2e8f0;
    }

    .btn-danger:hover {
      color: #ef4444;
    }

    .btn-row {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }

    .small {
      font-size: 12px;
      color: var(--muted);
    }

    .app-shell {
      min-height: 100vh;
    }

    .topbar {
      background: var(--bg);
      color: #fff;
      padding: 12px 20px;
      border-bottom: 4px solid var(--gold);
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 14px;
    }

    
.topbar-left {
    display:flex;
    align-items:center;
    gap:24px;
    flex:1;
}


    .topbar img {
      height: 40px;
      object-fit: contain;
    }

    .topbar h2 {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
    }

    .topbar-right {
      display: flex;
      align-items: center;
      gap: 15px;
    }

    .topbar .meta {
      color: #cbd5e1;
      font-size: 13px;
    }


    .dropdown {
      position: relative;
      z-index: 1;
    }

    .dropdown-display {
      border: 1px solid #334155;
      padding: 10px;
      border-radius: 8px;
      background: #0f172a;
      color: #e2e8f0;
      cursor: pointer;
    }

    .dropdown-options {
      position: absolute;
      top: 100%;
      left: 0;
      background: #111827;
      color: #e2e8f0;
      border: 1px solid #334155;
      border-radius: 8px;
      padding: 10px;
      width: 100%;
      max-height: 200px;
      overflow-y: auto;
      z-index: 2;
      pointer-events: auto;
    }

    .dropdown-options.hidden {
      display: none !important;
      pointer-events: none;
    }

    .dropdown-options label {
      display: block;
      margin-bottom: 5px;
    }

    .checkbox-option {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 6px 4px;
      cursor: pointer;
    }

    .checkbox-option input {
      margin: 0;
      width: auto;
    }

    #customersTable tr:hover {
      background: rgba(255, 255, 255, 0.03);
    }

    #customersTable strong {
      font-size: 14px;
      color: #f1f5f9;
    }

    #customersTable tr:nth-child(odd) {
      margin-top: 6px;
    }

   
    .layout {
      display: block;
    }


    
.mobile-menu-btn {
    display: none;
}


.mobile-logout {
    display: none;
}


.topbar-left .nav-btn {
    background: transparent;
    color: #fff;
    border: 1px solid transparent;
    padding: 12px 18px;
}

.topbar-left .nav-btn:hover,
.topbar-left .nav-btn.active {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.1);
    border-radius: 10px;
}


   

    .main {
      padding: 20px;
      overflow: visible;
    }

    .page-title {
      margin: 0 0 8px;
    }

    .card {
      background: #111827;
      border: 1px solid #1f2937;
      border-radius: 14px;
      padding: 18px;
      box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
      margin-bottom: 16px;
      color: #e2e8f0;
    }

    .card h3 {
      margin-top: 0;
    }

    .stats {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 14px;
    }

    .stat {
      background: #111827;
      border: 1px solid #1f2937;
      border-radius: 14px;
      padding: 16px;
    }

    .stat .label {
      color: var(--muted);
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .04em;
    }

    .stat .value {
      font-size: 28px;
      font-weight: 800;
      margin-top: 4px;
    }

    .pill {
      display: inline-flex;
      padding: 5px 10px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
    }

    
    .status-To_Quote {
      background: linear-gradient(
        135deg,
        rgba(245,158,11,0.25),
        rgba(251,191,36,0.15)
      );
      

      border: 1px solid #F59E0B;
      color: #FCD34D;
      font-weight: 700;
    }

    
    .To_Quote {
      background: linear-gradient(
        135deg,
        rgba(245,158,11,0.25),
        rgba(251,191,36,0.15)
      );

      border: 1px solid #F59E0B;
      color: #FCD34D;
      font-weight: 700;
    }


    .status-Quoted {
      background: #dbeafe;
      color: #1d4ed8;
    }

    .status-Booked {
      background: #ede9fe;
      color: #6d28d9;
    }

    .status-In_Transit {
      background: #fef3c7;
      color: #b45309;
    }

    .status-Delivered {
      background: #dcfce7;
      color: #15803d;
    }

    .status-Invoiced {
      background: #cffafe;
      color: #0f766e;
    }

    .status-Paid {
      background: #d1fae5;
      color: #065f46;
    }

    .status-Issue {
      background: #fee2e2;
      color: #b91c1c;
    }

    .status-Lost {
      background: #e2e8f0;
      color: #475569;
    }

    .invoice-Pending {
      background: #fef3c7;
      color: #92400e;
    }

    .invoice-Partially_Received {
      background: #ffedd5;
      color: #c2410c;
    }

    .invoice-Received {
      background: #dcfce7;
      color: #166534;
    }

    .invoice-Discrepancy {
      background: #fee2e2;
      color: #991b1b;
    }

    .invoice-Paid {
      background: #d1fae5;
      color: #065f46;
    }

    [class^="status-"] {
      padding: 4px 10px;
      border-radius: 6px;
      font-weight: 600;
      font-size: 12px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      background: #0f172a;
    }

    th,
    td {
      text-align: left;
      padding: 10px;
      border-bottom: 1px solid #1f2937;
      vertical-align: top;
    }

    th {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .04em;
      color: #475569;
    }


    .contractor-row {
      display: grid;
      grid-template-columns: 1.6fr 1fr auto;
      gap: 10px;
      margin-bottom: 12px;
      align-items: start;
    }


    /* Second row layout for extra fields */
    .contractor-row>div:nth-child(4),
    .contractor-row>div:nth-child(5),
    .contractor-row>div:nth-child(6) {
      grid-column: span 1;
    }

    /* Force second row */
    .contractor-row>div:nth-child(4) {
      grid-column: 1;
    }

    .contractor-row>div:nth-child(5) {
      grid-column: 2;
    }


    .empty {
      color: var(--muted);
      padding: 8px 0;
    }

    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .split {
      display: grid;
      grid-template-columns: 1.1fr .9fr;
      gap: 16px;
    }

    .summary-list div {
      margin-bottom: 6px;
    }

    .form-title {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }

    .sticky-note {
      padding: 8px 10px;
      border-radius: 10px;
      background: #eff6ff;
      color: #1d4ed8;
      font-size: 12px;
      font-weight: 700;
    }

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
}

.btn-icon-soft,
.btn-icon-danger {
    background: transparent;
    border: none;
    padding: 0;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.15s ease,
                opacity 0.15s ease;
}

.btn-icon-soft {
    color: #94a3b8;
    opacity: 0.8;
}

.btn-icon-soft:hover {
    color: #ffffff;
    transform: translateY(-1px);
    opacity: 1;
}

.btn-icon-danger {
    color: #ef4444; 
    opacity: 0.8;
}

.btn-icon-danger:hover {
    color: #f87171;
    opacity: 1;
    transform: translateY(-1px);
}
    


    .contractor-filter {
      margin-bottom: 10px;
      max-width: 320px;
    }



    .contact-actions span {
      font-size: 12px;
      color: #64748b;
      cursor: pointer;
      margin-left: 8px;
    }

    .contact-actions span:hover {
      color: #e2e8f0;
    }

    span:hover {
      opacity: 0.7;
    }



    .customer-cards {
      display: grid;
      gap: 14px;
    }

    .customer-card {
      background: #0f172a;
      border: 1px solid #1f2937;
      border-radius: 14px;
      padding: 16px 18px;
      transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }

    .customer-card:hover {
      border-color: #334155;
      box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    }

    .customer-card-top {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      flex-wrap: wrap;
    }

    .customer-main {
      flex: 1;
      min-width: 260px;
    }

    .customer-company {
      font-size: 18px;
      font-weight: 800;
      color: #f8fafc;
      margin-bottom: 6px;
    }

    .customer-subline {
      color: #94a3b8;
      font-size: 14px;
      margin-bottom: 8px;
    }

    .customer-meta {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 10px;
    }

    .customer-meta-item {
      font-size: 13px;
      color: #cbd5e1;
    }

    .followup-badge {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      padding: 5px 10px;
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
    }

    .followup-overdue {
      background: rgba(239, 68, 68, .15);
      color: #f87171;
    }

    .followup-today {
      background: rgba(245, 158, 11, .15);
      color: #fbbf24;
    }

    .followup-future {
      background: rgba(59, 130, 246, .15);
      color: #60a5fa;
    }

    .followup-none {
      background: rgba(100, 116, 139, .18);
      color: #94a3b8;
    }

    .customer-notes-preview {
      color: #94a3b8;
      font-size: 13px;
      line-height: 1.45;
      margin-bottom: 12px;
    }

    .customer-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }

    .customer-expand {
      margin-top: 14px;
      padding-top: 14px;
      border-top: 1px solid #1f2937;
    }

    .customer-section-title {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .06em;
      color: #64748b;
      margin-bottom: 8px;
      font-weight: 700;
    }

    .customer-contact-line,
    .customer-activity-line {
      padding: 8px 0;
      border-bottom: 1px solid rgba(31, 41, 55, .6);
      font-size: 14px;
    }

    .customer-contact-line:last-child,
    .customer-activity-line:last-child {
      border-bottom: none;
    }

    .customer-empty {
      color: #64748b;
      font-size: 14px;
      padding: 4px 0 8px;
    }

    .customer-inline-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 12px;
    }



    #contractorCards {
      display: none;
    }

    #jobsCardsHeader {
      display: none;
    }





    .crm-modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(2, 6, 23, 0.72);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      z-index: 9999;
    }


    
    .crm-modal {
      width: min(1100px, 100%);
      max-height: 90vh;
      background: #111827;
      border: 1px solid #1f2937;
      border-radius: 16px;
      box-shadow: 0 24px 60px rgba(0, 0, 0, .45);

      display: flex;
      flex-direction: column;

      overflow: hidden;
    }


    .crm-modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 20px;
      border-bottom: 1px solid #1f2937;
    }

    .crm-modal-header h3 {
      margin: 0;
      font-size: 20px;
      color: #f8fafc;
    }

    .crm-modal-close {
      background: transparent;
      border: 1px solid #334155;
      color: #cbd5e1;
      border-radius: 10px;
      padding: 8px 10px;
      cursor: pointer;
    }

    .crm-modal-close:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #fff;
    }

    .crm-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

    .crm-modal-footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 16px 20px 20px;
      border-top: 1px solid #1f2937;
    }

    .activity-type-badge {
      display: inline-flex;
      align-items: center;
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
    }

    .activity-Call {
      background: rgba(59, 130, 246, .14);
      color: #60a5fa;
    }

    .activity-Email {
      background: rgba(168, 85, 247, .14);
      color: #c084fc;
    }

    .activity-Quote {
      background: rgba(34, 197, 94, .14);
      color: #4ade80;
    }

    .activity-Site_Visit {
      background: rgba(245, 158, 11, .14);
      color: #fbbf24;
    }

    .activity-Meeting {
      background: rgba(236, 72, 153, .14);
      color: #f472b6;
    }

    .activity-Follow_Up {
      background: rgba(14, 165, 233, .14);
      color: #38bdf8;
    }

    .activity-General_Note {
      background: rgba(148, 163, 184, .16);
      color: #cbd5e1;
    }

    .crm-toolbar {
      display: grid;
      gap: 12px;
      margin-bottom: 14px;
    }

    .crm-filter-chips {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .crm-chip {
      background: transparent;
      border: 1px solid #334155;
      color: #cbd5e1;
      padding: 8px 12px;
      border-radius: 999px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }

    .crm-chip:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #fff;
    }

    .crm-chip.active {
      background: rgba(29, 78, 216, .18);
      border-color: #3b82f6;
      color: #93c5fd;
    }

    .crm-summary-strip {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .crm-summary-card {
      background: #0f172a;
      border: 1px solid #1f2937;
      border-radius: 12px;
      padding: 14px;
    }

    .crm-summary-label {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .05em;
      color: #64748b;
      margin-bottom: 6px;
    }

    .crm-summary-value {
      font-size: 24px;
      font-weight: 800;
      color: #f8fafc;
    }


    .activity-date {
      font-size: 12px;
      color: #64748b;
    }


    .dashboard-header-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 14px;
      flex-wrap: wrap;
      margin-bottom: 16px;
    }

    .dashboard-range-chips {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .dashboard-card-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
    }

    .dashboard-money-card {
      background: #111827;
      border: 1px solid #1f2937;
      border-radius: 16px;
      padding: 18px;
      box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
      cursor: pointer;
      transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    }


    .dashboard-money-card:hover {
      transform: translateY(-2px);
      box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
      cursor: pointer;
    }

    .dashboard-card-kicker {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .08em;
      color: #64748b;
      margin-bottom: 10px;
      font-weight: 700;
    }

    .dashboard-money-card.quoted {
      border-color: rgba(59, 130, 246, .35);
    }

    .dashboard-money-card.operational {
      border-color: rgba(245, 158, 11, .35);
    }

    .dashboard-money-card.invoiced {
      border-color: rgba(34, 197, 94, .35);
    }




    .dashboard-card-main-value {
      font-size: 30px;
      font-weight: 800;
      color: #f8fafc;
      margin-bottom: 10px;
    }

    .dashboard-card-substats {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }

    .dashboard-substat {
      background: #0f172a;
      border: 1px solid #1f2937;
      border-radius: 12px;
      padding: 10px;
    }

    .dashboard-substat-label {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: .05em;
      color: #64748b;
      margin-bottom: 4px;
    }

    .dashboard-substat-value {
      font-size: 15px;
      font-weight: 800;
      color: #e2e8f0;
    }


    .dashboard-substat-value .margin-good,
    .dashboard-substat-value .margin-ok,
    .dashboard-substat-value .margin-bad {
      font-size: 12px;
      margin-left: 6px;
    }


    .dashboard-lower-grid,
    .dashboard-support-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
    }

    .dashboard-stage-row,
    .dashboard-action-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      padding: 10px 0;
      border-bottom: 1px solid rgba(31, 41, 55, .7);
    }

    .dashboard-stage-row:last-child,
    .dashboard-action-row:last-child {
      border-bottom: none;
    }

    .dashboard-stage-left,
    .dashboard-action-left {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .dashboard-stage-meta,
    .dashboard-action-meta {
      color: #94a3b8;
      font-size: 13px;
    }

    .dashboard-inline-button {
      background: transparent;
      border: 1px solid #334155;
      color: #cbd5e1;
      border-radius: 999px;
      padding: 6px 10px;
      font-size: 12px;
      font-weight: 700;
      cursor: pointer;
    }

    .dashboard-inline-button:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #fff;
    }

    .dashboard-small-muted {
      color: #64748b;
      font-size: 12px;
    }





    .job-status-dropdown {
      background: #0f172a;
      color: #e2e8f0;
      border: 1px solid #334155;
      border-radius: 8px;
      width: 130px;
      padding: 6px 32px 6px 10px;
      /* ✅ extra room */

      font-size: 13px;
      cursor: pointer;

      appearance: none;
      -webkit-appearance: none;
      /* ✅ IMPORTANT */
      -moz-appearance: none;
      /* ✅ IMPORTANT */

      background-image: url("data:image/svg+xml;utf8,<svg fill='%2394a3b8' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5.5 7l4.5 4.5L14.5 7'/></svg>");
      background-repeat: no-repeat;
      background-position: right 8px center;
      background-size: 12px;
    }

    .job-status-dropdown.Quoted {
      border-color: #3b82f6;
      color: #93c5fd;
    }

    
    
  
    .job-status-dropdown.To_Quote {
      border-color: #d4af37;
      color: #f4d03f;
      background: rgba(212, 175, 55, 0.12);
      font-weight: 700;
    }


    .job-status-dropdown.Booked {
      border-color: #8b5cf6;
      color: #c4b5fd;
    }

    
    .job-status-dropdown.In_Transit {
      border-color: #f97316;
      color: #fdba74;
    }


    .job-status-dropdown.Delivered {
      border-color: #22c55e;
      color: #86efac;
    }

    .job-status-dropdown.Invoiced {
      border-color: #06b6d4;
      color: #67e8f9;
    }

    .job-status-dropdown.Paid {
      border-color: #16a34a;
      color: #4ade80;
    }

    .job-status-dropdown.Issue {
      border-color: #ef4444;
      color: #fca5a5;
    }

    .job-status-dropdown.Lost {
      border-color: #64748b;
      color: #94a3b8;
    }

    .job-status-dropdown option {
      background: #0f172a;
    }

    .job-status-dropdown option[value="Quoted"] {
      color: #93c5fd;
    }

    .job-status-dropdown option[value="Booked"] {
      color: #c4b5fd;
    }

    .job-status-dropdown option[value="To Quote"] {
    color: #f4d03f;
    font-weight: 700;
     }

    .job-status-dropdown option[value="In Transit"] {
      color: #fdba74;
    }

    .job-status-dropdown option[value="Delivered"] {
      color: #86efac;
    }

    .job-status-dropdown option[value="Invoiced"] {
      color: #67e8f9;
    }

    .job-status-dropdown option[value="Paid"] {
      color: #4ade80;
    }

    .job-status-dropdown option[value="Issue"] {
      color: #fca5a5;
    }

    .job-status-dropdown option[value="Lost"] {
      color: #94a3b8;
    }




    .job-status-dropdown option:checked {
      background: #223a5c;
      color: #f8fafc;
    }

    .job-status-dropdown option:hover,
    .job-status-dropdown option:focus {
      background: linear-gradient(0deg, rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.16));
      color: #f8fafc;
    }


    #jobsTable td:first-child .small {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      line-height: 1.4;
    }


    #jobsTable td {
      word-break: break-word;
    }


    #jobsTable tr:last-child {
      position: sticky;
      bottom: 0;
    }


    .job-status-dropdown:hover {
      border-color: #3b82f6;
    }




    .job-status-dropdown option {
      white-space: normal;
    }



.filter-dropdown {
  position: relative;
}





.filter-panel label {
  display: grid;
  grid-template-columns: 18px 1fr;  /* ✅ checkbox column + text column */
  align-items: center;
  gap: 10px;

  padding: 6px 6px;
  font-size: 13px;
  cursor: pointer;
  color: #e2e8f0;
}


.jobs-controls > * {
  display: flex;
  align-items: center;
}

.jobs-controls label {
  margin: 0;
  font-size: 11px;
  white-space: nowrap;
}



.jobs-controls > div {
  display: flex;
  align-items: center;
}


.filter-dropdown > button {
  display: flex;
  align-items: center;
  justify-content: space-between;

  height: 32px;
  padding: 0 10px;
  min-width: 90px;

  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
}

.filter-dropdown > button::after {
  content: '▾';
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.8;
}


.contractor-filter {
  display: flex;
  align-items: center;
  height:32px;
  position: relative;
}

#contractorList {
  display: none;  /* ✅ hidden by default */
}



#contractorSearch {
  width: 180px;
  height: 32px;
  padding: 0 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  box-sizing: border-box;
  outline: none;
}


#contractorSearch:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}


#jobSearch {
  width: 180px;
  height: 32px;
  padding: 0 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  box-sizing: border-box;
  outline: none;
}


#jobSearch:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}



.jobs-controls input,
.jobs-controls select,
.jobs-controls button {
  height: 32px;
  padding: 0 10px;
  box-sizing: border-box;
}




.jobs-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.jobs-controls .contractor-filter {
  margin-bottom: 0;
}



.dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  width: 220px;
  max-height: 240px;
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  z-index: 9999;
}

.dropdown-item {
  padding: 6px 10px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: #1e293b;
}


.filter-dropdown > button::after {
  content: ' ▼';
  font-size: 10px;
  opacity: 0.7;
}


.filter-panel label input:checked + span {
  color: #38bdf8;
  font-weight: 500;
}

.filter-dropdown button:hover {
  background: #1e293b;
  border-color: #475569;
}

.filter-panel input[type="checkbox"] {
  margin: 0;
  accent-color: #38bdf8;
  width: 16px;         /* ✅ consistent size */
  height: 16px;
  flex-shrink: 0;      /* ✅ prevents weird shifting */
}



.filter-panel label span {
  white-space: nowrap;   /* ✅ keeps “In Transit” on one line */
}



.filter-panel {
  position: absolute;
  top: 110%;
  left: 0;
  z-index: 9999;

  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  width: 200px;

  display: flex;
  flex-direction: column;
  gap: 4px;
}


#statusFilterPanel {
  display: none;
}

.filter-actions {
  display: flex;
  gap: 8px;                /* ✅ space between buttons */
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #334155;
}


.inline-filter {
  display: flex;
  align-items: center;
  gap: 6px;
}


.filter-actions button {
  flex: 1;                 /* ✅ equal width */
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-align: center;      /* ✅ clean alignment */
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-actions button::after {
  content: none !important;
}


/* Clear button */

.btn-clear {
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5f5;
}


/* Apply button */

.btn-apply {
  background: #38bdf8;
  border: none;
  color: #0f172a;
}


    .margin-good {
      color: #22c55e;
      /* green */
      font-weight: 700;
    }

    .margin-ok {
      color: #f59e0b;
      /* amber */
      font-weight: 700;
    }

    .margin-bad {
      color: #ef4444;
      /* red */
      font-weight: 700;
    }


    .jobs-cards {
      display: grid;
      gap: 12px;
    }

    .job-card {
      background: #0f172a;
      border: 1px solid #1f2937;
      border-radius: 12px;
      padding: 14px;
    }

    .job-card select {
      width: 100%;
      margin-top: 6px;
    }

    .job-card input[type="checkbox"] {
      transform: scale(1.2);
    }



    .selection-left input[type="checkbox"] {
      transform: scale(1);
      margin-left: 2px;
    }


    .selection-left input[type="checkbox"] {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }


    .job-card-top {
      font-weight: 800;
      font-size: 15px;
      margin-bottom: 6px;
    }

    .job-card-row select {
      width: 140px;
    }


    .job-card-label {
      color: #64748b;
    }

    .job-card-value {
      font-weight: 700;
    }

    .job-card-actions {
      margin-top: 10px;
      display: flex;
      gap: 10px;
    }

    .job-card-desc {
      font-size: 12px;
      color: #94a3b8;
      margin-bottom: 10px;

      display: -webkit-box;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    #jobsCards,
    #contractorCards {
      display: none;
    }




    .mobile-cards {
      display: none;
    }



    /* ✅ Remove number input spinners (Chrome, Edge, Safari) */
    input[type=number]::-webkit-outer-spin-button,
    input[type=number]::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    /* ✅ Remove spinner (Firefox) */
    input[type=number] {
      appearance: textfield;
      -moz-appearance: textfield;
    }

    /* =========================
   ✅ JOB GRID (FINAL – STABLE)
   ========================= */

    .jobs-grid {
      margin-top: 10px;
      width: 100%;
    }

    /* ✅ Column structure */
    .jobs-grid-header,
    .job-grid-row,
    .job-grid-total-row {
      display: grid;
      grid-template-columns:
        40px minmax(260px, 2.5fr) minmax(160px, 1.5fr) 140px 110px 110px 110px 110px minmax(160px, 1.4fr) 80px;
      gap: 12px;
      align-items: start;
    }

    /* ✅ HEADER */
    .jobs-grid-header {
      padding: 12px 16px;
      border-bottom: 1px solid #1f2937;
      font-size: 12px;
      text-transform: uppercase;
      color: #64748b;
      letter-spacing: .05em;
    }

    /* ✅ ROWS */
    .job-grid-row {
      padding: 14px 16px;
      border-bottom: 1px solid #1f2937;
    }

    .job-grid-row:hover {
      background: rgba(255, 255, 255, 0.04);
    }

    .job-grid-row:nth-child(even) {
      background: rgba(255, 255, 255, 0.02);
    }

    /* ✅ CHECKBOX */
    .jobs-check-cell {
      display: flex;
      justify-content: center;
      padding-top: 4px;
    }

    .job-select {
      transform: scale(0.9);
    }

    /* ✅ JOB TEXT */
    .job-main strong {
      display: block;
      font-weight: 800;
      margin-bottom: 4px;
    }

    .job-main .small {
      font-size: 12px;
      color: #94a3b8;
      line-height: 1.4;
    }

    /* ✅ NUMBERS */
    .jobs-num {
      text-align: right;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
      font-weight: 700;
    }



    /* ✅ Ensures checkbox never stretches */
    .selection-left input {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }

    /* ✅ ACTION BAR — CLEAN FINAL */
    .jobs-selection-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 1rem;
      border-radius: 10px;
      background: #111827;
      border: 1px solid #1f2937;
      box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.4),
        0 -4px 12px -5px rgba(0, 0, 0, 0.4);

      /* Sticky bottom behaviour */
      position: sticky;
      top: 0;
      z-index: 100;
    }

    .selection-left {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .selection-left input[type="checkbox"] {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
      cursor: pointer;
    }

    .selection-right {
      display: flex;
      align-items: center;
    }

    /* ✅ CONTRACTORS */
    .job-contractors-cell {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    /* ✅ ACTIONS */
    .job-actions {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .job-actions button {
      background: none;
      border: none;
      color: #94a3b8;
      font-weight: 700;
      padding: 0;
    }

    .job-actions button:hover {
      color: #e2e8f0;
    }

    .job-actions .btn-danger:hover {
      color: #ef4444;
    }

    /* ✅ TOTAL ROW */
    .job-grid-total-row {
      padding: 14px 16px;
      background: #020617;
      border-top: 2px solid #334155;
      font-weight: 800;
    }

    .jobs-toggle {
      margin-left: 8px;
    }

    .job-total-label {
      grid-column: 1 / span 4;
    }



    /* ==================================================
   FINAL JOB GRID OVERRIDES — FITS DESKTOP WIDTH
   KEEP THIS AT VERY BOTTOM OF STYLE
   ================================================== */

    /* Desktop: grid visible, mobile cards hidden */
    .jobs-grid {
      display: block !important;
      width: 100%;
      max-width: 100%;
      margin-top: 18px;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
    }





    /* 
  ✅ Same layout for header, rows and total.
  ✅ No huge min-width now.
  ✅ Columns fit the card better on desktop.
*/
    .jobs-grid-header,
    .job-grid-row,
    .job-grid-total-row {
      display: grid !important;
      grid-template-columns:
        38px minmax(230px, 2.1fr) minmax(150px, 1.15fr) 130px 105px 105px 115px 105px minmax(160px, 1.1fr) 86px;
      column-gap: 12px;
      align-items: start;
      min-width: 1280px;
    }

    /* Header */
    .jobs-grid-header {
      padding: 12px 14px;
      border-bottom: 1px solid #1f2937;
      color: #64748b;
      font-size: 12px;
      font-weight: 800;
      letter-spacing: .05em;
      text-transform: uppercase;
      align-items: center;
    }

    /* Rows */
    .job-grid-row {
      padding: 14px 14px;
      border-bottom: 1px solid #1f2937;
      background: #0f172a;
    }

    .job-grid-row:nth-child(even) {
      background: rgba(255, 255, 255, 0.02);
    }

    .job-grid-row:hover {
      background: rgba(255, 255, 255, 0.04);
    }

    /* Checkbox */
    .jobs-check-cell {
      display: flex;
      justify-content: center;
      align-items: flex-start;
      padding-top: 3px;
    }

    .jobs-check-cell input,
    .job-select {
      width: auto !important;
      cursor: pointer;
      transform: scale(0.9);
    }

    /* Job column */
    .job-main {
      min-width: 0;
    }

    .job-main strong {
      display: block;
      font-size: 15px;
      font-weight: 800;
      color: #f8fafc;
      margin-bottom: 4px;
    }

    .job-main .small {
      display: block;
      font-size: 12px;
      color: #94a3b8;
      line-height: 1.35;
      max-width: 100%;
    }

    /* Customer */
    .job-customer-cell {
      color: #f8fafc;
      min-width: 0;
    }

    .jobs-grid {
      display: block !important;
    }


.contractor-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.contractor-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

/* Received */
.status-received {
  background: #dcfce7;
  color: #166534;
}

/* Pending */
.status-pending {
  background: #fef3c7;
  color: #92400e;
}

/* Sent */
.status-sent {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Approved */
.status-approved {
  background: #dcfce7;
  color: #166534;
}

/* Rejected */
.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

    .job-card-pricing {
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
    }

    .job-card-pricing>div {
      flex: 1;
      text-align: center;
    }

    .jobs-toggle {
      display: flex;
      background: #0f172a;
      border: 1px solid #1f2937;
      border-radius: 10px;
      overflow: hidden;
      width: 160px;
    }

    .toggle-btn {
      flex: 1;
      padding: 8px;
      border: none;
      background: transparent;
      color: #94a3b8;
      font-weight: 600;
      cursor: pointer;
    }

    .toggle-btn.active {
      background: #caa74a;
      color: #0b1220;
    }

    .jobs-header {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    /* ✅ Keeps alignment consistent with cards */
    .selection-left input {
      margin-left: 4px;
      /* match your card checkbox spacing */
    }



    #jobsCardsHeader {
      margin-top: 2px;
      margin-bottom: 16px;
    }



    #jobsCards {
      display: none !important;
    }



    /* =========================/*Desktop Section Min-Width 769px and above for desktop view adjustments
   ========================= */

    @media (min-width: 769px) {

      .jobs-controls {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 20px;
      }

      .jobs-header {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 20px;
        align-items: end;
      }

    }


    /* =========================/*Mobile Section Max-Width 1199px for mobile view adjustments
   ========================= */
                               @media (max-width: 1199px) {
                                #jobsCardsHeader {
                                  display: block;
                                }

                                .jobs-grid {
                                  display: none !important;
                                }


                                #jobsCards {
                                  display: grid !important;
                                  gap: 12px;
                                }


                              
                                #jobs table,
                                #contractors table {
                                  display: none;
                                }


                                #jobsCards,
                                #contractorCards {
                                  display: block !important;
                                }

                                #userMeta {
                                  display: none;
                              }
                            .topbar-right .btn-danger {
                            display:none;
                           }

                            .mobile-logout {
                             display: block;
                             }

                              .mobile-menu-btn {
                              display: block;
                              background: transparent;
                              border: none;
                              color: white;
                              font-size: 24px;
                              cursor: pointer;
                              line-height: 1;
                              padding: 4px 8px;
                              }

                              
                            

                              .topbar-nav {
                                  display: none;
                              }

                                .topbar-nav.mobile-open {
                              display: flex;
                              flex-direction: column;
                              gap: 4px;

                              position: absolute;
                              top: 70px;
                              right: 10px;

                              width: 220px;

                              background: #0f172a;
                              border: 1px solid #334155;
                              border-radius: 12px;

                              padding: 10px;

                              z-index: 9999;

                              box-shadow: 0 10px 30px rgba(0,0,0,.4);
                              }


                              .topbar-nav .nav-btn {
                                  width: 100%;
                                  justify-content: center;
                                  min-height: 42px;
                              }

                              .topbar {
                                display: flex;
                                flex-direction: column;
                                gap: 6px;
                                align-items: flex-start;
                                position: relative;
                              }

                              .topbar-nav.mobile-open .nav-btn {
                                  width: 100%;
                                  justify-content: flex-start;
                                  text-align: left;
                              }

                                  
                                                                   
                              .topbar-left {
                                  display: flex;
                                  flex-direction: row;
                                  justify-content: space-between;
                                  align-items: center;
                                  width: 100%;
                              }

                                                              
                              .topbar-left img {
                                  margin-bottom: 0px;
                                  max-width: 160px;
                              }


                              .topbar-right {
                                display: flex;
                                justify-content: space-between;
                                width: 100%;
                              }


                              /* Jobs toolbar: stack and space controls for small screens */
                              #jobs .jobs-controls {
                                flex-wrap: wrap;
                                align-items: stretch;
                                justify-content: flex-start;
                                gap: 10px;
                              }

                              #jobs .jobs-controls > * {
                                flex: 1 1 100%;
                                min-width: 0;
                              }

                              #jobs .jobs-controls .filter-dropdown,
                              #jobs .jobs-controls .contractor-filter,
                              #jobs .jobs-controls .inline-filter,
                              #jobs .jobs-controls .jobs-toggle {
                                width: 100%;
                              }

                              #jobs .jobs-controls .filter-dropdown button,
                              #jobs .jobs-controls #contractorSearch,
                              #jobs .jobs-controls #jobSearch,
                              #jobs .jobs-controls .btn-primary,
                              #jobs .jobs-controls .inline-filter select {
                                width: 100%;
                              }

                              #jobs .jobs-controls .contractor-filter {
                                max-width: none;
                                position: relative;
                                overflow: visible;
                              }

                              #jobs .jobs-controls #contractorList {
                                top: calc(100% + 4px);
                                left: 0;
                                width: 100%;
                                max-height: 220px;
                                z-index: 10050;
                              }

                              #jobs .jobs-controls .inline-filter {
                                flex-direction: column;
                                align-items: stretch;
                                gap: 4px;
                              }

                              #jobs .jobs-controls .jobs-toggle {
                                margin-left: 0;
                              }

                              #jobs .jobs-controls .filter-dropdown {
                                position: relative;
                                overflow: visible;
                              }

                              #jobs #statusFilterPanel {
                                width: min(280px, 92vw);
                                max-height: 60vh;
                                overflow-y: auto;
                              }

                              #jobs .jobs-controls .toggle-btn,
                              #jobs .jobs-controls .btn-primary,
                              #jobs .jobs-controls input,
                              #jobs .jobs-controls select,
                              #jobs .jobs-controls button {
                                min-height: 40px;
                              }

                              #showCompletedToggle {
                                transform: scale(0.85);
                              }

                              /* CARDS */
                              .card {
                                padding: 14px;
                                overflow: hidden;
                              }

                              #jobs .card {
                                overflow: visible;
                              }

                              .jobs-cards,
                              .customer-cards {
                                gap: 12px;
                              }

                              .job-card {
                                padding: 16px;
                                border-radius: 14px;
                              }

                              .job-card-top {
                                font-size: 15px;
                                font-weight: 800;
                                margin-bottom: 6px;
                              }

                              .job-card-sub {
                                font-size: 14px;
                                color: #cbd5e1;
                              }

                              .job-card-desc {
                                font-size: 12px;
                                color: #94a3b8;
                                margin-top: 6px;
                              }

                              .job-card-row {
                                display: flex;
                                justify-content: space-between;
                                margin-top: 6px;
                                font-size: 13px;
                              }

                              .job-card-actions {
                                margin-top: 12px;
                                display: flex;
                                justify-content: space-between;
                              }


                              .desktop-only {
                                display: none;
                              }

                              .mobile-cards {
                                display: grid;
                                gap: 12px;
                              }

                              .data-card {
                                background: #0f172a;
                                border: 1px solid #1f2937;
                                border-radius: 12px;
                                padding: 14px;
                              }

                              .data-card-title {
                                font-weight: 800;
                                font-size: 14px;
                                margin-bottom: 8px;
                              }

                              .data-row {
                                display: flex;
                                justify-content: space-between;
                                font-size: 13px;
                                margin-top: 4px;
                              }

                              .data-label {
                                color: #64748b;
                              }

                              .data-value {
                                font-weight: 700;
                              }

                              /* Second row */
                              .contractor-row .jc-invoice-number,
                              .contractor-row .jc-connote,
                              .contractor-row .jc-invoice-status {
                                grid-column: span 1;
                              }

                              /* Force layout row breaks */
                              .contractor-row>div:nth-child(4) {
                                grid-column: 1 / span 1;
                              }

                              .contractor-row>div:nth-child(5) {
                                grid-column: 2 / span 1;
                              }

                              .contractor-row>div:nth-child(6) {
                                grid-column: 3 / span 1;
                              }

                              .contractor-row input,
                              .contractor-row select {
                                width: 100%;
                                min-width: 0;
                              }

                              /* Create Job modal: contractor rows need a roomy stacked layout on mobile */
                              #createJobModal .crm-modal {
                                max-height: 92vh;
                              }

                              #createJobModal .crm-modal-body {
                                padding: 14px;
                              }

                              #createJobModal #jobContractorRows {
                                display: grid;
                                gap: 12px;
                              }

                              #createJobModal .contractor-row {
                                grid-template-columns: 1fr;
                                gap: 10px;
                                margin-bottom: 0;
                                padding: 12px;
                                border: 1px solid #334155;
                                border-radius: 12px;
                                background: rgba(15, 23, 42, 0.55);
                              }

                              #createJobModal .contractor-row > div {
                                grid-column: auto !important;
                              }

                              #createJobModal .contractor-row label {
                                margin: 0 0 4px;
                              }

                              #createJobModal .contractor-row input,
                              #createJobModal .contractor-row select,
                              #createJobModal .contractor-row button {
                                width: 100%;
                                min-height: 40px;
                              }

                              #createJobModal .contractor-row .btn-danger {
                                margin-top: 2px;
                              }
                            }



    @media (max-width: 1100px) {
      .dashboard-card-grid {
        grid-template-columns: 1fr;
      }
       /* ✅ CLEAN MOBILE SWITCH */
      .jobs-grid {
        display: none;
      }
    }

    @media (max-width: 900px) {

      .dashboard-lower-grid,
      .dashboard-support-grid {
        grid-template-columns: 1fr;
      }
      .crm-summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .customer-card-top {
        flex-direction: column;
        align-items: stretch;
      }

      .customer-actions {
        width: 100%;
      }

     
    }

    @media (max-width: 640px) {
      .dashboard-card-substats {
        grid-template-columns: 1fr;
      }
    }

    
    @media (max-width: 560px) {
      .crm-summary-strip {
        grid-template-columns: 1fr;
      }
    }

   
    /* SMALL PHONES */
    @media (max-width: 480px) {
      .job-card-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
      }
    }


    @media (max-width: 980px) {
      .layout {
        grid-template-columns: 1fr;
      }

      
      .stats,
      .split,
      .grid-2,
      .grid-3,
      .grid-4,
      .contractor-row {
        grid-template-columns: 1fr;
      }
    }