:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #17212b;
  --muted: #667485;
  --line: #d7e0e8;
  --line-strong: #c7d2dc;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e6f4f1;
  --nav: #111923;
  --nav-line: #253241;
  --danger: #b4233a;
  --warning: #b7791f;
  --shadow: 0 14px 34px rgba(24, 39, 55, 0.10);
  --shadow-soft: 0 7px 18px rgba(24, 39, 55, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 30px;
  border-bottom: 1px solid var(--nav-line);
  background: var(--nav);
  color: #fff;
  box-shadow: 0 8px 24px rgba(13, 21, 30, 0.18);
}

.topbar strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.topbar span {
  color: #b9c5cf;
  font-size: 13px;
}

.topbar a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.topbar a:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.setup-tabs {
  margin-top: -12px;
  margin-left: 18px;
  width: fit-content;
  background: #f7fafb;
}

.reorderable-tabs > a {
  cursor: grab;
}

.reorderable-tabs > a.tab-dragging {
  cursor: grabbing;
  opacity: 0.45;
}

.tabs a,
.pagination a,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tabs a.active,
.pagination a.active,
.button-link:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.table-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.table-tools label {
  margin-bottom: 0;
}

.login-panel {
  max-width: 420px;
}

h1 {
  margin: 0 0 18px;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-heading h1 {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: var(--accent-strong);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.icon,
.inline button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: #f2f5f7;
  color: var(--text);
  box-shadow: none;
}

button.icon:hover,
.inline button:hover {
  border-color: var(--line-strong);
  background: #e7edf2;
}

.email-recipient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.email-recipient-row button {
  margin-bottom: 14px;
}

.site-location-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.site-location-entry button {
  white-space: nowrap;
}

.actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 18px;
  margin-top: 16px;
}

.claim-workflow-save-status {
  margin: 0;
  min-width: 180px;
}

.claim-workflow-save-status select {
  margin-bottom: 0;
}

.worker-table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  padding: 10px 0 0 9px;
}

.confirmed-workers-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.confirmed-workers-box h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.submit-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(100%, 660px);
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.checkline input {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
  margin-bottom: 16px;
}

.painter-choice {
  min-height: 40px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(24, 39, 55, 0.04);
}

.painter-choice:has(input:checked) {
  border-color: rgba(15, 118, 110, 0.42);
  background: var(--accent-soft);
}

.painter-choice.is-filtered-out {
  display: none !important;
}

.painter-filter {
  max-width: 420px;
  margin-bottom: 16px;
}

.painter-id {
  display: block;
  margin-top: 2px;
  color: #9aa6b2;
  font-size: 12px;
  font-weight: 700;
}

.signature-box {
  width: 100%;
}

.signature-box label {
  margin-bottom: 6px;
}

#signature-pad {
  display: block;
  width: 100%;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

#clear-signature {
  margin-top: 8px;
}

.notice,
.error {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #e4f4ec;
  border: 1px solid #9bcdb7;
  box-shadow: var(--shadow-soft);
}

.error {
  background: #f8e8e8;
  border-color: #e1a6a6;
  color: var(--danger);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f6f8fa;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

tbody tr:hover {
  background: #fbfcfd;
}

#submitted-claims-table tbody tr.claim-workflow-new,
#submitted-claims-table tbody tr.claim-workflow-new:hover {
  background: #fff3b0;
}

#submitted-claims-table tbody tr.claim-workflow-ready,
#submitted-claims-table tbody tr.claim-workflow-ready:hover {
  background: #d9f2df;
}

#submitted-claims-table tbody tr.claim-workflow-ready-for-claim,
#submitted-claims-table tbody tr.claim-workflow-ready-for-claim:hover {
  background: #f4b7b7;
}

#submitted-claims-table tbody tr.claim-workflow-claimed,
#submitted-claims-table tbody tr.claim-workflow-claimed:hover {
  background: #72a87b;
  color: #102b16;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]::after {
  content: " Sort";
  color: #95a1ac;
  font-size: 10px;
  font-weight: 700;
}

th[data-direction="asc"]::after {
  content: " Asc";
}

th[data-direction="desc"]::after {
  content: " Desc";
}

td input {
  min-width: 130px;
  margin: 0;
}

td select {
  min-width: 230px;
  margin: 0;
}

td:first-child input {
  min-width: 230px;
}

.claim-review-table {
  width: max-content;
  min-width: 100%;
}

.claim-review-table tbody td {
  vertical-align: top;
}

.claim-review-table .claim-row-actions {
  width: 1%;
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  text-align: right;
  white-space: nowrap;
}

.claim-review-table .add-claim-row-button,
.claim-review-table .remove-claim-row-button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 18px;
}

.claim-review-table .remove-claim-row-button {
  color: var(--danger);
}

.claim-review-table .claim-review-number-column {
  width: 1%;
  white-space: nowrap;
}

.claim-review-table .claim-review-number-column input {
  width: 96px;
  min-width: 96px;
}

.claim-review-table .claim-review-adjustment-column {
  width: 1%;
}

.claim-review-table .claim-review-adjustment-column input {
  display: block;
  width: 118px;
  min-width: 118px;
}

.claim-review-table .quick-adjustment-entry {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.claim-review-table .quick-adjustment-entry input {
  width: 92px;
  min-width: 92px;
}

.claim-review-table .quick-adjustment-save {
  width: 28px;
  min-width: 28px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.claim-review-table .claim-review-adjustment-column .painter-id {
  width: 118px;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.ppe-review-button,
.additional-adjustment-button {
  display: block;
  width: 118px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.ppe-review-button:hover,
.ppe-review-button:focus-visible,
.additional-adjustment-button:hover,
.additional-adjustment-button:focus-visible {
  text-decoration: underline;
}

.claim-review-table .claim-review-net-column {
  width: 1%;
  min-width: max-content;
  white-space: nowrap;
}

.claim-review-table .subcontractor-claim-row {
  background: var(--accent-soft);
}

.claim-review-table .subcontractor-claim-row:hover {
  background: var(--accent-soft);
}

.claim-review-table .subcontractor-claim-amount-column {
  width: 1%;
  min-width: 202px;
}

.claim-review-table .subcontractor-claim-amount-column input {
  width: 202px;
  min-width: 202px;
  margin-top: 0;
}

#workers thead {
  display: none;
}

#workers tbody tr {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

#workers tbody td {
  display: block;
  padding: 0;
  border-bottom: 0;
}

#workers tbody td:first-child {
  grid-column: 1 / -1;
}

#workers tbody td[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

#workers td input,
#workers td select,
#workers td:first-child input {
  min-width: 0;
  width: 100%;
}

.worker-remove-cell {
  align-self: end;
}

#confirmed-workers td {
  white-space: nowrap;
}

#confirmed-workers input[type="hidden"] {
  display: none;
}

.confirmed-worker-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 32, 0.55);
}

.modal-backdrop[hidden] {
  display: none;
}

#map-pin-modal {
  z-index: 1100;
}

.modal {
  width: min(100%, 420px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(17, 24, 32, 0.28);
}

.ppe-review-dialog {
  width: min(1000px, calc(100vw - 2rem));
  max-width: 1000px;
}

.ppe-decision-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 16px 0;
}

.ppe-decision-options .checkline {
  margin: 0;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal .muted {
  margin-bottom: 16px;
}

.inline {
  margin: 0;
  display: inline-block;
}

.action-row {
  margin-right: 6px;
  vertical-align: middle;
}

td .action-row {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  margin-bottom: 0;
}

td .action-row button,
td button.action-row {
  min-height: 34px;
  margin: 0;
}

.danger-button {
  background: #b13737;
  color: #fff;
  box-shadow: 0 8px 18px rgba(177, 55, 55, 0.18);
}

.danger-button:hover {
  background: #862727;
}

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  box-shadow: none;
}

.link-button:hover {
  background: transparent;
  color: var(--danger);
  box-shadow: none;
}

.note-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.note-icon::before {
  content: "";
  width: 13px;
  height: 15px;
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 2px;
  background:
    linear-gradient(currentColor, currentColor) 3px 4px / 7px 1px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 8px / 7px 1px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 12px / 5px 1px no-repeat;
}

.painter-needs-action {
  background: #fff1f2;
}

.painter-needs-action td:first-child {
  border-left: 4px solid var(--danger);
}

.notes-modal {
  width: min(100%, 620px);
}

.notes-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin: 12px 0 16px;
}

.note-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.note-item.note-open {
  border-color: #f0a7b3;
  background: #fff5f6;
}

.note-item p {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.note-form {
  margin-top: 14px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-actions a {
    flex: 1 1 auto;
  }

  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .shell {
    padding-top: 18px;
  }

  .panel {
    padding: 18px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .table-tools {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  #workers tbody tr {
    grid-template-columns: 1fr;
  }

  #confirmed-workers thead {
    display: none;
  }

  #confirmed-workers tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }

  #confirmed-workers tbody td {
    display: block;
    padding: 0;
    border-bottom: 0;
    white-space: normal;
  }

  #confirmed-workers tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .confirmed-worker-actions,
  .modal-actions,
  .worker-table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .submit-area {
    align-items: stretch;
  }
}
