/* v0.71.2 release layout contract. These rules own modal sizing and visibility. */

#uploadDialog,
#editDialog {
  box-sizing: border-box !important;
  width: min(1480px, calc(100vw - 16px)) !important;
  height: min(960px, calc(100vh - 12px)) !important;
  max-width: calc(100vw - 16px) !important;
  max-height: calc(100vh - 12px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  zoom: 1 !important;
}

#uploadDialog > form.upload-landscape-form,
#editDialog > form.edit-landscape-form {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto auto !important;
  gap: .35rem !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  padding: .7rem .8rem !important;
  overflow: hidden !important;
}

#uploadDialog .dialog-heading,
#editDialog .dialog-heading {
  position: static !important;
  top: auto !important;
  margin: 0 !important;
  padding: 0 0 .5rem !important;
}

#uploadDialog .upload-landscape-grid,
#editDialog .edit-landscape-grid {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: minmax(0, .72fr) minmax(0, 1.35fr) minmax(0, 1.15fr) !important;
  grid-template-areas: "primary coding preview" "primary files preview" !important;
  grid-template-rows: auto auto !important;
  align-content: start !important;
  align-items: start !important;
  gap: .55rem !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 .15rem 0 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable;
}

#uploadDialog .upload-record-section,
#editDialog .upload-record-section { box-sizing: border-box; min-width: 0 !important; }
#uploadDialog .upload-primary-section,
#editDialog .upload-primary-section { grid-area: primary !important; }
#uploadDialog .upload-coding-section,
#editDialog .upload-coding-section { grid-area: coding !important; }
#uploadDialog .upload-files-section,
#editDialog .upload-files-section { grid-area: files !important; }
#uploadDialog .upload-preview-section,
#editDialog .upload-preview-section {
  grid-area: preview !important;
  align-self: stretch !important;
  min-width: 0 !important;
  min-height: 430px !important;
}
#uploadDocumentPreview,
#editDocumentPreview { min-width: 0 !important; min-height: 385px !important; }
#uploadDocumentPreview > iframe,
#editDocumentPreview > iframe,
#uploadDocumentPreview > img,
#editDocumentPreview > img {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  height: 385px !important;
  border: 0;
  object-fit: contain;
}

#uploadDialog .dialog-actions,
#editDialog .dialog-actions {
  position: static !important;
  bottom: auto !important;
  z-index: 2;
  box-sizing: border-box;
  min-height: 46px;
  margin: 0 !important;
  padding: .5rem 0 0 !important;
  border-top: 1px solid var(--line) !important;
  background: #fff !important;
}

#uploadDialog .upload-record-section,
#editDialog .upload-record-section { padding: .42rem .52rem !important; }
#uploadDialog .upload-record-section > h3,
#editDialog .upload-record-section > h3 { margin: 0 0 .25rem !important; }
#uploadDialog .upload-section-fields,
#editDialog .upload-section-fields { gap: .28rem .42rem !important; }
#uploadDialog .upload-section-fields input,
#uploadDialog .upload-section-fields select,
#uploadDialog .upload-section-fields textarea,
#editDialog .upload-section-fields input,
#editDialog .upload-section-fields select,
#editDialog .upload-section-fields textarea { min-height: 31px !important; padding: .3rem .42rem !important; }
#uploadDialog #uploadProjectAllocationField,
#uploadDialog #pdfSplitPanel,
#uploadDialog .confidential-record-control,
#editDialog .confidential-record-control {
  min-height: 0 !important;
  margin: .12rem 0 !important;
  padding: .32rem .44rem !important;
}
#uploadDialog #uploadProjectAllocationField .allocation-heading,
#uploadDialog #pdfSplitPanel .allocation-heading {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: .35rem !important;
}
#uploadDialog #uploadProjectAllocationField .action-buttons { display: flex !important; flex-wrap: nowrap !important; gap: .3rem !important; }
#uploadDialog #uploadProjectAllocationField .action-buttons button { min-height: 31px !important; padding: .28rem .48rem !important; }
#uploadDialog #uploadProjectAllocationField p,
#uploadDialog #pdfSplitPanel p,
#uploadDialog .confidential-record-control small,
#editDialog .confidential-record-control small { margin: 0 !important; line-height: 1.2 !important; }
#uploadDialog .confidential-record-control small,
#editDialog .confidential-record-control small { display: none !important; }
#uploadDialog #pdfSplitWorkspace > .pdf-split-guidance { padding: .22rem .34rem !important; }
#uploadDialog .upload-files-section textarea,
#editDialog .upload-files-section textarea { min-height: 38px !important; max-height: 50px !important; }

@media (max-width: 1180px) {
  #uploadDialog .upload-landscape-grid,
  #editDialog .edit-landscape-grid {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) !important;
    grid-template-areas: "primary coding" "primary files" "preview preview" !important;
  }
  #uploadDialog .upload-preview-section,
  #editDialog .upload-preview-section { min-height: 420px !important; }
  #uploadDocumentPreview,
  #editDocumentPreview { min-height: 380px !important; }
  #uploadDocumentPreview > iframe,
  #editDocumentPreview > iframe,
  #uploadDocumentPreview > img,
  #editDocumentPreview > img { height: 380px !important; }
}

@media (max-width: 1450px) and (min-width: 821px) {
  .invoice-card { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .invoice-card > :first-child { grid-column: 1 / -1; }
  .invoice-card > :last-child { justify-self: start; }
}

@media (min-width: 701px) and (max-height: 850px) {
  #uploadDialog .upload-preview-section,
  #editDialog .upload-preview-section { min-height: 345px !important; }
  #uploadDocumentPreview,
  #editDocumentPreview { min-height: 305px !important; }
  #uploadDocumentPreview > iframe,
  #editDocumentPreview > iframe,
  #uploadDocumentPreview > img,
  #editDocumentPreview > img { height: 305px !important; }
  #uploadDialog #uploadProjectAllocationField .allocation-heading p,
  #uploadDialog #pdfSplitPanel .allocation-heading p { display: none !important; }
  #uploadDialog #pdfSplitWorkspace:has(.pdf-split-guidance) { display: none !important; }
  #uploadDialog .upload-files-section textarea { min-height: 31px !important; max-height: 31px !important; }
  #uploadDialog .upload-files-section > h3 { display: none !important; }
}

@media (max-width: 700px) {
  #uploadDialog,
  #editDialog { width: calc(100vw - 6px) !important; max-width: calc(100vw - 6px) !important; height: calc(100vh - 6px) !important; max-height: calc(100vh - 6px) !important; }
  #uploadDialog .upload-landscape-grid,
  #editDialog .edit-landscape-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "primary" "coding" "files" "preview" !important;
  }
}

/* Message dialogs are content-sized; tone colours never become the dialog canvas. */
#appMessageDialog.message-dialog {
  box-sizing: border-box !important;
  width: min(560px, calc(100vw - 24px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100vh - 24px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  color: var(--ink) !important;
  background: #fff !important;
}
#appMessageDialog.message-dialog > form {
  box-sizing: border-box !important;
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100vh - 24px) !important;
  margin: 0 !important;
  padding: 1.1rem !important;
  overflow-y: auto !important;
  color: var(--ink) !important;
  background: #fff !important;
}
#appMessageDialog .message-dialog-actions { position: static !important; margin: .85rem 0 0 !important; padding: .75rem 0 0 !important; }

/* Project drill-downs are real readable records, not explanatory placeholders. */
.project-drilldown { display: grid; gap: .75rem; min-width: 0; }
.project-drilldown-section { min-width: 0; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.project-drilldown-section > h3 { margin: 0 0 .45rem; }
.project-drilldown-table-wrap,
.project-table-wrap { max-width: 100%; overflow-x: auto; }
.project-drilldown-table { width: 100%; min-width: 700px; border-collapse: collapse; }
.project-drilldown-table th,
.project-drilldown-table td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.project-drilldown-table th { color: #fff; background: #173b58; font-size: .72rem; text-transform: uppercase; }
.project-drilldown-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.project-activity-list { display: grid; gap: .4rem; }
.project-activity-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: .75rem; align-items: start; padding: .6rem .7rem; border: 1px solid var(--line); border-left: 4px solid #2b77a8; border-radius: 8px; background: #f7fafb; }
.project-activity-row small { color: var(--muted); }
.project-empty-drilldown { margin: 0; padding: 1rem; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); background: #fafcfc; }
.project-empty-row { padding: 1rem !important; text-align: center !important; color: var(--muted); }
.source-chip { display: inline-block; padding: .15rem .4rem; border-radius: 999px; color: #23516e; background: #e8f3f8; font-size: .72rem; font-weight: 700; }
.project-status-tabs { margin-bottom: .55rem; }
.project-inactive-badge { display: inline-block; margin-left: .3rem; padding: .1rem .35rem; border-radius: 999px; color: #76500d; background: #fff4d8; font-size: .66rem; vertical-align: middle; }

@media (max-width: 700px) {
  .project-activity-row { grid-template-columns: 1fr; gap: .2rem; }
}
