.project-workspace,
.project-detail,
.project-form {
  --project-ink: #172a44;
  --project-muted: #5d6e87;
  --project-line: #dce5f1;
  --project-accent: #4c40c5;
  display: grid;
  gap: 16px;
  min-width: 0;
  color: var(--project-ink);
}

.project-page-head,
.project-list-bar,
.project-detail-head,
.project-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.project-page-head {
  padding: 17px 19px;
  border: 1px solid var(--project-line);
  border-radius: 14px;
  background: #fff;
}
.project-page-head p { margin: 0; color: var(--project-muted); font-size: 13px; }
.project-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-head-actions button { min-height: 40px; }

.project-customer-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
  margin-top: 5px;
}
.project-customer-control input { min-width: 0; width: 100%; }

.project-image-count {
  color: var(--project-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.project-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  clip-path: inset(50%);
}
.project-upload-zone {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px dashed #b9c1e5;
  border-radius: 11px;
  background: #f7f8ff;
  cursor: pointer;
}
.project-upload-input:focus-visible + .project-upload-zone,
.project-upload-zone.is-dragging,
.project-upload-zone:not(.is-full):hover {
  border-color: #7261d9;
  background: #f0edff;
}
.project-upload-input:focus-visible + .project-upload-zone { outline: 2px solid #7261d9; outline-offset: 2px; }
.project-upload-input:disabled + .project-upload-zone { cursor: default; }
.project-upload-zone.is-full { border-color: var(--project-line); background: #f8fafc; }
.project-upload-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: #ece9ff;
  color: var(--project-accent);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}
.project-upload-zone strong { display: block; color: var(--project-accent); font-size: 13px; }
.project-upload-zone.is-full strong { color: var(--project-muted); }
.project-upload-zone small { display: block; margin-top: 4px; color: var(--project-muted); font-size: 12px; line-height: 1.45; }
.project-edit-card .project-upload-error { margin: 8px 0 0; color: #9f3044; font-size: 12px; }
.project-image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 104px), 1fr));
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.project-image-list:empty { display: none; }
.project-image-thumbnail {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--project-line);
  border-radius: 9px;
  background: #fff;
}
.project-image-thumbnail :is(a, div) { display: block; color: var(--project-ink); text-decoration: none; }
.project-image-thumbnail a:hover { color: var(--project-accent); }
.project-image-thumbnail img { display: block; width: 100%; height: 76px; object-fit: contain; background: #eef2f8; }
.project-image-thumbnail span {
  display: block;
  overflow: hidden;
  padding: 6px 8px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-image-thumbnail button, .project-task-sequence button {
  display: grid;
  width: 26px;
  min-height: 26px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--project-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.project-image-thumbnail button {
  position: absolute;
  top: 4px;
  right: 4px;
  border-color: var(--project-line);
  background: #fff;
}
.project-image-thumbnail button:hover, .project-task-sequence button:hover { border-color: #edc8d0; background: #fff1f3; color: #9f3044; }
.project-image-gallery { border: 1px solid var(--project-line); border-radius: 10px; background: #fff; }
.project-image-gallery > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: inherit;
  list-style: none;
  cursor: pointer;
}
.project-image-gallery > summary::-webkit-details-marker { display: none; }
.project-image-gallery > summary span { margin-inline-start: auto; color: var(--project-muted); font-size: 12px; }
.project-image-gallery > summary::after {
  width: 7px;
  height: 7px;
  margin-inline: 2px;
  transform: translateY(-2px) rotate(45deg);
  border-right: 1.5px solid var(--project-muted);
  border-bottom: 1.5px solid var(--project-muted);
  content: "";
}
.project-image-gallery > summary:hover { background: #f7f8fd; }
.project-image-gallery > summary:focus-visible { outline: 2px solid var(--project-accent); outline-offset: -2px; }
.project-image-gallery[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.project-image-gallery > .project-image-grid { padding: 0 12px 12px; }
.project-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.project-image-grid a {
  display: grid;
  min-width: 0;
  border: 1px solid var(--project-line);
  border-radius: 10px;
  overflow: hidden;
  color: var(--project-ink);
  text-decoration: none;
  background: #f5f8fc;
}
.project-image-grid img { display: block; width: 100%; height: 112px; object-fit: contain; }
.project-image-grid span { padding: 6px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.project-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.project-summary > button {
  display: grid;
  gap: 7px;
  justify-items: start;
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--project-line);
  border-radius: 12px;
  background: #fff;
  color: var(--project-muted);
  cursor: pointer;
}
.project-summary > button strong { color: var(--project-ink); font-size: 22px; font-variant-numeric: tabular-nums; }
.project-summary > button.is-overdue strong { color: #a43246; }
.project-summary > button[aria-pressed="true"] { border-color: #b4a9f2; background: #f2efff; }

.project-list-panel { overflow: hidden; margin: 0; }
.project-list-bar { padding: 12px 17px; border-bottom: 1px solid var(--project-line); background: #fafbfe; }
.project-list-scope {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--project-line);
  border-radius: 10px;
  background: #eef2fa;
}
.project-list-scope > button {
  min-height: 36px;
  padding: 6px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #425774;
  white-space: nowrap;
  font-size: 12px;
  cursor: pointer;
}
.project-list-scope > button[aria-pressed="true"] { background: #fff; color: var(--project-accent); box-shadow: 0 2px 6px #27355d16; }
.project-list-search { display: flex; gap: 7px; flex: 1 1 270px; justify-content: flex-end; margin: 0; }
.project-list-search > input { width: min(100%, 360px); min-width: 0; }
.project-list-search > button { white-space: nowrap; }
.project-list-table { min-width: 800px; }
.project-list-table td > small { display: block; margin-top: 4px; color: var(--project-muted); }
.project-list-table td:nth-child(4), .project-list-table td:nth-child(5) { white-space: nowrap; }
.project-list-table .row-actions { min-width: 0; flex-wrap: nowrap; }
.project-overdue-row td { background: #fff8f8; }

.project-status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf1f7;
  color: #4b5f7a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.project-status.pending { background: #fff2d9; color: #805011; }
.project-status.active { background: #ece9ff; color: #4838b8; }
.project-status.done { background: #e5f6ed; color: #096d51; }
.project-status.late { background: #fdecef; color: #a43246; }

#dialog:has(.project-form, .project-detail) { width: min(960px, calc(100vw - 28px)); }
.project-form fieldset { display: grid; min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.project-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; min-width: 0; }
.project-form-grid[hidden] { display: none; }
.project-form-grid label { display: block; min-width: 0; color: #354a68; font-size: 13px; font-weight: 650; }
.project-form-grid label > :is(input,select,textarea,button) { display: block; margin-top: 5px; min-width: 0; width: 100%; }
.project-form-grid input[readonly] { background: #f0f4fa; }
.project-form-wide { grid-column: 1 / -1; }
.project-form-help { margin: 0 0 9px; color: #5d6e87; font-size: 12px; line-height: 1.6; }
.project-selection { width: 100%; text-align: left; overflow-wrap: anywhere; }
.project-form-error, .project-return {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f3c7cf;
  border-radius: 9px;
  background: #fff1f3;
  color: #9f3044;
  font-size: 13px;
}

#dialog[open]:has(.project-edit-form) {
  display: flex;
  flex-direction: column;
  width: min(1020px, calc(100vw - 28px));
  max-height: min(90vh, calc(100dvh - 24px));
  overflow: hidden;
}
#dialog:has(.project-edit-form) .dialog-head { flex: none; padding: 14px 20px; }
#dialog:has(.project-edit-form) .dialog-head h3 { color: #172a44; font-size: 19px; }
#dialog:has(.project-edit-form) .dialog-kicker { display: none; }
#dialog:has(.project-edit-form) #dialogBody {
  display: flex;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  padding: 0;
  background: #f4f6fa;
}
.project-edit-form { display: flex; flex-direction: column; gap: 0; width: 100%; min-height: 0; }
.project-edit-form > .project-form-error { flex: none; margin: 12px 18px 0; }
.project-edit-form > .project-edit-content {
  display: block;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 18px 18px;
  scroll-padding-block: 12px;
}
.project-edit-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(260px, 3fr); gap: 14px; align-items: start; }
.project-edit-main { display: grid; gap: 14px; min-width: 0; }
.project-edit-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--project-line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 2px 4px #172a4407;
}
.project-edit-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.project-edit-card-head h4 { margin: 0; color: var(--project-ink); font-size: 15px; }
.project-edit-card .project-form-grid :is(input, select, textarea) { padding: 8px 10px; font-weight: 500; }
.project-edit-card .project-form-grid textarea { min-height: 80px; resize: vertical; }
.project-edit-card .project-customer-control button { white-space: nowrap; }
.project-repeat-fields {
  padding: 10px;
  border: 1px solid var(--project-line);
  border-radius: 9px;
  background: #f8f9ff;
}
.project-task-hours { color: var(--project-accent); font-size: 12px; text-align: right; }
.project-task-search { position: relative; margin-bottom: 9px; }
.project-task-search::before, .project-task-search::after { position: absolute; content: ""; pointer-events: none; }
.project-task-search::before { top: calc(50% - 7px); left: 12px; width: 10px; height: 10px; border: 1.5px solid #687b96; border-radius: 50%; }
.project-task-search::after { top: calc(50% + 3px); left: 21px; width: 6px; height: 1.5px; background: #687b96; transform: rotate(45deg); }
.project-task-search > input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px 7px 32px;
  font-size: 13px;
}
.project-task-options {
  display: grid;
  gap: 6px;
  max-height: 222px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 2px 2px 2px 0;
}
.project-task-options[hidden], .project-task-option[hidden] { display: none; }
.project-task-option {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid var(--project-line);
  border-radius: 9px;
  background: #fbfcfe;
  font-size: 13px;
  cursor: pointer;
}
.project-task-option:hover { border-color: #bdb6e3; }
.project-task-option:has(input:focus-visible) { border-color: var(--project-accent); }
.project-task-option:has(input:checked) { border-color: #bbb0ef; background: #f3f0ff; }
.project-task-option > input { width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--project-accent); }
.project-task-option > span { overflow-wrap: anywhere; }
.project-task-option > small { color: var(--project-muted); white-space: nowrap; }
.project-task-empty { margin: 0; padding: 9px 0; color: var(--project-muted); font-size: 12px; }
.project-task-selected { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--project-line); }
.project-task-selected header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.project-task-selected h5 { margin: 0; font-size: 13px; }
.project-task-selected header > span { color: var(--project-muted); font-size: 12px; }
.project-task-sequence {
  max-height: 138px;
  margin: 6px 0 0;
  overflow-y: auto;
  padding: 0 2px 0 25px;
  font-size: 12px;
}
.project-task-sequence li::marker { color: var(--project-accent); font-variant-numeric: tabular-nums; }
.project-task-sequence li > div { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 0; }
.project-task-sequence li span { min-width: 0; overflow-wrap: anywhere; }
.project-task-sequence button { flex: none; }
.project-form > .form-actions { position: static; margin: 0; padding: 13px 0 0; flex-wrap: wrap; }
.project-edit-form > .form-actions { flex: none; padding: 11px 18px; border-top-color: var(--project-line); background: #fff; }
.project-edit-form > .form-actions button { min-height: 40px; white-space: nowrap; }

.project-detail h4, .project-approval-history h4 { margin: 0; }
.project-detail-head { padding: 12px 14px; border: 1px solid var(--project-line); border-radius: 12px; background: #f7f8fd; }
.project-detail-head h4 { margin-top: 4px; font-size: 18px; overflow-wrap: anywhere; }
.project-detail-head > div > span, .project-detail-facts dt { color: var(--project-muted); font-size: 12px; }
.project-detail-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 0; }
.project-detail-facts > div { padding: 9px; min-width: 0; border: 1px solid var(--project-line); border-radius: 9px; }
.project-detail-facts dd { margin: 4px 0 0; color: var(--project-ink); font-size: 13px; overflow-wrap: anywhere; }
.project-order-link { padding: 0; border: 0; background: transparent; color: var(--project-accent); text-align: left; text-decoration: underline; cursor: pointer; }
.project-source { margin: 0; color: #465b78; font-size: 13px; }
.project-text { margin: 7px 0 0; color: #3f5674; white-space: pre-wrap; overflow-wrap: anywhere; }
.project-task-table { min-width: 545px; margin-top: 7px; }
.project-task-table td:nth-child(n+3) { white-space: nowrap; }
.project-file { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; color: var(--project-accent); overflow-wrap: anywhere; }
.project-file > small { color: var(--project-muted); white-space: nowrap; }
.project-approval-history { margin-top: 14px; }
.project-approval-history ol { margin: 7px 0; padding-inline-start: 21px; }
.project-approval-history li { margin: 5px 0; overflow-wrap: anywhere; }
.project-approval-history li > span { margin-inline-start: 7px; color: #5d6e87; }
.project-approval-history p { margin: 3px 0; }
.project-standard-table table { min-width: 420px; }
.project-setup > section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--project-line);
  border-radius: 10px;
}
.project-setup p { margin: 5px 0 0; color: var(--project-muted); font-size: 13px; }

@media (max-width: 1040px) {
  .project-summary { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .project-list-search { justify-content: flex-start; }
}
@media (max-width: 740px) {
  .project-edit-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .project-form-grid { grid-template-columns: minmax(0, 1fr); }
  .project-detail-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-list-search > input { flex: 1; }
  .project-head-actions { width: 100%; }
  #dialog[open]:has(.project-edit-form) { width: calc(100vw - 16px); border-radius: 15px; }
  #dialog:has(.project-edit-form) .dialog-head { padding: 10px 13px; }
  .project-edit-form > .project-edit-content { padding: 10px; }
  .project-edit-form > .project-form-error { margin: 8px 10px 0; }
  .project-edit-form > .form-actions { padding: 8px 10px; }
  .project-edit-card { padding: 11px; }
  .project-edit-layout, .project-edit-main { gap: 10px; }
  .project-upload-zone { gap: 9px; padding: 10px; }
}
