:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d7dee8;
  --text: #1d2939;
  --muted: #667085;
  --primary: #17375e;
  --primary-hover: #122c4b;

  /* ITS green accent */
  --accent: #69b345;
  --accent-hover: #5ca03b;
  --secondary: #eef3f7;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-logo {
  display: block;
  height: 42px;
  width: auto;
  max-width: 180px;
}

.portal-brand__title {
  color: var(--primary);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* Generic page */
.page {
  width: min(98%, 1900px);
  max-width: none;
  margin: 0 auto;
  padding: 16px;
}

.page-header {
  margin-bottom: 10px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid #c9d2de;
  font-size: 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  height: 39px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid #4e8f31;
  background: #5fa53d;
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition:
    background 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.primary-btn:hover {
  background: #f6fff1;
  border-color: #5fa53d;
  color: #000000;
  transform: translateY(-1px);

  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.primary-btn:active {
  background: #1e40af;
  border-color: #1e40af;
}

.danger-icon-btn {
  width: 34px;
  min-width: 34px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #000000;
  color: #000000;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.danger-icon-btn::before {
  content: "🗑";
}

.danger-icon-btn:hover {
  background: #b42318;
  color: #ffffff;
  border: 1px solid #b42318;
}

.danger-icon-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.doc-id-actions {
  display: inline-flex;
  align-items: center;
  gap: 25px;
  white-space: nowrap;
}

.document-delete-btn {
  flex-shrink: 0;
}

.danger-icon-btn:hover {
  background: #b42318;
  color: #ffffff;
}

.danger-icon-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.doc-id-inline {
  margin-right: 8px;
}

.document-delete-btn {
  flex-shrink: 0;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid #c9d2de;
  background: var(--secondary);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.status-row {
  margin-top: 12px;
  margin-bottom: 12px;
}

.status-message {
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}

/* Portal */
.portal-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.portal-topbar {
  width: 100%;
  margin: 0;
  padding: 14px max(24px, calc((100vw - 1900px) / 2)) 10px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background: #e9e9e9;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.portal-brand__title {
  font-size: 22px;
  font-weight: 700;
  color: #47b453;
}

.portal-userbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-card--iframe {
  max-width: 1500px;
  width: min(96vw, 1500px);
  height: min(94vh, 1100px);
}

.modal-card__body--iframe {
  padding: 0;
  overflow: hidden;
}

.modal-card--iframe {
  max-width: 1500px;
  width: min(96vw, 1500px);
  height: min(94vh, 1100px);
  display: flex;
  flex-direction: column;
}

.modal-card__body--iframe {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.create-job-modal-frame,
.create-customer-modal-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.create-job-modal-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.account-menu {
  position: relative;
}

.account-btn {
  gap: 8px;
  min-width: 0;
}

.account-btn::before {
  content: "Account:";
  color: var(--muted);
  font-weight: 500;
}

.account-btn__caret {
  font-size: 11px;
  line-height: 1;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.account-dropdown__item {
  width: 100%;
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.account-dropdown__item:hover {
  background: #f3f6fb;
}

.portal-tabs {
  width: 100%;
  margin: 0 0 12px;
  padding: 10px max(24px, calc((100vw - 1900px) / 2)) 14px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  background: #e9e9e9;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.portal-tabs__left {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex-wrap: wrap;
}

.portal-tabs__right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.portal-tab {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: transparent;
  color: #000000;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.portal-tab:hover {
  color: #39b418;
}

.portal-tab.is-active {
  background: #ffffff;
  border-color: #ffffff;
  color: #234b12;
}

.portal-main {
  width: min(98%, 1900px);
  max-width: none;
  margin: 0 auto;
}

.portal-view {
  width: 100%;
}

/* Home dashboard */
.home-dashboard-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 0;
}

.home-dashboard-card h2 {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 24px;
}

.home-dashboard-card > * {
  padding-left: 24px;
  padding-right: 24px;
}

.home-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.home-action-tile,
.home-panel-tile {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 0 22px;
  border: 1px solid #9dcb86;
  border-radius: 20px;
  background: #edf7e8;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.home-action-tile:hover,
.home-panel-tile:hover {
  background: #ffffff;

  border-color: #9dcb86;

  box-shadow:
    0 8px 18px rgba(16, 24, 40, 0.08),
    0 2px 4px rgba(16, 24, 40, 0.06);

  transform: translateY(-1px);
}

/* Job detail view */
.layout {
  display: grid;
  gap: 16px;
}

.layout--single {
  grid-template-columns: 1fr;
}

.layout--split {
  grid-template-columns: minmax(360px, 32%) minmax(0, 68%);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
}

.viewer-header {
  display: block;
}

.viewer-header h2 {
  margin: 0 0 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf4ff;
  color: #134074;
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #c9d2de;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}

.field input[readonly] {
  background: #f8fafc;
}

.field--full {
  grid-column: 1 / -1;
}

.field-label-spacer {
  display: block;
  height: 22px; /* match label + margin exactly */
}

.field--checkbox-inline {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.field--checkbox-inline .checkbox-inline {
  width: 100%;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #c9d2de;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 16px;
  font-weight: 600;
}

.checkbox-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.checkbox-inline span {
  line-height: 1.2;
}

#reloadDocBtn {
  white-space: nowrap;
}

.viewer-empty {
  min-height: 620px;
  border: 1px dashed #c7d0dc;
  border-radius: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.viewer-empty__icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.viewer-empty__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.doc-frame {
  width: 100%;
  min-height: 780px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f5f7fb;
  overflow: auto;
  padding: 12px;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto !important;
  margin: 0 auto 14px;
  background: #fff;
  border: 1px solid #d6dde8;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

/* Allow actual PDF zoom inside modal viewers */
.doc-frame--modal .pdf-page-canvas {
  width: auto;
  max-width: none;
}

.pdf-loading {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.back-btn {
  min-height: 40px;
  padding: 0 14px;
  margin-bottom: 8px;
}

.viewer-detail-header {
  padding-bottom: 10px;
}

.viewer-detail-header__title-row {
  margin-top: 10px;
  margin-bottom: 10px;
}

.viewer-detail-header__title-row h1 {
  margin: 0;
}

.viewer-detail-header__actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.viewer-detail-header .actions-left {
  display: flex;
  align-items: center;
}

.viewer-detail-header .actions-right {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 10px;
}

.viewer-detail-header .back-btn {
  margin-bottom: 0;
}

.viewer-detail-header__actions-row a,
.viewer-detail-header__actions-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.doc-grid {
  width: 100%;
}

.doc-grid-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.viewer-detail-header__title-row--with-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.viewer-session-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #c9d2de;
  border-radius: 10px;
  background: var(--secondary);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.viewer-session-chip::before {
  content: "Account:";
  margin-right: 6px;
  color: var(--muted);
  font-weight: 500;
}

.pdf-viewer-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
}

.pdf-viewer-nav-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.pdf-tool-btn {
  min-width: 38px;
  height: 34px;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

.pdf-zoom-level {
  min-width: 58px;
}

.pdf-print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 700px) {
  .documents-viewer-nav-buttons,
  .doc-viewer-nav-buttons {
    flex-wrap: wrap;
    gap: 8px;
  }

  .pdf-viewer-tools {
    order: 1;
    justify-content: flex-start;
    margin-right: 0;
  }

  .pdf-viewer-nav-actions {
    order: 2;
    justify-content: flex-end;
    margin-left: auto;
  }

  .pdf-tool-btn {
    height: 32px;
    min-height: 32px;
    padding: 0 9px;
    font-size: 13px;
  }
}

@media (max-width: 700px) {
  .viewer-detail-header__title-row--with-status {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

.doc-grid-table__head,
.doc-grid-table__row {
  display: grid;
  grid-template-columns: 160px 110px 130px minmax(120px, 1fr) 120px;
  gap: 0;
  align-items: stretch;
}

.doc-grid-table--with-delete .doc-grid-table__head,
.doc-grid-table--with-delete .doc-grid-table__row {
  grid-template-columns: 160px 110px 130px minmax(140px, 1fr) 130px;
}

.doc-grid-table__head {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.doc-grid-table__head > div {
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-grid-table__body .doc-grid-table__row:not(:last-child) {
  border-bottom: 1px solid #eceff5;
}

.doc-grid-table__row {
  cursor: pointer;
  background: #fff;
}

.doc-grid-table__row:hover {
  background: #f8fbff;
}

.doc-grid-table__row:focus {
  outline: none;
  background: #f8fbff;
  box-shadow: inset 0 0 0 2px rgba(15, 108, 189, 0.18);
}

.doc-grid-table__cell {
  padding: 16px 18px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  word-break: break-word;
}

/* Jobs dashboard */
.jobs-page {
  max-width: none;
  margin: 0;
  padding: 0;
}

.jobs-dashboard {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 220px);
  background: transparent;
}

.jobs-filters {
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 16px 0 0 16px;
  padding: 16px 16px 18px;
}

.jobs-filter-list {
  padding: 0;
}

.jobs-filter-item {
  padding: 0 0 14px;
}

.jobs-filter-label-row {
  display: block;
  margin-bottom: 6px;
}

.jobs-filter-label-row label {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}

.jobs-filter-item input,
.jobs-filter-item select,
.jobs-filter-item .lookup-input {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid #97a3b6;
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  color: var(--text);
}

/* Fix iPhone From/To date fields */
.jobs-filter-item input[type="date"] {
  min-height: 38px;
  height: 38px;
  padding: 6px 10px;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

.lookup-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  display: none;
}

.jobs-filter-item input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

.jobs-filter-item input[type="date"]::-webkit-calendar-picker-indicator {
  margin-left: 6px;
}

.jobs-filter-item input:focus,
.jobs-filter-item select:focus,
.jobs-toolbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 108, 189, 0.12);
}

.jobs-filter-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.jobs-filter-actions button {
  width: 100%;
}

.jobs-results {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 16px 16px 0;
  overflow: hidden;
  min-height: 0;
}

.jobs-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid #d9dee7;
  min-height: 50px;
  background: #fff;
}

.jobs-toolbar-search {
  display: flex;
  align-items: center;
  width: 313px;
  height: 36px;
  border: 1px solid #c9d2de;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.jobs-toolbar-search input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: transparent;
}

.jobs-toolbar-search button {
  width: 42px;
  min-width: 42px;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  border-left: 1px solid #d7dde7;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
}

.table-reset-btn {
  width: 36px !important;
  min-width: 36px !important;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  border-left: 1px solid #d7dde7;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.table-reset-btn:hover {
  background: #f3f6fb;
}

.table-export-btn {
  width: auto !important;
  height: 100%;
  min-height: 0;
  padding: 0 10px;
  border: none;
  border-left: 1px solid #d7dde7;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.table-export-btn:hover {
  background: #f3f6fb;
}

.jobs-result-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.jobs-status-row {
  min-height: 30px;
}

.jobs-status-message {
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}

.jobs-table-shell {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  padding: 0;
  background: #fff;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.jobs-table thead th {
  position: relative;
  user-select: none;
  top: 0;
  z-index: 2;
  background: #f2f2f2;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-align: left;

  min-height: 42px;
  padding: 15px 8px 12px 10px;

  border-bottom: 1px solid #d9dee7;
  border-right: 1px solid #e2e6ee;

  vertical-align: middle;

  white-space: normal;
  line-height: 1.15;
}

.jobs-table thead th .th-label {
  display: block;
  padding-right: 24px;

  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;

  line-height: 1.15;
}

.jobs-table thead th:last-child {
  border-right: none;
}

.jobs-table thead th .sort-indicator {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 12px;
  text-align: center;
  pointer-events: none;
}

.jobs-table thead th.is-sortable .sort-indicator::before {
  content: "↕";
  opacity: 0.7;
}

.jobs-table thead th.is-sortable {
  cursor: pointer;
}

.jobs-table thead th.is-sorted-asc .sort-indicator::before {
  content: "▲";
  opacity: 1;
}

.jobs-table thead th.is-sorted-desc .sort-indicator::before {
  content: "▼";
  opacity: 1;
}

.jobs-table thead th .column-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 2;
}

.jobs-table thead th .column-resizer::before {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 1px;
  background: #c9d2de;
}

.jobs-table.is-resizing {
  cursor: col-resize;
}

.jobs-table.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.jobs-table tbody td {
  padding: 8px 8px 8px 10px;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid #eceff5;
  vertical-align: top;
  background: #fff;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.jobs-empty-row td {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.jobs-data-row {
  cursor: pointer;
}

.jobs-data-row:hover td {
  background: #f8fbff;
}

/* Alternating table row colors */
.jobs-table tbody tr:nth-child(odd) td {
  background: #ffffff;
}

.jobs-table tbody tr:nth-child(even) td {
  background: #edf3fb;
}

/* Keep hover color stronger */
.jobs-data-row:hover td {
  background: #dbeafe !important;
}

.jobs-data-row td:first-child {
  cursor: default;
}

.jobs-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px 18px;
  border-top: 1px solid #eceff5;
  background: #fff;
}

.jobs-page-btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}

.jobs-page-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.jobs-page-info {
  min-width: 110px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

#customersView .jobs-data-row td {
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-card__header,
.modal-card__body,
.modal-card__footer {
  padding: 12px;
}

.modal-card__header {
  border-bottom: 1px solid var(--border);
}

.modal-card__header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-card__body {
  display: grid;
  gap: 14px;
}

.modal-card__footer {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-card--viewer {
  max-width: 1300px;
  height: min(88vh, 1100px);
  display: flex;
  flex-direction: column;
}

.modal-card__header--viewer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.doc-viewer-header {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.doc-viewer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.doc-viewer-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
}

.doc-viewer-nav-row .pdf-loading {
  flex: 1 1 auto;
  min-height: 20px;
  padding: 0;
  text-align: left;
}

/* PDF viewer toolbar layout */
.doc-viewer-nav-row {
  width: 100%;
}

.doc-viewer-nav-buttons,
.documents-viewer-nav-buttons {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.pdf-viewer-tools {
  justify-self: start;
}

.pdf-viewer-nav-actions {
  justify-self: end;
}

.doc-viewer-nav-row .pdf-loading,
.documents-viewer-toolbar-status {
  min-height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  overflow: hidden;
}

.doc-viewer-nav-row .pdf-loading.hidden,
.documents-viewer-toolbar-status.hidden {
  display: flex !important;
  visibility: hidden;
}

@media (max-width: 700px) {
  .doc-viewer-nav-buttons,
  .documents-viewer-nav-buttons {
    grid-template-columns: 1fr auto;
    grid-template-areas: "tools nav";
    gap: 8px;
  }

  .pdf-viewer-tools {
    grid-area: tools;
    justify-self: start;
  }

  .pdf-viewer-nav-actions {
    grid-area: nav;
    justify-self: end;
    margin-left: 0;
  }

  .doc-viewer-nav-row .pdf-loading,
  .documents-viewer-toolbar-status {
    display: none !important;
  }
}

.documents-viewer-nav-buttons,
.doc-viewer-nav-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.modal-card__body--viewer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-frame--modal {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}

.doc-grid-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.doc-grid-table__head,
.doc-grid-table__row {
  display: grid;
  grid-template-columns: 160px 110px 130px minmax(100px, 1fr) 140px;
  gap: 0;
  align-items: stretch;
}

.doc-grid-table--with-delete .doc-grid-table__head,
.doc-grid-table--with-delete .doc-grid-table__row {
  grid-template-columns: 160px 110px 130px minmax(140px, 1fr) 130px;
}

.doc-grid-table__head {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.doc-grid-table__head > div {
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-grid-table__body .doc-grid-table__row:not(:last-child) {
  border-bottom: 1px solid #eceff5;
}

.doc-grid-table__row {
  cursor: pointer;
  background: #fff;
}

.doc-grid-table__row:hover {
  background: #f8fbff;
}

.doc-grid-table__row:focus {
  outline: none;
  background: #f8fbff;
  box-shadow: inset 0 0 0 2px rgba(15, 108, 189, 0.18);
}

.doc-grid-table__cell {
  padding: 16px 18px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  word-break: break-word;
}

/* Ensure jobs text never disappears inside portal */
#jobsView,
#jobsView .jobs-page,
#jobsView .jobs-results,
#jobsView .jobs-table,
#jobsView .jobs-table thead th,
#jobsView .jobs-table tbody td,
#jobsView .jobs-result-meta,
#jobsView .jobs-status-message,
#jobsView .jobs-filter-label-row label,
#jobsView .jobs-filter-item input,
#jobsView .jobs-filter-item select,
#jobsView .jobs-toolbar-search input,
#jobsView .jobs-toolbar-search button {
  color: var(--text);
}

/* Responsive */
@media (max-width: 1225px) {
  .jobs-dashboard {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .jobs-filters {
    border-right: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    border-bottom: none;
  }

  .jobs-results {
    border-radius: 0 0 16px 16px;
  }
}

@media (max-width: 980px) {
  .portal-tabs {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .portal-tabs__right {
    width: 100%;
    justify-content: flex-end;
  }
  .layout--split {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .doc-frame {
    min-height: 70vh;
  }

  .home-action-grid {
    grid-template-columns: 1fr;
  }

  .portal-topbar,
  .portal-tabs,
  .portal-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .portal-topbar {
    flex-wrap: wrap;
  }
}

/* iPhone specific date input fixes */
@supports (-webkit-touch-callout: none) {
  .jobs-filter-item input[type="date"] {
    height: 38px;
    min-height: 38px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@media (max-width: 900px) {
  .doc-grid-table__head {
    display: none;
  }

  .doc-grid-table__row {
    grid-template-columns: 1fr;
    padding: 10px 0;
  }

  .doc-grid-table__cell {
    padding: 8px 16px;
  }

  .doc-grid-table__cell::before {
    content: "";
    display: inline-block;
    min-width: 110px;
    margin-right: 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .doc-grid-table__row .doc-grid-table__cell:nth-child(1)::before {
    content: "Doc Type";
  }

  .doc-grid-table__row .doc-grid-table__cell:nth-child(2)::before {
    content: "Date Stored";
  }

  .doc-grid-table__row .doc-grid-table__cell:nth-child(3)::before {
    content: "Created By";
  }

  .doc-grid-table__row .doc-grid-table__cell:nth-child(4)::before {
    content: "File Type";
  }

  .doc-grid-table__row .doc-grid-table__cell:nth-child(5)::before {
    content: "Doc Id";
  }

  .doc-viewer-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .doc-viewer-title-row h2 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 22px;
    line-height: 1.15;
  }

  .doc-viewer-nav-row .pdf-loading {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    text-align: left;
    font-size: 14px;
  }

  .doc-viewer-nav-buttons {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  #docViewerPrevBtn,
  #docViewerNextBtn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 0 12px;
    white-space: nowrap;
  }

  .jobs-toolbar {
    flex-wrap: wrap;
  }

  .jobs-toolbar-search {
    width: 100%;
  }

  .jobs-result-meta {
    margin-left: 0;
    width: 100%;
  }

  .jobs-pagination {
    justify-content: center;
    flex-wrap: wrap;
  }

  .page {
    padding: 12px;
  }

  .page-header h1,
  .portal-brand__title {
    font-size: 20px;
  }

  #jobsView .jobs-table thead {
    display: none;
  }

  #jobsView .jobs-table,
  #jobsView .jobs-table tbody,
  #jobsView .jobs-table tr,
  #jobsView .jobs-table td {
    display: block;
    width: 100%;
  }

  #jobsView .jobs-table-shell {
    padding: 10px;
    background: #fff;
  }

  #jobsView .jobs-data-row--mobile {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
  }

  #jobsView .jobs-data-row--mobile td.jobs-mobile-cell {
    padding: 0;
    border-bottom: none;
  }

  #jobsView .jobs-mobile-summary {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
  }

  #jobsView .jobs-mobile-summary__main {
    min-width: 0;
    flex: 1 1 auto;
  }

  #jobsView .jobs-mobile-open {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    text-align: left;
    min-height: 0;
    cursor: pointer;
  }

  #jobsView .jobs-mobile-summary__job-number {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
  }

  #jobsView .jobs-mobile-summary__job-name {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    word-break: break-word;
  }

  #jobsView .jobs-mobile-summary__toggle {
    flex: 0 0 auto;
    min-height: 36px;
    width: 36px;
    padding: 0;
    border: 1px solid #d7dde7;
    border-radius: 8px;
    background: #fff;
    color: var(--primary);
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
  }

  #jobsView .jobs-mobile-details {
    border-top: 1px solid #eceff5;
    padding: 10px 16px 12px;
    background: #f8fafc;
  }

  #jobsView .jobs-mobile-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #e8edf5;
  }

  #jobsView .jobs-mobile-detail-row:last-child {
    border-bottom: none;
  }

  #jobsView .jobs-mobile-detail-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 110px;
  }

  #jobsView .jobs-mobile-detail-value {
    font-size: 14px;
    color: var(--text);
    text-align: right;
    word-break: break-word;
    flex: 1 1 auto;
  }

  #jobsView .jobs-empty-row td {
    display: table-cell;
    width: auto;
    padding: 36px 16px;
  }

  #documentsView .documents-table thead {
    display: none !important;
  }

  #documentsView .documents-table,
  #documentsView .documents-table tbody,
  #documentsView .documents-table tr,
  #documentsView .documents-table td {
    display: block !important;
    width: 100% !important;
  }

  #documentsView .documents-table thead,
  #documentsView .documents-table thead tr,
  #documentsView .documents-table thead th {
    display: none !important;
  }

  #documentsView .jobs-table-shell {
    padding: 10px;
    background: #fff;
    overflow-x: hidden;
  }

  #documentsView .documents-data-row--mobile {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
  }

  #documentsView .documents-data-row--mobile > td.documents-mobile-cell {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border-bottom: none !important;
  }

  #documentsView .documents-mobile-summary {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: #fff;
  }

  #documentsView .documents-mobile-summary__main {
    min-width: 0;
    width: 100%;
  }

  #documentsView .documents-mobile-open {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    text-align: left !important;
    color: var(--text) !important;
    font: inherit !important;
  }

  #documentsView .documents-mobile-summary__job-number {
    display: block;
    width: 100%;
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
  }

  #documentsView .documents-mobile-summary__job-name {
    display: block;
    width: 100%;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
    word-break: break-word;
  }

  #documentsView .documents-mobile-summary__toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #d7dde7 !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: var(--primary) !important;
    font-size: 22px !important;
    line-height: 1 !important;
    font-weight: 700 !important;
    justify-self: end;
    align-self: start;
  }

  #documentsView .documents-mobile-details {
    display: block;
    border-top: 1px solid #eceff5;
    padding: 10px 16px 12px;
    background: #f8fafc;
  }

  #documentsView .documents-mobile-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #e8edf5;
  }

  #documentsView .documents-mobile-detail-row:last-child {
    border-bottom: none;
  }

  #documentsView .documents-mobile-detail-label {
    flex: 0 0 110px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #documentsView .documents-mobile-detail-value {
    flex: 1 1 auto;
    font-size: 14px;
    color: var(--text);
    text-align: right;
    word-break: break-word;
  }

  #documentsView .jobs-empty-row td {
    display: table-cell !important;
    width: auto !important;
    padding: 36px 16px;
  }

  .field-label-spacer {
    display: none;
  }
}

/* Documents view */
.documents-table {
  width: 100%;
  table-layout: fixed;
}

.documents-table thead th,
.documents-table tbody td {
  min-width: 0 !important;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}

.documents-table tbody td:nth-child(2),
.documents-table tbody td:nth-child(7),
.documents-table tbody td:nth-child(8),
#jobsView .jobs-table tbody td:nth-child(2),
#jobsView .jobs-table tbody td:nth-child(7),
#jobsView .jobs-table tbody td:nth-child(8),
#customersView .jobs-table tbody td:nth-child(3) {
  word-break: break-word;
  overflow-wrap: normal;
}

#documentsView .jobs-table-shell {
  overflow-x: hidden;
}

#documentsView .jobs-data-row {
  cursor: pointer;
}

#documentsView .jobs-data-row:hover td {
  background: #f8fbff;
}

#documentsView .jobs-table,
#documentsView .jobs-table thead th,
#documentsView .jobs-table tbody td,
#documentsView .jobs-result-meta,
#documentsView .jobs-status-message,
#documentsView .jobs-filter-label-row label,
#documentsView .jobs-filter-item input,
#documentsView .jobs-filter-item select,
#documentsView .jobs-toolbar-search input,
#documentsView .jobs-toolbar-search button {
  color: var(--text);
}

.dropdown-field {
  position: relative;
}

.dropdown-field .lookup-input {
  padding-right: 34px !important;
}

.dropdown-field::after {
  content: "▼";
  position: absolute;
  right: 12px;
  top: 38px;
  font-size: 12px;
  line-height: 1;
  color: #667085;
  pointer-events: none;
}

.filter-row--two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 0;
  margin-bottom: 14px;
}

.filter-row--two .jobs-filter-item {
  padding: 0;
  min-width: 0;
}

.filter-row--two .jobs-filter-item input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
}

.filter-row--two .jobs-filter-label-row {
  margin-bottom: 6px;
}

.modal-viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-viewer-nav-info {
  min-width: 70px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.documents-viewer-header {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.documents-viewer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.documents-viewer-title-row h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.documents-viewer-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.documents-viewer-nav-row .modal-viewer-nav-info {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}

.documents-viewer-nav-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

#documentsViewerPrevBtn,
#documentsViewerNextBtn,
#documentsViewerCloseBtn {
  white-space: nowrap;
}

@media (max-width: 700px) {
  #createJobModal {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    background: rgba(15, 23, 42, 0.45);
  }

  #createJobModal .modal-card--iframe {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  #createJobModal .modal-card__header--viewer {
    flex: 0 0 auto;
    background: #fff;
  }

  #createJobModal .modal-card__body--iframe {
    flex: 1 1 auto;
    min-height: 0;
    background: #fff;
  }

  #createJobModalFrame {
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #fff;
  }
}

@media (max-width: 700px) {
  .jobs-filter-list .filter-row--two {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: end;
  }

  .jobs-filter-list .filter-row--two .jobs-filter-item {
    width: 100%;
    min-width: 0;
    padding-bottom: 14px;
  }

  .jobs-filter-list .filter-row--two .jobs-filter-item input[type="date"] {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 15px;
    text-align: left;
    box-sizing: border-box;
  }
}

.modal-card--native-doc {
  width: min(98vw, 1900px);
  max-width: 1900px;
  height: 96vh;
}

.modal-card__body--native-doc {
  flex: 1 1 85%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.native-doc-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 700px) {
  #createJobModal,
  #createCustomerModal {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }

  #createJobModal .modal-card--iframe,
  #createCustomerModal .modal-card--iframe {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

.pdf-fallback-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 6px 0 0;
}

.pdf-fallback-toolbar .pdf-viewer-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.pdf-fallback-toolbar .documents-viewer-toolbar-status {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}

.modal-card__body--native-doc .doc-frame--modal {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #3c3c3c;
  padding: 12px;
}

.modal-card__body--native-doc .pdf-page-canvas {
  background: #fff;
  margin: 0 auto 14px;
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

@media (max-width: 700px) {
  .pdf-fallback-toolbar {
    align-items: flex-start;
    gap: 8px;
  }

  .pdf-fallback-toolbar .pdf-viewer-tools {
    width: auto;
  }

  .pdf-tool-btn {
    min-width: 34px;
    height: 32px;
    min-height: 32px;
    padding: 0 9px;
  }

  .pdf-zoom-level {
    min-width: 56px;
  }
  .modal-card--viewer {
    margin-top: 10px;
  }

  .modal-card--viewer .modal-card__header--viewer {
    padding-top: 18px;
  }

  #docViewerModal,
  #documentsViewerModal {
    background: #fff;
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
  }

  #docViewerModal .modal-card--viewer,
  #documentsViewerModal .modal-card--viewer {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #docViewerModal .modal-card__header--viewer,
  #documentsViewerModal .modal-card__header--viewer {
    padding-top: max(18px, env(safe-area-inset-top));
    background: #fff;
  }

  #docViewerModal .modal-card__body--viewer,
  #documentsViewerModal .modal-card__body--viewer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: #fff;
  }

  #docViewerModal .doc-frame--modal,
  #documentsViewerModal .doc-frame--modal,
  #docViewerModal .native-doc-frame,
  #documentsViewerModal .native-doc-frame {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

/* Strong iPhone fix for From / To date fields */
.filter-row--two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-row--two .jobs-filter-item {
  padding-bottom: 0;
  min-width: 0;
}

.filter-row--two input[type="date"] {
  height: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  padding: 0 10px !important;
  line-height: 38px !important;
  font-size: 15px !important;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
}

.filter-row--two input[type="date"]::-webkit-date-and-time-value {
  height: 38px;
  line-height: 38px;
  text-align: left;
}

.filter-row--two input[type="date"]::-webkit-calendar-picker-indicator {
  padding: 0;
  margin-left: 4px;
}

/* Sticky table headers */
.jobs-table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f3f6f9;
}

/* Keep header above scrolling rows */
.jobs-table thead {
  z-index: 21;
}

/* Prevent transparent overlap while scrolling */
.jobs-table {
  border-collapse: separate;
  border-spacing: 0;
}

/* Optional subtle shadow under fixed header */
.jobs-table thead th {
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.08);
}

/* Mobile compact buttons and tab icons */
@media (max-width: 700px) {
  .primary-btn {
    padding: 0 4px;
  }
  /* Back button -> left arrow */
  #backBtn {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 0;
  }

  #backBtn::before {
    content: "←";
    font-size: 24px;
    line-height: 1;
  }

  /* Close buttons -> X */
  #docViewerCloseBtn,
  #documentsViewerCloseBtn,
  #createJobModalCloseBtn,
  #createCustomerModalCloseBtn {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 0;
  }

  #docViewerCloseBtn::before,
  #documentsViewerCloseBtn::before,
  #createJobModalCloseBtn::before,
  #createCustomerModalCloseBtn::before {
    content: "×";
    font-size: 24px;
    line-height: 1;
  }

  /* Previous / Next buttons -> arrows */
  #docViewerPrevBtn,
  #documentsViewerPrevBtn,
  #docViewerNextBtn,
  #documentsViewerNextBtn {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 0;
  }

  #docViewerPrevBtn::before,
  #documentsViewerPrevBtn::before {
    content: "←";
    font-size: 22px;
    line-height: 1;
  }

  #docViewerNextBtn::before,
  #documentsViewerNextBtn::before {
    content: "→";
    font-size: 22px;
    line-height: 1;
  }

  /* Portal tabs -> 4 icon buttons, full row */
  .portal-tabs {
    padding-left: 8px;
    padding-right: 8px;
  }

  .portal-tabs__left {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .portal-tab {
    width: 100%;
    min-height: 44px;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
}

.job-actions-menu-btn {
  min-width: 42px;
  width: 42px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  border-radius: 10px;
  background: #ffffff;
}

.job-workflow-action {
  border-color: #c084fc;
  background: #faf5ff;
  color: #581c87;
}

.job-workflow-danger {
  border-color: #f97316;
  background: #fff7ed;
  color: #9a3412;
}

.job-workflow-warning {
  border-color: #facc15;
  background: #fefce8;
  color: #713f12;
}

@media (max-width: 700px) {
  body.job-actions-menu-mode .viewer-detail-header .actions-right {
    position: relative;
    flex-wrap: nowrap;
    gap: 8px;
    overflow: visible;
  }

  body.job-actions-menu-mode
    .viewer-detail-header
    .actions-right
    > button:not(.job-actions-menu-btn) {
    display: none !important;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right
    > button:not(.job-actions-menu-btn):not(.hidden) {
    display: inline-flex !important;
    position: absolute;
    right: 0;
    top: calc(100% + 8px + (var(--job-action-index) * 43px));
    z-index: 60;

    width: 238px;
    height: 43px;
    min-height: 43px;
    justify-content: flex-start;
    padding: 0 16px;

    border-radius: 0;
    border: 1px solid #d7dee8;
    background: #ffffff;
    color: var(--text);
    box-shadow: none;
    transform: none;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right
    > button.job-workflow-action:not(.hidden) {
    border-left: 4px solid #f97316;
    background: #fff7ed;
    color: #9a3412;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right
    > button.job-workflow-warning:not(.hidden) {
    border-left-color: #eab308;
    background: #fefce8;
    color: #713f12;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right
    > button.job-workflow-action:not(.hidden) {
    margin-top: 8px;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right
    > button:not(.job-actions-menu-btn):not(.hidden):hover {
    background: #f3f6fb;
    color: var(--text);
    transform: none;
  }

  body.job-actions-menu-mode.job-actions-menu-open
    .viewer-detail-header
    .actions-right::after {
    content: "";
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 238px;
    height: calc(var(--visible-job-actions) * 43px + 8px);
    border: 1px solid #d7dee8;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 14px 28px rgba(16, 24, 40, 0.18);
    pointer-events: none;
    z-index: 50;
  }
}

.related-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.related-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.related-tab-btn {
  min-height: 34px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.related-tab-btn.is-active {
  background: #edf7e8;
  border-color: #9dcb86;
  color: #234b12;
}

.tm-form-grid-table .doc-grid-table__head,
.tm-form-grid-table .doc-grid-table__row {
  grid-template-columns: 140px 140px 140px 110px minmax(220px, 1fr);
}

/* T&M Workflow */
.tm-workflow-page {
  max-width: none;
  margin: 0;
  padding: 0;
}

.tm-workflow-layout {
  display: grid;
  grid-template-columns: minmax(360px, 34%) minmax(0, 66%);
  min-height: calc(100vh - 220px);
  gap: 12px;
}

.tm-workflow-left {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.tm-workflow-queues,
.tm-workflow-list,
.tm-workflow-viewer {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.tm-workflow-queues {
	padding: 8px;
	display: flex;
	gap: 8px;
	flex-direction: column;
}

.tm-queue-btn {
  width: 100%;
  min-height: 42px;
  border: none;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.tm-queue-btn:hover,
.tm-queue-btn.is-active {
  background: #dbeafe;
}

.tm-queue-count {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.tm-workflow-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tm-workflow-list__header,
.tm-workflow-viewer__header {
  min-height: 52px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tm-form-list {
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.tm-form-list-empty {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.tm-form-card {
  width: 100%;
  min-height: 0;
  height: auto;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  display: block;
  font-size: 13px;
  font-weight: 400;
}

.tm-form-card:hover,
.tm-form-card.is-selected {
  background: #edf3fb;
  border-color: #97a3b6;
}

.tm-form-card__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.tm-form-card__top span,
.tm-form-card__meta {
  color: var(--muted);
  font-size: 12px;
}

.tm-form-card__title {
  margin-top: 4px;
  font-weight: 700;
  color: var(--text);
}

.tm-workflow-viewer {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tm-workflow-viewer__header h2 {
  margin: 0;
  font-size: 20px;
}

.tm-workflow-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tm-workflow-frame {
  width: 100%;
  flex: 1;
  min-height: 720px;
  border: 0;
  background: #fff;
}

@media (max-width: 900px) {
  .tm-workflow-layout {
    grid-template-columns: 1fr;
  }

  .tm-workflow-frame {
    min-height: 760px;
  }
}

/* Red style for T&M Do Not Approve button */
.tm-reject-btn {
  border-color: #b42318;
  background: #fff1f0;
  color: #b42318;
}

.tm-reject-btn:hover {
  border-color: #b42318;
  background: #b42318;
  color: #ffffff;
}

/* Compact one-line T&M form list item */
.tm-form-card--compact {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 145px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  height: 34px;
  padding: 0 10px;
  margin-bottom: 4px;
  font-size: 12px;
  line-height: 1;
}

.tm-form-card__job,
.tm-form-card__description,
.tm-form-card__date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-form-card__job {
  font-weight: 700;
}

.tm-form-card__description {
  color: var(--text);
}

.tm-form-card__date {
  color: var(--muted);
  text-align: right;
  font-size: 11px;
}
