﻿.job-modal[hidden] { display: none !important; }
    .job-modal {
      position: fixed;
      inset: 0;
      z-index: 50;
      overflow-y: auto;
      padding: 1rem;
      padding-top: max(1rem, env(safe-area-inset-top));
    }
    .job-modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
      z-index: 0;
    }
    .job-modal-panel {
      position: relative;
      z-index: 1;
      width: 100%;
      max-width: min(44rem, 94vw);
      margin: 0 auto 2rem;
      background: var(--card);
      border-radius: 14px;
      box-shadow: 0 20px 50px rgba(0,0,0,0.18);
      border: 1px solid var(--border);
    }
    @media (max-width: 639px) {
      .job-modal {
        padding: 0;
        padding-top: env(safe-area-inset-top);
      }
      .job-modal-panel {
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        display: flex;
        flex-direction: column;
      }
      .job-modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        padding-bottom: max(1.15rem, env(safe-area-inset-bottom));
      }
      .job-modal-edit-btn,
      #job-modal-close {
        min-width: 2.75rem;
        min-height: 2.75rem;
      }
      .job-modal-header {
        align-items: center;
        gap: 0.85rem;
        padding: 0.75rem 0.85rem;
      }
      .job-modal-header-text {
        flex: 1 1 auto;
        min-width: 0;
      }
      .job-modal-header h2 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.95rem;
        line-height: 1.25;
        font-weight: 600;
      }
      .job-modal-intake-date {
        font-size: 0.72rem;
      }
    }
    .job-modal-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 0.75rem;
      padding: 1rem 1.1rem;
      border-bottom: 1px solid var(--border);
    }
    .job-modal-header h2 {
      margin: 0;
      font-size: 1.15rem;
      line-height: 1.3;
      font-weight: 700;
    }
    .job-modal-header-text {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
    }
    .job-modal-intake-date {
      margin: 0;
      font-size: 0.8rem;
      line-height: 1.3;
      font-weight: 500;
      color: var(--muted);
      font-variant-numeric: tabular-nums;
    }
    #job-modal-close {
      flex-shrink: 0;
      width: 2.25rem;
      height: 2.25rem;
      border: none;
      border-radius: 8px;
      background: var(--bg);
      cursor: pointer;
      font-size: 1.25rem;
      line-height: 1;
      color: var(--muted);
    }
    #job-modal-close:hover { color: var(--text); background: #e4e4e7; }
    .job-modal-body { padding: 1rem 1.1rem 1.15rem; }
    .job-modal-section-title {
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
      margin: 0 0 0.5rem;
    }
    .job-modal-section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      margin-bottom: 0.5rem;
    }
    .job-modal-section-head .job-modal-section-title { margin: 0; }
    .job-modal-edit-btn {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 2rem;
      height: 2rem;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--card);
      color: var(--sh-primary);
      cursor: pointer;
    }
    .job-modal-edit-btn:hover {
      background: var(--sh-primary-soft);
      border-color: var(--sh-primary-border);
    }
    .job-modal-edit-btn svg {
      width: 1rem;
      height: 1rem;
    }
    .job-modal-details-edit {
      margin-bottom: 1.1rem;
    }
    .job-modal-details-edit label {
      display: block;
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--muted);
      margin-top: 0.55rem;
    }
    .job-modal-details-edit label:first-of-type { margin-top: 0; }
    .job-modal-details-edit input,
    .job-modal-details-edit select {
      width: 100%;
      max-width: none;
      margin-top: 0.2rem;
    }
    .job-modal-details-edit input:focus {
      outline: none;
      border-color: var(--sh-primary);
      box-shadow: 0 0 0 3px rgba(var(--sh-primary-rgb), 0.16);
    }
    .job-modal-edit-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-top: 0.85rem;
    }
    .job-modal-edit-actions button {
      padding: 0.5rem 1rem;
      font-size: 0.875rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
    }
    #job-modal-edit-cancel {
      border: 1px solid var(--border);
      background: var(--card);
      color: var(--text);
    }
    #job-modal-edit-save {
      border: none;
      background: var(--sh-primary);
      color: #fff;
    }
    #job-modal-edit-save:hover { background: var(--sh-primary-hover); }
    .job-modal-assign-row {
      margin-bottom: 1.1rem;
      padding-top: 0.15rem;
    }
    .job-modal-assign-row label {
      display: block;
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 0.35rem;
    }
    .job-modal-assign-controls {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      gap: 0.45rem;
    }
    .job-modal-assign-controls select,
    .job-modal-assign-controls .sh-select {
      flex: 1 1 auto;
      width: auto;
      min-width: 5.5rem;
      max-width: min(11rem, calc(100% - 5.5rem));
      margin-top: 0;
    }
    .job-modal-assign-controls .sh-select-trigger {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .job-modal-assign-save {
      flex: 0 0 auto;
      padding: 0.45rem 0.85rem;
      font-size: 0.8125rem;
      font-weight: 600;
      line-height: 1.25;
      min-height: 2.05rem;
      box-sizing: border-box;
      border: none;
      border-radius: 8px;
      background: var(--sh-primary);
      color: #fff;
      cursor: pointer;
    }
    .job-modal-assign-save:hover:not(:disabled) {
      background: var(--sh-primary-hover);
    }
    .job-modal-assign-save:disabled {
      opacity: 0.7;
      cursor: wait;
    }
    .job-modal-details-split {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.85rem 1.35rem;
      margin-bottom: 0.65rem;
    }
    @media (max-width: 640px) {
      .job-modal-details-split { grid-template-columns: 1fr; }
    }
    .job-modal-details-col--job .job-modal-assign-row {
      margin-top: 0.5rem;
      margin-bottom: 0;
      padding-top: 0;
    }
    .job-modal-rush-row {
      margin-top: 0.75rem;
      margin-bottom: 1.1rem;
      padding-top: 0.75rem;
      border-top: 1px solid rgba(15, 23, 42, 0.06);
    }
    .job-modal-rush-btn {
      font-family: var(--sh-font-display, inherit);
      font-size: 0.8125rem;
      font-weight: 600;
      line-height: 1.25;
      min-height: 2.05rem;
      padding: 0.45rem 0.85rem;
      border-radius: 8px;
      border: 1px solid #fed7aa;
      background: #fff7ed;
      color: #c2410c;
      cursor: pointer;
      box-sizing: border-box;
    }
    .job-modal-rush-btn:hover:not(:disabled) {
      background: #ffedd5;
    }
    .job-modal-rush-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }
    .job-modal-rush-btn--active {
      background: #fef4d4;
      color: #8f6918;
      border-color: #f5e6a8;
    }
    .job-modal-rush-btn--active:hover:not(:disabled) {
      background: #fdeeb8;
    }
    .job-modal-details-edit-split {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0 1.35rem;
    }
    @media (max-width: 640px) {
      .job-modal-details-edit-split { grid-template-columns: 1fr; }
    }
    .job-modal-details-edit-col label:first-of-type {
      margin-top: 0;
    }
    .job-modal-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 0.65rem 0;
      margin-bottom: 0;
    }
    .job-modal-field span {
      display: block;
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 0.15rem;
    }
    .job-modal-field p {
      margin: 0;
      font-size: 0.92rem;
    }
    .job-modal-field p.muted { color: var(--muted); font-style: italic; }
    .job-modal-notes-block {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0.85rem 0.9rem 0.75rem;
      background: linear-gradient(180deg, #fafafa 0%, var(--card) 28%);
    }
    .job-modal-notes-block .job-modal-section-title,
    .job-modal-notes-heading {
      margin-bottom: 0.7rem;
      font-size: 0.92rem;
      font-weight: 800;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      color: var(--sh-text);
      font-family: var(--sh-font-display);
    }
    #job-modal-notes-list {
      list-style: none;
      margin: 0 0 0.75rem;
      padding: 0;
      max-height: min(42vh, 18rem);
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
    #job-modal-notes-list:empty::before {
      content: "No notes yet. Add one below.";
      display: block;
      font-size: 0.85rem;
      color: var(--muted);
      font-style: italic;
      padding: 0.35rem 0;
    }
    .job-note-item {
      position: relative;
      display: flex;
      gap: 0.6rem;
      align-items: flex-start;
      padding: 0.55rem 2rem 0.55rem 0.6rem;
      border-radius: 8px;
      background: color-mix(in srgb, var(--note-color, var(--accent)) 12%, var(--card));
      border: 1px solid color-mix(in srgb, var(--note-color, var(--border)) 28%, var(--border));
      border-left: 4px solid var(--note-color, var(--accent));
      box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    }
    .job-note-avatar {
      flex-shrink: 0;
      width: 2rem;
      height: 2rem;
      border-radius: 50%;
      background: var(--note-color, var(--sh-primary));
      color: #fff;
      font-size: 0.72rem;
      font-weight: 700;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 2px solid var(--card);
      box-shadow: 0 0 0 1px var(--border);
    }
    .job-note-content {
      flex: 1;
      min-width: 0;
    }
    .job-note-body {
      min-width: 0;
      font-size: 0.92rem;
      font-weight: 500;
      line-height: 1.45;
      white-space: pre-wrap;
      word-break: break-word;
      color: var(--sh-text);
    }
    .job-note-meta {
      font-size: 0.72rem;
      color: var(--muted);
      margin-top: 0.25rem;
    }
    .job-note-meta .job-note-author {
      font-weight: 600;
      color: var(--note-color, var(--accent));
    }
    .job-note-remove {
      position: absolute;
      top: 0.4rem;
      right: 0.35rem;
      z-index: 2;
      min-width: 1.35rem;
      min-height: 1.35rem;
      padding: 0.1rem 0.2rem;
      border: none;
      background: transparent;
      color: #94a3b8;
      font-size: 1.15rem;
      font-weight: 500;
      line-height: 1;
      cursor: pointer;
      pointer-events: auto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .job-note-remove:hover {
      color: #475569;
      background: rgba(0, 0, 0, 0.04);
      border-radius: 4px;
    }
    .job-modal-note-form {
      display: flex;
      gap: 0.45rem;
      align-items: stretch;
    }
    #job-modal-note-input {
      flex: 1;
      min-width: 0;
      max-width: none;
      margin: 0;
      padding: 0.55rem 0.65rem;
      border-radius: 8px;
      border: 1px solid var(--border);
      font-size: 0.9rem;
    }
    #job-modal-note-input:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.15);
    }
    #job-modal-note-submit {
      flex-shrink: 0;
      padding: 0 1rem;
      font-weight: 600;
      font-size: 0.85rem;
      border: none;
      border-radius: 8px;
      background: var(--accent);
      color: #fff;
      cursor: pointer;
    }
    #job-modal-note-submit:hover { filter: brightness(1.06); }
    .job-modal-history-block {
      margin-top: 1rem;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0.65rem 0.9rem;
      background: linear-gradient(180deg, #fafafa 0%, var(--card) 28%);
    }
    .job-modal-history-toggle {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      margin: 0;
      padding: 0.15rem 0;
      border: none;
      background: transparent;
      cursor: pointer;
      font-family: var(--sh-font-display, inherit);
      font-size: 0.95rem;
      font-weight: 600;
      color: var(--text);
      text-align: left;
    }
    .job-modal-history-toggle:hover {
      color: var(--accent);
    }
    .job-modal-history-toggle-label {
      flex: 1;
      min-width: 0;
    }
    .job-modal-history-chevron {
      flex-shrink: 0;
      font-size: 0.72rem;
      color: var(--muted);
      transition: transform 0.15s ease;
    }
    .job-modal-history-toggle[aria-expanded="true"] .job-modal-history-chevron {
      transform: rotate(180deg);
    }
    .job-modal-history-panel {
      margin-top: 0.65rem;
      padding-top: 0.65rem;
      border-top: 1px solid var(--border);
    }
    .job-modal-history-panel[hidden] {
      display: none !important;
    }
    #job-modal-history-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
      max-height: 10rem;
      overflow-y: auto;
    }
    #job-modal-history-list li {
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fff;
      padding: 0.45rem 0.55rem;
      font-size: 0.84rem;
      display: flex;
      justify-content: space-between;
      gap: 0.65rem;
      align-items: baseline;
    }
    #job-modal-history-list .muted {
      font-style: italic;
      color: var(--muted);
    }
    .history-meta { color: var(--muted); font-size: 0.78rem; }
    .job-modal-files-block {
      margin-top: 1rem;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0.65rem 0.9rem;
      background: linear-gradient(180deg, #fafafa 0%, var(--card) 28%);
    }
    .job-modal-files-toggle {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      margin: 0;
      padding: 0.15rem 0;
      border: none;
      background: transparent;
      cursor: pointer;
      font-family: var(--sh-font-display, inherit);
      font-size: 0.95rem;
      font-weight: 600;
      color: var(--text);
      text-align: left;
    }
    .job-modal-files-toggle:hover {
      color: var(--accent);
    }
    .job-modal-files-toggle-label {
      flex: 1;
      min-width: 0;
    }
    .job-modal-files-count {
      flex-shrink: 0;
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--muted);
    }
    .job-modal-files-count:empty {
      display: none;
    }
    .job-modal-files-chevron {
      flex-shrink: 0;
      font-size: 0.72rem;
      color: var(--muted);
      transition: transform 0.15s ease;
    }
    .job-modal-files-toggle[aria-expanded="true"] .job-modal-files-chevron {
      transform: rotate(180deg);
    }
    .job-modal-files-panel {
      margin-top: 0.65rem;
      padding-top: 0.65rem;
      border-top: 1px solid var(--border);
    }
    .job-modal-files-panel[hidden] {
      display: none !important;
    }
    .job-modal-files-empty {
      margin: 0 0 0.65rem;
      font-size: 0.84rem;
      color: var(--muted);
      font-style: italic;
    }
    .job-modal-files-empty[hidden] {
      display: none !important;
    }
    .job-modal-files-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
      gap: 0.55rem;
      margin-bottom: 0.75rem;
    }
    .job-modal-files-grid:empty {
      display: none;
      margin-bottom: 0;
    }
    .job-file-tile {
      position: relative;
      display: block;
      width: 100%;
      aspect-ratio: 1;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
      cursor: pointer;
      text-align: left;
    }
    .job-file-tile img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .job-file-tile--pdf {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0.35rem;
      padding: 0.45rem;
      color: var(--text);
      text-decoration: none;
    }
    .job-file-tile--pdf svg {
      width: 1.75rem;
      height: 1.75rem;
      flex-shrink: 0;
      color: var(--accent);
    }
    .job-file-tile-name {
      font-size: 0.65rem;
      line-height: 1.25;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      word-break: break-word;
    }
    .job-file-delete {
      position: absolute;
      top: 0.2rem;
      right: 0.2rem;
      width: 1.35rem;
      height: 1.35rem;
      padding: 0;
      border: none;
      border-radius: 999px;
      background: rgba(15, 23, 42, 0.72);
      color: #fff;
      font-size: 0.95rem;
      line-height: 1;
      cursor: pointer;
      z-index: 1;
    }
    .job-file-delete:hover {
      background: #b91c1c;
    }
    .job-modal-files-actions {
      display: flex;
      justify-content: flex-start;
    }
    .job-modal-files-uploading {
      margin: 0 0 0.55rem;
      font-size: 0.84rem;
      color: var(--accent);
      font-weight: 500;
    }
    .job-modal-files-uploading[hidden] {
      display: none !important;
    }
    .job-files-lightbox {
      position: fixed;
      inset: 0;
      z-index: 200;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.25rem;
      background: rgba(15, 23, 42, 0.82);
    }
    .job-files-lightbox[hidden] {
      display: none !important;
    }
    .job-files-lightbox img {
      max-width: min(100%, 56rem);
      max-height: min(88vh, 48rem);
      border-radius: 10px;
      box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
    }
    .job-files-lightbox-close {
      position: absolute;
      top: 1rem;
      right: 1rem;
      width: 2.5rem;
      height: 2.5rem;
      border: none;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.92);
      color: #0f172a;
      font-size: 1.35rem;
      line-height: 1;
      cursor: pointer;
    }
    .job-modal-invoice-block {
      margin-top: 1rem;
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 0.85rem 0.9rem 0.75rem;
      background: linear-gradient(180deg, #fafafa 0%, var(--card) 28%);
    }
    .job-modal-invoice-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.55rem;
      margin-bottom: 0.6rem;
      flex-wrap: wrap;
    }
    .job-modal-invoice-top-actions {
      display: flex;
      align-items: center;
      gap: 0.45rem;
      flex-wrap: wrap;
    }

    .job-modal-invoice-pdf-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.4rem;
      min-height: 2rem;
      height: 2rem;
      padding: 0 0.8rem;
      margin: 0;
      font-family: inherit;
      font-size: 0.8125rem;
      font-weight: 600;
      letter-spacing: -0.01em;
      line-height: 1;
      border-radius: 10px;
      border: 1px solid var(--sh-primary-border, #93c5fd);
      background: var(--sh-primary-soft, #eff6ff);
      color: var(--sh-primary-hover, #1d4ed8);
      box-shadow: none;
      cursor: pointer;
      transition:
        background-color 0.12s ease,
        border-color 0.12s ease,
        color 0.12s ease;
    }

    .job-modal-invoice-pdf-btn span {
      display: block;
      line-height: 1;
    }

    .job-modal-invoice-pdf-btn svg {
      width: 0.875rem;
      height: 0.875rem;
      flex-shrink: 0;
      display: block;
    }

    .job-modal-invoice-pdf-btn:hover:not(:disabled) {
      background: #e8f2ff;
      border-color: var(--sh-primary, #2563eb);
      color: var(--sh-primary, #2563eb);
    }

    .job-modal-invoice-pdf-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    }

    .job-modal-invoice-pdf-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .invoice-status-pill {
      display: inline-flex;
      align-items: center;
      font-family: var(--sh-font-display);
      font-size: 0.6875rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      line-height: 1;
      padding: 0.3rem 0.62rem;
      border-radius: 999px;
      border: none;
      text-transform: capitalize;
      white-space: nowrap;
    }
    .invoice-status-pill.draft {
      background: #eef2f6;
      color: #475569;
    }
    .invoice-status-pill.sent {
      background: var(--sh-primary-soft);
      color: var(--sh-primary-hover);
    }
    .invoice-status-pill.paid {
      background: #ecfdf5;
      color: #047857;
    }
    .invoice-status-pill.void {
      background: #fff1f2;
      color: #be123c;
    }
    #job-modal-create-invoice {
      padding: 0.45rem 0.8rem;
      border: none;
      border-radius: 8px;
      background: var(--accent);
      color: #fff;
      font-weight: 600;
      cursor: pointer;
    }
    #job-modal-create-invoice:hover { filter: brightness(1.06); }
    .invoice-inline-form {
      display: grid;
      grid-template-columns: 8rem 1fr 4.5rem 6.5rem auto;
      gap: 0.45rem;
      margin-bottom: 0.55rem;
    }
    #job-modal-item-form.invoice-inline-form {
      --invoice-row-h: 2.05rem;
      grid-template-columns: minmax(6.75rem, 8.25rem) minmax(5rem, 1fr) minmax(3.5rem, 4rem) minmax(5.5rem, 6.25rem) auto;
      align-items: center;
    }
    #job-modal-item-form input,
    #job-modal-item-form select {
      margin: 0;
      max-width: none;
      height: var(--invoice-row-h);
      box-sizing: border-box;
    }
    #job-modal-item-form #job-modal-item-qty {
      width: 100%;
      min-width: 0;
      padding-left: 0.2rem;
      padding-right: 0.2rem;
      text-align: center;
      font-variant-numeric: tabular-nums;
    }
    #job-modal-item-form #job-modal-item-description {
      min-width: 0;
    }
    #job-modal-item-form .price-catalog-search-wrap {
      min-width: 0;
      width: 100%;
    }
    #job-modal-item-form .job-modal-item-normal-fields {
      display: contents;
    }
    #job-modal-item-form .sh-select {
      margin: 0;
      min-width: 0;
      width: 100%;
    }
    .invoice-inline-form input,
    .invoice-inline-form select {
      margin: 0;
      max-width: none;
    }
    .invoice-inline-form .invoice-add-btn,
    .invoice-inline-form .invoice-record-btn {
      border: none;
      border-radius: 8px;
      padding: 0 0.8rem;
      background: var(--accent);
      color: #fff;
      font-weight: 600;
      cursor: pointer;
    }
    .invoice-inline-form .invoice-add-btn:hover,
    .invoice-inline-form .invoice-record-btn:hover { filter: brightness(1.06); }
    #job-modal-item-form .invoice-add-btn {
      width: var(--invoice-row-h);
      height: var(--invoice-row-h);
      min-width: var(--invoice-row-h);
      padding: 0;
      border-radius: 8px;
      background: var(--sh-primary);
      color: #fff;
      font-size: 1.15rem;
      font-weight: 600;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-family: inherit;
      box-sizing: border-box;
      box-shadow: 0 2px 6px rgba(var(--sh-primary-rgb), 0.3);
    }
    #job-modal-item-form .invoice-add-btn:hover {
      background: var(--sh-primary-hover);
      filter: none;
      box-shadow: 0 2px 10px rgba(var(--sh-primary-rgb), 0.38);
    }
    #job-modal-payment-form.invoice-inline-form {
      grid-template-columns: minmax(5.5rem, 6.75rem) minmax(10.5rem, 1fr) minmax(10.75rem, auto);
      align-items: center;
    }
    #job-modal-payment-form #job-modal-payment-method,
    #job-modal-payment-form #job-modal-payment-amount {
      height: 2.05rem;
      box-sizing: border-box;
      margin: 0;
      max-width: none;
      font-size: 0.84rem;
      font-family: inherit;
      font-weight: 400;
    }
    #job-modal-payment-form #job-modal-payment-amount {
      width: 100%;
      min-width: 10.5rem;
      padding: 0 0.5rem;
    }
    #job-modal-payment-form .invoice-record-btn {
      height: 2.05rem;
      width: 100%;
      min-width: 10.75rem;
      padding: 0 1rem;
      border: none;
      border-radius: 8px;
      background: var(--sh-primary);
      color: #fff;
      font-size: 0.84rem;
      font-weight: 600;
      font-family: var(--sh-font-display);
      white-space: nowrap;
      cursor: pointer;
      box-sizing: border-box;
      box-shadow: 0 2px 6px rgba(var(--sh-primary-rgb), 0.3);
    }
    #job-modal-payment-form .invoice-record-btn:hover {
      background: var(--sh-primary-hover);
      filter: none;
      box-shadow: 0 2px 10px rgba(var(--sh-primary-rgb), 0.38);
    }
    #job-modal-payment-form .sh-select,
    #job-modal-item-form .sh-select {
      position: relative;
      z-index: 1;
    }
    #job-modal-payment-form .sh-select.is-open,
    #job-modal-item-form .sh-select.is-open {
      z-index: 10062;
    }
    .invoice-sheet {
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: visible;
      background: linear-gradient(180deg, #f8fafc 0%, #fff 18%);
      margin-bottom: 0.55rem;
    }
    .invoice-sheet .invoice-inline-form {
      margin-bottom: 0;
      padding: 0.55rem 0.6rem 0.5rem;
      border-bottom: 1px solid var(--border);
      background: #fff;
      overflow: visible;
      position: relative;
      z-index: 2;
    }
    .invoice-sheet .sh-select.is-open {
      z-index: 3;
    }
    .invoice-sheet ul.invoice-list {
      margin: 0;
      padding: 0.38rem 0.45rem 0.5rem;
      gap: 0.28rem;
      max-height: 12rem;
      scroll-behavior: smooth;
    }
    .invoice-sheet ul.invoice-list li {
      border-radius: 7px;
      padding: 0.4rem 0.52rem;
    }
    .invoice-sheet ul.invoice-list li.invoice-line-muted {
      justify-content: flex-start;
      border-style: dashed;
      background: rgba(248, 250, 252, 0.85);
      color: var(--muted);
      font-style: italic;
      font-size: 0.8rem;
    }
    .invoice-sheet ul.invoice-list li.invoice-line-muted span:last-child {
      font-weight: 400;
      font-variant-numeric: normal;
    }
    .invoice-lines-toolbar {
      padding: 0.55rem 0.6rem;
      border-top: 1px solid var(--border);
      background: #fff;
    }
    .invoice-lines-toolbar:not(:has(.invoice-lines-expand-btn:not([hidden]))) {
      display: none;
    }
    .invoice-lines-expand-btn {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 2.25rem;
      margin: 0;
      padding: 0 1rem;
      border: 1px solid var(--sh-primary-border, #93c5fd);
      border-radius: 10px;
      background: var(--sh-primary-soft, #eff6ff);
      color: var(--sh-primary-hover, #1d4ed8);
      cursor: pointer;
      font-family: inherit;
      font-size: 0.8125rem;
      font-weight: 600;
      letter-spacing: -0.01em;
      line-height: 1;
      text-decoration: none;
      box-shadow: none;
      transition:
        background-color 0.12s ease,
        border-color 0.12s ease,
        color 0.12s ease;
    }
    .invoice-lines-expand-btn:hover {
      background: #e8f2ff;
      border-color: var(--sh-primary, #2563eb);
      color: var(--sh-primary, #2563eb);
    }
    .invoice-lines-expand-btn:focus-visible {
      outline: none;
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    }
    .invoice-lines-overlay {
      position: fixed;
      inset: 0;
      z-index: 60;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: max(0.75rem, env(safe-area-inset-top, 0px))
        max(0.75rem, env(safe-area-inset-right, 0px))
        max(0.75rem, env(safe-area-inset-bottom, 0px))
        max(0.75rem, env(safe-area-inset-left, 0px));
    }
    .invoice-lines-overlay[hidden] {
      display: none !important;
    }
    .invoice-lines-overlay-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
    }
    .invoice-lines-overlay-panel {
      position: relative;
      z-index: 1;
      display: flex;
      flex-direction: column;
      width: min(40rem, 94vw);
      max-height: min(88dvh, calc(100dvh - 1.5rem));
      background: var(--card, #fff);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22);
      overflow: hidden;
    }
    .invoice-lines-overlay-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      padding: 0.85rem 1rem 0.65rem;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    }
    .invoice-lines-overlay-header h3 {
      margin: 0;
      font-size: 1rem;
      font-weight: 700;
    }
    .invoice-lines-overlay-close {
      flex-shrink: 0;
      width: 2rem;
      height: 2rem;
      margin: 0;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fff;
      color: var(--muted);
      font-size: 1.25rem;
      line-height: 1;
      cursor: pointer;
    }
    .invoice-lines-overlay-close:hover {
      color: var(--text);
      background: #f4f4f5;
    }
    .invoice-lines-overlay-body {
      overflow-y: auto;
      flex: 1;
      min-height: 0;
      padding: 0 0.5rem 0.75rem;
    }
    .invoice-sheet--expanded {
      border: none;
      margin: 0;
      background: transparent;
    }
    .invoice-sheet--expanded .invoice-lines-toolbar {
      display: none;
    }
    .invoice-sheet--expanded ul.invoice-list {
      max-height: none;
    }
    .invoice-list {
      list-style: none;
      margin: 0 0 0.6rem;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
      max-height: 9rem;
      overflow-y: auto;
    }
    .invoice-list li {
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 0.45rem 0.55rem;
      background: #fff;
      font-size: 0.82rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.65rem;
    }
    .invoice-list li:not(.invoice-line-row) span:last-child {
      font-weight: 700;
      font-variant-numeric: tabular-nums;
    }
    .invoice-line-row .invoice-line-main {
      flex: 1;
      min-width: 0;
      line-height: 1.35;
    }
    .invoice-line-row .invoice-line-amt {
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      flex-shrink: 0;
    }
    .invoice-line-row.invoice-line-row--warranty {
      flex-wrap: wrap;
      align-items: flex-start;
    }
    .invoice-line-row--warranty .invoice-line-body {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
    }
    .invoice-line-warranty-detail {
      font-size: 0.74rem;
      color: var(--muted);
      line-height: 1.35;
    }
    #job-modal-item-form .job-modal-item-normal-fields {
      display: contents;
    }
    #job-modal-item-form.is-warranty-line {
      grid-template-columns: minmax(6.75rem, 8.25rem) minmax(0, 1fr) auto;
    }
    #job-modal-item-form.is-warranty-line .job-modal-item-normal-fields {
      display: none;
    }
    .invoice-warranty-panel {
      padding: 0.5rem 0.6rem 0.6rem;
      border-bottom: 1px solid var(--border);
      background: #f8fafc;
    }
    .invoice-warranty-hint {
      margin: 0 0 0.45rem;
      font-size: 0.78rem;
      color: var(--muted);
      line-height: 1.35;
    }
    .invoice-warranty-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      column-gap: 0.6rem;
      row-gap: 0.5rem;
      grid-auto-rows: auto auto;
    }
    .invoice-warranty-field {
      display: grid;
      grid-template-rows: subgrid;
      grid-row: span 2;
      gap: 0.28rem;
      min-width: 0;
    }
    .invoice-warranty-field--wide {
      grid-column: 1 / -1;
      grid-row: span 2;
    }
    .invoice-warranty-label {
      font-size: 0.72rem;
      color: var(--muted);
      line-height: 1.25;
      display: flex;
      align-items: flex-end;
      margin: 0;
      min-width: 0;
    }
    .invoice-warranty-label-required::after {
      content: " *";
      color: #b45309;
      font-weight: 600;
    }
    .invoice-warranty-field input,
    .invoice-warranty-field textarea {
      margin: 0;
      max-width: none;
      font-size: 0.8125rem;
      box-sizing: border-box;
      width: 100%;
      height: 2.05rem;
    }
    .invoice-warranty-field textarea {
      height: auto;
      resize: vertical;
      min-height: 2.5rem;
    }
    .invoice-warranty-money {
      display: flex;
      align-items: stretch;
      min-width: 0;
    }
    .invoice-warranty-money-prefix {
      display: flex;
      align-items: center;
      flex-shrink: 0;
      padding: 0 0.45rem;
      font-size: 0.8125rem;
      font-weight: 600;
      color: var(--muted);
      background: #fff;
      border: 1px solid var(--border);
      border-right: none;
      border-radius: 8px 0 0 8px;
      box-sizing: border-box;
      height: 2.05rem;
    }
    .invoice-warranty-money input {
      border-radius: 0 8px 8px 0;
      flex: 1;
      min-width: 0;
    }
    @media (max-width: 520px) {
      .invoice-warranty-grid {
        grid-template-columns: 1fr;
      }
      .invoice-warranty-field {
        grid-row: span 2;
      }
    }
    @supports not (grid-template-rows: subgrid) {
      .invoice-warranty-field {
        grid-template-rows: 2.875rem auto;
      }
      .invoice-warranty-label {
        min-height: 2.875rem;
      }
    }
    button.invoice-line-remove {
      flex-shrink: 0;
      width: 1.65rem;
      height: 1.65rem;
      margin: 0;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 7px;
      background: #fff;
      color: var(--muted);
      font-size: 1.05rem;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    button.invoice-line-remove:hover:not(:disabled) {
      color: #b91c1c;
      border-color: #fecaca;
      background: #fef2f2;
    }
    button.invoice-line-remove:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }
    .invoice-list li.payment-row {
      position: relative;
      padding-right: 2rem;
    }
    .payment-row .payment-line-main {
      flex: 1;
      min-width: 0;
    }
    .payment-row .payment-line-amt {
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      flex-shrink: 0;
    }
    button.payment-remove {
      position: absolute;
      top: 50%;
      right: 0.35rem;
      transform: translateY(-50%);
      z-index: 2;
      min-width: 1.35rem;
      min-height: 1.35rem;
      padding: 0.1rem 0.2rem;
      border: none;
      background: transparent;
      color: #94a3b8;
      font-size: 1.15rem;
      font-weight: 500;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    button.payment-remove:hover {
      color: #475569;
      background: rgba(0, 0, 0, 0.04);
      border-radius: 4px;
    }
    .invoice-totals {
      border: 1px solid var(--border);
      border-radius: 8px;
      background: #fff;
      padding: 0.5rem 0.6rem;
      margin-bottom: 0.6rem;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 0.25rem 0.65rem;
      font-size: 0.82rem;
    }
    .invoice-totals strong { font-size: 0.88rem; }
    .invoice-empty-text {
      margin: 0.2rem 0 0.5rem;
      color: var(--muted);
      font-size: 0.84rem;
      font-style: italic;
    }
    .invoice-loading-hint {
      margin: 0.35rem 0 0.55rem;
      font-size: 0.85rem;
      color: var(--muted);
      font-style: italic;
    }
    .invoice-loading-hint[hidden] { display: none !important; }
    .invoice-tax-hint {
      margin: 0 0 0.55rem;
      font-size: 0.78rem;
      color: var(--muted);
      line-height: 1.35;
    }
    .invoice-tax-hint a {
      color: var(--accent);
      font-weight: 600;
    }
    @media (max-width: 620px) {
      .invoice-inline-form {
        grid-template-columns: 1fr 1fr;
      }
      #job-modal-payment-form.invoice-inline-form {
        grid-template-columns: 1fr;
      }
      #job-modal-payment-form.invoice-inline-form input[type="number"] {
        width: 100%;
      }
      .invoice-inline-form .invoice-add-btn,
      .invoice-inline-form .invoice-record-btn { min-height: 2rem; }
    }
    
.job-modal--readonly #job-modal-edit-details,
.job-modal--readonly #job-modal-assign-row,
.job-modal--readonly #job-modal-rush-row,
.job-modal--readonly #job-modal-details-edit,
.job-modal--readonly .job-modal-note-form,
.job-modal--readonly .job-modal-files-actions,
.job-modal--readonly .job-file-delete,
.job-modal--readonly #job-modal-review-actions,
.job-modal--readonly #job-modal-create-invoice,
.job-modal--readonly #job-modal-item-form,
.job-modal--readonly #job-modal-payment-form,
.job-modal--readonly .job-note-remove,
.job-modal--readonly .invoice-line-remove,
.job-modal--readonly .payment-remove { display: none !important; }
.job-modal-readonly-footer { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--sh-border); text-align: center; }
.job-modal-readonly-footer[hidden] { display: none !important; }
.customer-jobs-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.customer-job-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; width: 100%; padding: 0.55rem 0.5rem; border: none; border-bottom: 1px solid var(--sh-border); background: transparent; font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer; color: inherit; }
.customer-job-row:hover { background: #f1f5f9; }
.customer-job-row .job-meta { color: var(--sh-muted); font-size: 0.78rem; }

/* Mobile: read-only job view (e.g. Customers → job history) — centered popup, not full-screen sheet */
@media (max-width: 639px) {
  .job-modal.job-modal--readonly {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
      max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    overflow-y: auto;
  }

  .job-modal.job-modal--readonly .job-modal-panel {
    width: 100%;
    max-width: min(26rem, 100%);
    min-height: 0;
    max-height: min(88dvh, calc(100dvh - 1.5rem));
    margin: auto;
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  }

  .job-modal.job-modal--readonly .job-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
