:root {
  color-scheme: light;
  --ink-950: #17222e;
  --ink-800: #2b3a49;
  --slate-600: #5b6875;
  --slate-400: #89949e;
  --mist-100: #edf1f2;
  --paper: #f8faf9;
  --white: #ffffff;
  --signal: #2f63d9;
  --signal-dark: #244fac;
  --signal-soft: #e8eefc;
  --amber: #ad671e;
  --amber-soft: #fbf0df;
  --green: #287253;
  --green-soft: #e7f3ed;
  --red: #a14444;
  --red-soft: #f9eaea;
  --border: #dbe1e3;
  --border-strong: #c7d0d4;
  --shadow-dialog: 0 24px 80px rgb(23 34 46 / 20%);
  --body-font: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --display-font: "DIN Alternate", "Arial Narrow", "Avenir Next Condensed", sans-serif;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --content-max: 1500px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--mist-100);
  color: var(--ink-950);
  font-family: var(--body-font);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button,
input,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgb(47 99 217 / 32%);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink-950);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--border);
  background: rgb(248 250 249 / 92%);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 25px;
  height: 30px;
  align-content: center;
  gap: 3px;
  padding: 0 4px;
  border: 1px solid var(--ink-950);
  border-radius: 3px;
}

.brand-mark span {
  display: block;
  height: 2px;
  border-radius: 20px;
  background: var(--signal);
}

.brand-mark span:nth-child(2) {
  width: 70%;
}

.brand-mark span:nth-child(3) {
  width: 45%;
}

.brand-copy {
  display: grid;
  line-height: 1.12;
}

.brand-copy strong {
  font-family: var(--display-font);
  font-size: 1rem;
  font-stretch: condensed;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.brand-copy span {
  margin-top: 3px;
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

.availability-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.header-context.is-local {
  color: #80501a;
  font-weight: 700;
}

.header-context.is-local .availability-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logout-form {
  margin: 0;
}

.logout-button {
  display: inline-flex;
  min-height: 34px;
  appearance: none;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--slate-600);
  font-size: 0.76rem;
  font-weight: 680;
  line-height: 1.2;
}

.logout-button:hover {
  border-color: var(--border);
  background: var(--white);
  color: var(--ink-950);
}

.logout-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.page-shell {
  width: min(calc(100% - clamp(32px, 8vw, 128px)), var(--content-max));
  margin: 0 auto;
  padding: clamp(38px, 7vw, 78px) 0 72px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 34px;
}

.page-heading h1 {
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--signal-dark);
  font-family: var(--utility-font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--ink-950);
}

h1 {
  margin-bottom: 6px;
  font-family: var(--display-font);
  font-size: clamp(2.35rem, 5vw, 4.25rem);
  font-stretch: condensed;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.page-intro {
  max-width: 590px;
  margin: 0;
  color: var(--slate-600);
  font-size: 0.98rem;
}

.heading-actions,
.dialog-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button,
.icon-button,
.text-button {
  appearance: none;
  border: 0;
  background: transparent;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 680;
  line-height: 1.2;
  transition:
    background-color 130ms ease,
    border-color 130ms ease,
    color 130ms ease,
    transform 130ms ease;
}

.button svg,
.icon-button svg,
.matter-search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

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

.button-primary {
  background: var(--ink-950);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  background: var(--signal-dark);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--white);
  color: var(--ink-800);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--ink-800);
  background: var(--paper);
}

.button-small {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 0.78rem;
}

.matter-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: 0 9px 30px rgb(23 34 46 / 5%);
}

.matter-toolbar {
  display: flex;
  min-height: 67px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
}

.status-tabs {
  display: flex;
  align-self: stretch;
  gap: 24px;
}

.status-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--slate-600);
  font-size: 0.86rem;
  font-weight: 680;
}

.status-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--signal);
  content: "";
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 150ms ease;
}

.status-tab.is-active {
  color: var(--ink-950);
}

.status-tab.is-active::after {
  transform: scaleX(1);
}

.tab-count {
  min-width: 25px;
  padding: 2px 6px;
  border-radius: 20px;
  background: var(--mist-100);
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
}

.status-tab.is-active .tab-count {
  background: var(--signal-soft);
  color: var(--signal-dark);
}

.matter-search {
  display: flex;
  width: min(310px, 35vw);
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--slate-400);
  transition:
    border-color 130ms ease,
    box-shadow 130ms ease;
}

.matter-search:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgb(47 99 217 / 12%);
}

.matter-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-950);
  font-size: 0.82rem;
}

.matter-search input::placeholder {
  color: var(--slate-400);
}

.matter-list {
  min-height: 280px;
}

.table-scroll {
  overflow-x: auto;
}

.matter-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.matter-table th {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: #f9fbfa;
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.matter-table th:first-child,
.matter-table td:first-child {
  width: 22%;
  padding-left: 25px;
}

.matter-table th:nth-child(2) {
  width: 15%;
}

.matter-table th:nth-child(3) {
  width: 18%;
}

.matter-table th:nth-child(4) {
  width: 27%;
}

.matter-table th:nth-child(5) {
  width: 14%;
}

.matter-table th:last-child,
.matter-table td:last-child {
  width: 48px;
  padding-right: 16px;
}

.matter-table td {
  padding: 18px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-800);
  font-size: 0.81rem;
  vertical-align: middle;
}

.matter-row {
  position: relative;
  transition: background-color 120ms ease;
}

.matter-row:hover {
  background: #fbfcfc;
}

.matter-row:last-child td {
  border-bottom: 0;
}

.matter-row > td:first-child {
  position: relative;
}

.matter-row > td:first-child::after {
  position: absolute;
  top: 17px;
  bottom: 17px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--workflow-color, var(--signal));
  content: "";
}

.client-cell {
  display: grid;
  gap: 4px;
}

.client-cell strong {
  overflow: hidden;
  color: var(--ink-950);
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-number {
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.counsel-cell {
  display: grid;
  gap: 2px;
}

.counsel-cell span:last-child {
  color: var(--slate-600);
  font-size: 0.74rem;
}

.workflow-rail {
  display: grid;
  gap: 6px;
}

.workflow-track {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.workflow-track::before {
  display: block;
  width: var(--track-width, 12px);
  height: 3px;
  border-radius: 10px;
  background: var(--track-color, var(--signal));
  content: "";
}

.workflow-track span {
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-overflow {
  padding-left: 23px;
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.62rem;
}

.muted-value {
  color: var(--slate-400);
}

.row-action {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--slate-600);
}

.row-action:hover {
  border-color: var(--border);
  background: var(--white);
  color: var(--signal-dark);
}

.row-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.empty-state {
  display: flex;
  min-height: 310px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 4px;
  font-family: var(--display-font);
  font-size: 1.42rem;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 0;
  color: var(--slate-600);
  font-size: 0.86rem;
}

.empty-state.compact {
  min-height: 250px;
}

.empty-rail {
  display: grid;
  width: 50px;
  gap: 6px;
}

.empty-rail span {
  height: 3px;
  border-radius: 5px;
  background: var(--signal);
}

.empty-rail span:nth-child(2) {
  width: 72%;
  background: var(--amber);
}

.empty-rail span:nth-child(3) {
  width: 42%;
  background: var(--green);
}

.text-button {
  padding: 4px;
  color: var(--signal-dark);
  font-size: 0.82rem;
  font-weight: 680;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.loading-state {
  display: grid;
  gap: 1px;
  background: var(--border);
}

.loading-line {
  height: 72px;
  background: var(--white);
  animation: loading-pulse 1.15s ease-in-out infinite alternate;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.notice div {
  display: grid;
}

.notice-error {
  border-color: #e8c4c4;
  background: var(--red-soft);
  color: #772f2f;
}

.sheet-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  max-height: min(900px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-dialog);
  color: var(--ink-950);
}

.reference-dialog {
  width: min(920px, calc(100vw - 32px));
}

.sheet-dialog::backdrop {
  background: rgb(23 34 46 / 54%);
  backdrop-filter: blur(3px);
}

.sheet-dialog[open] {
  animation: dialog-in 160ms ease-out;
}

.dialog-shell {
  display: flex;
  max-height: inherit;
  flex-direction: column;
  margin: 0;
}

.dialog-header {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px 20px;
  border-bottom: 1px solid var(--border);
}

.dialog-header .eyebrow {
  margin-bottom: 4px;
}

.dialog-header h2 {
  margin-bottom: 0;
  font-family: var(--display-font);
  font-size: 1.75rem;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.dialog-intro {
  margin: 6px 0 0;
  color: var(--slate-600);
  font-size: 0.8rem;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--slate-600);
}

.icon-button:hover {
  border-color: var(--ink-800);
  color: var(--ink-950);
}

.dialog-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.form-section {
  padding: 27px 28px 30px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 11px;
  margin-bottom: 20px;
}

.section-index {
  padding-top: 2px;
  color: var(--signal-dark);
  font-family: var(--utility-font);
  font-size: 0.65rem;
  font-weight: 700;
}

.section-heading h3 {
  margin-bottom: 2px;
  font-size: 0.93rem;
  font-weight: 720;
}

.section-heading p {
  margin: 0;
  color: var(--slate-600);
  font-size: 0.76rem;
}

.form-grid {
  display: grid;
  gap: 18px;
  padding-left: 38px;
}

.form-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  align-content: start;
  gap: 6px;
}

.field > span,
.service-selector legend {
  color: var(--ink-800);
  font-size: 0.72rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: 0;
  background-color: var(--white);
  color: var(--ink-950);
  font-size: 0.84rem;
  transition:
    border-color 130ms ease,
    box-shadow 130ms ease;
}

.field select {
  padding-right: 33px;
}

.field input:focus,
.field select:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgb(47 99 217 / 12%);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--red);
}

.field small {
  color: var(--slate-600);
  font-size: 0.68rem;
}

.field .optional-label {
  margin-left: 5px;
  color: var(--slate-400);
  font-family: var(--utility-font);
  font-size: 0.56rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.choice-fieldset,
.service-selector {
  min-width: 0;
  padding: 0;
  border: 0;
}

.choice-fieldset {
  margin: 0 0 20px 38px;
}

.workflow-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-card,
.service-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  cursor: pointer;
}

.check-card {
  min-height: 43px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 0.73rem;
  font-weight: 620;
  line-height: 1.25;
  transition:
    background-color 130ms ease,
    border-color 130ms ease;
}

.check-card:hover {
  border-color: var(--slate-400);
}

.check-card:has(input:checked) {
  border-color: #9eb4e9;
  background: var(--signal-soft);
  color: var(--signal-dark);
}

.check-card input,
.service-check input,
.vendor-option input {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  accent-color: var(--signal);
}

.workflow-assignments {
  display: grid;
  gap: 9px;
  margin-left: 38px;
}

.assignment-card {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.assignment-signal {
  background: var(--assignment-color, var(--signal));
}

.assignment-content {
  padding: 13px 14px;
}

.assignment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.assignment-header strong {
  font-size: 0.78rem;
}

.assignment-header span {
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.62rem;
}

.vendor-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vendor-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--paper);
  cursor: pointer;
  font-size: 0.7rem;
}

.vendor-option:has(input:checked) {
  border-color: #9eb4e9;
  background: var(--signal-soft);
  color: var(--signal-dark);
}

.vendor-option.is-untagged {
  border-color: #e4c8a7;
  background: var(--amber-soft);
  color: #80501a;
}

.no-capable-vendors {
  margin: 0;
  color: var(--slate-600);
  font-size: 0.72rem;
}

.no-capable-vendors button {
  margin-left: 3px;
}

.form-error,
.reference-error {
  margin: 18px 28px 0;
  padding: 10px 12px;
  border: 1px solid #e8c4c4;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: #772f2f;
  font-size: 0.76rem;
}

.dialog-footer {
  flex: none;
  justify-content: flex-end;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: #fafbfb;
}

.button-progress {
  display: none;
}

.button.is-busy .button-label {
  display: none;
}

.button.is-busy .button-progress {
  display: inline;
}

.reference-layout {
  display: grid;
  min-height: min(570px, calc(100vh - 190px));
  grid-template-columns: 190px minmax(0, 1fr);
  overflow: hidden;
}

.reference-tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: #f7f9f8;
}

.reference-tab {
  position: relative;
  min-height: 39px;
  padding: 8px 12px 8px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--slate-600);
  font-size: 0.78rem;
  font-weight: 650;
  text-align: left;
}

.reference-tab::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 5px;
  width: 2px;
  border-radius: 2px;
  background: var(--signal);
  content: "";
  opacity: 0;
}

.reference-tab:hover {
  background: var(--mist-100);
  color: var(--ink-800);
}

.reference-tab.is-active {
  background: var(--signal-soft);
  color: var(--signal-dark);
}

.reference-tab.is-active::before {
  opacity: 1;
}

.reference-panel {
  min-width: 0;
  overflow-y: auto;
  padding: 25px 28px 32px;
}

.reference-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 19px;
}

.reference-panel-header h3 {
  margin-bottom: 2px;
  font-size: 1rem;
}

.reference-panel-header p {
  margin: 0;
  color: var(--slate-600);
  font-size: 0.75rem;
}

.record-count {
  padding-top: 2px;
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.63rem;
  white-space: nowrap;
}

.reference-error {
  margin: 0 0 14px;
}

.add-reference-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.reference-form-actions {
  display: flex;
  grid-row: 1;
  grid-column: 2;
  align-items: center;
  gap: 8px;
}

#add-reference-button {
  min-width: 108px;
}

.service-selector {
  grid-row: 2;
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.service-selector p {
  margin: 2px 0 11px;
  color: var(--slate-600);
  font-size: 0.7rem;
}

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

.service-check {
  font-size: 0.7rem;
  line-height: 1.25;
}

.service-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--slate-600);
  font-size: 0.72rem;
}

.reference-list {
  display: grid;
  gap: 0;
  margin-top: 22px;
  border-top: 1px solid var(--border);
}

.reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 53px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  transition:
    background-color 130ms ease,
    box-shadow 130ms ease;
}

.reference-row.is-editing {
  background: var(--signal-soft);
  box-shadow: inset 3px 0 var(--signal);
}

.reference-row[aria-busy="true"] {
  opacity: 0.58;
}

.reference-row-main {
  display: grid;
  gap: 4px;
}

.reference-row-name {
  font-size: 0.79rem;
  font-weight: 650;
}

.reference-row-services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.service-tag {
  padding: 2px 6px;
  border-radius: 20px;
  background: var(--mist-100);
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.56rem;
}

.reference-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reference-action {
  appearance: none;
  padding: 5px 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--signal-dark);
  font-size: 0.72rem;
  font-weight: 680;
  line-height: 1.2;
}

.reference-action:hover:not(:disabled) {
  background: var(--signal-soft);
}

.reference-action-danger {
  color: var(--red);
}

.reference-action-danger:hover:not(:disabled) {
  background: var(--red-soft);
}

.reference-empty {
  padding: 35px 12px;
  color: var(--slate-600);
  font-size: 0.77rem;
  text-align: center;
}

.reference-footer {
  display: none;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: 0 10px 30px rgb(23 34 46 / 14%);
  color: var(--ink-800);
  font-size: 0.77rem;
  pointer-events: auto;
  animation: toast-in 160ms ease-out;
}

.toast.is-error {
  border-left-color: var(--red);
}

.toast button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--slate-600);
  font-size: 1rem;
  line-height: 1;
}

.login-page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  background: var(--paper);
}

.login-header {
  flex: none;
}

.login-context {
  color: var(--green);
  font-weight: 700;
}

.login-shell {
  display: grid;
  width: min(calc(100% - clamp(40px, 10vw, 160px)), 1180px);
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
  align-items: center;
  gap: clamp(56px, 9vw, 130px);
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) 0;
}

.login-introduction {
  max-width: 650px;
}

.login-workflow-mark {
  display: grid;
  width: 82px;
  gap: 6px;
  margin-bottom: 30px;
}

.login-workflow-mark span {
  display: block;
  height: 4px;
  border-radius: 20px;
  background: var(--signal);
}

.login-workflow-mark span:nth-child(2) {
  width: 68%;
  background: var(--amber);
}

.login-workflow-mark span:nth-child(3) {
  width: 39%;
  background: var(--green);
}

.login-introduction h1 {
  max-width: 650px;
  margin-bottom: 18px;
  font-size: clamp(3.2rem, 6.4vw, 5.6rem);
  line-height: 0.93;
}

.login-introduction > p:last-child {
  max-width: 525px;
  margin: 0;
  color: var(--slate-600);
  font-size: 1rem;
}

.login-card {
  padding: clamp(28px, 4vw, 38px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: 0 18px 56px rgb(23 34 46 / 10%);
}

.login-card-header {
  margin-bottom: 25px;
}

.login-card-header h2 {
  margin-bottom: 6px;
  font-family: var(--display-font);
  font-size: 2rem;
  letter-spacing: -0.025em;
  line-height: 1;
}

.login-card-header > p:last-child {
  margin: 0;
  color: var(--slate-600);
  font-size: 0.82rem;
}

.login-error {
  margin-bottom: 18px;
  padding: 11px 12px;
  border: 1px solid #e8c4c4;
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: #772f2f;
  font-size: 0.76rem;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-field input {
  min-height: 47px;
  font-size: 0.9rem;
}

.login-submit {
  width: 100%;
  min-height: 47px;
  margin-top: 3px;
}

.login-access-note {
  margin: 20px 0 0;
  padding-top: 17px;
  border-top: 1px solid var(--border);
  color: var(--slate-600);
  font-family: var(--utility-font);
  font-size: 0.62rem;
  line-height: 1.5;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes loading-pulse {
  from {
    opacity: 0.58;
  }

  to {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1050px) {
  .matter-table th:nth-child(5),
  .matter-table td:nth-child(5) {
    display: none;
  }

  .matter-table th:first-child,
  .matter-table td:first-child {
    width: 25%;
  }

  .matter-table th:nth-child(2) {
    width: 18%;
  }

  .matter-table th:nth-child(3) {
    width: 22%;
  }

  .matter-table th:nth-child(4) {
    width: auto;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--paper);
  }

  .app-header {
    min-height: 64px;
    padding: 0 18px;
  }

  .header-context {
    display: none;
  }

  .header-context.is-local {
    display: inline-flex;
  }

  .header-actions {
    gap: 8px;
  }

  .login-context {
    display: inline-flex;
  }

  .login-shell {
    width: min(calc(100% - 36px), 520px);
    grid-template-columns: 1fr;
    align-content: start;
    gap: 38px;
    padding: 54px 0 64px;
  }

  .login-introduction h1 {
    max-width: 520px;
    font-size: clamp(3rem, 12vw, 4.4rem);
  }

  .login-introduction > p:last-child {
    font-size: 0.92rem;
  }

  .page-shell {
    width: calc(100% - 28px);
    padding: 32px 0 48px;
  }

  .page-heading {
    display: grid;
    align-items: start;
    margin-bottom: 24px;
  }

  h1 {
    font-size: clamp(2.3rem, 13vw, 3.4rem);
  }

  .heading-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .matter-toolbar {
    display: grid;
    min-height: auto;
    gap: 0;
    padding: 0;
  }

  .status-tabs {
    min-height: 58px;
    justify-content: center;
    padding: 0 16px;
  }

  .matter-search {
    width: auto;
    margin: 12px 14px;
  }

  .matter-table,
  .matter-table tbody,
  .matter-table tr,
  .matter-table td {
    display: block;
    width: 100% !important;
  }

  .matter-table thead {
    display: none;
  }

  .matter-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto;
    gap: 14px 18px;
    padding: 20px 18px 20px 22px;
    border-bottom: 1px solid var(--border);
  }

  .matter-row:last-child {
    border-bottom: 0;
  }

  .matter-row::before {
    position: absolute;
    top: 18px;
    bottom: 18px;
    left: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--workflow-color, var(--signal));
    content: "";
  }

  .matter-row > td:first-child::after {
    content: none;
  }

  .matter-table td,
  .matter-table td:first-child,
  .matter-table td:last-child {
    padding: 0;
    border: 0;
  }

  .matter-table td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--slate-600);
    content: attr(data-label);
    font-family: var(--utility-font);
    font-size: 0.56rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .matter-table td:first-child {
    grid-column: 1 / 3;
  }

  .matter-table td:first-child::before,
  .matter-table td:last-child::before {
    display: none;
  }

  .matter-table td:nth-child(4) {
    grid-column: 1 / 3;
  }

  .matter-table td:nth-child(5) {
    display: block;
  }

  .matter-table td:last-child {
    grid-row: 1;
    grid-column: 3;
  }

  .matter-row .client-cell strong {
    white-space: normal;
  }

  .sheet-dialog,
  .reference-dialog {
    width: 100vw;
    max-height: 100dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }

  .dialog-header {
    padding: 20px 18px 16px;
  }

  .form-section {
    padding: 23px 18px 26px;
  }

  .form-grid,
  .choice-fieldset,
  .workflow-assignments {
    margin-left: 0;
    padding-left: 0;
  }

  .workflow-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-footer {
    padding: 13px 18px max(13px, env(safe-area-inset-bottom));
  }

  .dialog-footer .button {
    flex: 1;
  }

  .reference-layout {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
  }

  .reference-tabs {
    flex: none;
    flex-direction: row;
    gap: 5px;
    padding: 10px 14px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .reference-tab {
    flex: none;
    min-height: 34px;
    padding: 6px 11px;
    white-space: nowrap;
  }

  .reference-tab::before {
    display: none;
  }

  .reference-panel {
    padding: 21px 18px 28px;
  }

  .reference-footer {
    display: flex;
  }
}

@media (max-width: 520px) {
  .header-context.is-local #workspace-label {
    display: none;
  }

  .header-context.is-local::after {
    content: "Local";
    font-size: 0.62rem;
  }

  .login-context {
    display: none;
  }

  .login-shell {
    width: calc(100% - 28px);
    gap: 30px;
    padding: 38px 0 48px;
  }

  .login-workflow-mark {
    margin-bottom: 22px;
  }

  .login-introduction h1 {
    font-size: clamp(2.65rem, 14vw, 3.5rem);
  }

  .login-card {
    padding: 25px 21px;
    border-radius: var(--radius-md);
  }

  .heading-actions,
  .form-grid.two-columns,
  .service-grid {
    grid-template-columns: 1fr;
  }

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

  .add-reference-form {
    grid-template-columns: 1fr;
  }

  .add-reference-form .button {
    width: 100%;
  }

  .reference-form-actions,
  .service-selector {
    grid-row: auto;
    grid-column: 1;
  }

  .reference-form-actions .button {
    flex: 1;
  }

  .matter-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .matter-table td:first-child,
  .matter-table td:nth-child(4) {
    grid-column: 1;
  }

  .matter-table td:nth-child(2),
  .matter-table td:nth-child(3),
  .matter-table td:nth-child(4),
  .matter-table td:nth-child(5) {
    grid-column: 1 / -1;
  }

  .matter-table td:last-child {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
