.mat-tool {
  --mat-ink: #203d51;
  --mat-muted: #577183;
  --mat-line: #dbe5ec;
  --mat-blue: #235f93;
  max-width: 1280px;
  color: var(--mat-ink);
  font-size: 14px;
}
.mat-tool > fieldset { border: 0; min-width: 0; padding: 0; margin: 0; }
.mat-panel {
  margin: 0 0 16px;
  padding: 22px 24px;
  border: 1px solid var(--mat-line);
  border-radius: 10px;
  background: white;
  min-width: 0;
}
.mat-panel h2 { margin: 0 0 16px; font-size: 17px; }
.mat-side { align-self: start; }
.mat-side > header { padding-bottom: 12px; border-bottom: 1px solid var(--mat-line); }
.mat-side h3 { margin: 0; font-size: 15px; }
.mat-side .mat-firm header, .mat-side .mat-role > header { margin-bottom: 12px; }
.mat-side .mat-role { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--mat-line); }
.mat-panel header, .mat-submit, .mat-preview > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.mat-panel header h2, .mat-panel h4 { margin: 0; }
.mat-panel > header { margin-bottom: 14px; }
.mat-panel h4 { font-size: 14px; }
.mat-location { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.mat-location > span {
  flex: none; white-space: nowrap;
  display: flex; align-items: center; height: 39px; padding: 0 16px;
  background: #edf4fb; color: #295579; border-radius: 6px; font-weight: 600;
}
.mat-combo { position: relative; width: min(100%, 330px); }
.mat-combo > label, .mat-field span { color: #365369; font-size: 13px; }
.mat-combo-input { display: flex; margin-top: 6px; }
.mat-combo-input input { flex: 1; min-width: 0; border-radius: 6px 0 0 6px; }
.mat-combo-input button {
  width: 40px; border: 1px solid var(--mat-line); border-left: none; border-radius: 0 6px 6px 0;
  background: #f6f9fc; color: var(--mat-blue); cursor: pointer;
}
.mat-region-list {
  position: absolute; z-index: 9; left: 0; right: 0; top: 100%; max-height: 260px;
  overflow-y: auto; padding: 4px; background: white; border: 1px solid #bbccd9;
  border-radius: 6px; box-shadow: 0 8px 20px #203d511b;
}
.mat-region-list button { display: block; width: 100%; border: 0; background: white; text-align: left; padding: 8px 10px; color: var(--mat-ink); cursor: pointer; }
.mat-region-list button:hover, .mat-region-list button.active, .mat-region-list button[aria-selected=true] { background: #e6f1fc; }
.mat-list-title { margin: 18px 0 7px; font-size: 14px; }
.mat-file-list { display: flex; flex-wrap: wrap; gap: 6px 12px; list-style: none; padding: 0; margin: 0; }
.mat-file-list li { background: #f1f6fa; padding: 6px 10px; border-radius: 4px; overflow-wrap: anywhere; }
.mat-attach:not([hidden]) { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.mat-tool input[type=checkbox] { width: 15px; height: 15px; margin: 0; flex: none; accent-color: #25669b; }
.mat-note, .mat-hint { margin: 10px 0 0; font-size: 13px; line-height: 1.55; color: var(--mat-muted); }
.mat-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; }
.mat-case-fields { grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(130px, 1fr)); }
.mat-firm .mat-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
.mat-holder { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--mat-line); }
.mat-holder .mat-field { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.mat-holder select { flex: 1 1 170px; max-width: 100%; }
.mat-section-note { margin: -7px 0 15px; font-size: 13px; color: var(--mat-muted); }
.mat-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mat-field input, .mat-field select, .mat-combo-input input {
  box-sizing: border-box; height: 39px; width: 100%; min-width: 0; border: 1px solid #c7d6e0;
  padding: 6px 9px; border-radius: 6px; color: var(--mat-ink); background: #fff;
}
.mat-combo-input input { border-radius: 6px 0 0 6px; }
.mat-tool :is(input, select, button, summary):focus-visible, .mat-batch:focus-within, .mat-photo-empty:focus-within {
  outline: 2px solid #3078ae; outline-offset: 2px;
}
.mat-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(370px, 100%), 1fr)); gap: 0 16px; }
.mat-role { align-self: start; }
.mat-person, .mat-deal { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--mat-line); }
.mat-person header, .mat-deal header { margin-bottom: 12px; }
.mat-allocation h3 { margin: 0; font-size: 15px; }
.mat-allocation p { margin: 6px 0 10px; color: var(--mat-muted); font-size: 13px; }
.mat-allocation-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--mat-line); border-radius: 6px; }
.mat-allocation table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.mat-allocation :is(th, td) { min-width: 92px; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--mat-line); text-align: center; white-space: normal; overflow-wrap: anywhere; }
.mat-allocation th:first-child { position: sticky; left: 0; min-width: 98px; max-width: 15em; background: white; color: var(--mat-ink); text-align: left; }
.mat-allocation thead th, .mat-allocation tfoot :is(th, td) { background: #eff5fa; color: var(--mat-ink); font-weight: 600; }
.mat-allocation thead th:first-child, .mat-allocation tfoot th:first-child { background: #eff5fa; }
.mat-allocation tfoot :is(th, td) { border-bottom: 0; }
.mat-allocation-value { display: inline-flex; align-items: center; gap: 5px; color: var(--mat-muted); }
.mat-allocation-value input { box-sizing: border-box; width: 6.5em; height: 34px; border: 1px solid #c7d6e0; border-radius: 5px; padding: 4px 7px; text-align: right; }
.mat-text, .mat-photo button { border: 0; background: transparent; color: var(--mat-blue); cursor: pointer; padding: 4px; font-size: 13px; }
.mat-extra { margin-top: 13px; }
.mat-extra > summary, [data-mat-missing] > summary { cursor: pointer; color: var(--mat-blue); font-size: 13px; width: fit-content; }
.mat-extra[open] > summary { margin-bottom: 12px; }
.mat-hint { font-size: 12px; }
.mat-role > details { margin: 0 0 14px; }
.mat-batch, .mat-photo-change, .mat-photo-empty { position: relative; cursor: pointer; overflow: hidden; }
.mat-batch { display: inline-flex; padding: 7px 12px; border: 1px solid #b8cddd; border-radius: 6px; color: var(--mat-blue); font-weight: 600; font-size: 13px; }
.mat-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.mat-scan-button { background: #f3f8fc; }
.mat-scan-result:empty, .mat-scan-progress:empty { display: none; }
.mat-scan-progress { margin: 8px 0 12px; color: #285879; overflow-wrap: anywhere; }
.mat-scan-result { margin: 10px 0 14px; font-size: 13px; color: var(--mat-ink); }
.mat-scan-result > details { padding: 7px 10px; border-left: 3px solid #7cabc3; background: #f4f8fb; margin: 4px 0; }
.mat-scan-result summary { cursor: pointer; overflow-wrap: anywhere; }
.mat-scan-result p { margin: 6px 0; }
.mat-filled { margin: 8px 0; }
.mat-filled > div { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; padding: 4px 0; }
.mat-filled dt { color: var(--mat-muted); }
.mat-filled dd { margin: 0; overflow-wrap: anywhere; }
.mat-scan-raw { margin-top: 8px; }
.mat-scan-raw pre { margin: 6px 0; max-height: 16em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.mat-scan-diff { display: grid; gap: 3px; margin: 7px 0; padding: 8px; border: 1px solid #d0dee7; background: #fff; border-radius: 4px; overflow-wrap: anywhere; }
.mat-tool input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.mat-photos { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin-top: 14px; gap: 10px; }
.mat-photo-empty {
  display: flex; justify-content: center; align-items: center; gap: 7px; min-height: 51px;
  border: 1px dashed #adc2d1; background: #f7fafc; border-radius: 6px; color: #497089; font-size: 13px;
}
.mat-photo { padding: 8px; border: 1px solid var(--mat-line); border-radius: 6px; overflow: hidden; }
.mat-photo > button { width: 100%; padding: 0; }
.mat-photo img { width: 100%; height: 96px; object-fit: contain; background: #f3f6f8; }
.mat-photo small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mat-muted); }
.mat-photo-change, .mat-photo button { font-size: 12px; color: var(--mat-blue); }
.mat-photo-change { display: inline-block; margin-right: 10px; vertical-align: middle; padding: 4px; }
.mat-photo select { width: 100%; min-width: 0; margin-top: 4px; font-size: 12px; }
.mat-submit { background: #f1f6fb; border: 1px solid var(--mat-line); border-radius: 8px; padding: 13px 18px; }
[data-mat-missing] { padding: 12px 16px; background: #fff7ee; border: 1px solid #ecd7bd; border-radius: 8px; }
[data-mat-missing] ul { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }
.mat-status { overflow-wrap: anywhere; color: var(--mat-ink); }
.mat-status.error { color: #a5362e; }
.mat-preview { border: 1px solid var(--mat-line); border-radius: 10px; max-width: 90vw; max-height: 90vh; padding: 16px; background: white; }
.mat-preview img { display: block; margin: 12px auto 0; max-width: 80vw; max-height: 75vh; object-fit: contain; }
.mat-preview::backdrop { background: #172b3cc4; }
.mat-file-list .mat-text { padding: 0; font: inherit; text-align: left; }
.mat-file-list .mat-text:hover { text-decoration: underline; }
.mat-file-preview { box-sizing: border-box; width: min(1020px, 95vw); height: min(940px, 93dvh); max-height: 96dvh;
  padding: 0; color: var(--mat-ink); background: white; border: 1px solid var(--mat-line); border-radius: 10px; }
.mat-file-preview[open] { display: flex; flex-direction: column; }
.mat-file-preview::backdrop { background: #172b3caa; }
.mat-file-preview header, .mat-preview-tools, .mat-file-preview footer { display: flex; align-items: center; gap: 10px 16px; padding: 10px 18px; }
.mat-file-preview header, .mat-preview-tools { justify-content: space-between; }
.mat-file-preview h2 { margin: 0; font-size: 18px; }
.mat-preview-tools { border-top: 1px solid var(--mat-line); flex-wrap: wrap; }
.mat-preview-tools label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; max-width: 100%; font-size: 13px; }
.mat-preview-tools label:first-child { flex: 1; }
.mat-preview-tools label[hidden] { display: none; }
.mat-preview-tools select { min-width: 0; max-width: 100%; padding: 6px; color: var(--mat-ink); border: 1px solid #b8cbd9; border-radius: 5px; background: white; }
.mat-file-preview details { margin: 0; padding: 8px 18px; background: #fff6e9; color: #795027; font-size: 13px; }
.mat-file-preview details summary { cursor: pointer; }
.mat-file-preview details > div { max-height: 14vh; overflow: auto; padding-top: 5px; }
.mat-preview-paper { flex: 1; min-height: 0; overflow: auto; text-align: center; padding: 12px; background: #e7edf2; border-block: 1px solid var(--mat-line); }
.mat-preview-paper img { display: block; width: min(100%, 880px); height: auto; margin: 0 auto; box-shadow: 0 2px 7px #203d5124; }
.mat-preview-paper img[hidden] { display: none; }
.mat-preview-paper.enlarged img { width: max(140%, 850px); max-width: none; }
.mat-file-preview footer { justify-content: center; font-size: 13px; }
@media (max-width: 600px) {
  .mat-file-preview { width: 98vw; max-width: 98vw; height: 95dvh; }
  .mat-file-preview header, .mat-preview-tools, .mat-file-preview footer { padding: 8px 10px; gap: 6px; }
  .mat-preview-tools > label { flex-basis: 100% !important; }
  .mat-preview-tools > label select { flex: 1; }
  .mat-preview-paper { padding: 5px; }
  .mat-file-preview .btn { white-space: nowrap; }
}
@media (max-width: 900px) { .mat-case-fields { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 600px) {
  .mat-panel { padding: 16px 13px; }
  .mat-location { flex-wrap: nowrap; }
  .mat-case-fields { grid-template-columns: 1fr; }
  .mat-firm .mat-fields { grid-template-columns: 1fr; }
  .mat-submit .btn { flex: 1; }
}

