body,
body *,
body *::before,
body *::after { font-size: 14px !important; }

.casePageShell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 14px 18px 28px;
}

.casePageLoading,
.casePageError {
  width: min(680px, calc(100% - 32px));
  margin: 16vh auto 0;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 26px;
  padding: 36px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  text-align: center;
}

.casePageError h1 { margin: 8px 0 12px; }
.casePageError p { margin-bottom: 22px; color: var(--muted); }

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

.casePageTopbar h1 {
  max-width: 1120px;
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.12;
  letter-spacing: -.025em;
}

.casePageTopbar p { margin-top: 4px; font-size: 11px; }
.casePageActions { display: flex; gap: 10px; flex-wrap: wrap; }
.casePageActions button,
.casePageActions .buttonLink { border-radius: 11px; padding: 9px 12px; font-size: 13px; }

.buttonLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 12px 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 24px rgba(42, 66, 127, .18);
  font-weight: 700;
  text-decoration: none;
}

.buttonLink.secondary {
  border: 1px solid rgba(183, 123, 90, .24);
  color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(242, 236, 230, .96));
  box-shadow: none;
}

.caseOverviewCard,
.districtTablesSection,
.caseFilesSection,
.caseInfoCard {
  border: 1px solid rgba(135, 113, 96, .18);
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: none;
}

.caseOverviewCard {
  margin-bottom: 8px;
  padding: 5px 7px;
}

.districtTablesSection {
  margin-bottom: 8px;
  padding: 8px;
}

.districtTablesGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-items: start;
}

.districtTableCard {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(135, 113, 96, .2);
  border-radius: 6px;
  background: #fff;
}

.districtCaseDetailsTable { grid-column: 1 / -1; }

.districtTableCard h2 {
  margin: 0;
  border-bottom: 1px solid rgba(135, 113, 96, .18);
  padding: 6px 8px;
  color: #273553;
  background: #f8f6f3;
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.districtTableScroll { overflow-x: auto; }

.districtTableCard table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  color: #30394c;
  font-size: 9.5px;
  line-height: 1.25;
}

.districtTableCard th,
.districtTableCard td {
  border-right: 1px solid rgba(135, 113, 96, .13);
  border-bottom: 1px solid rgba(135, 113, 96, .13);
  padding: 5px 7px;
  vertical-align: top;
  text-align: left;
}

.districtTableCard tr:last-child > * { border-bottom: 0; }
.districtTableCard tr > *:last-child { border-right: 0; }
.districtTableCard th { color: #222f4d; background: rgba(248, 246, 243, .7); font-weight: 700; white-space: nowrap; }

.caseOverviewMeta {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
}

.caseMetaItem {
  min-height: 34px;
  border-right: 1px solid rgba(135, 113, 96, .14);
  padding: 4px 9px;
}

.caseMetaItem:last-child { border-right: 0; }
.caseMetaItem span { display: block; margin-bottom: 1px; color: var(--muted); font-size: 8px; letter-spacing: .045em; text-transform: uppercase; }
.caseMetaItem strong { display: block; overflow: hidden; font-size: 10.5px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.caseMetaItem small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 8px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }

.caseFilesSection { margin-bottom: 8px; padding: 8px; }
.caseFilesToolbar { display: flex; justify-content: flex-end; margin-bottom: 6px; }
#downloadCaseFolder { border-radius: 6px; padding: 6px 9px; font-size: 10px; }
#downloadCaseFolder:disabled { cursor: wait; opacity: .66; }
.caseSectionHeading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 11px;
}
.caseSectionHeading h2 { font-size: 21px; line-height: 1.15; letter-spacing: -.015em; }
.caseSectionHeading > p { max-width: 420px; color: var(--muted); font-size: 12px; text-align: right; }
.caseSectionHeading.compact { margin-bottom: 10px; }
.caseSectionHeading.compact h2 { font-size: 19px; }

.caseFolderGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: start;
  justify-content: flex-start;
}

.caseFolderColumn {
  flex: 0 0 auto;
  align-self: start;
  height: fit-content;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(135, 113, 96, .2);
  border-radius: 7px;
  background: #fff;
}

.caseFolderColumn[data-folder="orders"] {
  width: min(520px, 100%);
}

.caseFolderHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  gap: 6px;
  border-bottom: 1px solid rgba(135, 113, 96, .18);
  padding: 5px 7px;
  background: #f8f6f3;
}

.caseFolderTitle { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.caseFolderHeader h3 { font-size: 11px; line-height: 1.2; text-transform: uppercase; }
.caseFolderCount {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  text-align: center;
}
.caseFolderFiles {
  display: block;
  height: auto;
  max-height: min(680px, calc(100vh - 220px));
  overflow: auto;
  padding: 0;
}

.caseFileLine {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 27px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid rgba(135, 113, 96, .13);
  border-radius: 0;
  padding: 4px 8px;
  color: #24355f;
  background: #fff;
  box-shadow: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: .015em;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.caseFileLine:last-child { border-bottom: 0; }
a.caseFileLine:hover,
button.caseFileLine:hover { color: var(--accent); background: #f7f4f1; }
.caseFileLineRecord { color: #4f5b75; cursor: default; }
.caseFileLine span { overflow: hidden; text-overflow: ellipsis; }

.orderColumnHeader,
.orderRecordRow {
  display: grid;
  grid-template-columns: minmax(132px, .82fr) minmax(170px, 1.18fr);
}

.orderColumnHeader {
  min-height: 23px;
  border-bottom: 1px solid rgba(135, 113, 96, .15);
  color: #626a78;
  background: #fbfaf8;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.orderColumnHeader span {
  display: flex;
  align-items: center;
  padding: 4px 8px;
}

.orderColumnHeader span + span { border-left: 1px solid rgba(135, 113, 96, .13); }

.orderRecordRow {
  min-height: 27px;
  border-bottom: 1px solid rgba(135, 113, 96, .13);
}

.orderRecordRow:last-child { border-bottom: 0; }
.orderRecordCell { min-width: 0; }
.orderRecordRow .caseFileLine { min-height: 100%; border-bottom: 0; }

.orderNoteCell {
  display: flex;
  align-items: center;
  min-width: 0;
  border-left: 1px solid rgba(135, 113, 96, .13);
  padding: 4px 8px;
  color: #8a8d94;
  background: #fff;
  cursor: text;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.2;
}

.orderNoteCell span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orderNoteCell.hasNote { color: #3f4757; }
.orderNoteCell:hover,
.orderNoteCell:focus { outline: 0; background: #faf7f4; }
.orderNoteCell:focus-visible { box-shadow: inset 0 0 0 1px rgba(126, 42, 58, .45); }
.orderNoteCell.editing { padding: 2px 4px; background: #fff; }

.orderNoteInput {
  width: 100%;
  height: 23px;
  min-height: 23px;
  border: 1px solid rgba(126, 42, 58, .38);
  border-radius: 3px;
  padding: 3px 6px;
  color: #263044;
  background: #fff;
  font-family: inherit;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 0 0 2px rgba(126, 42, 58, .07);
}

.caseFolderEmpty {
  min-height: 27px;
  padding: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 9px;
  line-height: 1.2;
  text-align: left;
}

.caseLowerGrid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.caseInfoCard { min-width: 0; padding: 10px 11px; }
.caseNotesList { display: grid; gap: 6px; }
.caseNoteItem {
  border: 1px solid rgba(135, 113, 96, .14);
  border-radius: 11px;
  padding: 9px 10px;
  background: rgba(250, 248, 246, .82);
}
.caseNoteItem time { color: var(--muted); font-size: 10px; }
.caseNoteItem strong { display: block; margin: 3px 0; font-size: 13px; }
.caseNoteItem p { color: var(--muted); font-size: 11px; line-height: 1.38; }
.caseNoteForm { display: grid; gap: 7px; margin-top: 11px; }
.caseNoteForm textarea { min-height: 74px; padding: 9px 10px; font-size: 12px; }
.caseNoteForm button { border-radius: 10px; padding: 8px 11px; font-size: 12px; }
.caseNoteForm button { justify-self: start; }

@media (max-width: 1180px) {
  .caseOverviewMeta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .casePageTopbar,
  .caseSectionHeading { align-items: flex-start; flex-direction: column; }
  .caseSectionHeading > p { text-align: left; }
  .caseOverviewMeta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caseLowerGrid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .casePageShell { padding: 18px 12px 36px; }
  .caseOverviewMeta { grid-template-columns: 1fr; }
  .caseOverviewCard,
  .districtTablesSection,
  .caseFilesSection,
  .caseInfoCard { border-radius: 8px; padding: 8px; }
  .districtTablesGrid { grid-template-columns: 1fr; }
  .districtCaseDetailsTable { grid-column: auto; }
  .casePageActions,
  .casePageActions > * { width: 100%; }
  .caseFolderFiles { max-height: none; }
  .caseFolderColumn[data-folder="orders"] { width: 100%; }
  .orderColumnHeader,
  .orderRecordRow { grid-template-columns: minmax(112px, .8fr) minmax(150px, 1.2fr); }
}
.caseWorkspaceReference {
  margin: 2px 0 5px;
  color: var(--accent);
  font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .02em;
}
