:root {
  color-scheme: light;
  --font-size-base: 14px;
  --font-size-desktop-fhd: 12.5px;
  --font-size-desktop-wide: 13px;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #dfe7ef;
  --line-soft: #edf2f7;
  --text: #1f2937;
  --muted: #64748b;
  --soft: #94a3b8;
  --brand: #2296b8;
  --brand-dark: #17677e;
  --shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
  --font-sans: "Plus Jakarta Sans", "Inter", "Segoe UI", "Roboto", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

.ai-settings-editor footer {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.ai-settings-shell {
  grid-template-columns: minmax(0, 1fr);
}

.ai-settings-list {
  width: 100%;
  min-width: 0;
}

.ai-settings-filters {
  display: grid;
  gap: 0.75rem;
}

.ai-settings-filters {
  grid-template-columns: minmax(280px, 1.4fr) repeat(3, minmax(180px, 0.75fr)) auto;
  margin-bottom: 1rem;
}

.ai-settings-filters input,
.ai-settings-filters select,
.ai-settings-editor input,
.ai-settings-editor select,
.ai-settings-editor textarea {
  width: 100%;
  border: 1px solid #d9e3ef;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  color: #10233f;
  font: inherit;
}

.ai-settings-list > header {
  align-items: center;
}

.ai-settings-add-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #0f86a7;
  border-radius: 8px;
  background: #0f86a7;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 134, 167, 0.18);
}

.ai-settings-add-button:hover,
.ai-settings-add-button:focus-visible {
  background: #0b6f8a;
  border-color: #0b6f8a;
  outline: 2px solid rgba(15, 134, 167, 0.22);
  outline-offset: 2px;
}

.ai-settings-prompt-table {
  display: grid;
  gap: 0.35rem;
}

.ai-settings-prompt-row {
  display: grid;
  grid-template-columns: minmax(320px, 1.5fr) minmax(170px, 0.55fr) minmax(360px, 1.2fr) minmax(110px, 0.35fr) minmax(82px, 0.25fr);
  gap: 0.75rem;
  align-items: center;
  border: 1px solid #dbe7f3;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.ai-settings-prompt-row:not(.ai-settings-prompt-row--head):hover,
.ai-settings-prompt-row:not(.ai-settings-prompt-row--head):focus-visible {
  border-color: #9acfe1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  outline: 0;
  transform: translateY(-1px);
}

.ai-settings-prompt-row--head {
  border: 0;
  padding: 0 0.75rem 0.25rem;
  background: transparent;
  color: #66728a;
  cursor: default;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: none;
}

.ai-settings-prompt-row.is-paused {
  opacity: 0.68;
}

.ai-settings-prompt-main {
  min-width: 0;
}

.ai-settings-prompt-main strong,
.ai-settings-prompt-main small,
.ai-settings-prompt-main p {
  display: block;
}

.ai-settings-prompt-main strong {
  color: #10233f;
  font-size: 0.93rem;
}

.ai-settings-prompt-main small,
.ai-settings-prompt-kicker {
  color: #66728a;
  font-size: 0.78rem;
  font-weight: 800;
}

.ai-settings-prompt-main p {
  margin: 0.12rem 0 0;
  color: #4b5874;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-settings-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ai-settings-tags em {
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: #eef6ff;
  color: #285c8f;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
}

.ai-settings-filters .secondary-action,
.ai-settings-editor .secondary-action,
.ai-settings-editor .primary-action {
  min-height: 34px;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-weight: 800;
}

.ai-settings-order {
  color: #4b5874;
  font-weight: 800;
}

.ai-settings-editor-dialog {
  width: min(1120px, calc(100vw - 3rem));
  max-width: calc(100vw - 3rem);
  overflow: visible;
}

.ai-settings-editor {
  width: 100%;
  max-width: none;
  max-height: calc(100vh - 3rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ai-settings-editor header {
  align-items: flex-start;
  min-width: 0;
}

.ai-settings-editor header > div {
  min-width: 0;
}

.ai-settings-editor header p {
  max-width: 72rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.ai-settings-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.ai-settings-editor-grid label {
  display: grid;
  gap: 0.35rem;
  color: #4b5874;
  font-size: 0.82rem;
  font-weight: 800;
}

.ai-settings-editor-grid .span-2 {
  grid-column: 1 / -1;
}

.ai-settings-editor textarea {
  resize: vertical;
}

.ai-settings-editor select[multiple] {
  min-height: 7.2rem;
}

.ai-settings-editor footer {
  position: sticky;
  bottom: 0;
  margin: 0 -1rem -1rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #e1e8f0;
  background: #ffffff;
}

.ai-settings-context-menu {
  position: fixed;
  z-index: 1100;
  min-width: 190px;
  padding: 0.35rem;
  border: 1px solid #d9e3ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.ai-settings-context-menu form {
  margin: 0;
}

.ai-settings-context-menu button {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  background: transparent;
  color: #10233f;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.ai-settings-context-menu button:hover,
.ai-settings-context-menu button:focus-visible {
  background: #eef6ff;
  outline: 0;
}

.ai-settings-context-menu .danger-action {
  color: #b42318;
}

html[data-theme="dark"] .ai-settings-filters input,
html[data-theme="dark"] .ai-settings-filters select,
html[data-theme="dark"] .ai-settings-editor input,
html[data-theme="dark"] .ai-settings-editor select,
html[data-theme="dark"] .ai-settings-editor textarea,
html[data-theme="dark"] .ai-settings-prompt-row,
html[data-theme="dark"] .ai-settings-context-menu {
  border-color: #334155;
  background: #111827;
  color: #e5edf7;
}

html[data-theme="dark"] .ai-settings-prompt-row--head {
  background: transparent;
  color: #9fb0c6;
}

html[data-theme="dark"] .ai-settings-prompt-main strong,
html[data-theme="dark"] .ai-settings-context-menu button {
  color: #e5edf7;
}

html[data-theme="dark"] .ai-settings-prompt-main p,
html[data-theme="dark"] .ai-settings-prompt-main small,
html[data-theme="dark"] .ai-settings-prompt-kicker,
html[data-theme="dark"] .ai-settings-order,
html[data-theme="dark"] .ai-settings-editor-grid label {
  color: #a8b5c7;
}

html[data-theme="dark"] .ai-settings-tags em,
html[data-theme="dark"] .ai-settings-context-menu button:hover,
html[data-theme="dark"] .ai-settings-context-menu button:focus-visible {
  background: #16324a;
  color: #b9dcff;
}

html[data-theme="dark"] .ai-settings-editor footer {
  border-color: #334155;
  background: #111827;
}

html[data-theme="dark"] .ai-settings-context-menu .danger-action {
  color: #fca5a5;
}

@media (max-width: 980px) {
  .ai-settings-filters {
    grid-template-columns: 1fr;
  }

  .ai-settings-prompt-row,
  .ai-settings-prompt-row--head {
    grid-template-columns: 1fr;
  }

  .ai-settings-prompt-row--head {
    display: none;
  }

  .ai-settings-editor-grid {
    grid-template-columns: 1fr;
  }

  .ai-settings-editor-dialog {
    width: calc(100vw - 1rem);
    max-width: calc(100vw - 1rem);
  }

  .ai-settings-editor {
    max-height: calc(100vh - 1rem);
  }
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
}

@media (min-width: 1600px) and (max-width: 2100px) {
  :root {
    --font-size-base: var(--font-size-desktop-fhd);
  }
}

@media (min-width: 2101px) {
  :root {
    --font-size-base: var(--font-size-desktop-wide);
  }
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  --menu-width: 48px;
  --menu-overlay-width: 248px;
  grid-template-columns: var(--menu-width) minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  min-height: 100vh;
}

.app-shell.is-menu-hovered {
  --menu-width: 48px;
}

.app-shell.is-menu-expanded {
  --menu-width: var(--menu-overlay-width);
}

.icon-sprite {
  position: fixed;
  inset: auto;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  z-index: -1;
  display: none !important;
}

.app-menu,
.topbar,
.work-panel,
.metric-card,
.module-table,
.module-filters {
  background: var(--surface);
}

.app-menu {
  grid-column: 1 !important;
  grid-row: 1;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: var(--menu-width);
  min-height: 100dvh;
  border-right: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
  transition: width 0.14s ease, box-shadow 0.14s ease;
}

.app-shell.is-menu-expanded .app-menu,
.app-shell.is-menu-hovered .app-menu {
  width: var(--menu-overlay-width);
  box-shadow: 10px 0 24px rgba(15, 23, 42, 0.12);
}

.app-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 52px;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
}

.app-shell.is-menu-expanded .app-title,
.app-shell.is-menu-hovered .app-title {
  justify-content: flex-start;
  gap: 0.7rem;
  padding-inline: 0.75rem;
}

.app-mark-wrap {
  display: inline-grid;
  place-items: center;
  gap: 0.16rem;
  flex: 0 0 auto;
}

.app-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--brand);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.app-env-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 13px;
  padding: 0 0.24rem;
  border: 1px solid #fecaca;
  border-radius: 4px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.55rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.app-title-text,
.menu-label {
  width: 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-0.2rem);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
  pointer-events: none;
}

.app-shell.is-menu-expanded .app-title-text,
.app-shell.is-menu-expanded .menu-label,
.app-shell.is-menu-hovered .app-title-text,
.app-shell.is-menu-hovered .menu-label {
  width: auto;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.app-title strong {
  display: block;
  font-size: 1rem;
}

.app-title small,
.app-menu p {
  color: var(--soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.menu-stack {
  display: grid;
  align-content: start;
  gap: 0.08rem;
  padding: 0.45rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.34) transparent;
}

.menu-stack::-webkit-scrollbar {
  width: 8px;
}

.menu-stack::-webkit-scrollbar-track {
  background: transparent;
}

.menu-stack::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.3);
  background-clip: content-box;
}

.menu-stack::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 116, 144, 0.42);
  background-clip: content-box;
}

.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 44px;
  padding: 0 0.75rem;
  border-left: 3px solid transparent;
  color: var(--muted);
  font-weight: 650;
  overflow: hidden;
}

.app-shell.is-menu-expanded .menu-item,
.app-shell.is-menu-hovered .menu-item {
  justify-content: flex-start;
  gap: 0.9rem;
}

.menu-item svg,
.menu-toggle svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-item:hover,
.menu-item.is-active,
.menu-settings.is-active > .menu-settings-summary {
  border-left-color: var(--brand);
  background: #eef8fc;
  color: var(--brand-dark);
}

.menu-item.is-active,
.menu-settings.is-active > .menu-settings-summary {
  font-weight: 800;
}

.menu-settings {
  display: grid;
}

.menu-settings summary {
  list-style: none;
  cursor: pointer;
}

.menu-settings summary::-webkit-details-marker {
  display: none;
}

.menu-settings-body {
  display: none;
  padding: 0.18rem 0.5rem 0.35rem 2.45rem;
}

.app-shell.is-menu-expanded .menu-settings[open] .menu-settings-body,
.app-shell.is-menu-hovered .menu-settings[open] .menu-settings-body {
  display: grid;
  gap: 0.32rem;
}

.menu-subgroup {
  display: grid;
  gap: 0.06rem;
}

.menu-subgroup p {
  display: block;
  margin: 0.35rem 0 0.08rem;
  color: var(--soft);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-subitem {
  display: block;
  min-width: 0;
  border-radius: 6px;
  padding: 0.36rem 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.menu-subitem span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-subitem:hover,
.menu-subitem.is-active {
  background: #eef8fc;
  color: var(--brand-dark);
}

.menu-toggle {
  display: inline-grid;
  place-items: center;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  cursor: pointer;
}

.menu-toggle:hover {
  background: #eef8fc;
  color: var(--brand-dark);
}

.app-shell.is-menu-expanded .menu-toggle,
.app-shell.is-menu-hovered .menu-toggle {
  justify-content: start;
  padding-left: 0.8rem;
}

.app-menu p {
  display: none;
}

.app-main {
  grid-column: 2 / -1 !important;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  position: relative;
  z-index: 1;
}

.app-shell.is-menu-expanded .menu-item:hover,
.app-shell.is-menu-expanded .menu-item.is-active,
.app-shell.is-menu-expanded .menu-settings.is-active > .menu-settings-summary,
.app-shell.is-menu-hovered .menu-item:hover,
.app-shell.is-menu-hovered .menu-item.is-active,
.app-shell.is-menu-hovered .menu-settings.is-active > .menu-settings-summary {
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
}

.topbar input {
  width: min(760px, 100%);
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.7rem;
  color: var(--text);
  background: #f8fafc;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
}

.work-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-width: max-content;
}

.work-timer output {
  min-width: 72px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.work-timer button {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.work-timer button:hover,
.work-timer button:focus {
  border-color: #98cfe3;
  background: #eef8fc;
}

.work-timer svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.work-timer[data-running="true"] [data-work-timer-toggle] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.work-timer__reset {
  width: 28px;
  padding: 0;
}

.work-timer [data-work-timer-convert] {
  display: inline-flex;
  min-width: 0;
  padding: 0 0.45rem;
  color: var(--text);
  font-size: 0.72rem;
}

.role-notifications {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.role-notifications a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.55rem;
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.role-notifications strong {
  color: var(--brand-dark);
}

.context-switcher {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 700;
}

.context-switcher select {
  height: 34px;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 2rem 0 0.65rem;
  color: var(--text);
  background: #f8fafc;
  font: inherit;
  font-weight: 750;
}

[data-context-hidden="true"] {
  display: none !important;
}

.dashboard,
.module-page {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-header--registry {
  align-items: center;
  padding: 0.95rem 0 0.4rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}

.page-header--registry h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 850;
}

.page-header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 800;
}

.page-header h1 {
  margin: 0.15rem 0;
  font-size: 1.55rem;
}

.page-header span {
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.page-actions a,
.page-actions button {
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: center;
  padding: 0.34rem 0.65rem;
  text-decoration: none;
}

.page-actions button {
  cursor: pointer;
}

.page-actions .primary-action {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.status-message {
  margin: 0;
  border: 1px solid #bae6fd;
  border-left: 4px solid var(--brand);
  padding: 0.65rem 0.85rem;
  background: #f0f9ff;
  color: var(--brand-dark);
  font-weight: 750;
}

.evidence-panel {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  background: #f8fafc;
}

.evidence-panel h3 {
  margin: 0;
  font-size: 0.92rem;
}

.evidence-panel span {
  display: block;
  border-left: 3px solid var(--brand);
  padding: 0.22rem 0 0.22rem 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.decision-gate {
  display: grid;
  gap: 0.18rem;
  margin: 0 0 0.75rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  background: var(--surface-soft);
}

.decision-gate strong {
  color: var(--ink);
}

.decision-gate span {
  color: var(--muted);
  font-size: 0.86rem;
}

.decision-gate em {
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 850;
}

.decision-gate.is-blocked {
  border-left-color: var(--danger);
}

.decision-gate.is-blocked em {
  color: var(--danger);
}

.primary-action {
  align-self: start;
  border: 0;
  padding: 0.52rem 0.85rem;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.section-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.secondary-action {
  align-self: start;
  border: 1px solid var(--line);
  padding: 0.48rem 0.72rem;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0.75rem;
}

.role-playbook {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 0.75rem;
}

.role-playbook article {
  display: grid;
  gap: 0.35rem;
  min-height: 138px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  padding: 0.85rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.role-playbook p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.role-playbook h2 {
  margin: 0;
  font-size: 1rem;
}

.role-playbook span {
  color: var(--muted);
}

.role-playbook a {
  align-self: end;
  color: var(--brand-dark);
  font-weight: 800;
}

.metric-card {
  display: grid;
  gap: 0.18rem;
  min-height: 88px;
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--line);
  border-top: 2px solid var(--brand);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 1.32rem;
  line-height: 1.05;
}

.metric-card--orange {
  border-top-color: #f59e0b;
}

.metric-card--green {
  border-top-color: #22c55e;
}

.metric-card--slate {
  border-top-color: #64748b;
}

.metric-card--purple {
  border-top-color: #7c3aed;
}

.metric-card--high {
  border-top-color: #dc2626;
}

.metric-card--medium {
  border-top-color: #f59e0b;
}

.metric-card--low {
  border-top-color: #22c55e;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 0.75rem;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 0.75rem;
}

.work-panel {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.work-panel header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.work-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.work-panel header a {
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.work-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.18rem 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

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

.work-row:hover,
.module-table a:hover,
.module-table-row:hover {
  background: #f8fbfd;
}

.work-row.is-active {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.work-row strong,
.work-row span,
.work-row small {
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-row span,
.work-row small {
  color: var(--muted);
}

.work-row em {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  justify-self: end;
  max-width: 12rem;
  color: var(--brand-dark);
  font-style: normal;
  font-size: 0.76rem;
  font-weight: 800;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-workspace {
  display: grid;
  gap: 0.75rem;
}

.lead-summary-row {
  grid-template-columns: minmax(180px, 0.75fr) minmax(130px, 0.45fr) minmax(280px, 1.35fr) auto auto;
  align-items: center;
}

.lead-summary-row strong,
.lead-summary-row span,
.lead-summary-row small {
  grid-column: auto;
}

.lead-summary-row small:first-of-type {
  white-space: normal;
}

.lead-summary-row em {
  grid-column: auto;
  grid-row: auto;
  justify-self: end;
}

.lead-summary-row button {
  justify-self: end;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--brand-dark);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
}

.lead-summary-row button:hover {
  border-color: var(--brand);
  background: #eef9fc;
}

.lead-summary-row.is-active {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  background: #fff;
}

.module-shell {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 0.75rem;
}

.module-shell--wide {
  grid-template-columns: 180px minmax(0, 1fr) 300px;
}

.contacts-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.62rem;
  min-width: 0;
}

.contacts-workspace .module-list-header,
.contacts-workspace .registry-toolbar,
.contacts-workspace .modern-list--contacts,
.contacts-workspace .empty-state {
  min-width: 0;
}

.contacts-workspace .registry-toolbar {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(160px, 220px) minmax(160px, 220px) minmax(220px, 320px);
  align-items: end;
  justify-content: stretch;
  gap: 0.55rem;
}

.contacts-workspace .segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.contacts-workspace .segmented-control button,
.contacts-workspace .modern-row__side button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--brand-dark);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 850;
  padding: 0 0.65rem;
  cursor: pointer;
}

.contacts-workspace .segmented-control button.is-active,
.contacts-workspace .segmented-control button:hover,
.contacts-workspace .segmented-control button:focus-visible,
.contacts-workspace .modern-row__side button:hover,
.contacts-workspace .modern-row__side button:focus-visible {
  border-color: rgba(14, 165, 196, 0.35);
  background: #e8f8fd;
  color: #075b72;
  outline: none;
}

.contacts-workspace .filter-field,
.contacts-workspace .search-box {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.contacts-workspace .filter-field span,
.contacts-workspace .search-box span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.contacts-workspace .filter-field select,
.contacts-workspace .search-box input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  padding: 0 0.55rem;
}

.modern-list--contacts {
  display: grid;
  gap: 0.42rem;
}

.modern-list--contacts .modern-row--compact {
  grid-template-columns: minmax(260px, 1.4fr) minmax(320px, 1fr);
  min-height: 58px;
  border-radius: 10px;
  padding: 0.55rem 0.62rem;
}

.modern-list--contacts .modern-row__main {
  grid-template-columns: minmax(0, 1fr);
}

.modern-list--contacts .modern-row__side {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr) auto;
  align-items: center;
  justify-items: start;
  gap: 0.45rem;
}

.modern-list--contacts .modern-row__side a,
.modern-list--contacts .modern-row__side > span:not(.status-pill) {
  min-width: 0;
  overflow: hidden;
  color: var(--brand-dark);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .contacts-workspace .registry-toolbar,
  .modern-list--contacts .modern-row--compact {
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-list--contacts .modern-row__side {
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }
}

.module-shell--register {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.module-shell--admin-overview {
  grid-template-columns: minmax(0, 1fr);
}

.admin-overview-shell {
  align-items: start;
}

.admin-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.admin-summary-strip div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  min-width: 0;
  padding: 0.48rem 0.55rem;
}

.admin-summary-strip dt {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  margin: 0 0 0.18rem 0;
  text-transform: uppercase;
}

.admin-summary-strip dd {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  margin: 0;
}

.case-registry {
  display: grid;
  gap: 0;
}

.registry-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.registry-toolbar--legaldesk {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) minmax(0, max-content) minmax(180px, 240px);
  align-items: center;
  justify-content: start;
  padding: 0.1rem 0 0.65rem;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.registry-toolbar--legaldesk .registry-tabs {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  overflow: visible;
}

.registry-add-link {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  padding: 0 0.35rem;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.registry-add-link span {
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
}

.registry-search-group {
  position: relative;
  min-width: 0;
}

.registry-search--legaldesk {
  width: 100%;
  padding-right: 2rem;
}

.registry-search-icon {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  width: 15px;
  height: 15px;
  border: 2px solid #b8c0ca;
  border-radius: 999px;
  transform: translateY(-58%);
  pointer-events: none;
}

.registry-search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: #b8c0ca;
  transform: rotate(45deg);
}

.registry-group-hint {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
  padding: 0 0.85rem;
  background: #eef8fd;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.registry-group-hint span {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand-dark);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.registry-group-hint p {
  margin: 0;
}

.registry-tabs {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  min-width: 0;
  overflow-x: auto;
}

.registry-search {
  width: min(360px, 34vw);
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: 0 0.75rem;
  font: inherit;
}

.registry-search--compact {
  width: min(240px, 24vw);
}

.registry-filter-stack {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: min(720px, 48vw);
}

.registry-filter-stack .registry-search {
  width: min(280px, 22vw);
}

.registry-filter-stack .registry-search--compact {
  width: min(170px, 14vw);
}

.registry-tabs button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 0.52rem;
  font-size: 0.78rem;
  white-space: nowrap;
  font-weight: 800;
}

.registry-tabs button strong,
.tabs button strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 0.25rem;
  border-radius: 999px;
  padding: 0 0.28rem;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 0.64rem;
  line-height: 1;
  font-weight: 850;
}

.registry-tabs button.is-active,
.registry-tabs button:hover {
  border-color: #b7dcea;
  background: #eef9fc;
  color: var(--brand-dark);
}

.module-filters,
.module-table,
.detail-pane,
.calendar-board,
.agenda-panel,
.kanban-column,
.modal-card {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--surface);
}

.module-filters {
  display: grid;
  align-content: start;
  padding: 0.5rem;
}

.module-filters button {
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem;
  text-align: left;
  font-weight: 700;
}

.module-filters button.is-active,
.module-filters button:hover {
  border-left-color: var(--brand);
  background: #f8fbfd;
  color: var(--text);
}

.module-table {
  min-width: 0;
}

.module-table--registry {
  overflow-x: auto;
}

.module-table header,
.module-table > a,
.module-table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(140px, 1fr) minmax(120px, 0.7fr) minmax(110px, 0.7fr);
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
}

.module-table header {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.module-table > a span,
.module-table > a strong,
.module-table-row span,
.module-table-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-table .inline-form {
  margin: 0;
}

.module-table .inline-form select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.module-table small {
  color: var(--muted);
  font-weight: 500;
}

.module-table-row a {
  display: inline;
  padding: 0;
  border: 0;
  color: var(--brand-dark);
  font-weight: 800;
}

.module-table--matters header,
.module-table--matters a {
  grid-template-columns:
    minmax(330px, 1.8fr)
    minmax(190px, 0.9fr)
    36px
    minmax(105px, 0.5fr)
    minmax(180px, 0.8fr)
    minmax(140px, 0.6fr)
    minmax(300px, 1.25fr);
}

.module-table--matters header {
  background: #eef8fd;
  min-height: 68px;
  align-items: end;
}

.module-table--matters a {
  min-height: 46px;
  padding-block: 0.5rem;
  color: var(--ink);
  font-size: 0.86rem;
}

.module-table--matters a:hover,
.module-table--matters a:focus {
  background: #f8fbfd;
}

.matter-name {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.matter-name > span {
  width: 15px;
  height: 11px;
  border: 1.5px solid #b9c0c7;
  border-radius: 2px;
  flex: 0 0 auto;
}

.matter-name > span::before {
  content: "";
  display: block;
  width: 7px;
  height: 3px;
  margin: -4px 0 0 1px;
  border: 1.5px solid #b9c0c7;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: var(--surface);
}

.matter-open-icon {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 2px solid #bde7fb;
  border-radius: 999px;
  justify-self: center;
}

.matter-open-icon::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #8ecdec;
}

.assignee-stack {
  display: flex;
  align-items: center;
  gap: 0.28rem;
}

.assignee-stack small {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #a8adb3;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 850;
}

.inline-form--owner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.inline-form--owner select {
  min-width: 0;
  min-height: 28px;
}

.inline-form--owner button {
  min-height: 28px;
  padding: 0 0.4rem;
}

.registry-lookup-form {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.registry-lookup-form button {
  width: max-content;
}

.registry-lookup-form small,
.form-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.module-table--clients header,
.module-table--clients a {
  grid-template-columns:
    minmax(170px, 1fr)
    minmax(110px, 0.55fr)
    minmax(150px, 0.8fr)
    minmax(190px, 1fr)
    minmax(120px, 0.65fr)
    minmax(130px, 0.65fr)
    minmax(90px, 0.45fr)
    minmax(210px, 1.2fr)
    minmax(70px, 0.35fr);
}

.module-table--clients header,
.module-table--clients a {
  min-width: 1290px;
}

.module-table--clients a em {
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
}

.module-table--matters a {
  min-width: 1340px;
}

.module-table--matters header {
  min-width: 1340px;
}

.module-table--matters a em {
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
}

.module-table--activities header,
.module-table--activities a {
  grid-template-columns: 90px 90px 120px minmax(240px, 1fr) 110px 90px 100px 120px;
}

.module-table--correspondence header,
.module-table--correspondence a,
.module-table--correspondence .module-table-row {
  grid-template-columns: 90px 90px 120px minmax(280px, 1fr) 150px 82px;
}

.module-table--correspondence .module-table-row > span,
.module-table--correspondence .module-table-row > strong {
  white-space: normal;
}

.module-table--correspondence {
  border-radius: 16px;
}

.module-table--correspondence header {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.module-table--correspondence .module-table-row {
  padding-top: 0.88rem;
  padding-bottom: 0.88rem;
  align-items: start;
}

.module-table--correspondence .module-table-row strong {
  font-size: 1rem;
  line-height: 1.2;
}

.module-table--correspondence .module-table-row > span {
  font-size: 0.98rem;
  line-height: 1.3;
}

.module-table--correspondence .module-table-row small {
  font-size: 0.88rem;
  line-height: 1.35;
}

.module-table--correspondence .status-pill {
  min-height: 28px;
  padding: 0 0.62rem;
  font-size: 0.8rem;
}

.module-table--correspondence .row-actions--compact button {
  min-height: 32px;
  padding: 0 0.66rem;
  font-size: 0.84rem;
  font-weight: 750;
}

.correspondence-process-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  color: var(--muted);
}

.correspondence-process-note strong {
  color: var(--ink);
}

.correspondence-process-note span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: var(--panel-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.module-filters button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.module-filters button strong {
  color: var(--brand-dark);
  font-size: 0.74rem;
}

.process-note,
.module-empty,
.correspondence-path {
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.process-note {
  display: grid;
  gap: 0.25rem;
  margin: 0.65rem 0 0;
  padding: 0.65rem;
}

.process-note span,
.correspondence-path strong {
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.process-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.module-empty {
  margin: 0.75rem;
  padding: 0.8rem;
  color: var(--muted);
  font-weight: 750;
}

.correspondence-path {
  display: grid;
  gap: 0.38rem;
  margin: 0.75rem 0;
  padding: 0.7rem;
}

.correspondence-path span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stack-form small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.inline-check {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.inline-check input {
  margin-top: 0.2rem;
}

.module-table--costs header,
.module-table--costs a {
  grid-template-columns: 90px 110px 120px minmax(220px, 1fr) 90px 90px 110px;
}

.compact-summary {
  display: grid;
  gap: 0;
  margin: 0 0 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface);
}

.compact-summary div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line-soft);
}

.compact-summary div:last-child {
  border-bottom: 0;
}

.compact-summary dt {
  color: var(--muted);
  font-weight: 800;
}

.compact-summary dd {
  margin: 0;
  color: var(--ink);
  font-weight: 850;
}

.billing-rates {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
  padding: 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface-soft);
}

.billing-rates header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.billing-rates h3 {
  margin: 0;
  font-size: 0.9rem;
}

.billing-rates span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.billing-rate-row {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) 64px 54px minmax(92px, 1fr) auto;
  gap: 0.3rem;
  align-items: center;
}

.billing-rate-row strong {
  font-size: 0.78rem;
}

.billing-rate-row input,
.billing-rate-row select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.42rem;
  color: var(--text);
  background: var(--surface);
}

.billing-rate-row button {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.42rem 0.5rem;
  color: var(--ink);
  background: var(--surface);
  font-weight: 850;
}

.personal-cost-fields {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) minmax(90px, 0.45fr);
  gap: 0.6rem;
  align-items: end;
  padding: 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
}

.personal-cost-fields[hidden] {
  display: none;
}

.personal-cost-fields label {
  display: grid;
  gap: 0.25rem;
}

.personal-cost-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.invoice-queue {
  display: grid;
  gap: 0;
  margin: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.invoice-queue > header,
.invoice-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(130px, 0.8fr) minmax(180px, 1fr) minmax(100px, 0.6fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.invoice-queue > header {
  background: var(--surface-soft);
}

.invoice-queue h2 {
  margin: 0;
  font-size: 0.95rem;
}

.invoice-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.invoice-actions a {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.42rem 0.6rem;
  color: var(--ink);
  background: var(--surface);
  font-weight: 850;
}

.invoice-queue span,
.invoice-row small {
  color: var(--muted);
}

.invoice-row div {
  display: grid;
  gap: 0.16rem;
}

.invoice-row em {
  font-style: normal;
  color: var(--brand-dark);
  font-weight: 850;
}

.invoice-row form {
  margin: 0;
}

.invoice-row button,
.invoice-row > a {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.48rem 0.65rem;
  color: var(--ink);
  background: var(--surface);
  font-weight: 850;
  text-align: center;
}

.client-relations-panel {
  align-content: start;
}

.relation-map {
  display: grid;
  grid-template-columns: minmax(150px, 0.45fr) minmax(260px, 1fr);
  gap: 0.8rem;
  align-items: stretch;
}

.relation-node,
.relation-lanes section,
.relation-risk {
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface-soft);
}

.relation-node {
  display: grid;
  align-content: center;
  gap: 0.35rem;
  padding: 0.85rem;
}

.relation-node strong {
  font-size: 1rem;
}

.relation-node span,
.relation-lanes p,
.relation-chip small,
.relation-empty {
  color: var(--muted);
}

.relation-node--client {
  border-left: 3px solid var(--brand);
}

.relation-lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.relation-lanes section {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  padding: 0.65rem;
}

.relation-lanes p {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.relation-chip {
  display: grid;
  gap: 0.1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.42rem 0.5rem;
  color: var(--ink);
  background: var(--surface);
  font-weight: 850;
}

.relation-chip small {
  font-size: 0.72rem;
  font-weight: 750;
}

.relation-risk {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding: 0.6rem;
}

.relation-risk span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.5rem;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 800;
}

.lead-client-match {
  display: grid;
  gap: 0.5rem;
  margin: 0.8rem 0;
  padding: 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--surface-soft);
}

.lead-client-match header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.lead-client-match h3 {
  margin: 0;
  font-size: 0.95rem;
}

.lead-client-match header span,
.lead-client-match small,
.lead-client-match article span {
  color: var(--muted);
}

.lead-client-match article {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 0.35rem 0.8rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.lead-client-match article div {
  display: grid;
  gap: 0.15rem;
}

.lead-client-match article a {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.38rem 0.55rem;
  color: var(--ink);
  font-weight: 850;
}

.lead-client-match article small {
  grid-column: 1 / -1;
}

.module-table--automation header,
.module-table--automation a,
.module-table--automation .module-table-row {
  grid-template-columns: minmax(160px, 1.1fr) 120px 90px 130px 140px 60px minmax(130px, 0.8fr) minmax(170px, 1fr) 150px;
}

.automation-run-history {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.8rem 0.7rem 0.8rem;
}

.automation-run-history summary {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 0.78rem;
  font-weight: 850;
  gap: 0.45rem;
  justify-content: flex-start;
  list-style: none;
}

.automation-run-history summary::-webkit-details-marker {
  display: none;
}

.automation-run-history summary::before {
  color: var(--brand);
  content: "+";
  font-weight: 900;
}

.automation-run-history[open] summary::before {
  content: "-";
}

.automation-run-history summary strong {
  align-items: center;
  background: #e0f2fe;
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-size: 0.62rem;
  height: 16px;
  justify-content: center;
  min-width: 16px;
  padding: 0 0.25rem;
}

.automation-run-history ul {
  display: grid;
  gap: 0.35rem;
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
}

.automation-run-history li {
  align-items: center;
  background: var(--panel-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 135px minmax(180px, 0.8fr) minmax(260px, 1fr);
  min-width: 0;
  padding: 0.42rem 0.55rem;
}

.automation-run-history span,
.automation-run-history small {
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-run-history b {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-run-history p {
  color: var(--muted);
  margin: 0.5rem 0 0 0;
}

.module-table--admin header,
.module-table--admin a {
  grid-template-columns: minmax(150px, 0.7fr) minmax(260px, 1.5fr) 110px 110px;
}

.module-table--team header,
.module-table--team a {
  grid-template-columns: minmax(150px, 1fr) 100px 120px 140px 110px minmax(180px, 1fr);
}

.team-row--absence {
  box-shadow: inset 3px 0 0 #fb7185;
  background: #fff7f8 !important;
}

.team-control-pane {
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.team-add-absence {
  justify-self: stretch;
}

.team-side-section {
  display: grid;
  gap: 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line-soft);
}

.team-side-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.team-side-section h3 {
  margin: 0;
  font-size: 0.9rem;
}

.team-side-section header span {
  color: var(--brand-dark);
  font-weight: 900;
}

.absence-wizard {
  gap: 1rem;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.wizard-steps button {
  justify-content: flex-start;
  min-height: 40px;
  border-color: var(--line-soft);
  background: #f8fafc;
  text-align: left;
}

.wizard-steps button.is-active {
  border-color: #0ea5a8;
  background: #e6fffb;
  color: var(--brand-dark);
}

.wizard-panel {
  min-height: 250px;
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 0.9rem;
}

.wizard-note {
  margin-top: 0.75rem;
  border-left: 3px solid var(--brand);
  background: #eef9fc;
  padding: 0.65rem 0.75rem;
  color: var(--brand-dark);
  font-weight: 850;
}

.wizard-collision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.wizard-collision-grid article {
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.wizard-collision-list {
  display: grid;
  gap: 0.45rem;
}

.wizard-collision-list div,
.wizard-collision-list em {
  display: grid;
  gap: 0.1rem;
  border: 1px solid var(--line-soft);
  background: #f8fafc;
  padding: 0.6rem;
  font-style: normal;
}

.wizard-collision-list small {
  color: var(--muted);
}

.absence-wizard footer {
  align-items: center;
}

.module-table--prompts header,
.module-table--prompts .module-table-row {
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) minmax(190px, 1fr) minmax(180px, 0.95fr) minmax(110px, 0.55fr) minmax(95px, 0.45fr) minmax(80px, 0.35fr) minmax(90px, 0.45fr);
  min-width: 1120px;
}

.module-table--prompts code {
  color: #db2777;
  font-size: 0.78rem;
}

.module-table--prompts mark {
  width: fit-content;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 0 0.5rem;
  background: #eef2f7;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.model-pill--primary {
  background: #e0f2fe;
  color: #0369a1;
}

.model-pill--fallback {
  background: #eef2f7;
  color: #64748b;
}

.module-table--documents header,
.module-table--documents .module-table-row {
  grid-template-columns:
    44px
    minmax(260px, 1.35fr)
    minmax(130px, 0.6fr)
    minmax(250px, 1.15fr)
    minmax(180px, 0.82fr)
    minmax(190px, 0.82fr)
    minmax(118px, 0.5fr)
    minmax(90px, 0.42fr)
    minmax(110px, 0.35fr);
  min-width: 1360px;
}

.module-table--documents .module-table-row > span,
.module-table--documents .module-table-row > strong {
  white-space: normal;
}

.module-table--documents header span:first-child {
  text-align: center;
}

.module-table--documents .document-type-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #bfe3f1;
  border-radius: 4px;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.document-matter-link {
  display: grid;
  gap: 0.12rem;
}

.document-matter-link a {
  display: grid;
  gap: 0.08rem;
  color: var(--ink);
}

.document-matter-link a:hover strong,
.document-matter-link a:focus strong {
  color: var(--brand);
}

.document-matter-link em {
  color: var(--muted);
  font-style: normal;
  font-weight: 650;
}

.document-matter-link small {
  color: var(--muted);
}

.module-table-row .document-matter-link strong,
.module-table-row .document-matter-link em,
.module-table-row .document-matter-link small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.document-workspace {
  gap: 0.75rem;
}

.document-legaldesk-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.4rem;
  border-bottom: 1px solid var(--line);
  padding: 0 0 0.75rem;
}

.document-legaldesk-toolbar__main {
  display: grid;
  gap: 0.75rem;
  width: min(720px, 100%);
}

.document-legaldesk-toolbar__filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.document-searchbox {
  width: min(280px, 34vw);
}

.legaldesk-add-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  padding: 0.25rem 0;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.legaldesk-add-link span {
  color: var(--brand);
  font-size: 1.55rem;
  font-weight: 300;
  line-height: 1;
}

.legaldesk-add-link:hover,
.legaldesk-add-link:focus {
  color: var(--brand);
}

.legaldesk-segmented {
  flex-wrap: nowrap;
  gap: 0;
  border: 1px solid #dbe7ef;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.legaldesk-segmented button {
  border: 0;
  border-radius: 0;
  min-height: 30px;
  padding: 0.35rem 1rem;
}

.legaldesk-segmented button + button {
  border-left: 1px solid #dbe7ef;
}

.document-legaldesk-toolbar__tools {
  justify-content: end;
}

.document-legaldesk-toolbar__tools button,
.document-tool-button {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    min-height: 34px;
    padding: 0.5rem 0.65rem;
    font: inherit;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
}

.document-legaldesk-toolbar__tools button:hover,
.document-legaldesk-toolbar__tools button:focus,
.document-tool-button:hover,
.document-tool-button:focus {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.document-tool-button--primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.document-tool-button--primary:hover,
.document-tool-button--primary:focus {
  background: var(--brand-dark);
  color: #fff;
}

.document-group-hint {
  background: #eef7fc;
  margin-top: -0.1rem;
}

.module-table--documents .module-table-row {
  cursor: pointer;
}

.module-table--documents .module-table-row:hover {
  background: #f7fbfe;
}

.module-table--documents .module-table-row a {
  display: inline;
  border: 0;
  padding: 0;
  color: var(--brand-dark);
  font-weight: 800;
}

.document-location {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.document-location::before {
  content: "";
  width: 15px;
  height: 10px;
  border-radius: 2px 2px 1px 1px;
  background: #f6c84c;
  box-shadow: inset 0 3px 0 #f8d97a;
}

.document-status-cell {
  align-self: center;
}

.document-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    width: 100%;
}

.module-table--documents .module-table-row > span:last-child {
    justify-self: end;
    min-width: 0;
}

.document-row-actions .document-more-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    min-height: 30px;
    border: 1px solid #cfe1ec;
    border-radius: 4px;
    background: #fff;
    color: var(--brand-dark);
    padding: 0 0.65rem;
    font: inherit;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.document-row-actions .document-more-button:hover,
.document-row-actions .document-more-button:focus {
  border-color: var(--brand);
  background: #eef8fc;
}
@media (max-width: 1180px) {
  .document-legaldesk-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .document-legaldesk-toolbar__main {
    width: 100%;
  }

  .document-legaldesk-toolbar__filters,
  .document-legaldesk-toolbar__tools {
    flex-wrap: wrap;
  }

  .document-searchbox {
    width: min(100%, 320px);
  }

  .document-legaldesk-toolbar__tools {
    justify-content: start;
  }
}

.document-list-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-height: 36px;
  padding: 0 0.25rem;
}

.document-list-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.document-command-strip {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) repeat(3, minmax(180px, 0.7fr));
  gap: 0.75rem;
}

.document-command-strip article {
  display: grid;
  gap: 0.22rem;
  padding: 0.75rem 0.85rem;
}

.document-command-strip p,
.document-bottom-grid header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-command-strip strong {
  color: var(--ink);
  font-size: 1.25rem;
}

.document-command-strip span,
.document-bottom-grid header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.document-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 0.75rem;
}

.document-bottom-grid--collapsed {
  grid-template-columns: 1fr;
}

.document-bottom-grid > article {
  padding: 0.85rem;
}

.document-bottom-grid details {
  padding: 0;
}

.document-bottom-grid summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 46px;
  padding: 0 0.85rem;
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 900;
}

.document-bottom-grid summary::-webkit-details-marker {
  display: none;
}

.document-bottom-grid summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 0.35rem;
  border: 1px solid #cfe1ed;
  border-radius: 999px;
  color: var(--muted);
}

.document-bottom-grid details[open] summary::before {
  content: "-";
}

.document-bottom-grid details .compact-register {
  padding: 0 0.85rem 0.85rem;
}

.document-bottom-grid header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.65rem;
}

.document-bottom-grid h2 {
  margin: 0.2rem 0 0;
}

.document-runs-panel {
  grid-column: 1 / -1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 0.65rem;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.status-pill--document {
  background: #eef8fc;
  color: var(--brand-dark);
}

.row-actions--compact {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.row-actions--compact a,
.row-actions--compact button,
.row-actions--inline a,
.row-actions--inline button {
  min-height: 28px;
}

.row-actions--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.document-action-modal {
  max-width: 760px;
}

.document-action-modal header span {
  color: var(--muted);
  font-size: 0.84rem;
}

.document-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.document-action-grid__wide {
  grid-column: 1 / -1;
}

.document-action-grid section {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0.75rem;
  background: #fff;
}

.document-action-grid h3 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
}

.document-action-grid p,
.document-action-grid small {
  overflow-wrap: anywhere;
}

.document-detail-page {
  display: grid;
  gap: 0.75rem;
}

.document-tab-panels {
  display: grid;
  gap: 0.75rem;
}

.document-tab-panels [data-tab-panel] {
  display: none !important;
}

.document-tab-panels [data-tab-panel].is-active {
  display: grid !important;
}


.document-profile-card,
.document-preview-card,
.document-context-card {
  padding: 0.85rem;
}

.document-profile-card > p,
.document-preview-card header p,
.document-context-card header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-profile-card h2,
.document-preview-card h2,
.document-context-card h2 {
  margin: 0.2rem 0 0;
}

.document-profile-card dl {
  display: grid;
  gap: 0;
  margin: 0.75rem 0 0;
}

.document-profile-card dl div {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.document-profile-card dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.document-profile-card dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}



.document-preview-card header,
.document-context-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.65rem;
}

.document-preview-card iframe {
  width: 100%;
  min-height: 56vh;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.document-tab-panels [data-tab-panel="document-preview"] {
  min-height: calc(100vh - 280px);
}

.document-tab-panels [data-tab-panel="document-preview"] iframe {
  min-height: calc(100vh - 360px);
}

.document-context-card {
  display: grid;
  gap: 0.45rem;
}
.document-register-table {
  min-width: 0;
}

.document-register-table > header,
.document-register-table .module-table-row {
  grid-template-columns: minmax(220px, 0.85fr) minmax(320px, 1.35fr) minmax(180px, 0.8fr);
}

.document-register-table .row-actions {
  justify-content: flex-start;
}

.document-search-preview {
  display: block;
  margin-top: 0.18rem;
  max-width: 46rem;
  color: var(--muted);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-review-card {
  grid-column: auto;
}

.review-panel {
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.review-panel__main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.review-panel__main > div,
.review-panel__notes {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface);
}

.review-panel p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-panel span,
.review-panel small {
  color: var(--muted);
}

.review-panel__notes small {
  color: #92400e;
}

.limited-trust-review {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.6rem;
  border: 1px solid rgba(14, 165, 164, 0.35);
  border-radius: 5px;
  background: #ecfeff;
}

.limited-trust-review > div {
  display: grid;
  gap: 0.25rem;
}

.limited-trust-review label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.limited-trust-review p {
  align-self: center;
  color: #0f766e;
  font-size: 0.78rem;
  letter-spacing: 0;
  line-height: 1.5;
  text-transform: none;
}

.review-version-preview {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface);
}

.review-version-preview header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.review-version-preview iframe {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.review-panel__actions {
  justify-content: flex-end;
}

.review-decision-form {
  flex: 1 1 100%;
  display: grid;
  gap: 0.45rem;
  width: 100%;
  padding: 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--surface);
}

.review-decision-form__checks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.review-decision-form__checks label {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  border: 1px solid #b7dcea;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: #eef9fc;
  color: var(--brand-dark);
  font-style: normal;
  font-size: 0.76rem;
  font-weight: 850;
}

.row-actions--compact {
  justify-content: flex-end;
}

.row-actions--compact button {
  min-height: 28px;
  border-color: #b7dcea;
  background: #fff;
  color: var(--brand-dark);
}

.correspondence-detail-modal header span {
  color: var(--muted);
  font-size: 0.84rem;
}

.correspondence-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.correspondence-modal-actions a {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.38rem 0.55rem;
  color: var(--brand-dark);
  font-weight: 850;
}

.review-decision-form__comment {
  display: grid;
  gap: 0.2rem;
}

.review-decision-form__comment span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-decision-form__comment textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
}

.review-decision-form__buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.row-actions .inline-form {
  margin: 0;
}

.row-actions a,
.row-actions button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0.28rem 0.45rem;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.row-actions .primary-action {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.row-actions .danger-action {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff7f7;
}

.confirmation-upload input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.confirmation-upload label span {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0.28rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.status-chip {
  border-radius: 4px;
  padding: 0.2rem 0.42rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-chip--low {
  background: #ecfdf5;
  color: #047857;
}

.status-chip--medium {
  background: #fffbeb;
  color: #b45309;
}

.status-chip--high {
  background: #fff1f2;
  color: #be123c;
}

.compact-stack {
  display: grid;
  gap: 0.25rem;
  margin: 0.75rem 0;
  padding: 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--panel-muted);
  font-size: 0.78rem;
}

.compact-stack strong {
  color: var(--ink);
}

.compact-stack span {
  color: var(--muted);
}

.compact-register {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.compact-register div {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 0.55rem;
  background: #f8fafc;
}

.compact-register dt {
  color: var(--text);
  font-weight: 800;
}

.compact-register dd {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.reroute-preview {
  margin-top: 0.45rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
}

.reroute-preview summary {
  cursor: pointer;
  padding: 0.42rem 0.5rem;
  color: var(--text);
  font-weight: 800;
}

.reroute-preview ul {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0 0.5rem 0.5rem;
  list-style: none;
}

.reroute-preview li {
  display: grid;
  gap: 0.08rem;
  padding: 0.42rem;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #f8fafc;
}

.reroute-preview li strong,
.reroute-preview li span,
.reroute-preview li small,
.reroute-preview__empty {
  display: block;
}

.reroute-preview li strong {
  color: var(--text);
}

.reroute-preview li span,
.reroute-preview li small,
.reroute-preview__empty {
  color: var(--muted);
}

.reroute-preview__empty {
  padding: 0 0.5rem 0.5rem;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.35fr) minmax(180px, 0.45fr);
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.history-filters label {
  display: grid;
  gap: 0.24rem;
}

.history-filters span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.history-filters input,
.history-filters select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.48rem 0.55rem;
  background: #fff;
  color: var(--text);
}

.scoring-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.scoring-presets button {
  display: grid;
  gap: 0.2rem;
  min-height: 74px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  padding: 0.62rem;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 850;
}

.scoring-presets button:hover,
.scoring-presets button.is-selected {
  background: #f8fbfd;
  border-color: var(--brand);
}

.scoring-presets small {
  color: var(--muted);
  font-weight: 600;
}

.scoring-history-list {
  display: grid;
  gap: 0.5rem;
}

.scoring-history-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(120px, 0.35fr) minmax(240px, 1fr);
  gap: 0.35rem 0.75rem;
  align-items: start;
  padding: 0.6rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
}

.scoring-history-row strong {
  color: var(--text);
}

.scoring-history-row span {
  color: var(--brand-dark);
  font-weight: 800;
}

.scoring-history-row small {
  color: var(--muted);
}

.scoring-history-row em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.scoring-history-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  color: var(--muted);
  background: #fff;
}

.detail-pane {
  min-width: 0;
  padding: 0.85rem;
}

.detail-pane p,
.agenda-panel p,
.modal-card p {
  margin: 0 0 0.25rem;
  color: var(--brand-dark);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.detail-pane h2,
.modal-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.detail-pane dl {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.8rem;
}

.detail-pane dl div {
  display: grid;
  gap: 0.12rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line-soft);
}

.detail-pane dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.detail-pane dd {
  margin: 0;
}

.tabs,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.tabs button,
.button-row button,
.modal-card button {
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.modal-card button.primary-action,
.modal-card footer button.primary-action,
.modal-card .form-actions button.primary-action {
  border-color: rgba(14, 165, 196, 0.34);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(14, 165, 196, 0.14);
}

.modal-card button.danger-action,
.modal-card .matter-modal-danger-form button.danger-action {
  border-color: rgba(220, 38, 38, 0.32);
  background: #ef4444;
  color: #fff;
}

.modal-card button.secondary-action,
.modal-card a.secondary-action,
.modal-card footer a.secondary-action,
.modal-card .form-actions a.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
  text-decoration: none;
}

.tabs button {
  padding: 0 0.48rem;
  font-size: 0.78rem;
}

.tabs button.is-active {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: #eef9fc;
}

.risk {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 0 0.45rem;
  background: #e2e8f0;
  color: #334155;
}

.risk-wysoki {
  background: #fee2e2;
  color: #991b1b;
}

.risk-sredni {
  background: #fef3c7;
  color: #92400e;
}

.risk-niski {
  background: #dcfce7;
  color: #166534;
}

.calendar-workspace {
  display: grid;
  gap: 0.75rem;
}

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.calendar-period-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.calendar-period-nav button {
  width: 30px;
  min-height: 29px;
  border: 1px solid #b7dcea;
  border-radius: 4px;
  background: #eef9fc;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.calendar-period-nav strong {
  min-width: 7.5rem;
  color: var(--ink);
  text-align: center;
}

.calendar-period-nav strong.is-pulsing {
  color: var(--brand-dark);
}

.registry-tabs--compact {
  flex: 0 0 auto;
}

.calendar-type-tabs button {
  border-color: #b7dcea;
  background: #eef9fc;
}

.calendar-type-tabs button[data-calendar-filter="hearing"],
.calendar-event--hearing {
  border-color: #0ea5a8 !important;
  background: #e6fffb !important;
}

.calendar-type-tabs button[data-calendar-filter="deadline"],
.calendar-event--deadline {
  border-color: #38bdf8 !important;
  background: #eef9ff !important;
}

.calendar-type-tabs button[data-calendar-filter="consultation"],
.calendar-event--consultation {
  border-color: #14b8a6 !important;
  background: #ecfdf5 !important;
}

.calendar-type-tabs button[data-calendar-filter="internal"],
.calendar-event--internal {
  border-color: #67e8f9 !important;
  background: #ecfeff !important;
}

.calendar-type-tabs button[data-calendar-filter="absence"],
.calendar-event--absence,
.calendar-event--hearing.has-warning,
.calendar-event--deadline.has-warning,
.calendar-event--consultation.has-warning,
.calendar-event--internal.has-warning,
.timeline-row.has-warning {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
}

.calendar-type-tabs button[data-calendar-filter="unavailable"],
.calendar-absence-band {
  border-color: #fb7185 !important;
  background: #ffe4e6 !important;
  color: #881337;
}

.calendar-absence-band {
  display: grid;
  gap: 0.08rem;
  margin-top: 0.35rem;
  border-left: 3px solid #fb7185;
  border-radius: 4px;
  padding: 0.32rem 0.42rem;
  font-size: 0.74rem;
  font-weight: 850;
}

.calendar-absence-band small {
  color: #9f1239;
  font-weight: 750;
}

.calendar-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 0.75rem;
}

.calendar-summary-strip article {
  display: grid;
  gap: 0.22rem;
  padding: 0.75rem 0.85rem;
}

.calendar-summary-strip p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calendar-summary-strip strong {
  color: var(--ink);
  font-size: 1.25rem;
}

.calendar-summary-strip span {
  color: var(--muted);
  font-size: 0.82rem;
}

.calendar-alert-strip {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border-color: #facc15;
  background: #fffbeb;
}

.calendar-alert-strip header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}

.calendar-alert-strip p {
  margin: 0;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calendar-alert-strip h2 {
  margin: 0.2rem 0 0;
}

.calendar-alert-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.5rem;
}

.calendar-alert-list article {
  display: grid;
  gap: 0.14rem;
  padding: 0.6rem;
  border: 1px solid #fde68a;
  border-radius: 4px;
  background: #fff;
}

.calendar-view-header {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
}

.calendar-view-header p,
.calendar-view-header h2 {
  margin: 0;
}

.calendar-view-header p {
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calendar-view-header h2 {
  font-size: 1rem;
}

.calendar-view-header span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.calendar-day-view,
.calendar-week-view {
  min-width: 0;
}

.calendar-time-grid {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  display: grid;
}

.calendar-time-slot {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 74px minmax(0, 1fr);
  min-height: 58px;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.calendar-time-slot > strong {
  color: var(--muted);
  font-size: 0.76rem;
}

.calendar-time-slot > div {
  display: grid;
  gap: 0.35rem;
}

.calendar-week-grid {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  overflow-x: auto;
}

.calendar-week-column {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 230px;
  padding: 0.55rem;
  border-right: 1px solid var(--line-soft);
  cursor: pointer;
}

.calendar-week-column.is-today {
  background: #eef9fc;
}

.calendar-week-column header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
}

.calendar-event-card {
  border-left: 3px solid var(--brand);
  background: #f8fbfd;
  display: grid;
  gap: 0.08rem;
  padding: 0.4rem;
  font-size: 0.76rem;
}

.calendar-event-card.has-warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.calendar-muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.calendar-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  min-width: 0;
  overflow: auto;
}

.calendar-board--wide {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.calendar-weekdays {
  display: contents;
}

.calendar-weekdays span {
  padding: 0.55rem;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 118px;
  padding: 0.5rem;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  cursor: pointer;
}

.calendar-day.is-today {
  background: #eef9fc;
}

.calendar-day.has-absence-impact {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.calendar-day strong {
  color: var(--muted);
  font-size: 0.8rem;
}

.calendar-day a,
.agenda-panel a {
  display: grid;
  gap: 0.08rem;
  margin-top: 0.4rem;
  padding: 0.35rem;
  border-left: 3px solid var(--brand);
  background: #f8fbfd;
  font-size: 0.76rem;
}

.calendar-day small,
.agenda-panel small {
  color: var(--muted);
}

.calendar-day a.has-warning,
.timeline-row.has-warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.warning-text {
  color: #92400e !important;
  font-weight: 800;
}

.agenda-panel {
  padding: 0.75rem;
}

.agenda-panel--wide {
  display: grid;
  gap: 0.45rem;
}

.agenda-panel--wide header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.agenda-add-button {
  white-space: nowrap;
}

.agenda-panel--wide h2 {
  margin: 0.2rem 0 0;
}

.calendar-matter-context {
  align-items: center;
  background: var(--panel-muted);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  display: grid;
  gap: 0.2rem 0.75rem;
  grid-template-columns: 90px minmax(180px, 1.1fr) minmax(220px, 1.3fr) minmax(220px, 1.2fr) auto;
  margin-top: 0.35rem;
  min-width: 0;
  padding: 0.5rem 0.65rem;
}

.calendar-matter-context span {
  color: var(--brand-dark);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.calendar-matter-context strong,
.calendar-matter-context small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-matter-context a {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  margin-top: 0;
  padding: 0.32rem 0.55rem;
  text-align: center;
}

.agenda-inline-form {
  display: inline-flex;
}

.agenda-select {
  min-height: 32px;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.32rem 1.75rem 0.32rem 0.5rem;
}

.agenda-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(20, 158, 190, 0.16);
  outline: none;
}

.activities-legaldesk {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  min-height: calc(100vh - 190px);
}

.activities-inbox,
.activities-register {
  min-width: 0;
  background: #fff;
}

.activities-inbox {
  align-self: start;
  padding: 0.85rem;
}

.activities-inbox h2 {
  margin: 0 0 0.85rem;
  color: #0072bc;
  font-size: 1rem;
  font-weight: 800;
}

.activity-inbox-card {
  position: relative;
  display: grid;
  gap: 0.42rem;
  min-height: 112px;
  margin-bottom: 0.65rem;
  padding: 0.75rem 0.75rem 0.65rem 0.95rem;
  border: 1px solid #dbe7f1;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.activity-inbox-card:hover,
.activity-inbox-card:focus-visible {
  border-color: #9bd4e7;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
  outline: none;
}

.activity-warning-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: #f59e0b;
}

.activity-inbox-card strong,
.activity-description strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.activity-inbox-card p,
.activities-empty,
.activity-description small {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.activity-inbox-card footer {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.74rem;
}

.avatar-chip {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 999px;
  background: #a3a7aa;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 850;
}

.activities-register {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  min-height: 640px;
  overflow: auto;
}

.activities-register-top {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  padding: 0 0 0.95rem;
}

.activities-register-actions {
  display: grid;
  gap: 0.7rem;
  width: min(100%, 560px);
}

.activity-add-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #0072bc;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.activity-add-link span {
  color: #0072bc;
  font-size: 1.7rem;
  line-height: 1;
}

.activity-search {
  width: 260px;
  min-height: 34px;
  border: 1px solid #d0d9e2;
  border-radius: 3px;
  padding: 0.45rem 0.65rem;
  background: #fff;
  color: var(--text);
}

.activity-period {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.activity-period select,
.activity-status-form select {
  min-height: 32px;
  border: 1px solid #d0d9e2;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 1.8rem 0.35rem 0.5rem;
}

.activity-filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.7rem;
}

.activity-filter-strip button {
  border: 1px solid #d7e3ee;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.34rem 0.65rem;
}

.activity-filter-strip button.is-active {
  border-color: #9ad7ea;
  background: #edf8fc;
  color: #006b91;
}

.activity-register-tools {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  padding: 0.15rem 0 0.65rem;
}

.activity-register-tools button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #98a2ad;
  cursor: pointer;
  font-size: 1.1rem;
}

.activity-group-hint {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  background: #eef7fc;
  color: var(--muted);
  font-size: 0.8rem;
}

.activity-group-hint strong {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #0072bc;
  color: #fff;
  font-size: 0.72rem;
}

.activity-grid {
  min-width: 1180px;
}

.activity-grid-header,
.activity-grid-row {
  display: grid;
  grid-template-columns: minmax(250px, 1.5fr) minmax(170px, 0.9fr) minmax(180px, 0.9fr) minmax(120px, 0.65fr) minmax(90px, 0.45fr) minmax(150px, 0.75fr) minmax(190px, 1fr) minmax(150px, 0.8fr);
  align-items: center;
}

.activity-grid-header {
  min-height: 48px;
  background: #eef7fc;
  color: #a0a7ad;
  font-size: 0.74rem;
  font-weight: 850;
}

.activity-grid-header span,
.activity-grid-row > span,
.activity-grid-row > a {
  min-width: 0;
  padding: 0.72rem 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-grid-header span {
  border-right: 1px solid #cfdde8;
}

.activity-grid-row {
  min-height: 54px;
  border-bottom: 1px solid #eef2f6;
  color: var(--text);
  font-size: 0.82rem;
}

.activity-grid-row:hover {
  background: #f9fcfe;
}

.activity-description {
  display: grid;
  gap: 0.14rem;
  color: var(--ink);
  text-decoration: none;
}

.activity-person {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
}

.activity-status-form {
  margin: 0;
}

.activities-total-bar {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  justify-content: flex-end;
  padding: 0.95rem 0.25rem 0;
  color: var(--ink);
}

.activities-total-bar span {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.activities-total-bar strong {
  font-size: 1.1rem;
}

.app-modal {
  width: min(940px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  padding: 0;
  border: 0;
  background: transparent;
}

.app-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.app-modal__panel {
  display: grid;
  overflow: hidden;
  border: 1px solid #d7e3ee;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.25);
}

.app-modal__panel > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.4rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.app-modal__panel > header p {
  margin: 0 0 0.2rem;
  color: var(--brand-dark);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.app-modal__panel > header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #d7e3ee;
  border-radius: 4px;
  background: #f8fbfd;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.activity-modal-form {
  display: grid;
  gap: 1rem;
  padding: 1.1rem 1.4rem 1.2rem;
}

.activity-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.activity-form-grid label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.activity-form-grid input,
.activity-form-grid select {
  min-height: 38px;
  border: 1px solid #d0d9e2;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.45rem 0.65rem;
}

.activity-form-wide {
  grid-column: 1 / -1;
}

.activity-modal-form footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

@media (max-width: 960px) {
  .activities-legaldesk {
    grid-template-columns: 1fr;
  }

  .activities-register-top,
  .activities-total-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .activity-search {
    width: 100%;
  }

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

.calendar-legaldesk {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  min-height: calc(100vh - 130px);
}

.calendar-legaldesk-sidebar {
  display: grid;
  align-content: start;
  gap: 1rem;
  min-width: 0;
}

.calendar-add-link button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: #0072bc;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.calendar-add-link span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #0072bc;
  font-size: 1.5rem;
  line-height: 1;
}

.calendar-day-plan {
  min-height: 310px;
  padding: 1.15rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
}

.calendar-day-plan h2,
.calendar-source-panel summary {
  margin: 0;
  color: #0072bc;
  font-size: 0.98rem;
  font-weight: 800;
}

.calendar-day-plan article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.5rem;
  margin-top: 1.15rem;
  color: #2f2f2f;
  font-size: 0.76rem;
}

.calendar-day-plan article strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day-plan article span {
  color: #0072bc;
  font-size: 0.7rem;
}

.calendar-day-plan article small,
.calendar-day-plan p {
  grid-column: 1 / -1;
  color: #9ca3af;
}

.calendar-source-panel {
  display: grid;
  gap: 0.75rem;
  max-height: 470px;
  overflow-y: auto;
  padding: 0.5rem 0.4rem 1rem 0;
}

.calendar-source-panel details {
  display: grid;
  gap: 0.5rem;
}

.calendar-source-panel summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  color: #3f3f46;
  cursor: pointer;
}

/* 2026-05 layout hardening and premium unification */
.matter-workspace {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

.matter-layout {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 280px);
}

.matter-content {
  min-width: 0;
}

.task-workspace,
.calendar-legaldesk,
.report-grid,
.case-registry,
.lead-workspace {
  border: 1px solid #e4edf7;
  border-radius: 20px;
  background: #fff;
  padding: 0.9rem;
}

.task-toolbar,
.registry-toolbar,
.calendar-legaldesk-header,
.calendar-legaldesk-tools {
  border: 1px solid #e7eef8;
  border-radius: 16px;
  background: #f9fbff;
  padding: 0.65rem 0.75rem;
}

.kanban-column,
.workspace-section,
.module-table,
.calendar-day-plan,
.calendar-source-panel,
.calendar-legaldesk-board,
.calendar-legaldesk-list {
  border-radius: 16px;
}

.module-table--clients > a,
.workload-row,
.timeline-row {
  border-radius: 12px;
}

.module-table--clients > a {
  margin: 0.32rem 0.42rem;
  border: 1px solid #e6edf7;
  background: #fff;
}

.module-table--clients > a:hover {
  border-color: #b4d6e8;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

@media (max-width: 1250px) {
  .matter-layout {
    grid-template-columns: 1fr;
  }
}

.calendar-source-panel summary::before {
  content: "^";
  color: #9ca3af;
  font-weight: 400;
}

.calendar-source-panel details:not([open]) summary::before {
  content: ">";
}

.calendar-source-panel summary small {
  color: #6b7280;
  font-size: 0.65rem;
  font-weight: 500;
}

.calendar-source-panel summary button,
.calendar-source-option button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #a1a1aa;
  font: inherit;
  font-weight: 600;
}

.calendar-source-option {
  display: grid;
  grid-template-columns: 18px 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px;
  padding-left: 1.2rem;
  color: #3f3f46;
  font-size: 0.8rem;
}

.calendar-source-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.source-check {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 3px;
  background: #fff;
}

.calendar-source-option input:checked + .source-check {
  background: linear-gradient(135deg, transparent 55%, currentColor 56%);
  box-shadow: inset 0 0 0 3px #fff;
}

.source-check--blue {
  color: #73b8e5;
  border-color: #73b8e5;
}

.source-check--red {
  color: #a02c2c;
  border-color: #a02c2c;
}

.source-check--pink {
  color: #f5a6b8;
  border-color: #f5a6b8;
}

.source-check--gray {
  color: #a3a3a3;
  border-color: #a3a3a3;
}

.source-avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #a3a3a3;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
}

.calendar-source-option strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.calendar-legaldesk-main {
  position: relative;
  min-width: 0;
}

.calendar-legaldesk-header,
.calendar-legaldesk-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.calendar-legaldesk-header {
  margin-bottom: 1.25rem;
}

.calendar-titlebar {
  display: flex;
  align-items: center;
  gap: 1.05rem;
  min-width: 0;
}

.calendar-titlebar h1 {
  margin: 0 2rem 0 0;
  color: #2b2b2b;
  font-size: 1.45rem;
  font-weight: 700;
}

.calendar-titlebar strong {
  color: #1f1f1f;
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-today-link,
.calendar-caret,
.calendar-nav-button {
  border: 0;
  background: transparent;
  color: #0072bc;
  font: inherit;
  cursor: pointer;
}

.calendar-nav-button {
  width: 28px;
  height: 28px;
  color: #9ca3af;
  font-size: 1.5rem;
  line-height: 1;
}

.calendar-caret {
  color: #9ca3af;
}

.calendar-view-label {
  color: #9ca3af;
  font-size: 0.82rem;
}

.calendar-view-label strong {
  color: #3f3f46;
}

.calendar-legaldesk-tools {
  margin-bottom: 0.9rem;
}

.calendar-search {
  position: relative;
  flex: 0 0 min(280px, 32vw);
}

.calendar-search input {
  width: 100%;
  min-height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  background: #fff;
  color: #1f2937;
  padding: 0 0.75rem;
  font: inherit;
}

.calendar-type-switches,
.calendar-view-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.calendar-type-switches {
  flex: 1 1 auto;
  justify-content: flex-start;
  overflow-x: auto;
}

.calendar-type-switches button,
.calendar-view-buttons button {
  min-height: 28px;
  border: 1px solid #d6e2ec;
  border-radius: 4px;
  background: #fff;
  color: #64748b;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.calendar-type-switches button {
  padding: 0 0.65rem;
}

.calendar-type-switches button span {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: #e8f7ff;
  color: #4f46e5;
}

.calendar-type-switches button.is-active,
.calendar-view-buttons button.is-active {
  border-color: #7cc8e6;
  background: #eef9fc;
  color: #00688f;
}

.calendar-legaldesk-board {
  position: relative;
  border: 1px solid #d1d5db;
  background: #fff;
}

.calendar-legaldesk-weekdays,
.calendar-legaldesk-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(138px, 1fr));
}

.calendar-legaldesk-weekdays span {
  min-height: 26px;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  color: #9ca3af;
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
  padding-top: 0.38rem;
}

.calendar-legaldesk-day {
  position: relative;
  min-height: 122px;
  padding: 0.45rem 0.45rem 0.35rem;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  background: #fff;
  cursor: default;
}

.calendar-legaldesk-day.is-muted {
  background: #f7f7f7;
}

.calendar-legaldesk-day.is-muted > strong {
  color: #a3a3a3;
}

.calendar-legaldesk-day.is-today {
  box-shadow: inset 0 3px 0 #0072bc;
}

.calendar-legaldesk-day.is-today > strong {
  color: #0072bc;
}

.calendar-legaldesk-day > strong {
  display: block;
  margin-bottom: 0.45rem;
  color: #2b2b2b;
  font-size: 0.74rem;
  font-weight: 800;
  text-align: right;
}

.calendar-legaldesk-event {
  display: grid;
  grid-template-columns: 10px auto minmax(0, 1fr);
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  min-height: 20px;
  margin-bottom: 0.12rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #2b2b2b;
  font: inherit;
  font-size: 0.66rem;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
}

.calendar-legaldesk-event.is-active {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(35, 158, 188, 0.14);
}

.calendar-legaldesk-event strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.calendar-legaldesk-event span:not(.event-dot) {
  color: #2b2b2b;
  font-size: 0.64rem;
}

.event-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #9d2d2d;
}

.calendar-legaldesk-event--hearing .event-dot {
  background: #9d2d2d;
}

.calendar-legaldesk-event--deadline .event-dot {
  background: #0e7490;
}

.calendar-legaldesk-event--consultation .event-dot {
  background: #0284c7;
}

.calendar-legaldesk-event--internal .event-dot {
  background: #64748b;
}

.calendar-legaldesk-event--absence {
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0.15rem 0 0.35rem;
  padding: 0.18rem 0.35rem;
  border-radius: 4px;
  background: #fde8e8;
}

.calendar-legaldesk-event--absence .event-dot {
  display: none;
}

.calendar-legaldesk-list {
  border: 1px solid #d1d5db;
  background: #fff;
}

.calendar-legaldesk-list > header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.calendar-legaldesk-list h2 {
  margin: 0;
  font-size: 1rem;
}

.calendar-list-day {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 1rem;
  min-height: 54px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eef2f7;
}

.calendar-list-day > strong {
  color: #64748b;
  font-size: 0.82rem;
}

.calendar-list-day > div {
  display: grid;
  gap: 0.35rem;
}

.calendar-event-popover {
  position: absolute;
  z-index: 8;
  top: 33%;
  left: 36%;
  width: min(430px, calc(100% - 2rem));
  border: 1px solid #e5e7eb;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 1rem 1.2rem;
}

.calendar-event-popover header {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.calendar-event-popover button {
  min-width: 28px;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  cursor: pointer;
}

.calendar-popover-play {
  border: 1px solid #dbeafe !important;
  color: #93c5fd !important;
  font-size: 0.68rem !important;
}

.calendar-event-popover h2 {
  margin: 1.2rem 0 1.5rem;
  color: #2b2b2b;
  font-size: 1rem;
}

.calendar-event-popover dl {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.calendar-event-popover dl div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
}

.calendar-event-popover dt {
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
}

.calendar-event-popover dd {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  min-width: 0;
}

.calendar-event-popover p {
  margin: 1.5rem -1.2rem 1rem;
  padding: 0.9rem 1.2rem;
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  color: #a1a1aa;
}

.calendar-event-popover small {
  color: #a1a1aa;
}

.calendar-popover-target {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 0 0 0.75rem;
  border: 1px solid #d5e0ea;
  border-radius: 3px;
  background: #fff;
  color: var(--brand-dark);
  padding: 0.25rem 0.65rem;
  font-size: 0.74rem;
  font-weight: 850;
  text-decoration: none;
}

.calendar-popover-target:hover {
  border-color: var(--brand);
  background: #eef9fc;
}

.calendar-empty-state {
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
}

@media (max-width: 1100px) {
  .calendar-legaldesk {
    grid-template-columns: 1fr;
  }

  .calendar-legaldesk-sidebar {
    grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.2fr);
  }

  .calendar-source-panel {
    max-height: 310px;
  }
}

@media (max-width: 1024px) {
  .calendar-legaldesk-sidebar,
  .calendar-legaldesk-header,
  .calendar-legaldesk-tools {
    display: grid;
  }

  .calendar-titlebar {
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .calendar-titlebar h1 {
    width: 100%;
    margin-right: 0;
  }

  .calendar-search {
    flex-basis: auto;
  }

  .calendar-legaldesk-weekdays,
  .calendar-legaldesk-grid {
    grid-template-columns: repeat(7, minmax(116px, 1fr));
  }

  .calendar-legaldesk-board {
    overflow-x: auto;
  }
}

.task-workspace {
  display: grid;
  gap: 0.55rem;
}

.task-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.task-search-group {
  position: relative;
  width: min(280px, 35vw);
}

.task-search-group input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  padding: 0 2rem 0 0.55rem;
  font: inherit;
}

.task-view-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.task-view-actions button {
  position: relative;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
}

.task-view-actions button::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid #a7b0bb;
}

.task-view-actions button:first-of-type::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 7px;
  bottom: 7px;
  border-left: 2px solid #a7b0bb;
}

.task-view-actions button:last-of-type::before {
  border-left: 0;
  border-right: 0;
  height: 2px;
  top: 9px;
  box-shadow: 0 6px 0 #a7b0bb, 0 12px 0 #a7b0bb;
}

.task-view-actions button.is-active::before,
.task-view-actions button.is-active::after {
  border-color: var(--brand);
}

.task-mine-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 30px;
  padding: 0 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.task-mine-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--brand);
}

.task-sort-control {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 30px;
}

.task-sort-control span {
  color: var(--muted);
  font-size: 0.72rem;
}

.task-sort-control select {
  min-height: 30px;
  max-width: 132px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 290px));
  align-items: start;
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.kanban-column {
  display: flex;
  flex-direction: column;
  min-height: 68vh;
  border: 1px solid var(--line);
  background: #eff7fb;
}

.kanban-column header {
  display: flex;
  justify-content: space-between;
  padding: 0.68rem 0.75rem;
  border-bottom: 1px solid rgba(208, 220, 232, 0.8);
  color: var(--muted);
}

.kanban-column h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 850;
}

.kanban-move-form {
  display: none;
}

.kanban-dropzone {
  flex: 1;
  min-height: 60vh;
  padding: 0.34rem;
}

.kanban-column.is-drag-over {
  background: #eef8fb;
  box-shadow: inset 0 0 0 2px rgba(20, 158, 190, 0.22);
}

.task-card {
  display: grid;
  gap: 0.42rem;
  position: relative;
  min-height: 122px;
  margin: 0 0 0.52rem;
  padding: 0.68rem;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.12);
  cursor: grab;
}

.task-card.is-selected {
  border-color: #9ed8ef;
  box-shadow: 0 0 0 2px rgba(34, 150, 184, 0.14), 0 2px 7px rgba(15, 23, 42, 0.12);
}

.task-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.task-card:active {
  cursor: grabbing;
}

.task-card.is-dragging {
  opacity: 0.55;
  outline: 2px solid var(--brand);
}

.task-card__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px 12px;
  gap: 0.35rem;
  align-items: start;
}

.task-card__top strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.task-open-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid #bde7fb;
  border-radius: 999px;
}

.task-open-dot::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #8ecdec;
}

.task-menu-button {
  display: inline-grid;
  place-items: start center;
  width: 18px;
  min-height: 22px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.task-menu-dot {
  position: relative;
  width: 4px;
  height: 4px;
  margin: 0.35rem auto 0;
  border-radius: 999px;
  background: #b5bdc8;
  box-shadow: 0 5px 0 #b5bdc8, 0 10px 0 #b5bdc8;
}

.task-card span,
.task-card small {
  color: var(--muted);
}

.task-card > small {
  min-height: 2.8em;
  overflow: hidden;
  line-height: 1.4;
}

.task-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.task-owner-stack {
  display: inline-flex;
  align-items: center;
  min-width: 54px;
}

.task-owner-stack em + em {
  margin-left: -0.38rem;
}

.task-card em {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #a8adb3;
  color: #fff;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
}

.task-date {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.task-date.is-overdue {
  color: #b42318;
}

.task-date.is-overdue::before {
  border-color: #d92d20;
}

.task-date::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 0.3rem;
  border: 1.5px solid #aeb6c2;
  border-radius: 2px;
  vertical-align: -2px;
}

.task-card form:not(.kanban-move-form) {
  display: grid;
  place-items: center;
  margin: 0;
}

.task-card select,
.task-card button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
}

.task-card button {
  padding: 0 0.5rem;
  color: var(--brand-dark);
  font-weight: 800;
}

.task-card .task-menu-button {
  min-height: 22px;
  border: 0;
  background: transparent;
  padding: 0;
}

.task-card__delete {
  width: 24px;
  min-height: 24px;
  border-color: #f4c7c3;
  background: #fff5f5;
  color: #b42318;
  line-height: 1;
}

.task-context-menu {
  position: absolute;
  right: 0.55rem;
  top: 2.25rem;
  z-index: 8;
  display: grid;
  gap: 0.42rem;
  width: min(230px, calc(100% - 1rem));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
  padding: 0.55rem;
}

.task-context-menu[hidden] {
  display: none;
}

.task-context-menu a,
.task-context-menu button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--brand-dark);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
}

.task-context-menu form,
.task-context-menu label {
  display: grid;
  gap: 0.32rem;
  margin: 0;
}

.task-context-menu label span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.task-context-menu select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.76rem;
}

.task-context-menu .danger-action {
  background: #ef4444;
  color: #fff;
}

.split-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0.75rem;
}

.case-tabs,
.admin-tabs {
  position: sticky;
  top: 57px;
  z-index: 5;
  display: flex;
  gap: 0.28rem;
  overflow-x: auto;
  padding: 0.34rem 0;
  background: var(--bg);
}

.admin-tabs--menu-backed {
  display: none;
}

.case-tabs a,
.admin-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.28rem 0.5rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.case-tabs a:hover,
.case-tabs a:focus,
.case-tabs a.is-active,
.admin-tabs a:hover,
.admin-tabs a:focus,
.admin-tabs a.is-active {
  border-color: var(--brand);
  background: #eef9fc;
  color: var(--brand-dark);
}

.case-tabs strong,
.admin-tabs strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 0.26rem;
  background: #e0f2fe;
  color: var(--brand-dark);
  font-size: 0.62rem;
  line-height: 1;
}

.case-command {
  display: grid;
  grid-template-columns: 300px repeat(2, minmax(260px, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.matter-workspace {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

.matter-sidecard {
  position: sticky;
  top: 108px;
}

.matter-tab-panels {
  min-width: 0;
}

.matter-tab-panel {
  display: none;
}

.matter-tab-panel.is-active {
  display: block;
}

.admin-tab-panels {
  display: grid;
  gap: 0.75rem;
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.is-active {
  display: block;
}

.admin-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.1rem 0 0.75rem;
  padding: 0.35rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
}

.admin-subtabs a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.36rem 0.62rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
}

.admin-subtabs a:hover,
.admin-subtabs a:focus,
.admin-subtabs a.is-active {
  border-color: var(--brand);
  background: #eef9fc;
  color: var(--brand-dark);
}

.admin-subtab-panels {
  min-width: 0;
}

.admin-subtab-panel {
  display: none;
}

.admin-subtab-panel.is-active {
  display: grid;
  gap: 0.75rem;
}

.admin-subtab-panel > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  border: 0;
}

.admin-subtab-panel > header h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-subtab-panel > header p {
  margin: 0.18rem 0 0;
  color: var(--muted);
}

.client-detail-page {
  display: grid;
  gap: 0.75rem;
}

.user-settings-page {
  display: grid;
  gap: 0;
  min-height: calc(100vh - 52px);
  background: #f4f4f4;
}

.user-settings-title {
  background: #f4f4f4;
}

.user-settings-title h1 {
  margin: 0;
  font-size: 1.25rem;
}

.user-settings-shell {
  min-height: calc(100vh - 150px);
}

.user-settings-nav {
  background: #fff;
}

.user-settings-panel {
  align-content: start;
  background: #fff;
  padding: 1rem 1rem 5rem;
}

.user-settings-heading {
  display: grid;
  gap: 0.35rem;
  max-width: 940px;
  margin-bottom: 0.65rem;
}

.user-settings-heading p {
  margin: 0;
  color: #9aa1aa;
  font-weight: 850;
}

.user-settings-heading span {
  color: var(--muted);
}

.settings-table {
  display: grid;
  max-width: 860px;
  border-top: 1px solid var(--line-soft);
}

.settings-table header,
.settings-table label {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px 130px;
  gap: 1rem;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-table header {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 850;
}

.settings-table label {
  margin: 0;
  color: var(--text);
}

.settings-table input,
.scope-list input,
.provider-row input,
.settings-checkbox-line input {
  width: 20px;
  height: 20px;
  accent-color: #0877b8;
}

.settings-note {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  max-width: 980px;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.settings-note strong {
  font-size: 0.88rem;
}

.settings-note span {
  color: var(--muted);
}

.settings-note button,
.provider-button,
.settings-register-toolbar button,
.settings-register-table button,
.user-settings-actions button,
.user-settings-actions a {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--brand-dark);
  padding: 0 0.75rem;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.settings-note--quiet {
  align-items: start;
  display: grid;
}

.integration-account,
.settings-form-card,
.settings-register {
  display: grid;
  gap: 1rem;
  max-width: 980px;
}

.integration-account--compact {
  max-width: 760px;
}

.integration-callout {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 1fr) auto;
  gap: 1rem;
  align-items: center;
  max-width: 820px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.integration-callout strong {
  font-size: 0.82rem;
  color: var(--muted);
}

.integration-callout span {
  font-weight: 750;
}

.provider-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding-inline: 1rem;
  color: var(--text);
  box-shadow: var(--shadow);
}

.provider-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.provider-button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #fff;
  border-radius: 3px;
  background: var(--brand);
  font-weight: 900;
}

.provider-button--google span {
  background: #fff;
  color: #4285f4;
  font-size: 1.2rem;
}

.provider-button--microsoft span {
  background: linear-gradient(90deg, #f25022 0 50%, #7fba00 50% 100%);
}

.provider-row {
  display: grid;
  grid-template-columns: 24px 12px minmax(220px, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  max-width: 720px;
}

.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.provider-dot--rose {
  background: #f4a6b5;
}

.provider-row em {
  color: #a3aab3;
  font-style: normal;
  font-weight: 700;
}

.settings-link {
  color: var(--brand-dark);
  font-weight: 700;
}

.scope-list {
  display: grid;
  gap: 0.4rem;
}

.scope-list label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 750;
}

.settings-warning {
  margin: 0;
  color: #d97706;
  font-weight: 700;
}

.settings-metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
}

.settings-metadata-grid div {
  display: grid;
  gap: 0.35rem;
  min-height: 76px;
  padding: 0.75rem;
  border-right: 1px solid var(--line-soft);
}

.settings-metadata-grid div:last-child {
  border-right: 0;
}

.settings-metadata-grid strong {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.settings-metadata-grid span {
  font-weight: 750;
}

.settings-form-card {
  padding-top: 0.4rem;
}

.settings-checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 750;
}

.settings-register-toolbar {
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.settings-register-table {
  display: grid;
  border-top: 1px solid var(--line-soft);
}

.settings-register-table header,
.settings-register-table div {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 0.65fr) minmax(260px, 1.1fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-register-table--prints header,
.settings-register-table--prints div {
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 0.65fr) minmax(120px, 0.45fr) auto;
}

.settings-register-table header {
  background: #eef6fb;
  color: #9aa1aa;
  font-size: 0.78rem;
  font-weight: 850;
}

.settings-register-table span,
.settings-register-table strong {
  padding-left: 0.75rem;
}

.user-settings-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin: 2rem -1rem -5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--line);
  background: #fff;
}

.user-settings-actions .primary-action {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.client-legaldesk-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 0;
  align-items: start;
  min-height: calc(100vh - 170px);
  padding-bottom: 74px;
}

.client-legaldesk-main {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.client-legaldesk-form {
  display: grid;
  gap: 0;
  min-width: 0;
}

.client-form-title {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 58px;
  padding: 0 1rem;
}

.client-form-title a,
.client-back-link {
  color: var(--brand-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

.client-form-title h2 {
  margin: 0;
  font-size: 1.15rem;
}

.client-form-title button {
  justify-self: end;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-dark);
  font-weight: 800;
}

.client-form-section {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-width: 0;
  background: var(--surface);
}

.client-form-section--single {
  grid-template-columns: minmax(0, 1fr);
}

.client-form-section + .client-form-section {
  border-top: 1px solid var(--line-soft);
}

.client-form-section > aside {
  display: grid;
  align-content: start;
  gap: 0.08rem;
  padding: 0.9rem 0;
  border-right: 1px solid var(--line-soft);
}

.client-form-section--single > aside {
  display: none;
}

.client-form-section > aside h3 {
  margin: 0;
  padding: 0 1rem 0.45rem;
  font-size: 0.92rem;
}

.client-form-section > aside a,
.client-form-section > aside span {
  display: block;
  padding: 0.42rem 1rem;
  border-left: 2px solid transparent;
  color: var(--ink);
  font-size: 0.86rem;
}

.client-form-section > aside span {
  color: var(--muted);
  line-height: 1.45;
}

.client-form-section > aside a.is-active,
.client-form-section > aside a:hover,
.client-form-section > aside a:focus {
  border-left-color: var(--brand);
  background: #eef7fc;
  color: var(--brand-dark);
}

.client-form-panel {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
  padding: 1rem;
}

.client-form-panel--tinted {
  background: #f0f8fc;
}

.client-form-panel > p {
  margin: 0;
  color: #9aa8b8;
  font-weight: 850;
}

.legaldesk-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 1rem 1.25rem;
}

.legaldesk-field-grid--three {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
}

.legaldesk-field-grid label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  color: var(--ink);
  font-weight: 850;
}

.legaldesk-field-grid label > span:first-child {
  font-size: 0.82rem;
}

.legaldesk-field-grid input,
.legaldesk-field-grid textarea {
  width: 100%;
  border: 1px solid #e2edf5;
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.legaldesk-field-grid input {
  min-height: 34px;
  padding: 0 0.55rem;
}

.legaldesk-field-grid textarea {
  min-height: 54px;
  padding: 0.45rem 0.55rem;
  resize: vertical;
}

.legaldesk-field-grid input:disabled {
  background: #f8fafc;
  color: var(--muted);
}

.client-checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  font-weight: 700;
}

.client-checkbox-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.client-related-section {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-related-section header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line-soft);
}

.client-related-section header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.client-related-section h2 {
  margin: 0.16rem 0 0;
  font-size: 1rem;
}

.client-related-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(150px, 0.8fr) minmax(180px, 1fr) minmax(120px, 0.7fr) minmax(110px, 0.55fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 52px;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}

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

.client-related-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.client-related-row span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.client-related-row--link:hover,
.client-related-row--link:focus {
  background: #f8fbfd;
}

.client-relation-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line-soft);
}

.client-relation-summary span {
  padding: 0.75rem 1rem;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
}

.client-relation-summary span:last-child {
  border-right: 0;
}

.client-relation-summary strong {
  color: var(--ink);
}

.client-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  grid-column: 2;
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(8px);
}

.client-save-bar a,
.client-save-bar button,
.matter-save-bar a,
.matter-save-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  align-self: center;
  height: 32px;
  min-height: 32px;
  max-width: max-content;
  border: 1px solid #d5e0ea;
  border-radius: 3px;
  background: #fff;
  color: var(--brand-dark);
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.matter-save-bar a:not(.primary-action) {
  min-width: auto;
  border-color: transparent;
  background: transparent;
}

.client-save-bar button,
.matter-save-bar button {
  cursor: pointer;
}

.client-save-bar .primary-action,
.matter-save-bar .primary-action {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.matter-legaldesk-page {
  display: grid;
  gap: 0;
  padding: 0.9rem 1rem 0;
}

.legaldesk-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 30px;
  color: #a0a8b3;
  font-size: 0.8rem;
}

.legaldesk-breadcrumb--page {
  align-self: start;
}

.legaldesk-breadcrumb a {
  color: var(--brand-dark);
}

.legaldesk-breadcrumb span + span::before,
.legaldesk-breadcrumb a + span::before {
  content: ">";
  margin-right: 0.55rem;
  color: #b9c0c7;
}

.matter-form-title {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 78px;
}

.matter-form-title h1 {
  margin: 0;
  font-size: 1.24rem;
  font-weight: 850;
}

.matter-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.matter-form-actions a,
.matter-form-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid #d5e0ea;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.matter-form-actions button:first-child {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.matter-form-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: calc(100vh - 170px);
  background: var(--surface);
}

.matter-section-menu {
  display: grid;
  align-content: start;
  gap: 0.04rem;
  padding: 0.85rem 0;
  border-right: 1px solid var(--line-soft);
  background: #fff;
}

.matter-section-menu strong {
  padding: 0.45rem 1rem 0.35rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.matter-section-menu a,
.matter-section-menu span {
  display: block;
  min-height: 32px;
  padding: 0.42rem 1rem;
  border-left: 2px solid transparent;
  color: var(--ink);
  font-size: 0.86rem;
}

.matter-section-menu span {
  color: var(--muted);
}

.matter-section-menu a:hover,
.matter-section-menu a:focus,
.matter-section-menu a.is-active {
  border-left-color: var(--brand);
  background: #eef7fc;
  color: var(--brand-dark);
}

.matter-form-main {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  padding-bottom: 76px;
}

.legaldesk-edit-form {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
  padding: 1rem;
}

.legaldesk-edit-form h2 {
  margin: 0 0 0.35rem;
  color: #9aa8b8;
  font-size: 0.94rem;
  font-weight: 850;
}

.legaldesk-field-grid select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #e2edf5;
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  padding: 0 0.55rem;
  font: inherit;
}

.matter-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  min-height: 58px;
  margin: 1rem -1rem -1rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.matter-form-main {
  align-content: start;
}

.legaldesk-related-panel {
  display: grid;
  gap: 0;
  align-self: start;
  margin: 0 1rem 0.75rem;
  border-top: 1px solid var(--line-soft);
  background: #fff;
}

.legaldesk-related-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: 0 0.15rem;
  border-bottom: 1px solid var(--line-soft);
}

.legaldesk-related-panel header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legaldesk-related-panel h2 {
  margin: 0.12rem 0 0;
  font-size: 1rem;
}

.legaldesk-related-panel header a,
.legaldesk-related-panel header button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid #d5e0ea;
  border-radius: 3px;
  background: #fff;
  color: var(--brand-dark);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 0.25rem 0.65rem;
  text-decoration: none;
}

.legaldesk-list-row {
  display: grid;
  gap: 0.8rem;
  align-items: center;
  min-height: 48px;
  padding: 0.55rem 0.15rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 0.84rem;
}

.legaldesk-list-row strong,
.legaldesk-list-row span,
.legaldesk-list-row a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legaldesk-list-row span {
  color: var(--muted);
}

.legaldesk-list-row a {
  justify-self: end;
  color: var(--brand-dark);
  font-weight: 850;
}

.legaldesk-list-row--team {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.7fr) minmax(220px, 1fr) minmax(130px, 0.7fr);
  min-height: 46px;
  align-items: center;
  padding: 0.55rem 0.15rem;
}

.legaldesk-list-row--tasks {
  grid-template-columns: minmax(260px, 1.1fr) minmax(260px, 1.2fr) minmax(140px, 0.6fr) minmax(120px, 0.5fr);
  cursor: pointer;
}

.legaldesk-list-row--activities {
  grid-template-columns: minmax(320px, 1.4fr) minmax(150px, 0.7fr) minmax(130px, 0.55fr) minmax(120px, 0.55fr) minmax(90px, 0.4fr);
}

.legaldesk-list-row--documents {
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr) minmax(130px, 0.55fr) minmax(90px, 0.4fr) minmax(70px, 0.3fr);
}

.legaldesk-list-row--deadlines,
.legaldesk-list-row--correspondence,
.legaldesk-list-row--costs {
  grid-template-columns: minmax(260px, 1.2fr) minmax(260px, 1.2fr) minmax(140px, 0.7fr) minmax(130px, 0.6fr);
}

.matter-section-panel {
  min-height: auto;
}

.matter-table {
  display: grid;
  min-width: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
}

.matter-table-row {
  display: grid;
  align-items: center;
  min-width: 720px;
  min-height: 46px;
  padding: 0 0.15rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 0.84rem;
}

.matter-table-row > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-table-row span {
  color: var(--muted);
}

.matter-table-head {
  min-height: 38px;
  background: #eef7fb;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.matter-table--team .matter-table-row {
  grid-template-columns: minmax(180px, 1.1fr) minmax(120px, 0.6fr) minmax(250px, 1.3fr) minmax(120px, 0.6fr) minmax(110px, 0.5fr);
}

.matter-table--finance .matter-table-row,
.matter-table--financial-docs .matter-table-row {
  grid-template-columns: minmax(260px, 1.3fr) minmax(150px, 0.7fr) minmax(110px, 0.5fr) minmax(130px, 0.6fr) minmax(120px, 0.6fr);
}

.matter-table--access .matter-table-row {
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.6fr) minmax(260px, 1.35fr) minmax(120px, 0.6fr) minmax(240px, 1.2fr);
}

.matter-readonly-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line-soft);
}

.matter-readonly-item {
  min-height: 70px;
  padding: 0.75rem;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.matter-readonly-item span {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.matter-readonly-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
}

.matter-note-list {
  display: grid;
  gap: 0;
}

.matter-note-item {
  padding: 0.8rem 0.15rem;
  border-bottom: 1px solid var(--line-soft);
}

.matter-note-item header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  min-height: 0;
  padding: 0;
  border: 0;
}

.matter-note-item header span {
  color: var(--muted);
  font-size: 0.78rem;
}

.matter-note-item p {
  margin: 0.35rem 0;
  color: var(--ink);
}

.matter-note-item footer {
  color: var(--muted);
  font-size: 0.78rem;
}

.client-record-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.client-section-menu {
  position: sticky;
  top: 66px;
  display: grid;
  gap: 0.1rem;
  padding: 0.85rem 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-section-menu strong {
  padding: 0.45rem 1rem 0.35rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 850;
}

.client-section-menu a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 1rem;
  border-left: 2px solid transparent;
  color: var(--ink);
  font-size: 0.84rem;
}

.client-section-menu a:hover,
.client-section-menu a:focus,
.client-section-menu a.is-active {
  border-left-color: var(--brand);
  background: #eef7fc;
  color: var(--brand-dark);
}

.client-record-main {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.client-data-card {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
}

.client-data-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line-soft);
}

.client-data-card header p,
.client-matters-panel header p,
.client-contacts-panel header p,
.client-correspondence-panel header p,
.client-intake-panel header p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.client-data-card h2 {
  margin: 0.12rem 0 0;
  font-size: 1rem;
}

.client-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 0;
  margin: 0;
}

.client-field-grid div {
  display: grid;
  grid-template-columns: minmax(125px, 0.34fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  min-height: 44px;
  padding: 0.42rem 0.65rem;
  border-bottom: 1px solid var(--line-soft);
}

.client-field-grid .span-2 {
  grid-column: 1 / -1;
}

.client-field-grid dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.client-field-grid dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.client-registry-action {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-left: 0.65rem;
}

.client-status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  margin: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-status-strip div {
  min-height: 58px;
  padding: 0.55rem 0.75rem;
  border-right: 1px solid var(--line-soft);
}

.client-status-strip div:last-child {
  border-right: 0;
}

.client-status-strip dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.client-status-strip dd {
  margin: 0.18rem 0 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1;
}

.client-hero-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.2fr) repeat(4, minmax(145px, 0.55fr));
  gap: 0.75rem;
  align-items: stretch;
}

.client-hero-grid--compact {
  grid-template-columns: minmax(420px, 0.78fr) minmax(520px, 1.22fr);
}

.client-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-summary-strip div {
  display: grid;
  align-content: center;
  gap: 0.15rem;
  min-height: 74px;
  padding: 0.65rem 0.8rem;
  border-right: 1px solid var(--line-soft);
}

.client-summary-strip div:last-child {
  border-right: 0;
}

.client-summary-strip dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.client-summary-strip dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.client-work-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.25fr) minmax(360px, 0.75fr);
  gap: 0.75rem;
  align-items: start;
}

.client-tabs {
  display: flex;
  gap: 0.28rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-tabs--subtle {
  box-shadow: none;
}

.client-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 34px;
  padding: 0 0.7rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.client-tabs a:hover,
.client-tabs a:focus,
.client-tabs a.is-active {
  border-bottom-color: var(--brand);
  background: #f8fbfd;
  color: var(--brand-dark);
}

.client-tabs strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.client-tab-panels {
  grid-template-columns: minmax(0, 1fr);
}

.client-tab-panel {
  display: none;
}

.client-tab-panel.is-active {
  display: block;
}

.client-profile-card,
.client-metric-card,
.client-matters-panel,
.client-contacts-panel,
.client-correspondence-panel,
.client-intake-panel {
  padding: 0.72rem;
}

.client-profile-card > p,
.client-metric-card > p {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.client-profile-card h2 {
  margin: 0.22rem 0 0.65rem;
}

.client-profile-card dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.client-profile-card dl div {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.client-profile-card dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.client-profile-card dd {
  margin: 0;
  min-width: 0;
}

.client-metric-card {
  display: grid;
  align-content: center;
  gap: 0.12rem;
  min-height: 84px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.client-metric-card strong {
  color: var(--ink);
  font-size: 1.24rem;
  line-height: 1;
}

.client-metric-card span {
  color: var(--muted);
  font-size: 0.76rem;
}

.client-matters-panel,
.client-correspondence-panel,
.client-intake-panel {
  display: grid;
  gap: 0.45rem;
}

.client-matters-panel header,
.client-contacts-panel header,
.client-correspondence-panel header,
.client-intake-panel header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}

.client-correspondence-panel,
.client-intake-panel {
  grid-column: 1 / -1;
}

.client-edit-form,
.client-note-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.client-edit-form button,
.client-note-form button {
  grid-column: 1 / -1;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.report-grid > .workspace-section--wide,
.report-grid > .report-section--status {
  grid-column: 1 / -1;
}

.report-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.report-status-card {
  color: var(--text);
}

.workload-table {
  display: grid;
  padding: 0.75rem;
}

.workload-table header,
.workload-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(70px, 0.45fr));
  gap: 0.55rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.workload-table header {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.workload-row {
  color: var(--text);
}

.workload-row span {
  font-weight: 800;
}

.workload-row small {
  color: var(--muted);
  font-weight: 500;
}

.workload-row--high {
  border-left: 4px solid #dc2626;
  padding-left: 0.45rem;
}

.workload-row--medium {
  border-left: 4px solid #f59e0b;
  padding-left: 0.45rem;
}

.workload-row--low {
  border-left: 4px solid #22c55e;
  padding-left: 0.45rem;
}

.admin-settings {
  display: grid;
  gap: 0.75rem;
}

.admin-settings-tools header p {
  margin: 0.18rem 0 0;
  color: var(--muted);
}

.admin-danger-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 0.9rem;
}

.admin-danger-card {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 1rem;
}

.admin-danger-card--danger {
  border-color: rgba(220, 38, 38, 0.28);
  background: #fffafa;
}

.admin-danger-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  border: 0;
}

.admin-danger-card header p,
.admin-danger-card h4 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-danger-card h3 {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
}

.admin-danger-card > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-reset-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.7fr);
  gap: 0.75rem;
}

.admin-reset-list {
  border: 1px solid rgba(220, 38, 38, 0.2);
  background: rgba(254, 242, 242, 0.62);
}

.admin-reset-list--safe {
  border-color: var(--line-soft);
  background: var(--surface-soft);
}

.admin-reset-list h4 {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.admin-reset-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.62rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.admin-reset-list div:last-child {
  border-bottom: 0;
}

.admin-reset-list span {
  color: var(--text);
  font-weight: 800;
}

.admin-reset-list strong {
  color: var(--brand-dark);
}

.admin-confirm-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.45fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
}

.confirmation-code {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid rgba(220, 38, 38, 0.24);
  background: #fff1f2;
}

.confirmation-code span {
  color: #b91c1c;
  font-size: 0.72rem;
  font-weight: 900;
}

.confirmation-code strong {
  color: #7f1d1d;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

.admin-confirm-form label {
  display: grid;
  gap: 0.35rem;
}

.admin-confirm-form label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.admin-confirm-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.62rem 0.7rem;
  font: inherit;
}

.danger-action {
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: 5px;
  background: #ef4444;
  color: #fff;
  padding: 0.68rem 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.demo-load-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border: 1px solid var(--line-soft);
}

.demo-load-summary div {
  padding: 0.8rem;
  border-right: 1px solid var(--line-soft);
}

.demo-load-summary div:last-child {
  border-right: 0;
}

.demo-load-summary dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.demo-load-summary dd {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
}

.audit-strip {
  margin-top: 0.75rem;
}

.audit-strip header p {
  margin: 0.18rem 0 0;
  color: var(--muted);
}

.audit-filters {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

.audit-list {
  display: grid;
  gap: 0;
}

.audit-row {
  border-top: 0;
  position: relative;
}

.audit-row[hidden] {
  display: none;
}

.audit-module-pill,
.audit-severity {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 800;
}

.audit-module-pill {
  margin-left: 0.45rem;
  padding: 0.2rem 0.45rem;
  color: var(--brand-dark);
  background: rgba(34, 150, 184, 0.12);
  font-style: normal;
}

.audit-severity {
  padding: 0.24rem 0.5rem;
  color: var(--muted);
  background: rgba(100, 116, 139, 0.12);
}

.audit-severity--kontrola {
  color: #b45309;
  background: rgba(245, 158, 11, 0.14);
}

.audit-severity--wysokie {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

.audit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.audit-grid .timeline-row {
  min-width: 0;
  border-right: 1px solid var(--line-soft);
}

.audit-grid .timeline-row:nth-child(4n) {
  border-right: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0.85rem;
}

.settings-grid label,
.permissions-grid label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.settings-grid input,
.settings-grid select,
.settings-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.55rem;
  color: var(--text);
  background: #f8fafc;
  font: inherit;
}

.settings-grid fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
}

.settings-grid legend {
  padding: 0 0.35rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.ai-model-catalog {
  margin: 0.25rem 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(14, 165, 190, 0.06), rgba(255, 255, 255, 0.86));
  padding: 1rem;
}

.ai-model-catalog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.ai-model-catalog h3 {
  margin: 0 0 0.75rem;
  font-size: 0.98rem;
}

.ai-model-catalog > header h3 {
  margin: 0;
}

.ai-model-catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.ai-model-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  padding: 0.75rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.ai-model-card.is-muted {
  opacity: 0.58;
}

.ai-model-card label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.ai-model-card input,
.ai-model-card select,
.ai-model-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
  padding: 0.45rem 0.5rem;
}

.ai-model-card p {
  color: var(--muted);
  font-size: 0.78rem;
}

.ai-model-card__flags span {
  border-radius: 999px;
  background: rgba(14, 165, 190, 0.11);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.25rem 0.5rem;
}

.ai-model-card__flags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ai-model-card__flags label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  background: rgba(14, 165, 190, 0.09);
  color: var(--accent-strong);
  padding: 0.3rem 0.55rem;
}

.ai-model-card__flags input {
  width: auto;
}

.ai-model-card__description {
  grid-column: 1 / -1;
}

.settings-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.55rem;
}

.settings-checklist label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.5rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem;
  background: #f8fafc;
}

.settings-checklist input {
  width: auto;
  margin-top: 0.15rem;
}

.settings-checklist small {
  grid-column: 2;
}

.span-3 {
  grid-column: span 3;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.7rem;
  padding: 0.85rem;
}

.permissions-grid label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 0.86rem;
}

.admin-access-grid {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1.2fr;
  gap: 0.85rem;
  padding: 0.85rem;
}

.admin-access-summary {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.3fr);
  gap: 0.85rem;
  padding: 0.85rem 0.85rem 0;
}

.admin-access-summary section {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  background: #f8fafc;
}

.admin-access-summary h3 {
  margin: 0;
  font-size: 0.92rem;
}

.admin-users-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  background: #fff;
}

.billing-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 0.85rem;
  padding: 0.85rem;
}

.billing-admin-card {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  background: #f8fafc;
}

.billing-admin-card--wide {
  grid-column: 1 / -1;
}

.billing-admin-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0;
  border-bottom: 0;
}

.billing-admin-card h3 {
  margin: 0;
  font-size: 0.92rem;
}

.billing-admin-card header span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.billing-config-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  background: var(--surface);
}

.billing-config-table__head,
.billing-config-row {
  display: grid;
  gap: 0.45rem;
  align-items: center;
  min-width: 760px;
  padding: 0.55rem;
}

.billing-config-table--rates .billing-config-table__head,
.billing-config-table--rates .billing-config-row {
  grid-template-columns: minmax(150px, 1.2fr) minmax(110px, 0.75fr) minmax(170px, 1fr) minmax(82px, 0.45fr) minmax(120px, 0.75fr) minmax(150px, 1fr) minmax(110px, 0.7fr);
}

.billing-config-table--custom-fields .billing-config-table__head,
.billing-config-table--custom-fields .billing-config-row {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.25fr) minmax(100px, 0.55fr) minmax(110px, 0.6fr) minmax(90px, 0.45fr) minmax(180px, 1.15fr) minmax(110px, 0.6fr);
}

.billing-config-table--categories .billing-config-table__head,
.billing-config-table--categories .billing-config-row,
.billing-config-table--forms .billing-config-table__head,
.billing-config-table--forms .billing-config-row,
.billing-config-table--tables .billing-config-table__head,
.billing-config-table--tables .billing-config-row {
  min-width: 0;
  grid-template-columns: minmax(140px, 1fr) minmax(110px, 0.55fr) minmax(120px, 0.65fr);
}

.billing-config-table__head {
  color: var(--muted);
  background: #eef6fb;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.billing-config-row {
  border-top: 1px solid var(--line-soft);
}

.billing-config-row input,
.billing-config-row select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.42rem;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 0.8rem;
}

.billing-config-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.billing-config-check input {
  width: auto;
}

.client-custom-checkbox {
  align-content: start;
}

.control-settings-grid {
  display: grid;
  gap: 0.85rem;
  padding: 0.85rem;
}

.control-settings-group {
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.8rem;
  background: #f8fafc;
}

.control-settings-group h3 {
  margin: 0;
  font-size: 0.92rem;
}

.control-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.control-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
}

.control-toggle span {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.control-toggle strong {
  color: var(--text);
}

.control-toggle small {
  color: var(--muted);
}

.admin-users-table {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  overflow: auto;
  background: var(--surface);
  box-shadow: none;
}

.admin-users-table__head,
.admin-user-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.35fr) minmax(150px, 0.55fr) minmax(130px, 0.45fr);
  gap: 0.75rem;
  align-items: center;
  min-width: 620px;
  padding: 0.72rem 0.85rem;
}

.admin-users-table__head {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-user-row {
  appearance: none;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.admin-user-row:hover,
.admin-user-row:focus-visible {
  position: relative;
  z-index: 1;
  background: #f4fbfe;
  box-shadow: inset 3px 0 0 var(--brand);
  outline: 0;
}

.admin-user-row__identity {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.admin-user-row__identity strong,
.admin-user-row__identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-row__identity small {
  color: var(--muted);
}

.admin-user-role-pill {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.admin-user-role-pill {
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  background: #e0f2fe;
  color: #0c4a6e;
  font-style: normal;
  font-weight: 900;
}

.admin-user-account-state {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  justify-self: start;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 900;
}

.admin-user-account-state small {
  font-size: 0.68rem;
  opacity: 0.78;
}

.admin-user-account-state.is-open {
  background: #dcfce7;
  color: #166534;
}

.admin-user-account-state.is-locked {
  background: #fee2e2;
  color: #991b1b;
}

.admin-user-account-state.is-warning {
  background: #fef3c7;
  color: #92400e;
}

.admin-user-modal {
  width: min(760px, calc(100vw - 2rem));
}

.admin-user-modal__card {
  gap: 1rem;
}

.admin-user-modal__card header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.admin-user-modal__card header p {
  margin: 0 0 0.15rem;
}

.admin-user-modal__card header h2 {
  margin: 0;
}

.admin-user-modal__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-user-modal__grid label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.admin-user-modal__grid input,
.admin-user-modal__grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.6rem 0.68rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.admin-user-lock-toggle {
  align-self: end;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.55rem 0.65rem;
  background: #f8fafc;
}

.admin-user-lock-toggle input {
  width: 1rem;
  height: 1rem;
}

.admin-user-modal__card footer {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

@media (max-width: 820px) {
  .admin-users-table__head {
    display: none;
  }

  .admin-user-row,
  .admin-user-modal__grid {
    grid-template-columns: 1fr;
  }
}

.auth-page {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #eff6fb 0%, #f8fafc 100%);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  display: grid;
  gap: 1.1rem;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.2rem;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.auth-card__brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.auth-card__brand p,
.auth-card__brand h1 {
  margin: 0;
}

.auth-card__brand p {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-env-label {
  display: inline-flex;
  align-items: center;
  min-height: 1.25rem;
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-card__brand h1 {
  font-size: 1.35rem;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.72rem 0.8rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.auth-error:not(:empty) {
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 0.65rem 0.75rem;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.82rem;
  font-weight: 800;
}

.logout-form {
  display: inline-flex;
}

.logout-form .topbar-icon-button {
  width: auto;
  min-width: 42px;
  padding-inline: 0.6rem;
  font-size: 0.72rem;
  font-weight: 900;
}

.admin-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  padding: 0.85rem;
}

.admin-role-card {
  display: grid;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.85rem;
  background: #f8fafc;
}

.admin-role-card strong {
  color: var(--text);
  font-size: 0.95rem;
}

.admin-role-card code {
  width: fit-content;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  background: #e0f2fe;
  color: #075985;
  font-size: 0.75rem;
  font-weight: 800;
}

.admin-role-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.permission-matrix {
  padding: 0.85rem;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.permission-matrix__table {
  min-width: 1040px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.permission-matrix__row {
  display: grid;
  grid-template-columns: minmax(280px, 1.3fr) repeat(6, minmax(112px, 0.45fr));
  align-items: center;
  min-height: 3rem;
  border-top: 1px solid var(--line-soft);
}

.permission-matrix__head {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 2.6rem;
  border-top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.permission-matrix__row > span,
.permission-matrix__permission,
.permission-matrix__check {
  padding: 0.62rem 0.75rem;
}

.permission-matrix__group {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--line);
  background: #eef9fc;
  color: #075985;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.permission-matrix__permission {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.permission-matrix__permission strong {
  color: var(--text);
}

.permission-matrix__permission small {
  color: var(--muted);
  line-height: 1.35;
}

.permission-matrix__check {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
}

.permission-matrix__check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.admin-access-grid--technical {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.access-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.access-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.access-row strong {
  color: var(--text);
}

.access-row span {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.access-row em,
.access-row b {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
  background: var(--surface);
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.access-row b {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}

.admin-access-grid section {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.admin-access-grid h3 {
  margin: 0;
  font-size: 0.92rem;
}

.admin-access-grid label {
  display: grid;
  gap: 0.25rem;
  color: var(--text);
  font-size: 0.84rem;
}

.admin-access-grid input[type="checkbox"] {
  margin-right: 0.35rem;
}

.template-draft-preview {
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border-top: 1px solid var(--line);
}

.template-draft-preview h3,
.template-draft-preview p {
  margin: 0;
}

.template-draft-preview details {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.template-draft-preview summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 0.55rem;
  align-items: center;
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line-soft);
}

.template-draft-preview summary span,
.template-draft-preview summary em {
  justify-self: end;
  color: var(--muted);
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 800;
}

.template-variable-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.45rem;
  padding: 0.7rem;
}

.template-variable-grid div {
  display: grid;
  gap: 0.18rem;
  padding: 0.45rem;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #f8fafc;
}

.template-variable-grid .is-missing {
  border-color: #fecaca;
  background: #fff7f7;
}

.template-draft-preview pre {
  margin: 0 0.7rem 0.7rem;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.65rem;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 0.78rem;
}

.prompt-json-editor {
  border-top: 0;
}

.prompt-json-editor label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.prompt-json-editor textarea {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 0.65rem;
  font: 0.78rem Consolas, monospace;
}

.prompt-editor-modal {
  max-width: 860px;
}

.template-draft-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 0.7rem 0.7rem;
}

.template-draft-actions button {
  border: 1px solid var(--brand);
  border-radius: 4px;
  background: var(--brand);
  color: white;
  font-weight: 900;
  padding: 0.45rem 0.75rem;
}

.admin-access-grid select,
.admin-access-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.45rem;
  color: var(--text);
  background: #f8fafc;
  font: inherit;
}

.workspace-section {
  scroll-margin-top: 112px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-section--wide {
  grid-column: span 2;
}

.workspace-section header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.workspace-section h2 {
  margin: 0;
  font-size: 1rem;
}

.workspace-section header a,
.workspace-section header button {
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
}

.timeline-row {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

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

.timeline-row span,
.timeline-row small,
.empty-state {
  color: var(--muted);
}

.client-contact-row small,
.module-table--clients small {
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  padding: 0.9rem;
}

.modal {
  width: min(640px, calc(100vw - 2rem));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal[open] {
  display: block;
}

.modal--wide {
  width: min(980px, calc(100vw - 2rem));
}

.modal--intake-decision {
  width: min(1360px, calc(100vw - 3rem));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.32);
}

.modal-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.modal-card--wide {
  width: min(980px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.modal--intake-decision .modal-card--wide {
  width: min(1360px, calc(100vw - 3rem));
  max-height: calc(100vh - 2.5rem);
}

.modal-card header,
.modal-card footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-card header button {
  width: 32px;
}

.lead-decision-modal header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.lead-decision-modal {
  gap: 1rem;
  font-size: 0.94rem;
  line-height: 1.45;
}

.lead-decision-modal > header {
  align-items: flex-start;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}

.lead-decision-modal > header h2 {
  margin: 0.12rem 0 0.35rem;
}

.lead-decision-modal > header button {
  width: 40px;
  min-height: 40px;
  font-size: 1rem;
}

.lead-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 0.9rem;
  align-items: start;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
}

.modal-grid label {
  display: grid;
  gap: 0.24rem;
  min-width: 0;
}

.modal-grid label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.modal-grid input,
.modal-grid select,
.modal-grid textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 0.45rem 0.55rem;
}

.modal-grid textarea {
  min-height: 82px;
  resize: vertical;
}

.modal-grid select[multiple] {
  min-height: 112px;
  padding-block: 0.35rem;
}

.modal-grid .span-2 {
  grid-column: 1 / -1;
}

.lead-modal-section {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #fff;
  padding: 1rem;
}

.lead-modal-section--wide {
  grid-column: auto;
}

.lead-modal-section header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line-soft);
  margin: -0.1rem 0 0.75rem;
  padding-bottom: 0.55rem;
}

.lead-modal-section h3 {
  margin: 0;
  font-size: 1rem;
}

.lead-modal-section .lead-client-match {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.compact-definition-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 1rem;
  margin: 0;
}

.compact-definition-list div {
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0.45rem;
}

.compact-definition-list dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.compact-definition-list dd {
  margin: 0.12rem 0 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.lead-score-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.65rem 0;
}

.lead-score-strip span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.3rem 0.65rem;
}

.lead-decision-modal .decision-gate {
  padding: 0.85rem 1rem;
}

.lead-decision-modal .evidence-panel {
  max-height: 430px;
  overflow: auto;
}

.lead-decision-actions {
  position: sticky;
  bottom: -1rem;
  z-index: 2;
  justify-content: flex-end;
  margin: 0 -1rem -1rem;
  border-top: 1px solid var(--line-soft);
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.lead-decision-actions form {
  margin: 0;
}

.lead-decision-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 850;
  padding: 0 0.85rem;
  cursor: pointer;
}

.lead-decision-actions button:hover,
.lead-decision-actions button:focus {
  border-color: var(--brand);
  background: #eef9fc;
  color: var(--brand-dark);
}

.lead-decision-actions .primary-action {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

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

.form-grid label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.55rem;
  color: var(--text);
  background: #f8fafc;
  font: inherit;
}

.matter-client-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.35rem;
  align-items: end;
  gap: 0.45rem;
}

.matter-client-picker label {
  min-width: 0;
}

.matter-client-picker__add {
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--brand-dark);
  font-size: 1.15rem;
  font-weight: 900;
}

.matter-client-picker__add:hover,
.matter-client-picker__add:focus {
  border-color: var(--brand);
  background: #eef9fc;
}

.matter-inline-client {
  display: grid;
  gap: 0.75rem;
  border: 1px solid rgba(9, 148, 179, 0.22);
  border-radius: 6px;
  padding: 0.8rem;
  background: #f8fbfd;
}

.matter-inline-client[hidden] {
  display: none;
}

.matter-inline-client header,
.matter-inline-client__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.matter-inline-client header p {
  margin: 0;
}

.matter-inline-client header strong {
  color: var(--text);
  font-size: 0.9rem;
}

.matter-inline-client__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.matter-inline-client__footer span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.matter-inline-client__footer span.is-error {
  color: #b91c1c;
}

.stack-form {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.stack-form--inline {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
}

.automation-rule-form {
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto auto;
  align-items: end;
}

.automation-rule-form label:nth-child(2) {
  grid-column: span 2;
}

.stack-form label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem;
  color: var(--text);
  background: #f8fafc;
  font: inherit;
}

.span-2 {
  grid-column: span 2;
}

@media (max-width: 1100px) {
  .panel-grid,
  .role-playbook,
  .work-grid,
  .kanban-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-shell--wide,
  .module-shell--register,
  .wizard-collision-grid,
  .calendar-workspace,
  .calendar-summary-strip,
  .split-workspace,
  .report-grid,
  .client-hero-grid,
  .client-work-grid,
  .client-hero-grid--compact,
  .client-summary-strip,
  .client-record-shell,
  .client-legaldesk-shell,
  .client-form-title,
  .client-form-section,
  .legaldesk-field-grid,
  .legaldesk-field-grid--three,
  .client-related-row,
  .client-relation-summary,
  .client-field-grid,
  .client-status-strip,
  .admin-summary-strip,
  .document-command-strip,
  .document-bottom-grid,
  .document-detail-grid,
  .settings-grid,
  .admin-access-summary,
  .admin-access-grid,
  .admin-danger-grid,
  .admin-reset-layout,
  .admin-confirm-form,
  .case-command {
    grid-template-columns: 1fr;
  }

  .matter-form-title,
  .matter-form-shell {
    grid-template-columns: 1fr;
  }

  .matter-section-menu {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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


  .access-row {
    grid-template-columns: 1fr;
  }

  .review-panel__main {
    grid-template-columns: 1fr;
  }

  .limited-trust-review {
    grid-template-columns: 1fr;
  }

  .review-decision-form__checks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .lead-summary-row strong,
  .lead-summary-row span,
  .lead-summary-row small {
    grid-column: 1;
  }

  .lead-summary-row em,
  .lead-summary-row button {
    grid-column: 2;
  }

  .lead-summary-row button {
    grid-row: 2;
    align-self: start;
  }

  .wizard-steps {
    grid-template-columns: 1fr;
  }

  .lead-modal-grid,
  .compact-definition-list {
    grid-template-columns: 1fr;
  }

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

  .workspace-section--wide {
    grid-column: 1 / -1;
  }

  .client-correspondence-panel,
  .client-intake-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .client-section-menu {
    position: static;
    display: flex;
    flex-wrap: wrap;
    padding: 0.45rem;
  }

  .client-section-menu strong {
    width: 100%;
    padding: 0.35rem 0.5rem 0.2rem;
  }

  .client-section-menu a {
    min-height: 30px;
    padding: 0 0.65rem;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .client-section-menu a:hover,
  .client-section-menu a:focus,
  .client-section-menu a.is-active {
    border-bottom-color: var(--brand);
  }

  .client-form-section > aside {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .client-save-bar {
    grid-column: 1;
  }

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

  .demo-load-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audit-grid .timeline-row:nth-child(2n) {
    border-right: 0;
  }

  .span-3 {
    grid-column: auto;
  }
}

@media (max-width: 1024px) {
  body.has-menu-open {
    overflow: hidden;
  }

  .app-shell {
    --menu-width: 0px;
    --menu-overlay-width: min(284px, calc(100vw - 20px));
    grid-template-columns: minmax(0, 1fr);
  }

  .app-menu {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--menu-overlay-width);
    min-height: 100dvh;
    max-width: calc(100vw - 12px);
    transform: translateX(calc(-100% - 10px));
    transition: transform 0.22s ease;
    box-shadow: 0 24px 42px rgba(15, 23, 42, 0.24);
    z-index: 60;
  }

  .app-shell.is-menu-expanded .app-menu,
  .app-shell.is-menu-hovered .app-menu {
    transform: translateX(0);
  }

  .app-shell::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 50;
  }

  .app-shell.is-menu-expanded::after {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    grid-column: 1;
    min-width: 0;
  }

  .panel-grid,
  .role-playbook,
  .work-grid,
  .module-shell,
  .kanban-board,
  .form-grid,
  .client-record-shell,
  .client-legaldesk-shell,
  .client-form-section,
  .client-field-grid,
  .legaldesk-field-grid,
  .legaldesk-field-grid--three,
  .client-related-row,
  .client-relation-summary,
  .client-status-strip,
  .demo-load-summary,
  .permissions-grid {
    grid-template-columns: 1fr;
  }

  .dashboard,
  .module-page {
    min-width: 0;
    padding: 0.65rem;
    gap: 0.65rem;
  }

  .page-actions,
  .module-actions,
  .module-filter-row,
  .module-tabs,
  .module-stat-pills {
    max-width: 100%;
    overflow-x: auto;
  }

  .client-data-card header,
  .client-registry-action {
    align-items: stretch;
    flex-direction: column;
  }

  .client-field-grid div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .page-header,
  .topbar {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .page-header {
    padding: 0.85rem;
  }

  .topbar {
    gap: 0.55rem;
    padding: 0.55rem;
  }

  .topbar input {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
    margin-left: 0;
  }

  .work-timer {
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .role-notifications {
    max-width: 100%;
    flex-wrap: wrap;
    overflow: visible;
  }

  .context-switcher {
    width: 100%;
    flex-wrap: wrap;
  }

  .context-switcher select {
    min-width: 0;
    flex: 1 1 150px;
  }

  .module-table {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
  }

  .matter-readonly-grid {
    grid-template-columns: 1fr;
  }

  .matter-save-bar {
    position: static;
  }

  .span-2 {
    grid-column: auto;
  }

  .lead-summary-row {
    grid-template-columns: 1fr;
  }

  .lead-summary-row strong,
  .lead-summary-row span,
  .lead-summary-row small,
  .lead-summary-row em,
  .lead-summary-row button {
    grid-column: 1;
  }

  .lead-summary-row em,
  .lead-summary-row button {
    justify-self: start;
  }

  .lead-client-match article {
    grid-template-columns: 1fr;
  }

  .lead-client-match article a {
    justify-self: start;
  }
}

/* ===== Layout v2 premium workspace ===== */
:root {
  --brand: #0891b2;
  --brand-strong: #0e7490;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

body,
input,
button,
select,
textarea {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

.app-shell--v2 {
  --menu-width: 88px;
  --menu-overlay-width: 240px;
  background:
    radial-gradient(1200px 420px at 55% -160px, rgba(8, 145, 178, 0.13), transparent 58%),
    var(--bg);
}

@media (min-width: 1025px) {
  .app-shell--v2 {
    --menu-width: 88px;
    --menu-overlay-width: 240px;
    grid-template-columns: var(--menu-width) minmax(0, 1fr);
  }

  .app-shell--v2.app-shell.is-menu-hovered {
    --menu-width: 88px;
  }

  .app-shell--v2.app-shell.is-menu-expanded {
    --menu-width: var(--menu-overlay-width);
  }

  .app-shell--v2 .app-menu {
    width: var(--menu-width);
  }

  .app-shell--v2.app-shell.is-menu-expanded .app-menu,
  .app-shell--v2.app-shell.is-menu-hovered .app-menu {
    width: var(--menu-overlay-width);
  }

  .app-shell--v2 .app-main {
    grid-column: 2 / -1 !important;
  }
}

.app-shell--v2 .app-menu {
  border-right: 1px solid #e6edf5;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.app-shell--v2 .menu-stack {
  gap: 0.65rem;
  padding: 0.9rem 0.45rem 1rem;
}

.app-shell--v2 .menu-group {
  display: grid;
  gap: 0.3rem;
}

.app-shell--v2 .app-menu p {
  display: none;
  margin: 0.2rem 0.4rem;
  color: #94a3b8;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.app-shell.is-menu-expanded .app-menu p,
.app-shell.is-menu-hovered .app-menu p {
  display: block;
}

.app-shell--v2 .menu-item {
  border: 0;
  border-radius: 14px;
  min-height: 42px;
  padding: 0 0.7rem;
  transition: all 0.18s ease;
}

.app-shell--v2 .menu-item:hover,
.app-shell--v2 .menu-item.is-active {
  color: #083344;
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.18), rgba(8, 145, 178, 0.06));
}

.app-shell--v2 .menu-item svg {
  stroke-width: 1.55;
}

.app-shell--v2 .menu-settings {
  border-radius: 16px;
}

.app-shell--v2 .menu-settings-summary {
  margin-inline: 0;
}

.app-shell--v2 .menu-settings[open] {
  background: linear-gradient(180deg, rgba(248, 252, 254, 0.96), rgba(241, 248, 251, 0.78));
  box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.7);
}

.app-shell--v2 .menu-settings[open] > .menu-settings-summary {
  border-radius: 14px 14px 10px 10px;
}

.app-shell--v2 .menu-settings-body {
  margin: 0 0.36rem 0.42rem;
  padding: 0.22rem 0.16rem 0.42rem;
  border-top: 1px solid rgba(203, 213, 225, 0.6);
}

.app-shell--v2 .menu-subgroup {
  position: relative;
  gap: 0.08rem;
  padding: 0.34rem 0 0.22rem;
}

.app-shell--v2 .menu-subgroup + .menu-subgroup {
  border-top: 1px solid rgba(226, 232, 240, 0.8);
}

.app-shell--v2 .menu-subgroup p {
  display: block;
  margin: 0 0 0.18rem;
  padding: 0 0.5rem;
  color: #7c8da3;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.075em;
}

.app-shell--v2 .menu-subitem {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 31px;
  border-radius: 9px;
  padding: 0.36rem 0.54rem;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 760;
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.app-shell--v2 .menu-subitem::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  margin-right: 0.48rem;
  border-radius: 999px;
  background: #cbd5e1;
  opacity: 0.78;
}

.app-shell--v2 .menu-subitem:hover,
.app-shell--v2 .menu-subitem:focus-visible {
  background: rgba(226, 245, 250, 0.72);
  color: #075985;
  outline: none;
}

.app-shell--v2 .menu-subitem.is-active {
  background: #dff4f8;
  color: #07566a;
  box-shadow: inset 0 0 0 1px rgba(103, 202, 220, 0.35);
}

.app-shell--v2 .menu-subitem.is-active::before {
  background: #0891b2;
  opacity: 1;
}

@media (max-width: 1024px) {
  .app-shell--v2 {
    --menu-width: 0px;
    --menu-overlay-width: min(284px, calc(100vw - 20px));
    grid-template-columns: minmax(0, 1fr);
  }
}

.topbar--v2 {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 72px;
  padding: 0.85rem 1.35rem;
  border-bottom: 1px solid #e6edf5;
  background: rgba(245, 247, 250, 0.88);
  backdrop-filter: blur(9px);
}

.topbar-start {
  display: flex;
  align-items: center;
}

.topbar-icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #fff;
  color: #334155;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.topbar-icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

.topbar-search-wrap {
  display: grid;
  gap: 0.32rem;
  flex: 1;
  max-width: 720px;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  border: 1px solid #d6e2ef;
  border-radius: 16px;
  padding: 0 0.75rem;
  background: #fff;
}

.topbar-search input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 0.92rem;
}

.topbar-search input:focus {
  outline: none;
}

.topbar-search svg {
  width: 16px;
  height: 16px;
  stroke: #94a3b8;
  fill: none;
}

.topbar-search-hints {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.topbar-search-hints a {
  border-radius: 999px;
  background: rgba(8, 145, 178, 0.08);
  color: #0f766e;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
}

.topbar-actions--v2 {
  gap: 0.48rem;
}

.ai-assistant-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(120deg, #0891b2, #0ea5e9);
  color: #fff;
  min-height: 38px;
  padding: 0 0.68rem;
  font-weight: 700;
}

.ai-assistant-btn svg {
  width: 15px;
  height: 15px;
  stroke: #fff;
  fill: none;
}

.context-switcher--v2 select {
  min-width: 108px;
  border-radius: 12px;
  height: 38px;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 0.62rem;
  font-size: 0.74rem;
  font-weight: 800;
}

.role-chip.is-partner,
.role-chip.is-senior { background: #eef2ff; color: #4338ca; }
.role-chip.is-student { background: #f1f5f9; color: #334155; }
.role-chip.is-aplikant { background: #ecfeff; color: #0e7490; }
.role-chip.is-admin { background: #fef3c7; color: #92400e; }
.role-chip.is-assistant { background: #dcfce7; color: #166534; }
.role-chip.is-secretariat { background: #cffafe; color: #155e75; }
.role-chip.is-lawyer { background: #e0f2fe; color: #0c4a6e; }

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #dbe4ee;
  border-radius: 999px;
  background: #fff;
  min-height: 38px;
  padding: 0 0.48rem;
  font-weight: 700;
}

.profile-chip__avatar {
  width: 27px;
  height: 27px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #0ea5e9;
  color: #fff;
  font-size: 0.75rem;
}

.dashboard--premium,
.module-page,
.matter-workspace {
  padding: 1.25rem 1.35rem 1.6rem;
  gap: 1rem;
}

.page-header--premium {
  border: 1px solid #e5edf6;
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.05);
}

.page-header--premium h1 { font-size: 2rem; }
.page-header--premium p { color: #0891b2; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 0.8rem;
}

.kpi-card {
  border-radius: 20px;
  border: 1px solid #e5edf6;
  background: #fff;
  padding: 1rem;
  display: grid;
  gap: 0.25rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  transition: transform 0.2s ease;
}

.kpi-card:hover { transform: translateY(-2px); }
.kpi-card strong { font-size: 2rem; line-height: 1; }
.kpi-card span { font-weight: 700; }
.kpi-card small { color: #64748b; }
.kpi-card em { color: #0369a1; font-style: normal; font-weight: 700; margin-top: 0.2rem; }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-size: 1.05rem;
}

.kpi-card--blue .kpi-icon { background: linear-gradient(120deg, #2563eb, #38bdf8); }
.kpi-card--green .kpi-icon { background: linear-gradient(120deg, #16a34a, #4ade80); }
.kpi-card--violet .kpi-icon { background: linear-gradient(120deg, #7c3aed, #a78bfa); }
.kpi-card--orange .kpi-icon { background: linear-gradient(120deg, #ea580c, #fb923c); }

.dashboard-grid {
  display: grid;
  gap: 0.8rem;
}

.dashboard-grid--main {
  grid-template-columns: 1.35fr 1fr 1fr;
}

.dashboard-grid--secondary {
  grid-template-columns: 1fr 1fr;
}

.workspace-card {
  border: 1px solid #e4edf7;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  padding: 0.95rem;
  display: grid;
  gap: 0.75rem;
}

.workspace-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-card > header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.workflow-feed {
  display: grid;
  gap: 0.55rem;
}

.workflow-item {
  display: grid;
  grid-template-columns: 4px 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid #edf2f7;
  border-radius: 14px;
  background: #fff;
  padding: 0.5rem;
}

.workflow-item--focused {
  border-color: #78c8da;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.14);
  background: linear-gradient(160deg, #ffffff, #f3fbff);
}

.workflow-reset-link {
  margin-left: auto;
  border: 1px solid #c9dbea;
  border-radius: 10px;
  padding: 0.26rem 0.56rem;
  color: #0e7490;
  font-size: 0.82rem;
  font-weight: 700;
}

.workflow-item__bar {
  border-radius: 999px;
  min-height: 100%;
  background: #cbd5e1;
}

.workflow-item__bar.is-danger { background: var(--danger); }
.workflow-item__bar.is-warning { background: var(--warning); }
.workflow-item__bar.is-success { background: var(--success); }
.workflow-item__bar.is-info { background: var(--info); }

.workflow-item__icon {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background: #f1f5f9;
  display: inline-grid;
  place-items: center;
}

.workflow-item__content {
  display: grid;
}

.workflow-item__content small,
.modern-row__main small,
.modern-row__meta small,
.timeline-item__body small {
  color: #64748b;
}

.workflow-item__owner {
  color: #64748b;
  font-size: 0.78rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
}

.status-pill.is-danger { background: #fee2e2; color: #b91c1c; }
.status-pill.is-warning { background: #fef3c7; color: #92400e; }
.status-pill.is-success { background: #dcfce7; color: #166534; }
.status-pill.is-info { background: #dbeafe; color: #1d4ed8; }

.timeline-agenda {
  display: grid;
  gap: 0.5rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.6rem;
  border: 1px solid #e9f0f7;
  border-left: 4px solid #cbd5e1;
  border-radius: 14px;
  padding: 0.55rem;
}

.timeline-item.is-danger { border-left-color: var(--danger); }
.timeline-item.is-warning { border-left-color: var(--warning); }
.timeline-item.is-success { border-left-color: var(--success); }
.timeline-item.is-info { border-left-color: var(--info); }

.timeline-item__date {
  min-width: 76px;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.35rem;
  display: grid;
  align-content: center;
  text-align: center;
}

.timeline-item__body {
  display: grid;
}

.timeline-item__body em {
  font-style: normal;
  color: #0f766e;
  font-weight: 700;
}

.approval-center {
  display: grid;
  gap: 0.55rem;
}

.approval-card {
  border: 1px solid #e7eef6;
  border-radius: 14px;
  padding: 0.65rem;
  display: grid;
  gap: 0.42rem;
}

.approval-actions {
  display: flex;
  gap: 0.4rem;
}

.approval-actions a {
  border: 1px solid #d4e0ec;
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.approval-actions .is-primary {
  background: #0891b2;
  color: #fff;
  border-color: #0891b2;
}

.workspace-card--insights ul {
  margin: 0;
  padding-left: 1rem;
  color: #0f172a;
}

.insight-actions {
  display: flex;
  gap: 0.45rem;
}

.insight-actions a {
  border: 1px solid #d7e2ee;
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.quick-actions-grid a,
.quick-actions-grid button {
  border: 1px solid #dbe5f0;
  border-radius: 16px;
  min-height: 52px;
  background: linear-gradient(160deg, #f8fcff, #f3f7fb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-weight: 700;
}

.registry-modern {
  display: grid;
  gap: 0.85rem;
}

.registry-modern__toolbar,
.registry-modern__controls {
  border: 1px solid #e4edf7;
  border-radius: 20px;
  background: #fff;
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.registry-modern__title h2 { margin: 0; font-size: 1.35rem; }
.registry-modern__title p { margin: 0.2rem 0 0; color: #64748b; }

.registry-modern__chips {
  display: flex;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.registry-modern__chips button {
  min-height: 34px;
  border: 1px solid #d9e4ef;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-weight: 700;
  padding: 0 0.62rem;
}

.registry-modern__chips button.is-active,
.registry-modern__chips button:hover {
  background: rgba(8, 145, 178, 0.12);
  border-color: #8fd0de;
  color: #0e7490;
}

.registry-modern__search {
  min-width: 320px;
  flex: 1;
}

.registry-modern__controls .registry-search--compact {
  min-width: 220px;
}

.modern-list {
  display: grid;
  gap: 0.55rem;
}

.modern-row {
  border: 1px solid #e5edf7;
  border-radius: 16px;
  padding: 0.78rem 0.85rem;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.modern-row:hover {
  border-color: #b7d7e8;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.modern-row__main,
.modern-row__meta,
.modern-row__side {
  display: grid;
  gap: 0.18rem;
}

.modern-row__main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.62rem;
}

.modern-row__main strong {
  font-size: 1rem;
}

.modern-row__side {
  justify-items: end;
  gap: 0.3rem;
}

.modern-row__icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  border: 1px solid #d9e6f1;
}

.modern-row__icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.modern-row__icon--case {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.16), rgba(14, 165, 233, 0.08));
  color: #1d4ed8;
}

.modern-row__icon--doc {
  background: linear-gradient(140deg, rgba(249, 115, 22, 0.16), rgba(251, 191, 36, 0.08));
  color: #c2410c;
}

.modern-row__owner {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.modern-row__owner small {
  white-space: nowrap;
}

.modern-row--case {
  min-height: 92px;
  padding: 0.95rem 1rem;
}

.modern-row--case .modern-row__main strong {
  font-size: 1.12rem;
  line-height: 1.2;
}

.modern-row--case .modern-row__main small {
  font-size: 0.92rem;
}

.modern-row--case .modern-row__meta span {
  font-size: 1rem;
  line-height: 1.25;
}

.modern-row--case .modern-row__meta small {
  font-size: 0.9rem;
}

.modern-row--case .status-pill {
  min-height: 28px;
  font-size: 0.82rem;
  padding: 0 0.62rem;
}

.modern-row--case .avatar-chip {
  width: 32px;
  height: 32px;
  font-size: 0.78rem;
}



.modern-list--cases .modern-row--case {
  min-height: 76px;
  padding: 0.72rem 0.82rem;
  border-radius: 12px;
  box-shadow: none;
}

.modern-list--cases .modern-row--case .modern-row__main strong {
  font-size: 1rem;
}

.modern-list--cases .modern-row--case .modern-row__meta {
  gap: 0.1rem;
}

.modern-list--cases .case-next-step {
  font-size: 0.95rem;
  line-height: 1.2;
}

.modern-list--cases .case-deadline {
  font-size: 0.82rem;
  color: #64748b;
}

.modern-list--cases .case-meta-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.modern-list--cases .case-meta-line span + span::before {
  content: "•";
  margin-right: 0.35rem;
  color: #94a3b8;
}

.modern-list--cases .modern-row__owner small {
  font-size: 0.86rem;
}

.modern-row--doc {
  min-height: 88px;
  padding: 0.9rem 1rem;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1.15fr) auto;
  align-items: start;
}

.modern-row--doc .modern-row__main strong {
  font-size: 1.1rem;
  line-height: 1.2;
}

.modern-row--doc .modern-row__main small {
  font-size: 0.9rem;
}

.modern-row--doc .modern-row__meta span {
  font-size: 1rem;
  line-height: 1.25;
}

.modern-row--doc .modern-row__meta small {
  font-size: 0.88rem;
}

.doc-file-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.doc-file-meta span + span::before {
  content: "•";
  margin-right: 0.4rem;
  color: #94a3b8;
}

.doc-meta-line {
  display: block;
}

.doc-meta-line strong {
  color: #475569;
  font-weight: 700;
}

.modern-row--doc .status-pill {
  min-height: 28px;
  font-size: 0.8rem;
  padding: 0 0.62rem;
}

.modern-row--doc .doc-format {
  font-size: 0.76rem;
  padding: 0.18rem 0.5rem;
}

.modern-row--team-member {
  min-height: 84px;
  padding: 0.86rem 0.95rem;
}

.modern-row--team-member .modern-row__main strong {
  font-size: 1.08rem;
}

.modern-row--team-member .modern-row__main small {
  font-size: 0.9rem;
}

.modern-row--team-member .modern-row__meta span {
  font-size: 0.98rem;
}

.modern-row--team-member .modern-row__meta small {
  font-size: 0.88rem;
}


.modern-row--compact {
  min-height: 0;
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
  gap: 0.55rem;
  box-shadow: none;
}

.modern-row--compact .modern-row__main strong {
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.2;
}

.modern-row--compact .modern-row__main small {
  font-size: 0.82rem;
  color: #6b7280;
}

.modern-row--compact .status-pill {
  min-height: 22px;
  padding: 0 0.48rem;
  font-size: 0.72rem;
}

.avatar-chip--team {
  background: linear-gradient(145deg, #dbeafe, #e0f2fe);
  color: #1d4ed8;
}


.doc-format {
  padding: 0.12rem 0.4rem;
  border-radius: 8px;
  border: 1px solid #d7e2ee;
  color: #64748b;
  font-weight: 700;
  font-size: 0.7rem;
}

.avatar-chip {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  display: inline-grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
}

.matter-workspace {
  display: grid;
  gap: 0.8rem;
}

.matter-hero {
  border: 1px solid #e3ecf7;
  border-radius: 20px;
  background: #fff;
  padding: 1rem;
}

.matter-hero h1 {
  margin: 0;
  font-size: 1.8rem;
}

.matter-hero p {
  margin: 0.25rem 0;
  color: #64748b;
}

.matter-hero__badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.matter-relation-badge {
  background: var(--relation-bg, #dcfce7);
  color: var(--relation-fg, #166534);
  border: 1px solid var(--relation-border, #86efac);
}

.matter-relation-badge:hover {
  filter: saturate(1.05);
}

.matter-relation-badge--more {
  --relation-bg: #f8fafc;
  --relation-fg: #334155;
  --relation-border: #cbd5e1;
}

.matter-relations-panel header {
  align-items: flex-start;
}

.modern-list--relations .modern-row--relation {
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.8fr) auto;
}

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

.modern-row--relation .modern-row__main small {
  grid-column: 2;
}

.modern-row--relation .matter-relation-badge {
  align-self: start;
  justify-self: start;
}

.relation-dictionary-card {
  margin-bottom: 1rem;
}

.billing-config-table--relations .billing-config-table__head,
.billing-config-table--relations .billing-config-row {
  grid-template-columns: minmax(110px, 0.8fr) minmax(130px, 1fr) minmax(180px, 1.25fr) 62px 62px 62px 120px 90px;
}

.billing-config-table--relations input[type="color"] {
  min-height: 38px;
  padding: 0.1rem;
}

.matter-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  border-radius: 16px;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #e1eaf5;
}

.matter-tabs a {
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
  color: #475569;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.matter-tabs a.is-active {
  background: linear-gradient(120deg, rgba(8, 145, 178, 0.2), rgba(8, 145, 178, 0.08));
  color: #0e7490;
}

.matter-tabs .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 0.3rem;
  border-radius: 999px;
  border: 1px solid #d9e6f2;
  background: #f8fafc;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}

.matter-tabs a.is-active .tab-count {
  border-color: #8fd0de;
  background: #e8f8fc;
  color: #0e7490;
}

.matter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 0.8rem;
  align-items: start;
}

.matter-content {
  display: grid;
  gap: 0.8rem;
}

.matter-sticky-actions {
  position: sticky;
  top: 92px;
  border: 1px solid #e4edf7;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(9px);
  padding: 0.75rem;
  display: grid;
  gap: 0.45rem;
}

.matter-sticky-actions h3 {
  margin: 0 0 0.2rem;
}

.matter-sticky-actions a,
.matter-sticky-actions button {
  min-height: 40px;
  border: 1px solid #d8e4ef;
  border-radius: 12px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0f172a;
}

.matter-sticky-actions a:hover,
.matter-sticky-actions button:hover {
  border-color: #7cc9da;
  color: #0f766e;
}

@media (max-width: 1250px) {
  .kpi-grid,
  .dashboard-grid--main,
  .dashboard-grid--secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matter-layout {
    grid-template-columns: 1fr;
  }

  .matter-sticky-actions {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard--premium,
  .module-page,
  .matter-workspace {
    padding: 0.72rem;
  }

  .kpi-grid,
  .dashboard-grid--main,
  .dashboard-grid--secondary,
  .quick-actions-grid,
  .matter-sticky-actions,
  .modern-row {
    grid-template-columns: 1fr;
  }

  .topbar--v2 {
    padding: 0.55rem;
  }

  .topbar-search-wrap {
    max-width: 100%;
  }

  .registry-modern__search {
    min-width: 0;
    width: 100%;
  }

  .registry-modern__controls .registry-search--compact {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  .registry-modern__chips {
    width: 100%;
  }

  .registry-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .billing-rates {
    overflow-x: auto;
  }

  .billing-rate-row {
    grid-template-columns: 1fr 74px 58px 1fr auto;
    min-width: 420px;
  }

  .invoice-queue {
    overflow-x: auto;
  }

  .invoice-queue > header,
  .invoice-row {
    min-width: 0;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.45rem;
  }

  .invoice-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .invoice-row form,
  .invoice-row > a {
    width: fit-content;
  }

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

  .module-table--clients header,
  .module-table--clients > a,
  .module-table--costs header,
  .module-table--costs > a,
  .module-table--correspondence header,
  .module-table--correspondence .module-table-row {
    min-width: 760px;
  }

  .activities-register {
    overflow-x: auto;
  }

  .activity-grid,
  .activity-grid-header,
  .activity-grid-row {
    min-width: 980px;
  }

  .calendar-legaldesk-board,
  .calendar-type-switches {
    overflow-x: auto;
  }

  .calendar-legaldesk-weekdays,
  .calendar-legaldesk-grid {
    min-width: 812px;
  }

  .modern-row--case {
    min-height: 0;
    padding: 0.78rem 0.85rem;
  }

  .modern-row--case .modern-row__main strong {
    font-size: 1.02rem;
  }

  .modern-row--case .modern-row__meta span {
    font-size: 0.92rem;
  }

  .modern-row--doc {
    min-height: 0;
    padding: 0.78rem 0.85rem;
    grid-template-columns: minmax(0, 1fr);
  }

  .modern-row--doc .modern-row__main strong {
    font-size: 1.02rem;
  }

  .modern-row--doc .modern-row__meta span {
    font-size: 0.92rem;
  }

  .modern-row--team-member {
    min-height: 0;
    padding: 0.75rem 0.82rem;
  }

  .modern-row--team-member .modern-row__main strong {
    font-size: 1rem;
  }
}

/* hotfix: case details layout stability */
.matter-layout {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.matter-content {
  flex: 1 1 auto;
  min-width: 0;
}

.matter-sticky-actions {
  width: 280px;
  flex: 0 0 280px;
}

.matter-tabs {
  display: flex;
  align-items: center;
}

@media (max-width: 1250px) {
  .matter-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .matter-sticky-actions {
    width: 100%;
    flex: 1 1 auto;
  }
}

/* final override: case details must stay single-column shell */
.matter-workspace {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
}

.matter-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0.8rem !important;
  align-items: start !important;
}

.matter-content {
  min-width: 0 !important;
}

.matter-actions-trigger {
  margin-left: auto;
  min-height: 34px;
  border: 1px solid #89cadb;
  border-radius: 999px;
  background: linear-gradient(120deg, #0891b2, #0ea5b7);
  color: #fff;
  font: inherit;
  font-weight: 800;
  padding: 0 0.8rem;
  cursor: pointer;
}

.matter-actions-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.matter-actions-drawer__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.24);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.matter-actions-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 92vw);
  height: 100%;
  border-left: 1px solid #d8e4ef;
  background: #fff;
  box-shadow: -18px 0 48px rgba(15, 23, 42, 0.22);
  padding: 1rem;
  transform: translateX(104%);
  transition: transform 0.24s ease;
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.matter-actions-drawer.is-open {
  pointer-events: auto;
}

.matter-actions-drawer.is-open .matter-actions-drawer__backdrop {
  opacity: 1;
}

.matter-actions-drawer.is-open .matter-actions-drawer__panel {
  transform: translateX(0);
}

.matter-actions-drawer__panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.matter-actions-drawer__panel h3 {
  margin: 0;
  font-size: 1.1rem;
}

.matter-actions-drawer__close {
  width: 30px;
  min-height: 30px;
  border: 1px solid #d8e4ef;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.matter-actions-drawer__buttons {
  display: grid;
  gap: 0.45rem;
}

.matter-actions-drawer__buttons a,
.matter-actions-drawer__buttons button {
  min-height: 42px;
  border: 1px solid #d8e4ef;
  border-radius: 12px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  color: #0f172a;
}

.matter-actions-drawer__buttons a:hover,
.matter-actions-drawer__buttons button:hover {
  border-color: #7cc9da;
  color: #0f766e;
}



/* ===== Unified compact lists across modules (May 2026) ===== */
.module-table {
  border-radius: 14px;
  overflow: hidden;
}

.module-table header,
.module-table > a,
.module-table-row {
  padding: 0.5rem 0.7rem;
  min-height: 44px;
}

.module-table header {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  background: #f5f9fd;
}

.module-table > a,
.module-table-row {
  font-size: 0.9rem;
}

.module-table small {
  font-size: 0.78rem;
  line-height: 1.3;
}

.module-table--clients a,
.module-table--correspondence .module-table-row,
.module-table--costs a,
.module-table--activities a {
  background: #fff;
}

.module-table--clients a:hover,
.module-table--correspondence .module-table-row:hover,
.module-table--costs a:hover,
.module-table--activities a:hover {
  background: #f8fbff;
}

.module-table--clients a em,
.module-table--correspondence .module-table-row strong,
.module-table--costs a strong {
  font-size: 0.95rem;
  line-height: 1.2;
}

.module-table--correspondence .module-table-row {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.module-table--correspondence .status-pill,
.module-table--costs .status-pill,
.module-table--clients .status-pill {
  min-height: 24px;
  padding: 0 0.5rem;
  font-size: 0.72rem;
}

.invoice-queue {
  margin: 0.65rem;
  border-radius: 12px;
  border-color: #dce6f0;
}

.invoice-queue > header,
.invoice-row {
  padding: 0.5rem 0.65rem;
  min-height: 40px;
}

.invoice-row button,
.invoice-row > a,
.invoice-actions a,
.row-actions--compact button {
  min-height: 28px;
  padding: 0.28rem 0.5rem;
  border-radius: 8px;
  font-size: 0.76rem;
}

.activity-grid-header {
  min-height: 38px;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  background: #f5f9fd;
}

.activity-grid-row {
  min-height: 40px;
  font-size: 0.84rem;
}

.activity-grid-header span,
.activity-grid-row > span,
.activity-grid-row > a {
  padding: 0.4rem 0.54rem;
}

.activity-description {
  gap: 0.04rem;
}

.activity-description strong {
  font-size: 0.86rem;
  font-weight: 760;
}

.activity-description small {
  font-size: 0.74rem;
}

.activity-inbox-card {
  min-height: 90px;
  margin-bottom: 0.5rem;
  padding: 0.58rem 0.6rem 0.54rem 0.82rem;
}

.activity-inbox-card strong {
  font-size: 0.84rem;
}

.activity-inbox-card p,
.activity-inbox-card footer {
  font-size: 0.72rem;
}

.activities-total-bar {
  padding-top: 0.7rem;
}

.activities-total-bar strong {
  font-size: 0.92rem;
}

.kanban-board {
  gap: 0.4rem;
  grid-template-columns: repeat(4, minmax(210px, 250px));
}

.kanban-column {
  min-height: 60vh;
  border-radius: 10px;
  border-color: #dce7f2;
}

.kanban-column header {
  padding: 0.44rem 0.56rem;
}

.kanban-column h2 {
  font-size: 0.74rem;
  font-weight: 780;
}

.kanban-column header span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 20px;
  padding: 0 0.34rem;
  border-radius: 999px;
  border: 1px solid #c9deec;
  background: #f4f9fd;
  color: #3f566d;
  font-size: 0.68rem;
  font-weight: 760;
  line-height: 1;
}

.kanban-dropzone {
  min-height: 56vh;
  padding: 0.3rem;
}

.task-card {
  min-height: 84px;
  margin: 0 0 0.36rem;
  padding: 0.44rem;
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
}

.task-card span,
.task-card small,
.task-date {
  font-size: 0.74rem;
}

.task-card__top {
  gap: 0.28rem;
}

.task-card__top strong {
  font-size: 0.84rem;
  font-weight: 760;
  line-height: 1.2;
}

.task-card footer {
  margin-top: 0.08rem;
}

.task-card em {
  width: 18px;
  height: 18px;
  font-size: 0.56rem;
}

.task-open-dot {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.task-open-dot::before {
  border-top-width: 3px;
  border-bottom-width: 3px;
  border-left-width: 4px;
}

.task-menu-dot {
  width: 3px;
  height: 3px;
  box-shadow: 0 4px 0 #b5bdc8, 0 8px 0 #b5bdc8;
}

.report-status-card {
  border-radius: 12px;
}

.workload-table {
  padding: 0.55rem;
}

.workload-table header,
.workload-row {
  padding: 0.42rem 0;
  gap: 0.45rem;
}

.workload-table header {
  font-size: 0.68rem;
}

.workload-row {
  font-size: 0.88rem;
}

/* ===== Billing + Correspondence compact harmonization (Block B, May 2026) ===== */
.module-table--correspondence {
  border-radius: 14px;
}

.module-table--correspondence header,
.module-table--costs header {
  min-height: 38px;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
}

.module-table--correspondence .module-table-row,
.module-table--costs > a {
  min-height: 40px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  font-size: 0.84rem;
}

.module-table--correspondence .module-table-row strong,
.module-table--costs > a strong {
  font-size: 0.86rem;
  line-height: 1.2;
}

.module-table--correspondence .module-table-row > span,
.module-table--costs > a > span {
  line-height: 1.28;
}

.module-table--correspondence .module-table-row small,
.module-table--costs > a small {
  font-size: 0.74rem;
}

.module-table--correspondence .status-pill,
.module-table--costs .status-pill,
.module-table--costs select,
.module-table--correspondence .row-actions--compact button {
  min-height: 24px;
  font-size: 0.72rem;
}

.module-table--costs .inline-form select {
  min-height: 28px;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.correspondence-process-note {
  padding: 0.58rem 0.72rem;
}

.correspondence-process-note span {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
}

.correspondence-detail-modal {
  gap: 0.75rem;
}

.correspondence-detail-modal header {
  align-items: flex-start;
  padding-bottom: 0.68rem;
  border-bottom: 1px solid var(--line-soft);
}

.correspondence-detail-modal header h2 {
  font-size: 1.08rem;
  margin: 0.08rem 0 0.3rem;
}

.correspondence-detail-modal header span {
  font-size: 0.76rem;
}

.correspondence-modal-actions {
  gap: 0.34rem;
  margin-bottom: 0.58rem;
}

.correspondence-modal-actions a,
.confirmation-upload label span,
.button-row .inline-form button {
  min-height: 28px;
  padding: 0.26rem 0.46rem;
  border-radius: 6px;
  font-size: 0.72rem;
}

.invoice-queue {
  margin: 0.55rem;
  border-radius: 10px;
}

.invoice-queue > header,
.invoice-row {
  padding: 0.42rem 0.56rem;
  min-height: 38px;
}

.invoice-queue h2 {
  font-size: 0.86rem;
}

.invoice-queue > header span,
.invoice-row small {
  font-size: 0.72rem;
}

.invoice-row {
  font-size: 0.82rem;
}

.invoice-row strong,
.invoice-row em {
  font-size: 0.84rem;
}

.invoice-row button,
.invoice-row > a,
.invoice-actions a {
  min-height: 28px;
  padding: 0.26rem 0.48rem;
  font-size: 0.72rem;
  border-radius: 8px;
}

.detail-pane {
  padding: 0.72rem;
}

.detail-pane h2 {
  font-size: 1rem;
  margin-bottom: 0.58rem;
}

.compact-summary {
  margin-bottom: 0.65rem;
}

.compact-summary div {
  padding: 0.4rem 0.5rem;
}

.compact-summary dt {
  font-size: 0.7rem;
}

.compact-summary dd {
  font-size: 0.84rem;
}

.billing-rates {
  margin-bottom: 0.65rem;
  padding: 0.52rem;
}

.billing-rates h3 {
  font-size: 0.8rem;
}

.billing-rate-row {
  grid-template-columns: minmax(64px, 1fr) 58px 50px minmax(82px, 1fr) auto;
  gap: 0.24rem;
}

.billing-rate-row strong {
  font-size: 0.72rem;
}

.billing-rate-row input,
.billing-rate-row select,
.billing-rate-row button {
  min-height: 28px;
  padding: 0.24rem 0.4rem;
  font-size: 0.72rem;
}
/* ===== Clients + Reports + Dashboard compact harmonization (Block C, May 2026) ===== */
.module-table--clients header {
  min-height: 38px;
  font-size: 0.66rem;
}

.module-table--clients > a {
  min-height: 44px;
  padding-top: 0.48rem;
  padding-bottom: 0.48rem;
  font-size: 0.84rem;
}

.module-table--clients > a strong {
  font-size: 0.88rem;
  line-height: 1.2;
}

.module-table--clients > a small {
  font-size: 0.72rem;
}

.module-table--clients > a em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  min-width: 56px;
  border: 1px solid #b7dcea;
  border-radius: 999px;
  padding: 0 0.48rem;
  color: var(--brand-dark);
  font-size: 0.72rem;
  font-weight: 760;
  font-style: normal;
  background: #fff;
}

.report-grid {
  gap: 0.72rem;
}

.metric-grid {
  gap: 0.52rem;
}

.metric-card {
  min-height: 84px;
  padding: 0.58rem 0.66rem;
  border-radius: 10px;
}

.metric-card strong {
  font-size: 1.14rem;
}

.metric-card span {
  font-size: 0.8rem;
}

.metric-card small {
  font-size: 0.72rem;
}

.workload-table {
  padding: 0.48rem;
}

.workload-table header,
.workload-row {
  min-height: 38px;
  padding: 0.34rem 0;
}

.workload-table header {
  font-size: 0.66rem;
}

.workload-row {
  font-size: 0.82rem;
}

.workload-row strong {
  font-size: 0.86rem;
}

.workload-row small {
  font-size: 0.72rem;
}

.timeline-row {
  min-height: 40px;
  padding: 0.4rem 0.56rem;
}

.timeline-row strong {
  font-size: 0.84rem;
}

.timeline-row span,
.timeline-row small {
  font-size: 0.74rem;
}

.report-status-card {
  border-radius: 10px;
}

.workflow-item {
  min-height: 40px;
  padding: 0.42rem 0.5rem;
}

.workflow-item__icon {
  min-width: 44px;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

.workflow-item__content strong {
  font-size: 0.84rem;
}

.workflow-item__content small,
.workflow-item__owner {
  font-size: 0.72rem;
}

.timeline-item {
  min-height: 44px;
  padding: 0.42rem 0.52rem;
}

.timeline-item__date strong {
  font-size: 0.82rem;
}

.timeline-item__date small,
.timeline-item__body small,
.timeline-item__body em {
  font-size: 0.72rem;
}

.approval-card {
  padding: 0.56rem;
}

.approval-card strong {
  font-size: 0.86rem;
}

.approval-card small {
  font-size: 0.72rem;
}

.approval-actions a {
  min-height: 28px;
  padding: 0.26rem 0.48rem;
  font-size: 0.72rem;
}

.quick-actions-grid a,
.quick-actions-grid button {
  min-height: 42px;
  font-size: 0.84rem;
}
/* ===== Cases + Documents + Case details compact harmonization (Block D, May 2026) ===== */
.modern-list {
  gap: 0.4rem;
}

.modern-row {
  border-radius: 12px;
  padding: 0.58rem 0.68rem;
  gap: 0.56rem;
}

.modern-row:hover {
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.05);
}

.modern-row__main {
  gap: 0.46rem;
}

.modern-row__main strong {
  font-size: 0.9rem;
  line-height: 1.2;
}

.modern-row__main small,
.modern-row__meta span,
.modern-row__meta small,
.modern-row__owner small {
  font-size: 0.74rem;
}

.modern-row__icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}

.modern-row--case {
  min-height: 74px;
  padding: 0.6rem 0.72rem;
}

.modern-row--case .modern-row__main strong {
  font-size: 0.94rem;
}

.modern-row--case .case-next-step {
  font-size: 0.84rem;
}

.modern-row--case .case-deadline {
  font-size: 0.72rem;
}

.modern-row--case .status-pill {
  min-height: 24px;
  font-size: 0.72rem;
  padding: 0 0.52rem;
}

.modern-row--case .avatar-chip {
  width: 22px;
  height: 22px;
  font-size: 0.62rem;
}

.modern-row--doc {
  min-height: 72px;
  padding: 0.58rem 0.72rem;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) auto;
}

.modern-row--doc .modern-row__main strong {
  font-size: 0.92rem;
}

.modern-row--doc .modern-row__main small,
.modern-row--doc .modern-row__meta span,
.modern-row--doc .modern-row__meta small {
  font-size: 0.74rem;
}

.modern-row--doc .status-pill {
  min-height: 24px;
  font-size: 0.72rem;
}

.doc-format {
  font-size: 0.68rem;
  padding: 0.14rem 0.42rem;
}

.matter-tabs {
  min-height: 44px;
  gap: 0.22rem;
}

.matter-tabs a,
.matter-tabs button {
  min-height: 30px;
  padding: 0.34rem 0.56rem;
  font-size: 0.8rem;
}

.tab-count {
  min-width: 20px;
  min-height: 18px;
  padding: 0 0.28rem;
  font-size: 0.66rem;
}

.matter-content .workspace-card {
  padding: 0.64rem;
}

.matter-content .workspace-card > header h2 {
  font-size: 0.98rem;
}

.matter-overview-editor > header {
  align-items: flex-start;
  gap: 0.75rem;
}

.matter-overview-editor > header p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.matter-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.72rem;
}

.matter-edit-grid label {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matter-edit-grid input,
.matter-edit-grid select,
.matter-edit-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.58rem 0.65rem;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  text-transform: none;
}

.matter-edit-grid textarea {
  resize: vertical;
  line-height: 1.45;
}

.matter-edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.matter-edit-actions small {
  color: var(--muted);
}

.matter-edit-actions button {
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0.58rem 0.95rem;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(14, 165, 198, 0.18);
}

.matter-edit-actions button:hover,
.matter-edit-actions button:focus-visible {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  outline: none;
}

.matter-content .timeline-item {
  min-height: 40px;
  padding: 0.38rem 0.5rem;
}

.matter-content .modern-row--compact {
  min-height: 34px;
  padding: 0.36rem 0.5rem;
  border-radius: 9px;
}

.matter-content .modern-row--compact .modern-row__main strong {
  font-size: 0.84rem;
}

.matter-content .modern-row--compact .modern-row__main small {
  font-size: 0.72rem;
}
/* ===== Dashboard + Calendar refinement (Block E, May 2026) ===== */
.page-header--premium h1 {
  font-size: 2rem;
}

.page-header--premium span {
  font-size: 0.95rem;
}

.kpi-grid {
  gap: 0.56rem;
}

.kpi-card {
  min-height: 120px;
  border-radius: 14px;
  padding: 0.64rem 0.74rem;
}

.kpi-card strong {
  font-size: 1.7rem;
}

.kpi-card span {
  font-size: 0.92rem;
}

.kpi-card small,
.kpi-card em {
  font-size: 0.76rem;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.dashboard-grid {
  gap: 0.56rem;
}

.workspace-card {
  border-radius: 14px;
  padding: 0.62rem;
}

.workspace-card header h2 {
  font-size: 1rem;
}

.workflow-feed,
.timeline-agenda,
.approval-center,
.quick-actions-grid {
  gap: 0.36rem;
}

.workflow-item {
  min-height: 38px;
  padding: 0.36rem 0.48rem;
}

.workflow-item__icon {
  min-width: 42px;
  font-size: 0.62rem;
}

.workflow-item__content strong {
  font-size: 0.82rem;
}

.workflow-item__content small,
.workflow-item__owner {
  font-size: 0.71rem;
}

.timeline-item {
  min-height: 40px;
  padding: 0.36rem 0.48rem;
  border-left-width: 3px;
}

.timeline-item__date strong {
  font-size: 0.8rem;
}

.timeline-item__date small,
.timeline-item__body small,
.timeline-item__body em {
  font-size: 0.71rem;
}

.timeline-item__body strong {
  font-size: 0.82rem;
}

.approval-card {
  padding: 0.52rem;
  border-radius: 10px;
}

.approval-card strong {
  font-size: 0.84rem;
}

.approval-card small {
  font-size: 0.71rem;
}

.approval-actions a {
  min-height: 28px;
  padding: 0.24rem 0.44rem;
  font-size: 0.71rem;
}

.quick-actions-grid a,
.quick-actions-grid button {
  min-height: 40px;
  border-radius: 11px;
  font-size: 0.82rem;
}

.calendar-legaldesk {
  gap: 0.7rem;
}

.calendar-legaldesk-sidebar,
.calendar-legaldesk-main {
  border-radius: 14px;
}

.calendar-day-plan,
.calendar-source-panel,
.calendar-legaldesk-board,
.calendar-legaldesk-list {
  border-radius: 12px;
}

.calendar-day-plan article {
  min-height: 54px;
  padding: 0.42rem 0.5rem;
}

.calendar-day-plan article strong {
  font-size: 0.8rem;
}

.calendar-day-plan article span,
.calendar-day-plan article small,
.calendar-day-plan p {
  font-size: 0.7rem;
}

.calendar-legaldesk-tools {
  gap: 0.45rem;
}

.calendar-type-switches button,
.calendar-view-buttons button {
  min-height: 30px;
  font-size: 0.72rem;
  padding: 0.26rem 0.5rem;
}

.calendar-legaldesk-weekdays span {
  min-height: 34px;
  font-size: 0.66rem;
}

.calendar-legaldesk-day {
  min-height: 110px;
  padding: 0.36rem;
}

.calendar-legaldesk-day > strong {
  font-size: 0.74rem;
}

.calendar-legaldesk-event {
  min-height: 24px;
  padding: 0.2rem 0.3rem;
  border-radius: 8px;
}

.calendar-legaldesk-event strong {
  font-size: 0.68rem;
}

.calendar-legaldesk-event span:not(.event-dot) {
  font-size: 0.64rem;
}

.calendar-list-day {
  padding: 0.42rem 0.52rem;
}

.calendar-list-day > strong {
  font-size: 0.78rem;
}

.calendar-event-popover {
  border-radius: 12px;
  padding: 0.62rem;
}

.calendar-event-popover h2 {
  font-size: 0.92rem;
}

.calendar-event-popover dt,
.calendar-event-popover dd,
.calendar-event-popover p,
.calendar-event-popover small {
  font-size: 0.72rem;
}
/* ===== Leads + Team + WorkQueue compact harmonization (Block F, May 2026) ===== */
.work-grid {
  gap: 0.56rem;
}

.work-panel {
  border-radius: 12px;
}

.work-panel header {
  padding: 0.52rem 0.62rem;
}

.work-panel h2 {
  font-size: 0.96rem;
}

.work-row {
  min-height: 38px;
  padding: 0.42rem 0.56rem;
  gap: 0.08rem;
}

.work-row strong {
  font-size: 0.84rem;
  line-height: 1.2;
}

.work-row span,
.work-row small,
.work-row em {
  font-size: 0.72rem;
}

.lead-workspace {
  gap: 0.6rem;
}

.lead-summary-row {
  min-height: 44px;
  padding: 0.48rem 0.56rem;
  border-radius: 10px;
}

.lead-summary-row strong {
  font-size: 0.84rem;
}

.lead-summary-row span,
.lead-summary-row small,
.lead-summary-row em {
  font-size: 0.72rem;
}

.lead-summary-row button {
  min-height: 26px;
  padding: 0.22rem 0.44rem;
  border-radius: 8px;
  font-size: 0.72rem;
}

.lead-decision-modal {
  gap: 0.85rem;
  font-size: 0.86rem;
}

.lead-decision-modal > header h2 {
  font-size: 1.08rem;
}

.lead-modal-grid {
  gap: 0.7rem;
}

.lead-modal-section {
  padding: 0.72rem;
  border-radius: 10px;
}

.compact-definition-list {
  gap: 0.55rem 0.75rem;
}

.compact-definition-list dt {
  font-size: 0.7rem;
}

.compact-definition-list dd {
  font-size: 0.8rem;
}

.lead-score-strip span,
.evidence-panel span {
  font-size: 0.72rem;
}

.lead-client-match article {
  padding: 0.46rem 0.52rem;
}

.lead-client-match strong {
  font-size: 0.84rem;
}

.lead-client-match span,
.lead-client-match small {
  font-size: 0.72rem;
}

.module-table--team header,
.module-table--team a {
  min-height: 40px;
  padding-top: 0.42rem;
  padding-bottom: 0.42rem;
  font-size: 0.82rem;
}

.module-table--team header {
  font-size: 0.66rem;
}

.module-table--team a strong {
  font-size: 0.86rem;
}

.module-table--team a small,
.module-table--team a span {
  font-size: 0.72rem;
}

.team-control-pane {
  padding: 0.7rem;
}

.team-side-section {
  margin-bottom: 0.58rem;
  padding: 0.5rem;
  border-radius: 10px;
}

.team-side-section header h3 {
  font-size: 0.84rem;
}

.compact-register {
  gap: 0.42rem;
}

.compact-register div {
  padding: 0.42rem 0.5rem;
}

.compact-register dt {
  font-size: 0.78rem;
}

.compact-register dd {
  font-size: 0.72rem;
}

.absence-wizard {
  gap: 0.75rem;
}

.wizard-steps {
  gap: 0.3rem;
}

.wizard-steps button {
  min-height: 30px;
  font-size: 0.74rem;
  padding: 0.24rem 0.44rem;
}

.wizard-panel {
  padding: 0.62rem;
}

.wizard-note {
  font-size: 0.74rem;
}

.wizard-collision-list div,
.wizard-collision-list em {
  padding: 0.36rem 0.42rem;
}

.wizard-collision-list strong {
  font-size: 0.8rem;
}

.wizard-collision-list span,
.wizard-collision-list small {
  font-size: 0.72rem;
}
/* ===== Admin + Integrations compact harmonization (Block G, May 2026) ===== */
.module-table--admin header {
  min-height: 38px;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
}

.module-table--admin > a,
.module-table--admin .module-table-row {
  min-height: 42px;
  padding-top: 0.42rem;
  padding-bottom: 0.42rem;
  font-size: 0.82rem;
}

.module-table--admin > a strong,
.module-table--admin .module-table-row strong {
  font-size: 0.86rem;
  line-height: 1.2;
}

.module-table--admin > a span,
.module-table--admin .module-table-row > span,
.module-table--admin > a small,
.module-table--admin .module-table-row small {
  font-size: 0.72rem;
}

.admin-tabs {
  min-height: 44px;
  gap: 0.22rem;
}

.admin-tabs a {
  min-height: 30px;
  padding: 0.34rem 0.56rem;
  font-size: 0.8rem;
}

.admin-tabs strong {
  min-width: 20px;
  min-height: 18px;
  padding: 0 0.28rem;
  font-size: 0.66rem;
}

.admin-summary-strip {
  gap: 0.42rem;
}

.admin-summary-strip div {
  padding: 0.5rem 0.56rem;
  border-radius: 10px;
}

.admin-summary-strip dt {
  font-size: 0.68rem;
}

.admin-summary-strip dd {
  font-size: 1.02rem;
}

.settings-grid {
  gap: 0.55rem;
}

.settings-grid label {
  gap: 0.24rem;
}

.settings-grid input,
.settings-grid select,
.settings-grid textarea {
  min-height: 34px;
  font-size: 0.8rem;
  padding: 0.34rem 0.48rem;
}

.admin-danger-grid {
  gap: 0.52rem;
}

.admin-danger-card {
  border-radius: 12px;
  padding: 0.62rem;
}

.admin-danger-card h3 {
  font-size: 1rem;
}

.admin-danger-card > p,
.admin-reset-list span,
.admin-confirm-form label span,
.demo-load-summary dt {
  font-size: 0.74rem;
}

.admin-reset-list div,
.demo-load-summary div {
  padding: 0.38rem 0.46rem;
}

.admin-reset-list strong,
.demo-load-summary dd {
  font-size: 0.84rem;
}

.audit-strip {
  gap: 0.55rem;
}

.audit-filters {
  gap: 0.4rem;
}

.audit-filters label span {
  font-size: 0.72rem;
}

.audit-row {
  min-height: 40px;
  padding: 0.4rem 0.5rem;
}

.audit-row strong {
  font-size: 0.84rem;
}

.audit-row span,
.audit-row small {
  font-size: 0.72rem;
}

.audit-module-pill,
.audit-severity {
  min-height: 22px;
  font-size: 0.68rem;
  padding: 0.16rem 0.42rem;
}

.module-filters button {
  min-height: 30px;
  font-size: 0.74rem;
  padding: 0.24rem 0.5rem;
}
/* ===== Cross-module interaction quality pass (Block H, May 2026) ===== */
.module-table > a,
.module-table-row,
.modern-row,
.workflow-item,
.timeline-item,
.work-row,
.invoice-row,
.activity-grid-row,
.workload-row,
.audit-row {
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.module-table > a:focus-visible,
.module-table-row:focus-visible,
.modern-row:focus-visible,
.workflow-item:focus-visible,
.timeline-item:focus-visible,
.work-row:focus-visible,
.invoice-row:focus-within,
.activity-grid-row:focus-within,
.workload-row:focus-visible,
.audit-row:focus-within {
  outline: 2px solid rgba(8, 145, 178, 0.45);
  outline-offset: 2px;
  border-color: #86c9db;
}

.module-table > a:hover,
.module-table-row:hover,
.work-row:hover,
.invoice-row:hover,
.activity-grid-row:hover,
.workload-row:hover,
.audit-row:hover {
  background: #f9fcff;
}

.status-pill,
.status-chip {
  letter-spacing: 0.01em;
}

.status-pill {
  border-width: 1px;
}

.row-actions--compact button,
.row-actions--compact a,
.invoice-row button,
.invoice-row > a,
.quick-actions-grid a,
.quick-actions-grid button,
.approval-actions a,
.work-panel header a,
.workspace-card header a {
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.row-actions--compact button:hover,
.row-actions--compact a:hover,
.invoice-row button:hover,
.invoice-row > a:hover,
.quick-actions-grid a:hover,
.quick-actions-grid button:hover,
.approval-actions a:hover,
.work-panel header a:hover,
.workspace-card header a:hover {
  border-color: #7ec8da;
  box-shadow: 0 2px 6px rgba(14, 116, 144, 0.12);
}

.registry-search,
.activity-search,
.task-search-group input,
.calendar-search input,
.module-shell input[type="search"] {
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.registry-search:focus,
.activity-search:focus,
.task-search-group input:focus,
.calendar-search input:focus,
.module-shell input[type="search"]:focus {
  border-color: #74bfd4;
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.14);
  outline: none;
}

.registry-tabs button,
.activity-filter-strip button,
.calendar-type-switches button,
.calendar-view-buttons button,
.module-filters button,
.admin-tabs a,
.case-tabs a,
.matter-tabs a {
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.registry-tabs button:focus-visible,
.activity-filter-strip button:focus-visible,
.calendar-type-switches button:focus-visible,
.calendar-view-buttons button:focus-visible,
.module-filters button:focus-visible,
.admin-tabs a:focus-visible,
.case-tabs a:focus-visible,
.matter-tabs a:focus-visible {
  outline: 2px solid rgba(8, 145, 178, 0.32);
  outline-offset: 1px;
}

.module-table > a strong,
.module-table-row strong,
.modern-row__main strong,
.workflow-item__content strong,
.timeline-item__body strong,
.work-row strong,
.workload-row strong,
.audit-row strong {
  color: #0f2440;
}

.module-table > a small,
.module-table-row small,
.modern-row__main small,
.modern-row__meta small,
.workflow-item__content small,
.workflow-item__owner,
.timeline-item__body small,
.timeline-item__body em,
.work-row small,
.work-row span,
.audit-row small,
.audit-row span {
  color: #5d6f83;
}
/* ===== Desktop scale tuning (Block I, May 2026) ===== */
@media (min-width: 1280px) and (max-width: 1599px) {
  :root {
    --font-size-base: 13px;
  }

  .topbar {
    min-height: 64px;
    padding: 0.44rem 0.7rem;
  }

  .topbar-search {
    max-width: 560px;
  }

  .workspace-header {
    padding-top: 0.72rem;
    padding-bottom: 0.52rem;
  }

  .workspace-header h1 {
    font-size: 2rem;
  }

  .workspace-card,
  .module-table,
  .work-panel,
  .detail-pane,
  .calendar-legaldesk-sidebar,
  .calendar-legaldesk-main {
    border-radius: 12px;
  }

  .module-table header,
  .module-table > a,
  .module-table-row,
  .modern-row,
  .workflow-item,
  .timeline-item,
  .work-row,
  .invoice-row,
  .activity-grid-row,
  .workload-row,
  .audit-row {
    min-height: 38px;
  }

  .kpi-card {
    min-height: 108px;
  }

  .kpi-card strong {
    font-size: 1.56rem;
  }

  .calendar-legaldesk-day {
    min-height: 100px;
  }
}
/* ===== Cases/Documents/Correspondence polish (Block H, May 2026) ===== */
.modern-list--cases .modern-row--case {
  min-height: 68px;
  border-radius: 10px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
}

.modern-list--cases .modern-row--case .modern-row__main strong {
  font-size: 0.85rem;
}

.modern-list--cases .modern-row--case .modern-row__meta {
  gap: 0.08rem;
  border-left: 1px solid var(--line-soft);
  padding-left: 0.6rem;
}

.modern-list--cases .modern-row__owner small {
  font-size: 0.7rem;
  white-space: nowrap;
}

.modern-list--documents .modern-row--doc {
  min-height: 62px;
  border-radius: 10px;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.05fr) auto;
}

.modern-list--documents .modern-row--doc .modern-row__main strong {
  font-size: 0.88rem;
}

.modern-list--documents .modern-row--doc .modern-row__main small,
.modern-list--documents .modern-row--doc .modern-row__meta span,
.modern-list--documents .modern-row--doc .modern-row__meta small {
  font-size: 0.71rem;
}

.modern-list--documents .modern-row--doc .modern-row__meta {
  border-left: 1px solid var(--line-soft);
  padding-left: 0.58rem;
}

.modern-list--documents .doc-meta-line {
  display: block;
  line-height: 1.22;
  font-size: 0.71rem;
}

.modern-list--documents .doc-meta-line strong {
  font-size: 0.69rem;
  color: var(--muted);
  font-weight: 600;
}

.modern-list--documents .doc-format {
  font-size: 0.64rem;
}

.correspondence-detail-modal {
  overflow-x: hidden;
}

.correspondence-detail-modal .lead-modal-grid {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr) minmax(0, 1.05fr);
}

.correspondence-detail-modal .lead-modal-section {
  min-width: 0;
}

.correspondence-detail-modal .correspondence-modal-actions,
.correspondence-detail-modal .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.correspondence-detail-modal .button-row .inline-form {
  min-width: 0;
}

.legal-drafts-panel {
  display: grid;
  gap: 1rem;
}

.legal-draft-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.7fr) auto;
  align-items: center;
}

.legal-draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.legal-draft-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #7dd3fc;
  border-radius: 10px;
  background: #eefbff;
  color: #075985;
  padding: 0.75rem 0.9rem;
}

.legal-draft-modal {
  overflow-x: hidden;
}

.legal-draft-modal .modal-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.legal-draft-modal label,
.legal-draft-modal textarea,
.legal-draft-modal select,
.legal-draft-modal input {
  min-width: 0;
}

.legal-draft-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  min-height: min(74vh, 820px);
}

.legal-draft-preview-shell {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.legal-draft-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.legal-draft-preview-grid iframe {
  width: 100%;
  min-height: min(70vh, 760px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.legal-draft-editor {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.legal-draft-editor textarea {
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  resize: vertical;
}

.legal-draft-editor details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fff;
}

.legal-draft-editor summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.templates-library,
.templates-library__panel,
.template-category,
.template-edit-modal {
  display: grid;
  gap: 1rem;
}

.templates-library__panel > header,
.template-category h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.template-category h3 span {
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--brand-dark);
  padding: 0.1rem 0.45rem;
  font-size: 0.78rem;
}

.template-library-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.45fr) auto;
}

.template-archive {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.template-archive-form {
  margin: 0 1.25rem 1.25rem;
}

@media (max-width: 1360px) {
  .modal--wide,
  .modal-card--wide {
    width: min(92vw, 980px);
  }

  .correspondence-detail-modal .lead-modal-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .correspondence-detail-modal .lead-modal-section--wide {
    grid-column: 1 / -1;
  }

  .legal-draft-preview-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1024px) {
  .modern-list--cases .modern-row--case,
  .modern-list--documents .modern-row--doc {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .modern-list--cases .modern-row--case .modern-row__meta,
  .modern-list--documents .modern-row--doc .modern-row__meta {
    border-left: 0;
    padding-left: 0;
  }
}
/* ===== Matter tabs compact register (Block I, May 2026) ===== */
.matter-content .modern-list {
  gap: 0.28rem;
}

.matter-content .modern-row,
.matter-content .workflow-item,
.matter-content .timeline-item {
  min-height: 34px;
  border-radius: 8px;
  padding: 0.32rem 0.46rem;
}

.matter-content .modern-row__main strong,
.matter-content .workflow-item__content strong,
.matter-content .timeline-item__body strong {
  font-size: 0.82rem;
  line-height: 1.2;
}

.matter-content .modern-row__main small,
.matter-content .modern-row__meta span,
.matter-content .modern-row__meta small,
.matter-content .workflow-item__content small,
.matter-content .workflow-item__owner,
.matter-content .timeline-item__date small,
.matter-content .timeline-item__body small {
  font-size: 0.7rem;
}

.matter-content .workflow-item__icon,
.matter-content .timeline-item__date {
  min-width: 44px;
}

.matter-content .status-pill {
  min-height: 20px;
  font-size: 0.68rem;
  padding: 0 0.45rem;
}

.matter-tabs .tab-count {
  margin-left: 0.2rem;
}
/* ===== Documents row quick actions (Block J, May 2026) ===== */
.modern-list--documents .modern-row__side {
  align-items: flex-end;
  gap: 0.2rem;
}

.doc-row-action {
  min-height: 20px;
  min-width: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfe;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.35rem;
}

.doc-row-action:hover,
.doc-row-action:focus-visible {
  border-color: rgba(8, 145, 178, 0.35);
  color: var(--brand-dark);
  background: #eef8fc;
}
/* ===== Correspondence register compact pass (Block K, May 2026) ===== */
.module-table--correspondence header {
  min-height: 34px;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
}

.module-table--correspondence .module-table-row {
  min-height: 36px;
  padding-top: 0.34rem;
  padding-bottom: 0.34rem;
  border-bottom: 1px solid #edf2f7;
}

.module-table--correspondence .module-table-row > span,
.module-table--correspondence .module-table-row strong,
.module-table--correspondence .module-table-row small {
  font-size: 0.72rem;
  line-height: 1.22;
}

.module-table--correspondence .module-table-row strong {
  font-size: 0.8rem;
}

.module-table--correspondence .status-pill {
  min-height: 20px;
  font-size: 0.67rem;
}

.module-table--correspondence .row-actions--compact button {
  min-height: 22px;
  font-size: 0.68rem;
  padding: 0 0.42rem;
}

.correspondence-process-note {
  gap: 0.22rem;
}

.correspondence-process-note strong {
  font-size: 0.76rem;
}

.correspondence-process-note span {
  min-height: 22px;
  font-size: 0.68rem;
}
/* ===== Clients + Reports + Calendar consistency pass (Block L, May 2026) ===== */
.module-table--clients header {
  min-height: 34px;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
}

.module-table--clients > a {
  min-height: 38px;
  padding-top: 0.36rem;
  padding-bottom: 0.36rem;
  border-bottom: 1px solid #edf2f7;
}

.module-table--clients > a strong {
  font-size: 0.82rem;
}

.module-table--clients > a span,
.module-table--clients > a small,
.module-table--clients > a em {
  font-size: 0.71rem;
  line-height: 1.2;
}

.action-link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 0 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(8, 145, 178, 0.3);
  color: var(--brand-dark);
  background: #edf8fc;
  font-style: normal;
  font-weight: 600;
}

.report-grid .workspace-section {
  padding: 0.56rem;
  border-radius: 12px;
}

.report-grid .workspace-section > header h2 {
  font-size: 0.94rem;
}

.report-grid .workspace-section > header a {
  min-height: 24px;
  font-size: 0.72rem;
}

.metric-grid {
  gap: 0.4rem;
}

.metric-card {
  min-height: 88px;
  padding: 0.54rem;
  border-radius: 10px;
}

.metric-card strong {
  font-size: 1.16rem;
}

.metric-card span {
  font-size: 0.79rem;
}

.metric-card small {
  font-size: 0.7rem;
}

.workload-table header {
  min-height: 32px;
  font-size: 0.62rem;
}

.workload-row {
  min-height: 36px;
  padding-top: 0.34rem;
  padding-bottom: 0.34rem;
}

.workload-row strong {
  font-size: 0.8rem;
}

.workload-row span,
.workload-row small {
  font-size: 0.71rem;
}

.calendar-legaldesk-sidebar {
  border-radius: 12px;
  padding: 0.5rem;
}

.calendar-day-plan article,
.calendar-source-option,
.calendar-list-day {
  min-height: 34px;
  border-radius: 8px;
}

.calendar-day-plan article strong,
.calendar-legaldesk-event strong {
  font-size: 0.78rem;
}

.calendar-day-plan article span,
.calendar-day-plan article small,
.calendar-legaldesk-event span {
  font-size: 0.69rem;
}

.calendar-legaldesk-event {
  min-height: 28px;
  padding: 0.24rem 0.34rem;
  border-radius: 8px;
}

.calendar-legaldesk-tools {
  padding: 0.36rem;
  border-radius: 10px;
}

.calendar-type-switches button,
.calendar-view-buttons button {
  min-height: 24px;
  font-size: 0.69rem;
}
/* ===== Billing + Activities compact pass (Block M, May 2026) ===== */
.module-table--costs header {
  min-height: 34px;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
}

.module-table--costs > a {
  min-height: 36px;
  padding-top: 0.32rem;
  padding-bottom: 0.32rem;
}

.module-table--costs > a strong {
  font-size: 0.8rem;
}

.module-table--costs > a span,
.module-table--costs > a small {
  font-size: 0.71rem;
}

.module-table--costs .inline-form select {
  min-height: 24px;
  font-size: 0.69rem;
}

.detail-pane {
  border-radius: 12px;
  padding: 0.6rem;
}

.detail-pane h2 {
  font-size: 0.96rem;
  margin-bottom: 0.38rem;
}

.detail-pane .compact-summary dd {
  font-size: 0.84rem;
}

.billing-rate-row {
  min-height: 30px;
  gap: 0.32rem;
}

.billing-rate-row strong {
  font-size: 0.74rem;
}

.billing-rate-row input,
.billing-rate-row select,
.billing-rate-row button {
  min-height: 24px;
  font-size: 0.69rem;
}

.invoice-row {
  min-height: 34px;
  padding-top: 0.32rem;
  padding-bottom: 0.32rem;
}

.invoice-row strong,
.invoice-row em {
  font-size: 0.78rem;
}

.invoice-row span,
.invoice-row small {
  font-size: 0.69rem;
}

.activity-grid-header {
  min-height: 32px;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
}

.activity-grid-row {
  min-height: 34px;
  padding-top: 0.28rem;
  padding-bottom: 0.28rem;
}

.activity-grid-row > span,
.activity-grid-row > a {
  font-size: 0.72rem;
}

.activity-description strong {
  font-size: 0.8rem;
}

.activity-description small {
  font-size: 0.69rem;
}

.activities-inbox h2 {
  font-size: 0.9rem;
}

.activity-inbox-card {
  min-height: 56px;
  border-radius: 10px;
  padding: 0.42rem 0.5rem;
}

.activity-inbox-card strong {
  font-size: 0.79rem;
}

.activity-inbox-card p,
.activity-inbox-card footer span {
  font-size: 0.68rem;
}.detail-pane-note {
  margin: 0.38rem 0 0.52rem;
  font-size: 0.71rem;
  line-height: 1.32;
  color: var(--muted);
}
/* ===== Cases/Documents/Correspondence final alignment (Block N, May 2026) ===== */
.modern-list--cases .modern-row--case .modern-row__side {
  align-items: flex-end;
  gap: 0.3rem;
  min-width: 170px;
}

.modern-list--cases .modern-row--case .status-pill {
  font-weight: 700;
}

.modern-list--cases .modern-row--case .modern-row__owner {
  gap: 0.24rem;
}

.modern-list--cases .modern-row--case:hover {
  border-color: rgba(8, 145, 178, 0.25);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.modern-list--documents .modern-row--doc:hover {
  border-color: rgba(8, 145, 178, 0.22);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.modern-list--documents .modern-row__side {
  align-items: flex-end;
  gap: 0.26rem;
}

.doc-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.doc-row-action {
  min-height: 20px;
  min-width: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfe;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.35rem;
}

button.doc-row-action {
  cursor: pointer;
}

button.doc-row-action:hover,
button.doc-row-action:focus-visible {
  border-color: rgba(8, 145, 178, 0.35);
  color: var(--brand-dark);
  background: #eef8fc;
}

.module-table--correspondence .module-table-row {
  grid-template-columns: 0.7fr 0.9fr 0.95fr 1.7fr 0.8fr 0.5fr;
}

.module-table--correspondence .module-table-row > span:nth-child(4) {
  font-size: 0.75rem;
}

.module-table--correspondence .module-table-row > span:nth-child(4) small {
  color: #718096;
}

.module-table--correspondence .module-table-row > span:nth-child(3) small a,
.module-table--correspondence .module-table-row > span:nth-child(4) small a {
  color: var(--brand-dark);
  font-weight: 600;
}

.module-table--correspondence .module-table-row:hover {
  background: #fcfeff;
  border-color: rgba(8, 145, 178, 0.22);
}
/* ===== Tasks kanban compact pass (Block O, May 2026) ===== */
.task-workspace {
  gap: 0.5rem;
}

.task-toolbar {
  padding: 0.42rem 0.5rem;
  border-radius: 10px;
}

.task-search-group input {
  min-height: 28px;
  font-size: 0.74rem;
}

.task-view-actions {
  gap: 0.2rem;
  font-size: 0.7rem;
}

.task-view-actions button {
  min-width: 24px;
  min-height: 24px;
}

.kanban-board {
  gap: 0.34rem;
  grid-template-columns: repeat(4, minmax(198px, 1fr));
}

.kanban-column {
  min-height: 58vh;
  border-radius: 9px;
}

.kanban-column header {
  min-height: 30px;
  padding: 0.34rem 0.44rem;
}

.kanban-column h2 {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.kanban-column header span {
  min-width: 24px;
  min-height: 18px;
  font-size: 0.64rem;
}

.kanban-dropzone {
  min-height: 54vh;
  padding: 0.24rem;
}

.task-card {
  min-height: 74px;
  margin-bottom: 0.28rem;
  padding: 0.34rem 0.38rem;
  border-radius: 8px;
}

.task-card__top strong {
  font-size: 0.78rem;
}

.task-card span,
.task-card small,
.task-date {
  font-size: 0.68rem;
  line-height: 1.2;
}

.task-card em {
  width: 16px;
  height: 16px;
  font-size: 0.52rem;
}
/* ===== Dashboard + Reports + Calendar final polish (Block P, May 2026) ===== */
.page-header--premium {
  padding: 0.72rem 0.82rem;
  border-radius: 14px;
}

.page-header--premium p {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.page-header--premium h1 {
  font-size: 2.05rem;
  margin: 0.15rem 0 0.25rem;
}

.page-header--premium span {
  font-size: 0.84rem;
}

.kpi-card {
  min-height: 110px;
  border-radius: 12px;
  padding: 0.58rem 0.68rem;
}

.kpi-card strong {
  font-size: 1.48rem;
}

.kpi-card span {
  font-size: 0.83rem;
}

.kpi-card small,
.kpi-card em {
  font-size: 0.7rem;
}

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 0.68rem;
}

.workflow-item {
  min-height: 34px;
  padding: 0.32rem 0.44rem;
  border-radius: 8px;
}

.workflow-item__icon {
  min-width: 38px;
  font-size: 0.58rem;
}

.workflow-item__content strong {
  font-size: 0.78rem;
}

.workflow-item__content small,
.workflow-item__owner {
  font-size: 0.69rem;
}

.timeline-agenda .timeline-item {
  min-height: 34px;
  border-radius: 8px;
  padding: 0.3rem 0.42rem;
}

.timeline-item__date strong {
  font-size: 0.76rem;
}

.timeline-item__date small,
.timeline-item__body small,
.timeline-item__body em {
  font-size: 0.67rem;
}

.timeline-item__body strong {
  font-size: 0.78rem;
}

.approval-card {
  padding: 0.44rem;
  border-radius: 8px;
}

.approval-card strong {
  font-size: 0.79rem;
}

.approval-card small {
  font-size: 0.69rem;
}

.approval-actions a {
  min-height: 24px;
  padding: 0.2rem 0.42rem;
  font-size: 0.68rem;
}

.quick-actions-grid a,
.quick-actions-grid button {
  min-height: 34px;
  font-size: 0.74rem;
}

.report-status-grid--compact {
  gap: 0.28rem;
}

.report-status-card--compact {
  min-height: 34px;
  padding: 0.34rem 0.44rem;
  border-radius: 9px;
}

.report-status-card--compact strong {
  font-size: 0.78rem;
}

.report-status-card--compact span,
.report-status-card--compact small {
  font-size: 0.68rem;
}

.report-stream-row {
  min-height: 34px;
  padding: 0.32rem 0.42rem;
  border-radius: 8px;
}

.report-stream-row strong {
  font-size: 0.78rem;
}

.report-stream-row span,
.report-stream-row small {
  font-size: 0.68rem;
}

.calendar-type-switches button,
.calendar-view-buttons button,
.calendar-today-link,
.calendar-nav-button,
.calendar-caret {
  min-height: 24px;
  font-size: 0.68rem;
}

.calendar-search input {
  min-height: 28px;
  font-size: 0.72rem;
}

.calendar-source-panel details > summary {
  min-height: 26px;
  font-size: 0.73rem;
}

.calendar-source-option strong {
  font-size: 0.72rem;
}

.calendar-source-option button {
  min-height: 20px;
  font-size: 0.66rem;
}
/* ===== Billing queue + Activities registry alignment (Block Q, May 2026) ===== */
.invoice-queue {
  margin: 0.45rem;
  border-radius: 9px;
  border: 1px solid #dce7f2;
  background: #fff;
}

.invoice-queue > header {
  min-height: 34px;
  padding: 0.34rem 0.48rem;
  border-bottom: 1px solid #e8f0f6;
}

.invoice-queue h2 {
  font-size: 0.8rem;
}

.invoice-queue > header span,
.invoice-actions strong {
  font-size: 0.68rem;
}

.invoice-row {
  border-bottom: 1px solid #edf2f7;
}

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

.invoice-row .status-pill {
  min-height: 20px;
  font-size: 0.66rem;
  font-style: normal;
}

.invoice-row button,
.invoice-row > a {
  min-height: 24px;
  font-size: 0.67rem;
  border-radius: 7px;
}

.activities-inbox,
.activities-register {
  border-radius: 12px;
}

.activity-filter-strip {
  min-height: 34px;
  padding: 0.24rem;
  border-radius: 9px;
  border: 1px solid #dce7f2;
  background: #fff;
}

.activity-filter-strip button {
  min-height: 24px;
  font-size: 0.68rem;
}

.activity-register-tools button {
  min-height: 22px;
  font-size: 0.66rem;
}

.activity-group-hint {
  min-height: 30px;
  border-radius: 8px;
  font-size: 0.69rem;
}

.activities-register-top {
  border-radius: 10px;
  padding: 0.36rem 0.46rem;
}
.modern-list--tasks {
  margin-top: 0.34rem;
  padding: 0.26rem;
  border: 1px solid #dce7f2;
  border-radius: 10px;
  background: #fff;
}

.modern-list--tasks .modern-row--compact {
  min-height: 32px;
}

.modern-list--tasks .modern-row__main {
  grid-template-columns: minmax(0, 1fr);
}

.modern-list--tasks .modern-row__main a {
  color: inherit;
  text-decoration: none;
}

.modern-list--tasks .modern-row__main a:hover {
  color: var(--brand);
}

.modern-list--tasks .modern-row__side .inline-form {
  margin: 0;
}

.modern-list--tasks .modern-row__side .danger-action {
  min-height: 28px;
  padding: 0.2rem 0.45rem;
  font-size: 0.68rem;
}
/* ===== Mobile cards for costs/correspondence (Block R, May 2026) ===== */
@media (max-width: 900px) {
  .module-table--correspondence,
  .module-table--costs {
    overflow: hidden;
  }

  .module-table--correspondence > header,
  .module-table--costs > header {
    display: none;
  }

  .module-table--correspondence .module-table-row,
  .module-table--costs > a {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.18rem;
    align-items: start;
    min-height: auto;
    padding: 0.48rem;
    border-radius: 10px;
    margin: 0.3rem;
    border: 1px solid #e3ebf3;
    background: #fff;
  }

  .module-table--correspondence .module-table-row > span,
  .module-table--correspondence .module-table-row > strong,
  .module-table--costs > a > span,
  .module-table--costs > a > strong {
    min-width: 0;
    white-space: normal;
  }

  .module-table--correspondence .row-actions,
  .module-table--costs .inline-form {
    justify-content: flex-start;
  }

  .module-table--costs .inline-form select,
  .module-table--correspondence .row-actions--compact button {
    min-height: 24px;
    font-size: 0.68rem;
  }

  .invoice-queue {
    margin: 0.34rem;
  }

  .invoice-row {
    grid-template-columns: 1fr;
    gap: 0.22rem;
    align-items: start;
  }

  .detail-pane {
    margin-top: 0.34rem;
  }
}
@media (max-width: 1100px) {
  .modern-list--tasks {
    margin-top: 0.22rem;
    padding: 0.2rem;
  }

  .modern-list--tasks .modern-row--compact {
    min-height: 30px;
    padding: 0.28rem 0.36rem;
  }

  .modern-list--tasks .modern-row__main strong {
    font-size: 0.76rem;
  }

  .modern-list--tasks .modern-row__main small,
  .modern-list--tasks .modern-row__meta span,
  .modern-list--tasks .modern-row__meta small {
    font-size: 0.66rem;
  }
}

/* Final pass: case task focus and denser registry rows */
.task-focus-banner {
  margin: 0;
  font-size: 0.72rem;
  color: var(--soft);
}

.modern-list--tasks .modern-row--task-focus {
  border-color: rgba(34, 150, 184, 0.45);
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.08), rgba(255, 255, 255, 0.98));
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.18);
}

.modern-list--cases .modern-row--case,
.modern-list--documents .modern-row--doc {
  min-height: 58px;
  padding-block: 0.58rem;
}

.modern-list--cases .modern-row--case .modern-row__main strong,
.modern-list--documents .modern-row--doc .modern-row__main strong {
  font-size: 0.84rem;
  line-height: 1.2;
}

.modern-list--cases .modern-row--case .modern-row__meta,
.modern-list--documents .modern-row--doc .modern-row__meta {
  gap: 0.1rem;
}

.modern-list--cases .modern-row--case .modern-row__meta span,
.modern-list--cases .modern-row--case .modern-row__meta small,
.modern-list--documents .modern-row--doc .modern-row__meta span,
.modern-list--documents .modern-row--doc .modern-row__meta small,
.modern-list--cases .modern-row--case .modern-row__main small,
.modern-list--documents .modern-row--doc .modern-row__main small {
  font-size: 0.72rem;
  line-height: 1.2;
}

/* Correspondence modal overflow hardening */
.modal-card--wide.correspondence-detail-modal {
  width: min(96vw, 1120px);
  max-width: 1120px;
  overflow-x: clip;
}

.correspondence-detail-modal .lead-modal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: start;
}

.correspondence-detail-modal .lead-modal-section,
.correspondence-detail-modal .lead-modal-section * {
  min-width: 0;
}

.correspondence-detail-modal .correspondence-modal-actions a,
.correspondence-detail-modal .button-row .inline-form button,
.correspondence-detail-modal .button-row .inline-form span {
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .modal-card--wide.correspondence-detail-modal {
    width: min(96vw, 980px);
  }

  .correspondence-detail-modal .lead-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .correspondence-detail-modal .lead-modal-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Registry tables compact pass: correspondence/clients/team/costs */
.module-table--registry,
.module-table--team,
.module-table--costs {
  border-radius: 12px;
  overflow: hidden;
}

.module-table--registry > header,
.module-table--team > header,
.module-table--costs > header {
  min-height: 34px;
  padding-block: 0.42rem;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
}

.module-table--registry .module-table-row,
.module-table--team .module-table-row,
.module-table--costs .module-table-row {
  min-height: 38px;
  padding-block: 0.4rem;
  align-items: center;
}

.module-table--registry .module-table-row > span,
.module-table--registry .module-table-row > strong,
.module-table--registry .module-table-row small,
.module-table--team .module-table-row > span,
.module-table--team .module-table-row > strong,
.module-table--team .module-table-row small,
.module-table--costs .module-table-row > span,
.module-table--costs .module-table-row > strong,
.module-table--costs .module-table-row small {
  font-size: 0.73rem;
  line-height: 1.22;
}

.module-table--registry .module-table-row strong,
.module-table--team .module-table-row strong,
.module-table--costs .module-table-row strong {
  font-size: 0.82rem;
  font-weight: 700;
}

.module-table--registry .status-pill,
.module-table--team .status-pill,
.module-table--costs .status-pill {
  min-height: 20px;
  font-size: 0.67rem;
  padding-inline: 0.45rem;
}

.module-table--registry .row-actions--compact button,
.module-table--team .row-actions--compact button,
.module-table--costs .row-actions--compact button {
  min-height: 23px;
  font-size: 0.68rem;
  padding-inline: 0.46rem;
}

.module-table--registry .module-table-row:hover,
.module-table--team .module-table-row:hover,
.module-table--costs .module-table-row:hover {
  background: #fbfdff;
}

/* Correspondence modal action layout stabilization */
.correspondence-detail-dialog {
  width: min(1180px, calc(100vw - 3rem));
  max-width: calc(100vw - 3rem);
  overflow: visible;
}

.correspondence-detail-dialog .modal-card--wide.correspondence-detail-modal {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  max-height: calc(100vh - 3rem);
  overflow-x: hidden;
  overflow-y: auto;
}

.correspondence-detail-dialog .lead-modal-grid {
  grid-template-columns: minmax(260px, 0.85fr) minmax(300px, 1fr) minmax(280px, 0.95fr);
  gap: 0.75rem;
}

.correspondence-detail-modal .correspondence-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 0.4rem;
}

.correspondence-detail-modal .correspondence-modal-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0.38rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbfe;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.correspondence-detail-modal .button-row {
  margin-top: 0.45rem;
  align-items: stretch;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 0.4rem;
}

.correspondence-detail-modal .button-row .inline-form {
  min-width: 0;
}

.correspondence-detail-modal .button-row .inline-form button,
.correspondence-detail-modal .button-row .inline-form label {
  width: 100%;
  justify-content: center;
  min-height: 30px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1180px) {
  .correspondence-detail-dialog {
    width: min(980px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
  }

  .correspondence-detail-dialog .lead-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .correspondence-detail-dialog .lead-modal-section--wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .correspondence-detail-dialog {
    width: calc(100vw - 1rem);
    max-width: calc(100vw - 1rem);
  }

  .correspondence-detail-dialog .modal-card--wide.correspondence-detail-modal {
    max-height: calc(100vh - 1rem);
  }

  .correspondence-detail-dialog .lead-modal-grid,
  .correspondence-detail-modal .correspondence-modal-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .correspondence-detail-modal .button-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Team and costs selector alignment (real markup targets) */
.module-table--team .team-row {
  min-height: 38px;
  padding-block: 0.4rem;
  align-items: center;
}

.module-table--team .team-row strong {
  font-size: 0.82rem;
}

.module-table--team .team-row small,
.module-table--team .team-row span {
  font-size: 0.73rem;
  line-height: 1.22;
}

.module-table--costs > a {
  min-height: 38px;
  padding-block: 0.4rem;
}

.module-table--costs > a > strong {
  font-size: 0.82rem;
}

.module-table--costs > a > span,
.module-table--costs > a small {
  font-size: 0.73rem;
  line-height: 1.22;
}

/* Section counters in case detail cards */
.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.2rem;
  margin-left: 0.34rem;
  padding: 0 0.34rem;
  border-radius: 999px;
  border: 1px solid #cfe3ef;
  background: #f2f9fd;
  color: var(--brand-dark);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

/* Final compacting: invoice queue + team side registries */
.invoice-queue {
  border-radius: 12px;
}

.invoice-queue > header {
  min-height: 36px;
  padding: 0.5rem 0.62rem;
}

.invoice-queue h2 {
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.invoice-row {
  min-height: 44px;
  padding: 0.42rem 0.62rem;
  gap: 0.48rem;
}

.invoice-row strong,
.invoice-row em {
  font-size: 0.8rem;
  line-height: 1.22;
}

.invoice-row span,
.invoice-row small {
  font-size: 0.71rem;
  line-height: 1.2;
}

.invoice-row .status-pill {
  min-height: 20px;
  font-size: 0.66rem;
}

.invoice-row button,
.invoice-row > a {
  min-height: 24px;
  font-size: 0.68rem;
  padding-inline: 0.5rem;
}

.team-side-section {
  border-radius: 10px;
}

.team-side-section header h3 {
  font-size: 0.82rem;
}

.compact-register {
  gap: 0.2rem;
}

.compact-register div {
  padding: 0.34rem 0.4rem;
  border-radius: 8px;
}

.compact-register dt {
  font-size: 0.76rem;
  line-height: 1.2;
}

.compact-register dd {
  font-size: 0.7rem;
  line-height: 1.18;
}

/* Desktop FHD compact pass for registry pages */
@media (min-width: 1200px) {
  .module-page {
    gap: 0.62rem;
  }

  .module-page .page-header {
    min-height: 82px;
    padding: 0.58rem 0.72rem;
    border-radius: 12px;
  }

  .module-page .page-header h1 {
    font-size: 2.02rem;
    line-height: 1.06;
  }

  .registry-modern {
    gap: 0.46rem;
  }

  .registry-modern__toolbar {
    min-height: 72px;
    padding: 0.5rem 0.62rem;
  }

  .registry-modern__controls,
  .registry-toolbar {
    min-height: 52px;
    padding: 0.4rem 0.54rem;
    border-radius: 10px;
  }

  .registry-modern__chips button,
  .registry-tabs button {
    min-height: 28px;
    font-size: 0.73rem;
    padding-inline: 0.54rem;
  }

  .registry-search {
    min-height: 32px;
    font-size: 0.76rem;
  }
}

/* Excel-like list heads for cases/documents */
.modern-list-head {
  display: grid;
  align-items: center;
  min-height: 28px;
  padding: 0 0.64rem;
  margin: 0.08rem 0 0.14rem;
  border: 1px solid #e7edf5;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modern-list-head--cases,
.modern-list-head--documents {
  grid-template-columns: 1.35fr 1fr 0.78fr;
}

.modern-list-head span:last-child {
  justify-self: end;
}

@media (max-width: 1024px) {
  .modern-list-head {
    display: none;
  }
}

.case-listing {
  --case-listing-blue: #0b93b8;
  --case-listing-blue-soft: #e3f8fe;
  --case-listing-line: #d8e5f0;
  --case-listing-soft: #f7fafd;
  --case-listing-muted: #63758b;
  --case-listing-green: #22b981;
  --case-listing-green-soft: #ddfbf0;
  --case-listing-amber: #b56a00;
  --case-listing-amber-soft: #fff3d7;
  --case-listing-red: #dc2626;
  --case-listing-red-soft: #fee2e2;
  --case-listing-title-size: 0.86rem;
  --case-listing-strong-size: 0.78rem;
  --case-listing-body-size: 0.68rem;
  --case-listing-chip-size: 0.66rem;
  gap: 0.78rem;
}

.case-listing-icons {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.case-listing svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.case-listing-card,
.case-listing-table {
  border: 1px solid var(--case-listing-line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(16, 42, 67, 0.06);
}

.case-listing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
}

.case-listing-controls {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  flex-wrap: wrap;
  padding: 0.78rem 1rem;
}

.case-listing-search {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: min(360px, 100%);
  min-height: 42px;
  border: 1px solid var(--case-listing-line);
  border-radius: 12px;
  background: #f8fbfe;
  color: #7c8ea4;
  padding: 0 0.82rem;
}

.case-listing-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
}

.case-listing-search input::placeholder {
  color: #7c8ea4;
}

.case-listing .registry-modern__chips {
  flex: 1 1 auto;
  align-items: center;
}

.case-listing .registry-modern__chips button {
  min-height: 30px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
}

.case-listing-owner-filter {
  min-width: 220px;
  min-height: 42px;
  border: 1px solid var(--case-listing-line);
  border-radius: 12px;
  background: #fff;
  color: #31425a;
  padding: 0 0.8rem;
  font: inherit;
  font-weight: 800;
}

.case-listing-table {
  overflow: hidden;
}

.case-listing-head,
.case-listing-row {
  display: grid;
  grid-template-columns:
    minmax(360px, 1.8fr)
    minmax(230px, 1.02fr)
    minmax(190px, 0.76fr)
    minmax(160px, 0.58fr)
    minmax(112px, 0.42fr);
  gap: 1rem;
  align-items: center;
}

.case-listing-head {
  min-height: 38px;
  padding: 0 1.15rem 0 1.75rem;
  background: var(--case-listing-soft);
  color: var(--case-listing-muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.case-listing-head span:last-child {
  justify-self: end;
}

.case-listing-row {
  position: relative;
  min-height: 68px;
  padding: 0.58rem 1.05rem 0.58rem 1.65rem;
  border-top: 1px solid #e7eff7;
  color: var(--text);
  text-decoration: none;
  background: #fff;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.case-listing-row:hover,
.case-listing-row:focus {
  background: #fbfeff;
  border-color: #cfe5ef;
}

.case-listing-strip {
  position: absolute;
  left: 0;
  top: 0.58rem;
  bottom: 0.58rem;
  width: 5px;
  border-radius: 0 4px 4px 0;
  background: var(--case-listing-green);
}

.case-listing-row.is-priority-medium .case-listing-strip {
  background: var(--case-listing-amber);
}

.case-listing-row.is-priority-high .case-listing-strip {
  background: var(--case-listing-red);
}

.case-listing-main,
.case-listing-owner {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  min-width: 0;
}

.case-listing-folder {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #d6e8ff;
  border-radius: 10px;
  background: #eaf4ff;
  color: #2d6cdf;
  flex: 0 0 auto;
}

.case-listing-folder svg {
  width: 18px;
  height: 18px;
}

.case-listing-main-text,
.case-listing-owner div,
.case-listing-next {
  min-width: 0;
}

.case-listing-title,
.case-listing-next strong,
.case-listing-owner strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-listing-title {
  font-size: var(--case-listing-title-size);
  letter-spacing: 0;
}

.case-listing-subline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  margin-top: 0.28rem;
  color: var(--case-listing-muted);
  font-size: var(--case-listing-body-size);
  white-space: nowrap;
  overflow: hidden;
}

.case-listing-reference,
.case-listing-tag {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  border: 1px solid var(--case-listing-line);
  border-radius: 999px;
  background: #f2f7fc;
  color: #4e6278;
  font-weight: 800;
  line-height: 1;
  font-size: var(--case-listing-chip-size);
  padding: 0.2rem 0.46rem;
  text-overflow: ellipsis;
}

.case-listing-reference {
  border-color: #cfe2ff;
  background: #eef6ff;
  color: #2451a6;
}

.case-listing-client {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-listing-client svg {
  width: 15px;
  height: 15px;
}

.case-listing-next {
  display: grid;
  gap: 0.24rem;
}

.case-listing-next strong {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--text);
  font-size: var(--case-listing-strong-size);
}

.case-listing-next strong svg {
  color: var(--case-listing-blue);
}

.case-listing-next small {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: var(--case-listing-amber);
  font-size: var(--case-listing-body-size);
  font-weight: 800;
}

.case-listing-next small svg {
  width: 16px;
  height: 16px;
  color: #7c8ea4;
}

.case-listing-avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #cfe2ff;
  border-radius: 999px;
  background: #e9f2ff;
  color: #1e4dd8;
  font-size: 0.62rem;
  font-weight: 950;
  flex: 0 0 auto;
}

.case-listing-owner strong {
  font-size: var(--case-listing-strong-size);
}

.case-listing-owner small {
  display: block;
  margin-top: 0.12rem;
  color: var(--case-listing-muted);
  font-size: var(--case-listing-body-size);
  font-weight: 700;
}

.case-listing-metrics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem 0.72rem;
  min-width: 0;
  color: #31425a;
  font-size: var(--case-listing-body-size);
  font-weight: 850;
}

.case-listing-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.case-listing-metrics svg {
  width: 16px;
  height: 16px;
  color: var(--case-listing-muted);
}

.case-listing-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.case-listing-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid #a7efd2;
  border-radius: 999px;
  background: var(--case-listing-green-soft);
  color: var(--case-listing-green);
  font-size: var(--case-listing-chip-size);
  font-weight: 950;
  line-height: 1;
  padding: 0 0.58rem;
  white-space: nowrap;
}

.case-listing-priority--medium {
  border-color: #ffd37a;
  background: var(--case-listing-amber-soft);
  color: var(--case-listing-amber);
}

.case-listing-priority--high {
  border-color: #fecaca;
  background: var(--case-listing-red-soft);
  color: var(--case-listing-red);
}

.case-listing-more {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #7c8ea4;
}

.case-listing-row:hover .case-listing-more,
.case-listing-row:focus .case-listing-more {
  background: #f2f7fc;
  color: #31425a;
}

.case-listing-table .empty-state {
  margin: 0;
  border-top: 1px solid #e7eff7;
  border-radius: 0;
}

@media (max-width: 1280px) {
  .case-listing-head,
  .case-listing-row {
    grid-template-columns:
      minmax(320px, 1.65fr)
      minmax(210px, 1fr)
      minmax(170px, 0.72fr)
      minmax(136px, 0.5fr)
      minmax(100px, 0.38fr);
    gap: 0.75rem;
  }
}

@media (max-width: 1120px) {
  .case-listing-head {
    display: none;
  }

  .case-listing-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.58rem;
    min-height: 0;
    padding: 0.9rem 1rem 0.9rem 1.45rem;
  }

  .case-listing-next,
  .case-listing-owner,
  .case-listing-metrics,
  .case-listing-side {
    padding-left: 48px;
  }

  .case-listing-side {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .case-listing-toolbar,
  .case-listing-controls {
    align-items: stretch;
    border-radius: 14px;
  }

  .case-listing-toolbar {
    display: grid;
  }

  .case-listing-search,
  .case-listing-owner-filter {
    width: 100%;
    min-width: 0;
  }

  .case-listing .registry-modern__chips {
    flex: 1 1 100%;
  }

  .case-listing-subline {
    flex-wrap: wrap;
    white-space: normal;
  }
}

html[data-theme="dark"] .case-listing-card,
html[data-theme="dark"] .case-listing-table,
html[data-theme="dark"] .case-listing-row {
  background: #0e1a24;
  border-color: rgba(148, 163, 184, 0.24);
  color: #eef6ff;
}

html[data-theme="dark"] .case-listing-head {
  background: #132231;
  color: #9fb0c3;
}

html[data-theme="dark"] .case-listing-row {
  border-top-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .case-listing-row:hover,
html[data-theme="dark"] .case-listing-row:focus {
  background: #132231;
}

html[data-theme="dark"] .case-listing-title,
html[data-theme="dark"] .case-listing-next strong,
html[data-theme="dark"] .case-listing-owner strong {
  color: #f8fbff;
}

html[data-theme="dark"] .case-listing-search,
html[data-theme="dark"] .case-listing-owner-filter,
html[data-theme="dark"] .case-listing-tag,
html[data-theme="dark"] .case-listing-more:hover {
  background: #0b1721;
  border-color: rgba(148, 163, 184, 0.28);
  color: #e6f2ff;
}

html[data-theme="dark"] .case-listing-search input {
  color: #e6f2ff;
}

html[data-theme="dark"] .case-listing-subline,
html[data-theme="dark"] .case-listing-owner small,
html[data-theme="dark"] .case-listing-metrics,
html[data-theme="dark"] .case-listing-client {
  color: #9fb0c3;
}

html[data-theme="dark"] .case-listing-reference {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.32);
  color: #bfdbfe;
}

/* Case details: enforce stable 3-column rhythm like Cases list */
.matter-content .modern-row--doc,
.matter-content .modern-row--team-member,
.matter-content .modern-row--compact {
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr) auto;
  column-gap: 0.72rem;
  align-items: center;
}

.matter-content .modern-row--doc .modern-row__meta,
.matter-content .modern-row--team-member .modern-row__meta,
.matter-content .modern-row--compact .modern-row__meta {
  border-left: 1px solid #e6edf6;
  padding-left: 0.66rem;
  margin-left: 0.06rem;
}

.matter-content .modern-row--doc .modern-row__side,
.matter-content .modern-row--team-member .modern-row__side,
.matter-content .modern-row--compact .modern-row__side {
  justify-self: end;
  align-items: flex-end;
  text-align: right;
}

.matter-content .modern-row--team-member .modern-row__main {
  display: flex;
  align-items: center;
  gap: 0.52rem;
}

.matter-content .modern-row--team-member .modern-row__main > div small,
.matter-content .modern-row--doc .modern-row__main small,
.matter-content .modern-row--compact .modern-row__main small {
  display: block;
  margin-top: 0.06rem;
}

@media (max-width: 1024px) {
  .matter-content .modern-row--doc,
  .matter-content .modern-row--team-member,
  .matter-content .modern-row--compact {
    grid-template-columns: 1fr;
    row-gap: 0.24rem;
  }

  .matter-content .modern-row--doc .modern-row__meta,
  .matter-content .modern-row--team-member .modern-row__meta,
  .matter-content .modern-row--compact .modern-row__meta {
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
  }

  .matter-content .modern-row--doc .modern-row__side,
  .matter-content .modern-row--team-member .modern-row__side,
  .matter-content .modern-row--compact .modern-row__side {
    justify-self: start;
    align-items: flex-start;
    text-align: left;
  }
}





.topbar-search-hints a:hover,
.topbar-search-hints a:focus {
  background: rgba(8, 145, 178, 0.16);
  color: #0b5e73;
}


.dashboard--mockup-card .page-header--premium {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-grid--mockup {
  grid-template-columns: 1.2fr 0.9fr 0.85fr;
  align-items: start;
}

.dashboard-side-stack {
  display: grid;
  gap: 0.8rem;
}

.workspace-card--calendar .mini-agenda {
  display: grid;
  gap: 0.55rem;
}

.workspace-card--calendar .mini-agenda a {
  display: grid;
  gap: 0.16rem;
  border: 1px solid #e9f0f7;
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
}

.workspace-card--calendar .mini-agenda a small {
  color: #64748b;
}

.dashboard-grid--mockup-secondary {
  grid-template-columns: 1fr 1fr 1fr;
}

.workspace-card--documents .documents-feed {
  display: grid;
  gap: 0.45rem;
}

.documents-feed__row {
  display: grid;
  gap: 0.1rem;
  border: 1px solid #e7eef6;
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
}

.documents-feed__row small {
  color: #64748b;
}

@media (max-width: 1400px) {
  .dashboard-grid--mockup {
    grid-template-columns: 1fr;
  }

  .dashboard-grid--mockup-secondary {
    grid-template-columns: 1fr;
  }
}

/* Dashboard mockup polish overrides */
.dashboard--mockup-card .kpi-card {
  background: linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

.dashboard--mockup-card .kpi-icon {
  font-weight: 800;
  letter-spacing: 0.04em;
}

.dashboard--mockup-card .status-pill.is-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.dashboard--mockup-card .status-pill.is-warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.dashboard--mockup-card .status-pill.is-success {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.dashboard--mockup-card .status-pill.is-info {
  background: #e0f2fe;
  color: #0c4a6e;
  border-color: #bae6fd;
}

.dashboard--mockup-card .documents-feed__row--empty {
  background: #f8fbff;
}

/* Case details alignment fix: team + documents rows */
.matter-team-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.matter-team-toolbar .registry-search {
  min-width: min(320px, 100%);
}

.matter-team-toolbar button {
  min-height: 36px;
  border: 1px solid rgba(14, 165, 196, 0.28);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 0.82rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(14, 165, 196, 0.16);
}

.matter-team-toolbar button.secondary-action {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: none;
}

.matter-team-toolbar button:hover,
.matter-team-toolbar button:focus-visible {
  filter: brightness(0.98);
  transform: translateY(-1px);
  outline: none;
}

.matter-team-row-button {
  width: 100%;
  border: 1px solid var(--line-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.matter-team-row-button:hover,
.matter-team-row-button:focus-visible {
  border-color: rgba(14, 165, 196, 0.35);
  background: #f0fbff;
  outline: none;
}

html[data-theme="dark"] .matter-team-row-button:hover,
html[data-theme="dark"] .matter-team-row-button:focus-visible {
  background: rgba(14, 165, 196, 0.14);
}

html[data-theme="dark"] .matter-team-toolbar button.secondary-action,
html[data-theme="dark"] .contacts-workspace .segmented-control button,
html[data-theme="dark"] .contacts-workspace .modern-row__side button {
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
}

html[data-theme="dark"] .matter-modal-summary--compact,
html[data-theme="dark"] .matter-modal-summary-note,
html[data-theme="dark"] .matter-new-contact-fields,
html[data-theme="dark"] .contacts-workspace .segmented-control button.is-active,
html[data-theme="dark"] .contacts-workspace .segmented-control button:hover,
html[data-theme="dark"] .contacts-workspace .segmented-control button:focus-visible,
html[data-theme="dark"] .contacts-workspace .modern-row__side button:hover,
html[data-theme="dark"] .contacts-workspace .modern-row__side button:focus-visible {
  background: rgba(14, 165, 196, 0.14);
}

.matter-modal-danger-form {
  display: flex;
  justify-content: flex-start;
  padding-top: 0.2rem;
  border-top: 1px solid var(--line-soft);
}

.matter-modal-summary {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.matter-modal-summary div {
  display: grid;
  gap: 0.12rem;
}

.matter-modal-summary dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matter-modal-summary dd {
  margin: 0;
  font-weight: 700;
}

.matter-modal-summary--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fbff;
}

.matter-modal-summary-note {
  margin: 0;
  padding: 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.matter-new-contact-fields {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fbff;
}

.matter-new-contact-fields legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.matter-contact-picker {
  display: grid;
  gap: 0.45rem;
}

.matter-contact-picker input[type="search"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.68rem 0.8rem;
  background: var(--surface);
  color: var(--ink);
}

.matter-contact-picker small {
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 760px) {
  .matter-modal-summary--compact {
    grid-template-columns: 1fr;
  }
}

.matter-content .modern-list--documents .modern-row--document,
.matter-content .modern-list--team .modern-row--team-member {
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.72rem;
}

.matter-content .modern-list--documents .modern-row__meta,
.matter-content .modern-list--team .modern-row__meta {
  border-left: 0;
  padding-left: 0;
  margin-left: 0;
  display: grid;
  gap: 0.1rem;
}

.matter-content .modern-list--documents .modern-row__side,
.matter-content .modern-list--team .modern-row__side {
  justify-self: end;
  align-self: center;
  text-align: right;
}

.matter-content .modern-list--documents .modern-row--document .modern-row__main,
.matter-content .modern-list--team .modern-row--team-member .modern-row__main {
  min-width: 0;
}

.matter-content .modern-list--team .modern-row--team-member .modern-row__main {
  display: flex;
  align-items: center;
  gap: 0.56rem;
}

@media (max-width: 1024px) {
  .matter-content .modern-list--documents .modern-row--document,
  .matter-content .modern-list--team .modern-row--team-member {
    grid-template-columns: 1fr;
    row-gap: 0.24rem;
    align-items: start;
  }

  .matter-content .modern-list--documents .modern-row__side,
  .matter-content .modern-list--team .modern-row__side {
    justify-self: start;
    text-align: left;
  }
}

/* Dashboard card: strict mock layout */
.dashboard--mockup-card .page-header p {
  color: #0f8fb2;
}

.dashboard--mockup-card .kpi-card {
  grid-template-areas:
    "icon"
    "label"
    "value"
    "meta"
    "cta";
  gap: 0.22rem;
}

.dashboard--mockup-card .kpi-card .kpi-icon {
  grid-area: icon;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.2rem;
}

.dashboard--mockup-card .kpi-card span { grid-area: label; }
.dashboard--mockup-card .kpi-card strong { grid-area: value; font-size: 2.65rem; font-weight: 800; }
.dashboard--mockup-card .kpi-card small { grid-area: meta; }
.dashboard--mockup-card .kpi-card em { grid-area: cta; }

.dashboard-grid--mockup {
  grid-template-columns: 1.15fr 1fr 0.95fr;
}

.dashboard--mockup-card .workflow-item {
  grid-template-columns: 24px minmax(0, 1fr) auto;
  border-radius: 12px;
}

.dashboard--mockup-card .workflow-item__icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #0f172a;
  background: #eef4fb;
}

.dashboard--mockup-card .workflow-item__icon.is-danger { background: #fee2e2; color: #b91c1c; }
.dashboard--mockup-card .workflow-item__icon.is-warning { background: #fef3c7; color: #92400e; }
.dashboard--mockup-card .workflow-item__icon.is-success { background: #dcfce7; color: #166534; }
.dashboard--mockup-card .workflow-item__icon.is-info { background: #e0f2fe; color: #0c4a6e; }

.dashboard--mockup-card .timeline-item {
  grid-template-columns: 92px minmax(0, 1fr) auto;
}

.dashboard--mockup-card .timeline-item__owner {
  align-self: center;
  justify-self: end;
  color: #0f766e;
  font-size: 0.92rem;
  font-style: normal;
  font-weight: 700;
}

.dashboard--mockup-card .approval-card {
  display: grid;
  gap: 0.25rem;
}

.dashboard--mockup-card .approval-actions {
  margin-top: 0.15rem;
}

.dashboard-grid--mockup-tail {
  grid-template-columns: 1fr 1fr;
}

.quick-actions-icons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
}

.quick-actions-icons a {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  border: 1px solid #e5edf6;
  border-radius: 14px;
  background: #fff;
  padding: 0.75rem 0.4rem;
}

.quick-actions-icons a span {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f1f7fd;
  color: #0c5e74;
  font-size: 1.05rem;
}

.quick-actions-icons a em {
  font-style: normal;
  color: #1e293b;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 1400px) {
  .dashboard-grid--mockup-tail,
  .quick-actions-icons {
    grid-template-columns: 1fr;
  }

  .quick-actions-icons a {
    grid-template-columns: 44px minmax(0, 1fr);
    justify-items: start;
    align-items: center;
  }

  .quick-actions-icons a em {
    text-align: left;
  }
}

/* Dashboard icon sheet crops */
.dashboard--mockup-card .kpi-card .kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent !important;
  color: transparent;
  overflow: hidden;
}

.dashboard--mockup-card .workflow-item {
  grid-template-columns: 32px minmax(0, 1fr) auto;
}

.dashboard--mockup-card .workflow-item__icon {
  width: 32px;
  height: 32px;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  color: transparent;
  overflow: hidden;
}

.dashboard--mockup-card .workflow-item__icon.is-danger,
.dashboard--mockup-card .workflow-item__icon.is-warning,
.dashboard--mockup-card .workflow-item__icon.is-success,
.dashboard--mockup-card .workflow-item__icon.is-info {
  background: transparent !important;
  color: transparent !important;
}

.dashboard--mockup-card .quick-actions-icons a > .mock-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: transparent !important;
  overflow: hidden;
}

.mock-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.mock-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mock-icon__dark {
  display: none !important;
}

.dashboard--mockup-card .documents-feed__row {
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
}

.dashboard--mockup-card .documents-feed__icon {
  width: 32px;
  height: 32px;
}

@media (prefers-color-scheme: dark) {
  .mock-icon__light {
    display: none !important;
  }

  .mock-icon__dark {
    display: block !important;
  }
}

/* Theme-aware icon assets and dark mode shell */
.mock-icon__light {
  display: block;
}

.mock-icon__dark {
  display: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08121a;
  --panel: #0e1a24;
  --panel-strong: #111f2b;
  --line: rgba(148, 163, 184, 0.22);
  --text: #eef6ff;
  --muted: #9fb0c3;
  --brand: #0ea5c8;
  --brand-dark: #38bdf8;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-main {
  background: radial-gradient(circle at 35% 0%, rgba(14, 165, 200, 0.14), transparent 32%), #08121a;
  color: var(--text);
}

html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .app-menu,
html[data-theme="dark"] .page-header,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .dashboard-card,
html[data-theme="dark"] .premium-card,
html[data-theme="dark"] .case-hero,
html[data-theme="dark"] .tab-strip,
html[data-theme="dark"] dialog,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .workflow-panel,
html[data-theme="dark"] .documents-feed,
html[data-theme="dark"] .quick-actions-icons,
html[data-theme="dark"] .timeline-panel,
html[data-theme="dark"] .approval-center,
html[data-theme="dark"] .ai-insights-card {
  background-color: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .app-menu,
html[data-theme="dark"] .topbar {
  background: rgba(8, 18, 26, 0.88);
  backdrop-filter: blur(18px);
}

html[data-theme="dark"] .app-title,
html[data-theme="dark"] .menu-item,
html[data-theme="dark"] .topbar-search input,
html[data-theme="dark"] .context-switcher select,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .profile-chip,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .work-timer,
html[data-theme="dark"] .topbar-icon-button {
  background-color: #0b1721;
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .menu-item.is-active,
html[data-theme="dark"] .menu-item:hover,
html[data-theme="dark"] .theme-toggle:hover {
  background: linear-gradient(135deg, rgba(14, 165, 200, 0.22), rgba(14, 165, 200, 0.08));
  color: #7dd3fc;
}

html[data-theme="dark"] .app-shell--v2 .menu-settings[open] {
  background: linear-gradient(180deg, rgba(15, 31, 43, 0.94), rgba(12, 25, 35, 0.86));
  box-shadow: inset 0 0 0 1px rgba(51, 65, 85, 0.78);
}

html[data-theme="dark"] .app-shell--v2 .menu-settings-body,
html[data-theme="dark"] .app-shell--v2 .menu-subgroup + .menu-subgroup {
  border-color: rgba(51, 65, 85, 0.78);
}

html[data-theme="dark"] .app-shell--v2 .menu-subgroup p {
  color: #8ea1b8;
}

html[data-theme="dark"] .app-shell--v2 .menu-subitem {
  color: #a8b6c7;
}

html[data-theme="dark"] .app-shell--v2 .menu-subitem::before {
  background: #475569;
}

html[data-theme="dark"] .app-shell--v2 .menu-subitem:hover,
html[data-theme="dark"] .app-shell--v2 .menu-subitem:focus-visible {
  background: rgba(14, 116, 144, 0.18);
  color: #7dd3fc;
}

html[data-theme="dark"] .app-shell--v2 .menu-subitem.is-active {
  background: rgba(14, 165, 200, 0.2);
  color: #a5f3fc;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.24);
}

html[data-theme="dark"] .topbar-search,
html[data-theme="dark"] .topbar-search-hints a,
html[data-theme="dark"] .status-pill,
html[data-theme="dark"] .filter-chip,
html[data-theme="dark"] .tab-link,
html[data-theme="dark"] .tab-button,
html[data-theme="dark"] .data-table,
html[data-theme="dark"] .data-list__row,
html[data-theme="dark"] .workflow-item,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .approval-card,
html[data-theme="dark"] .documents-feed__row,
html[data-theme="dark"] .quick-actions-icons a {
  background-color: #0b1721;
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] small,
html[data-theme="dark"] .page-header p,
html[data-theme="dark"] .workflow-item p,
html[data-theme="dark"] .timeline-item p,
html[data-theme="dark"] .documents-feed__row p,
html[data-theme="dark"] .menu-group p {
  color: var(--muted);
}

html[data-theme="dark"] .mock-icon__light {
  display: none;
}

html[data-theme="dark"] .mock-icon__dark {
  display: block;
}

.theme-toggle {
  min-height: 2.35rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 700;
  cursor: pointer;
}

/* Explicit app theme wins over browser/OS color preference. */
html:not([data-theme="dark"]) .mock-icon__light {
  display: block !important;
}

html:not([data-theme="dark"]) .mock-icon__dark {
  display: none !important;
}

html[data-theme="dark"] .mock-icon__light {
  display: none !important;
}

html[data-theme="dark"] .mock-icon__dark {
  display: block !important;
}

/* Dashboard dark theme polish */
html[data-theme="dark"] .dashboard--mockup-card .page-header,
html[data-theme="dark"] .dashboard--mockup-card .kpi-card,
html[data-theme="dark"] .dashboard--mockup-card .panel,
html[data-theme="dark"] .dashboard--mockup-card .approval-card,
html[data-theme="dark"] .dashboard--mockup-card .timeline-item,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item,
html[data-theme="dark"] .dashboard--mockup-card .documents-feed__row,
html[data-theme="dark"] .dashboard--mockup-card .quick-actions-icons a {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .dashboard--mockup-card .kpi-card strong,
html[data-theme="dark"] .dashboard--mockup-card h1,
html[data-theme="dark"] .dashboard--mockup-card h2,
html[data-theme="dark"] .dashboard--mockup-card h3,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item strong,
html[data-theme="dark"] .dashboard--mockup-card .timeline-item strong,
html[data-theme="dark"] .dashboard--mockup-card .approval-card strong,
html[data-theme="dark"] .dashboard--mockup-card .documents-feed__row strong {
  color: #f8fbff !important;
}

html[data-theme="dark"] .dashboard--mockup-card p,
html[data-theme="dark"] .dashboard--mockup-card small,
html[data-theme="dark"] .dashboard--mockup-card span,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item p,
html[data-theme="dark"] .dashboard--mockup-card .timeline-item p,
html[data-theme="dark"] .dashboard--mockup-card .documents-feed__row p {
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .dashboard--mockup-card a,
html[data-theme="dark"] .dashboard--mockup-card em {
  color: #38bdf8 !important;
}

html[data-theme="dark"] .dashboard--mockup-card .workspace-card,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card .approval-center,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card .timeline-agenda,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card .workflow-feed,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card .mini-agenda,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card .documents-feed {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .dashboard--mockup-card .workspace-card header,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card h2,
html[data-theme="dark"] .dashboard--mockup-card .workspace-card h3 {
  color: #f8fbff !important;
}

/* Dark theme for registry/detail surfaces */
html[data-theme="dark"] .registry-modern,
html[data-theme="dark"] .registry-modern__hero,
html[data-theme="dark"] .registry-modern__controls,
html[data-theme="dark"] .registry-modern__table-head,
html[data-theme="dark"] .registry-modern__card,
html[data-theme="dark"] .module-shell,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .modern-row,
html[data-theme="dark"] .compact-row,
html[data-theme="dark"] .detail-card,
html[data-theme="dark"] .case-detail-card,
html[data-theme="dark"] .document-detail-card,
html[data-theme="dark"] .data-table-wrap,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .doc-row,
html[data-theme="dark"] .document-row,
html[data-theme="dark"] .matter-row,
html[data-theme="dark"] .task-row {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .registry-modern__hero p,
html[data-theme="dark"] .registry-modern__card p,
html[data-theme="dark"] .modern-row small,
html[data-theme="dark"] .compact-row small,
html[data-theme="dark"] .doc-row small,
html[data-theme="dark"] .document-row small,
html[data-theme="dark"] .matter-row small,
html[data-theme="dark"] .task-row small {
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .registry-modern__hero h1,
html[data-theme="dark"] .registry-modern__hero h2,
html[data-theme="dark"] .registry-modern__card h2,
html[data-theme="dark"] .modern-row strong,
html[data-theme="dark"] .compact-row strong,
html[data-theme="dark"] .doc-row strong,
html[data-theme="dark"] .document-row strong,
html[data-theme="dark"] .matter-row strong,
html[data-theme="dark"] .task-row strong {
  color: #f8fbff !important;
}

/* Dark theme finishing pass for real registry markup. */
html[data-theme="dark"] .page-header--registry,
html[data-theme="dark"] .registry-modern__toolbar,
html[data-theme="dark"] .modern-list,
html[data-theme="dark"] .modern-list-head,
html[data-theme="dark"] .document-tab-panels,
html[data-theme="dark"] .document-profile-card,
html[data-theme="dark"] .document-preview-card,
html[data-theme="dark"] .document-context-card,
html[data-theme="dark"] .document-review-card,
html[data-theme="dark"] .matter-table,
html[data-theme="dark"] .matter-table-head,
html[data-theme="dark"] .matter-table-row,
html[data-theme="dark"] .module-table,
html[data-theme="dark"] .module-table header,
html[data-theme="dark"] .module-table-row,
html[data-theme="dark"] .workspace-section {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .modern-list-head,
html[data-theme="dark"] .matter-table-head,
html[data-theme="dark"] .module-table header,
html[data-theme="dark"] .document-register-table > header {
  background: #132231 !important;
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .registry-modern__title h2,
html[data-theme="dark"] .page-header--registry h1,
html[data-theme="dark"] .workspace-section h2,
html[data-theme="dark"] .document-profile-card h2,
html[data-theme="dark"] .document-preview-card h2,
html[data-theme="dark"] .document-context-card h2,
html[data-theme="dark"] .module-table-row strong,
html[data-theme="dark"] .matter-table-row strong {
  color: #f8fbff !important;
}

html[data-theme="dark"] .registry-modern__title p,
html[data-theme="dark"] .legaldesk-breadcrumb,
html[data-theme="dark"] .legaldesk-breadcrumb span,
html[data-theme="dark"] .module-table small,
html[data-theme="dark"] .matter-table-row span,
html[data-theme="dark"] .document-profile-card dt,
html[data-theme="dark"] .document-profile-card dd {
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .document-tool-button,
html[data-theme="dark"] .doc-row-action,
html[data-theme="dark"] .row-actions button,
html[data-theme="dark"] .inline-form select,
html[data-theme="dark"] .matter-tabs,
html[data-theme="dark"] .matter-tabs a {
  background: #0b1721 !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
  color: #e6f2ff !important;
}

html[data-theme="dark"] .matter-tabs a.is-active,
html[data-theme="dark"] .matter-tabs a:hover,
html[data-theme="dark"] .registry-modern__chips button.is-active,
html[data-theme="dark"] .registry-modern__chips button:hover {
  background: linear-gradient(135deg, rgba(14, 165, 200, 0.28), rgba(14, 165, 200, 0.11)) !important;
  border-color: rgba(34, 211, 238, 0.48) !important;
  color: #7dd3fc !important;
}

html[data-theme="dark"] .work-timer output,
html[data-theme="dark"] .work-timer button {
  background: #0b1721 !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
  color: #e6f2ff !important;
}

html[data-theme="dark"] .work-timer button[data-work-timer-toggle],
html[data-theme="dark"] .primary-action,
html[data-theme="dark"] .button-primary {
  background: linear-gradient(135deg, #0891b2, #06a7d0) !important;
  border-color: transparent !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .document-preview-card iframe {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.24);
}

/* Dark theme: matter details must not inherit light card fills. */
html[data-theme="dark"] .matter-workspace,
html[data-theme="dark"] .matter-hero,
html[data-theme="dark"] .matter-layout,
html[data-theme="dark"] .matter-content,
html[data-theme="dark"] .matter-content .workspace-card,
html[data-theme="dark"] .matter-content .modern-list,
html[data-theme="dark"] .matter-content .timeline-agenda,
html[data-theme="dark"] .matter-content .modern-row,
html[data-theme="dark"] .matter-content .timeline-item,
html[data-theme="dark"] .matter-actions-drawer,
html[data-theme="dark"] .matter-actions-drawer__panel {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .matter-hero h1,
html[data-theme="dark"] .matter-content h2,
html[data-theme="dark"] .matter-content h3,
html[data-theme="dark"] .matter-content .modern-row__main strong,
html[data-theme="dark"] .matter-content .timeline-item__body strong {
  color: #f8fbff !important;
}

html[data-theme="dark"] .matter-hero p,
html[data-theme="dark"] .matter-content .modern-row__main small,
html[data-theme="dark"] .matter-content .modern-row__meta,
html[data-theme="dark"] .matter-content .modern-row__meta span,
html[data-theme="dark"] .matter-content .modern-row__meta small,
html[data-theme="dark"] .matter-content .timeline-item__body small,
html[data-theme="dark"] .matter-content .timeline-item__body em,
html[data-theme="dark"] .task-focus-banner {
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .matter-content .timeline-item__date {
  background: #132231 !important;
  border: 1px solid rgba(148, 163, 184, 0.24) !important;
  color: #e6f2ff !important;
}

html[data-theme="dark"] .matter-content .timeline-item__date strong,
html[data-theme="dark"] .matter-content .timeline-item__date small {
  color: #e6f2ff !important;
}

html[data-theme="dark"] .matter-content .modern-row:hover,
html[data-theme="dark"] .matter-content .modern-row:focus-visible,
html[data-theme="dark"] .matter-content .timeline-item:hover {
  background: #132231 !important;
  border-color: rgba(34, 211, 238, 0.34) !important;
}

html[data-theme="dark"] .section-count,
html[data-theme="dark"] .tab-count {
  background: rgba(14, 165, 200, 0.18) !important;
  border-color: rgba(34, 211, 238, 0.34) !important;
  color: #7dd3fc !important;
}

html[data-theme="dark"] .status-pill.is-danger {
  background: rgba(239, 68, 68, 0.16) !important;
  border-color: rgba(248, 113, 113, 0.42) !important;
  color: #fecaca !important;
}

html[data-theme="dark"] .status-pill.is-warning {
  background: rgba(245, 158, 11, 0.16) !important;
  border-color: rgba(251, 191, 36, 0.42) !important;
  color: #fde68a !important;
}

html[data-theme="dark"] .status-pill.is-success {
  background: rgba(34, 197, 94, 0.14) !important;
  border-color: rgba(74, 222, 128, 0.38) !important;
  color: #bbf7d0 !important;
}

html[data-theme="dark"] .status-pill.is-info {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: rgba(96, 165, 250, 0.42) !important;
  color: #bfdbfe !important;
}

/* Dark theme: keep date/time chips and dense dashboard lists consistent. */
html[data-theme="dark"] .dashboard--mockup-card .timeline-item__date,
html[data-theme="dark"] .dashboard--mockup-card .mini-agenda time,
html[data-theme="dark"] .dashboard--mockup-card .calendar-day,
html[data-theme="dark"] .dashboard--mockup-card .calendar-strip span {
  background: #132231 !important;
  border: 1px solid rgba(148, 163, 184, 0.24) !important;
  color: #e6f2ff !important;
}

html[data-theme="dark"] .dashboard--mockup-card .timeline-item__date strong,
html[data-theme="dark"] .dashboard--mockup-card .timeline-item__date small,
html[data-theme="dark"] .dashboard--mockup-card .mini-agenda time strong,
html[data-theme="dark"] .dashboard--mockup-card .mini-agenda time small {
  color: #e6f2ff !important;
}

html[data-theme="dark"] .dashboard--mockup-card .workflow-item__icon.is-danger,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item__icon.is-warning,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item__icon.is-success,
html[data-theme="dark"] .dashboard--mockup-card .workflow-item__icon.is-info {
  background: #07131c !important;
  border-color: rgba(34, 211, 238, 0.28) !important;
  color: #38bdf8 !important;
}

html[data-theme="dark"] .matter-content .modern-row--doc,
html[data-theme="dark"] .matter-content .modern-row--team-member,
html[data-theme="dark"] .matter-content .modern-row--compact {
  background: #0b1721 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
}

/* Dark theme: the closed action drawer must not paint over the workspace. */
html[data-theme="dark"] .matter-actions-drawer {
  background: transparent !important;
  border-color: transparent !important;
  color: inherit !important;
}

html[data-theme="dark"] .matter-actions-drawer.is-open .matter-actions-drawer__backdrop {
  background: rgba(2, 8, 14, 0.62) !important;
}

html[data-theme="dark"] .matter-actions-drawer__panel {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

/* Dashboard document type icons stay brand-colored in both themes. */
html[data-theme="dark"] .dashboard--mockup-card .documents-feed__icon {
  width: 34px;
  height: 34px;
  padding: 0.22rem;
  border-radius: 10px;
  background: rgba(226, 232, 240, 0.06) !important;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .dashboard--mockup-card .documents-feed__icon .mock-icon__light {
  display: block !important;
}

html[data-theme="dark"] .dashboard--mockup-card .documents-feed__icon .mock-icon__dark {
  display: none !important;
}

/* Reports dark theme: keep KPI cards and operational tables on the dark surface. */
html[data-theme="dark"] .report-grid {
  background: #0e1a24 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .report-grid .metric-card,
html[data-theme="dark"] .report-grid .report-status-card,
html[data-theme="dark"] .report-grid .report-stream-row,
html[data-theme="dark"] .report-grid .workload-table,
html[data-theme="dark"] .report-grid .workload-row {
  background: #0b1721 !important;
  border-color: rgba(148, 163, 184, 0.22) !important;
  color: #eef6ff !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .report-grid .metric-card--high,
html[data-theme="dark"] .report-grid .workload-row--high {
  border-top-color: #f87171 !important;
  border-left-color: rgba(248, 113, 113, 0.55) !important;
}

html[data-theme="dark"] .report-grid .metric-card--medium,
html[data-theme="dark"] .report-grid .workload-row--medium {
  border-top-color: #fbbf24 !important;
  border-left-color: rgba(251, 191, 36, 0.55) !important;
}

html[data-theme="dark"] .report-grid .metric-card--low,
html[data-theme="dark"] .report-grid .workload-row--low {
  border-top-color: #4ade80 !important;
  border-left-color: rgba(74, 222, 128, 0.55) !important;
}

html[data-theme="dark"] .report-grid .metric-card strong,
html[data-theme="dark"] .report-grid .report-status-card strong,
html[data-theme="dark"] .report-grid .report-stream-row strong,
html[data-theme="dark"] .report-grid .workload-row strong,
html[data-theme="dark"] .report-grid .workload-row span {
  color: #f8fbff !important;
}

html[data-theme="dark"] .report-grid .metric-card span,
html[data-theme="dark"] .report-grid .metric-card small,
html[data-theme="dark"] .report-grid .report-status-card span,
html[data-theme="dark"] .report-grid .report-status-card small,
html[data-theme="dark"] .report-grid .report-stream-row span,
html[data-theme="dark"] .report-grid .report-stream-row small,
html[data-theme="dark"] .report-grid .workload-row small,
html[data-theme="dark"] .report-grid .workload-table header {
  color: #9fb0c3 !important;
}

html[data-theme="dark"] .report-grid .workspace-section > header {
  border-color: rgba(148, 163, 184, 0.22) !important;
}

html[data-theme="dark"] .report-grid .workspace-section > header a {
  color: #38bdf8 !important;
}

/* Matter FileService workspace */
.matter-files-shell {
  display: grid;
  gap: 1rem;
}

.matter-files-toolbar,
.matter-files-upload {
  align-items: end;
  background: color-mix(in srgb, var(--surface, #fff) 92%, var(--accent, #2563eb) 8%);
  border: 1px solid var(--border, #d8dee8);
  border-radius: 18px;
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

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

.matter-files-toolbar h3 {
  margin: .15rem 0;
}

.matter-files-inline-form,
.matter-files-upload {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}

.matter-files-inline-form input,
.matter-files-inline-form select,
.matter-files-upload input,
.matter-files-upload select {
  min-height: 2.5rem;
}

.matter-files-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(220px, .42fr) minmax(0, 1fr);
}

.matter-files-folders {
  display: grid;
  gap: .75rem;
}

.matter-folder-card {
  border: 1px solid var(--border, #d8dee8);
  border-radius: 18px;
  display: grid;
  gap: .55rem;
  padding: .9rem;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.matter-folder-card.is-drop-target {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 18px 38px rgba(37, 99, 235, .18);
  transform: translateY(-1px);
}

.matter-folder-card strong,
.matter-folder-card small {
  display: block;
}

.matter-folder-card__status {
  color: var(--muted, #64748b);
  margin: 0;
}

.matter-folder-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.matter-folder-card__actions form {
  margin: 0;
}

.matter-files-list .modern-row.is-dragging {
  opacity: .45;
}

.matter-file-row__icon[data-file-drag-handle],
.matter-tree-row__icon[data-folder-drag-handle] {
  cursor: grab;
  user-select: none;
}

.matter-file-row.is-dragging,
.matter-tree-row.is-dragging {
  opacity: .5;
}

.matter-file-row__icon[data-file-drag-handle]:active,
.matter-tree-row__icon[data-folder-drag-handle]:active {
  cursor: grabbing;
}

@media (max-width: 900px) {
  .matter-files-toolbar,
  .matter-files-grid {
    grid-template-columns: 1fr;
  }
}

/* Matter FileService workspace polish */
.matter-files-toolbar,
.matter-files-upload {
  background: linear-gradient(135deg, #f8fbff 0%, #edf7fb 100%);
  border-color: #d8e7f0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.matter-files-toolbar p {
  color: #0f8fa8;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  margin: 0;
  text-transform: uppercase;
}

.matter-files-toolbar small,
.matter-files-upload span,
.matter-files-list .modern-row__meta small {
  color: #64748b;
}

.matter-files-inline-form input,
.matter-files-inline-form select,
.matter-files-upload input,
.matter-files-upload select {
  background: #fff;
  border: 1px solid #cad9e8;
  border-radius: 12px;
  color: #172033;
  padding: .6rem .75rem;
}

.matter-files-upload {
  align-items: center;
  grid-template-columns: minmax(180px, .32fr) minmax(260px, 1fr) auto;
}

.matter-files-upload label {
  display: grid;
  gap: .35rem;
}

.matter-folder-card {
  background: #fff;
  box-shadow: 0 16px 34px rgba(15, 35, 64, .07);
  min-height: 170px;
}

.matter-folder-card__top {
  align-items: center;
  display: flex;
  gap: .75rem;
}

.matter-folder-icon {
  align-items: center;
  background: #eaf8fb;
  border-radius: 14px;
  color: #0f8fa8;
  display: inline-flex;
  height: 2.45rem;
  justify-content: center;
  width: 2.45rem;
}

.matter-folder-icon svg {
  height: 1.25rem;
  width: 1.25rem;
}

.matter-folder-card__actions button {
  background: #fff;
  border: 1px solid #cbdbea;
  border-radius: 11px;
  color: #172033;
  cursor: pointer;
  font-weight: 700;
  padding: .48rem .7rem;
}

.matter-folder-card__actions form:first-child button {
  background: #0898b3;
  border-color: #0898b3;
  color: #fff;
}

.matter-files-list {
  gap: .6rem;
}

.matter-files-list .modern-row {
  background: #fff;
  border-color: #dbe8f3;
  grid-template-columns: minmax(340px, 1.2fr) minmax(220px, .8fr) auto;
}

.matter-files-list .modern-row__main {
  align-items: center;
  display: flex;
  gap: .75rem;
  min-width: 0;
}

.matter-files-list .modern-row__main > div,
.matter-files-list .modern-row__meta {
  min-width: 0;
}

.matter-files-list .modern-row strong,
.matter-files-list .modern-row small,
.matter-files-list .modern-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .matter-files-toolbar,
html[data-theme="dark"] .matter-files-upload,
html[data-theme="dark"] .matter-folder-card,
html[data-theme="dark"] .matter-files-list .modern-row {
  background: #121b2b;
  border-color: rgba(148, 163, 184, .24);
}

html[data-theme="dark"] .matter-files-inline-form input,
html[data-theme="dark"] .matter-files-inline-form select,
html[data-theme="dark"] .matter-files-upload input,
html[data-theme="dark"] .matter-files-upload select,
html[data-theme="dark"] .matter-folder-card__actions button {
  background: #0d1524;
  border-color: rgba(148, 163, 184, .28);
  color: #eef6ff;
}

@media (max-width: 900px) {
  .matter-files-upload,
  .matter-files-list .modern-row {
    grid-template-columns: 1fr;
  }
}

/* Matter file manager */
.matter-files-shell--manager {
  gap: 1rem;
}

.matter-files-toolbar--manager {
  align-items: center;
  background: linear-gradient(135deg, rgba(9, 148, 179, 0.1), rgba(236, 249, 252, 0.92));
}

.matter-file-manager {
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  gap: 1rem;
  min-height: 520px;
}

.matter-file-tree,
.matter-file-browser,
.matter-folder-panel {
  border: 1px solid var(--border-soft);
  border-radius: 1.4rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 48px rgba(28, 45, 78, 0.08);
}

.matter-file-tree {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.matter-file-tree header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 1.05rem;
  border-bottom: 1px solid var(--border-soft);
}

.matter-file-tree__items {
  display: grid;
  gap: 0.15rem;
  padding: 0.45rem;
  overflow: auto;
}

.matter-tree-row {
  display: grid;
  grid-template-columns: 0.9rem 1.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: 0;
  border-radius: 0.95rem;
  padding: 0.72rem 0.7rem 0.72rem calc(0.75rem + (var(--depth, 0) * 1.05rem));
  color: var(--text-main);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.matter-tree-row.is-tree-hidden {
  display: none;
}

.matter-tree-row:hover,
.matter-tree-row.is-active,
.matter-tree-row.is-drop-target {
  background: rgba(9, 148, 179, 0.12);
}

.matter-tree-row.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.matter-tree-row.is-archive,
.matter-tree-row.is-system {
  margin-top: 0.35rem;
  color: var(--text-muted);
  background: rgba(107, 123, 145, 0.09);
  opacity: 0.72;
}

.matter-tree-row__toggle {
  display: inline-grid;
  place-items: center;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.matter-tree-row.has-children .matter-tree-row__toggle {
  background: rgba(9, 148, 179, 0.08);
  color: var(--accent-strong);
}

.matter-tree-row.has-children .matter-tree-row__toggle:hover {
  background: rgba(9, 148, 179, 0.16);
}

.matter-tree-row.is-collapsed .matter-tree-row__toggle {
  transform: rotate(0deg);
}

.matter-tree-row__icon svg,
.matter-folder-chip svg {
  width: 1.1rem;
  height: 1.1rem;
}

.matter-tree-row__label {
  display: grid;
  min-width: 0;
}

.matter-tree-row__label strong,
.matter-tree-row__label small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-tree-row__badges {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  justify-self: end;
}

.matter-tree-row__ai,
.matter-tree-row__status {
  border-radius: 999px;
  padding: 0.16rem 0.43rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
  border: 1px solid transparent;
}

.matter-tree-row__status {
  background: rgba(11, 169, 196, 0.12);
  color: var(--accent-strong);
}

.matter-file-browser {
  display: grid;
  gap: 0.9rem;
  padding: 0.9rem;
  align-content: start;
}

.matter-files-upload--current {
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto;
}

.matter-folder-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.matter-folder-panel[hidden] {
  display: none;
}

.matter-folder-panel.is-archive {
  background: linear-gradient(135deg, rgba(107, 123, 145, 0.09), rgba(255, 255, 255, 0.76));
}

.matter-folder-panel__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 1rem;
}

.matter-folder-panel__header p,
.matter-files-toolbar--manager p {
  margin: 0;
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.matter-folder-panel__header h3 {
  margin: 0.15rem 0;
}

.matter-folder-panel__status,
.matter-folder-panel__actions,
.matter-file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.matter-zip-import-status {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.matter-zip-import-status__item {
  max-width: min(100%, 42rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-zip-import-status__item--queued,
.matter-zip-import-status__item--running {
  background: #dbeafe;
  color: #1d4ed8;
}

.matter-zip-import-status__item--failed {
  background: #fee2e2;
  color: #b91c1c;
}

.matter-folder-panel__actions button,
.matter-file-actions button,
.matter-folder-chip {
  border: 1px solid var(--border-soft);
  border-radius: 0.8rem;
  padding: 0.52rem 0.72rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 700;
  cursor: pointer;
}

.matter-folder-panel__actions button:disabled,
.matter-file-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.matter-file-actions .danger-action {
  color: #a93838;
  border-color: rgba(169, 56, 56, 0.28);
}

.matter-folder-children {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.matter-folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(9, 148, 179, 0.1);
}

.matter-files-list--manager .modern-row {
  grid-template-columns: minmax(0, 1.25fr) minmax(160px, 0.55fr) auto;
}

html[data-theme="dark"] .matter-files-toolbar--manager,
html[data-theme="dark"] .matter-file-tree,
html[data-theme="dark"] .matter-file-browser,
html[data-theme="dark"] .matter-folder-panel {
  background: rgba(19, 27, 42, 0.84);
}

html[data-theme="dark"] .matter-tree-row:hover,
html[data-theme="dark"] .matter-tree-row.is-active,
html[data-theme="dark"] .matter-tree-row.is-drop-target {
  background: rgba(69, 191, 214, 0.15);
}

@media (max-width: 980px) {
  .matter-file-manager,
  .matter-folder-panel__header,
  .matter-files-list--manager .modern-row {
    grid-template-columns: 1fr;
  }

  .matter-folder-panel__status,
  .matter-folder-panel__actions,
  .matter-file-actions {
    justify-content: flex-start;
  }
}

.matter-folder-panel__actions[hidden],
.matter-file-actions[hidden],
.matter-files-upload--current[hidden] {
  display: none !important;
}

.matter-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 210px;
  padding: 0.35rem;
  border: 1px solid rgba(120, 145, 170, 0.34);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 70px rgba(16, 31, 55, 0.22);
}

.matter-context-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0.65rem;
  padding: 0.62rem 0.75rem;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.matter-context-menu button:hover:not(:disabled) {
  background: rgba(9, 148, 179, 0.12);
}

.matter-context-menu button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.matter-context-menu .danger-action {
  color: #a93838;
}
.matter-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(150px, auto) auto;
  gap: 0.85rem;
  align-items: center;
  min-height: 58px;
  border: 1px solid rgba(119, 151, 180, 0.24);
  border-radius: 0.9rem;
  padding: 0.55rem 0.7rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 252, 255, 0.9)), var(--surface);
  box-shadow: 0 10px 28px rgba(32, 56, 88, 0.05);
  cursor: default;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.matter-file-row:hover {
  border-color: rgba(9, 148, 179, 0.35);
  box-shadow: 0 16px 34px rgba(32, 56, 88, 0.1);
  transform: translateY(-1px);
}

.matter-file-row.is-dragging {
  opacity: 0.58;
}

.matter-file-row__icon {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border: 1px solid rgba(249, 115, 22, 0.22);
  border-radius: 0.7rem;
  background: #fff7ed;
  color: #ea580c;
}

.matter-file-row__icon svg {
  width: 1.05rem;
  height: 1.05rem;
}

.matter-file-row__body {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.matter-file-row__body strong,
.matter-file-row__body small,
.matter-file-row__body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-file-row__body strong {
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 900;
}

.matter-file-row__body small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.matter-file-row__body span,
.matter-file-row__facts small {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.matter-file-row__ai-states {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.12rem;
}

.matter-file-row__body .matter-file-row__ai-states {
  overflow: visible;
  white-space: normal;
}

.matter-file-row__ai-states .status-pill {
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.16rem 0.42rem;
}

.matter-file-row__facts {
  display: grid;
  gap: 0.08rem;
  justify-items: end;
  min-width: 0;
}

.matter-file-row__facts span {
  color: var(--text-main);
  font-weight: 850;
}

.matter-file-row__type span {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.matter-file-upload-popover {
  position: fixed;
  inset: 0;
  z-index: 1150;
  display: grid;
  place-items: start center;
  padding-top: min(18vh, 9rem);
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(3px);
}

.matter-file-upload-popover[hidden] {
  display: none;
}

.matter-file-upload-popover form {
  width: min(520px, calc(100vw - 2rem));
  border: 1px solid rgba(9, 148, 179, 0.28);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 90px rgba(16, 31, 55, 0.24);
  padding: 1rem;
}

.matter-file-upload-popover header,
.matter-file-upload-popover footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.matter-file-upload-popover header p {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matter-file-upload-popover header button,
.matter-file-upload-popover footer button {
  border: 1px solid var(--border-soft);
  border-radius: 0.8rem;
  padding: 0.55rem 0.85rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-main);
  font-weight: 800;
}

.matter-file-upload-drop {
  display: grid;
  place-items: center;
  min-height: 160px;
  margin: 1rem 0;
  border: 2px dashed rgba(9, 148, 179, 0.4);
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(9, 148, 179, 0.08), rgba(255, 255, 255, 0.9));
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
}

.matter-file-upload-drop.is-drop-target {
  border-color: var(--accent);
  background: rgba(9, 148, 179, 0.16);
}

.matter-file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.matter-file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.matter-file-picker__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 2.3rem;
  border-radius: 999px;
  padding: 0.58rem 1rem;
  border: 1px solid rgba(9, 148, 179, 0.28);
  background: #0891b2;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(9, 148, 179, 0.22);
}

.matter-file-picker__button--secondary {
  background: #ffffff;
  color: #0f766e;
  box-shadow: none;
}

.matter-file-picker__summary {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.matter-upload-progress {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  margin: 0.75rem 0;
  border: 1px solid rgba(9, 148, 179, 0.24);
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
  background: rgba(240, 253, 250, 0.9);
}

.matter-upload-progress[hidden] {
  display: none;
}

.matter-upload-progress div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.matter-upload-progress strong {
  color: var(--accent-strong);
}

.matter-upload-progress progress {
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
}

.matter-upload-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
}

.matter-upload-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: #0891b2;
}

.matter-upload-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: #0891b2;
}

form.is-uploading {
  cursor: progress;
}

.matter-file-upload-drop:focus-within .matter-file-picker__button {
  outline: 3px solid rgba(9, 148, 179, 0.24);
  outline-offset: 2px;
}

html[data-theme="dark"] .matter-context-menu,
html[data-theme="dark"] .matter-file-upload-popover form {
  background: rgba(19, 27, 42, 0.98);
  border-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .matter-file-upload-drop {
  background: rgba(9, 148, 179, 0.11);
}

html[data-theme="dark"] .matter-file-picker__button--secondary {
  border-color: rgba(45, 212, 191, 0.25);
  background: rgba(15, 23, 42, 0.88);
  color: #5eead4;
}

html[data-theme="dark"] .matter-upload-progress {
  border-color: rgba(45, 212, 191, 0.22);
  background: rgba(15, 23, 42, 0.78);
}
html[data-theme="dark"] .matter-file-row {
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(19, 27, 42, 0.9);
}

html[data-theme="dark"] .matter-file-row__icon {
  border-color: rgba(251, 146, 60, 0.28);
  background: rgba(251, 146, 60, 0.12);
  color: #fdba74;
}

.matter-file-preview-modal::backdrop {
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
}

.matter-file-preview-modal {
  width: min(1440px, calc(100vw - 2rem));
  max-width: none;
}

.matter-file-preview-modal.is-wide {
  width: calc(100vw - 1rem);
}

.matter-file-preview-card {
  width: 100%;
  height: min(92vh, 1040px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
}

.matter-file-preview-modal.is-wide .matter-file-preview-card {
  height: calc(100vh - 1rem);
}

.matter-file-preview-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.matter-file-preview-card header > div:first-child {
  min-width: 0;
}

.matter-file-preview-card h2,
.matter-file-preview-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-file-preview-actions {
  display: inline-flex;
  flex-shrink: 0;
  gap: 0.35rem;
  align-items: center;
}

.matter-file-preview-actions a,
.matter-file-preview-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 2.35rem;
  min-height: 2.35rem;
  border: 1px solid rgba(9, 148, 179, 0.24);
  border-radius: 0.75rem;
  background: #f8fdff;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.matter-file-preview-actions [data-file-preview-close] {
  min-width: auto;
  padding-inline: 0.8rem;
  background: #102033;
  color: #fff;
}

.matter-file-preview-actions a:hover,
.matter-file-preview-actions button:hover {
  border-color: rgba(9, 148, 179, 0.44);
  box-shadow: 0 8px 22px rgba(32, 56, 88, 0.1);
}

.matter-file-preview-card iframe {
  width: 100%;
  height: 100%;
  min-height: 76vh;
  border: 0;
  background: #fff;
}

@media (max-width: 760px) {
  .matter-file-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .matter-file-row__facts {
    grid-column: 2 / -1;
    justify-items: start;
  }
}

.ai-readiness-pill--ready {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: rgba(22, 101, 52, 0.24) !important;
}

.ai-readiness-pill--partial {
  background: #ffedd5 !important;
  color: #9a3412 !important;
  border-color: rgba(154, 52, 18, 0.24) !important;
}

.ai-readiness-pill--running {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
  border-color: rgba(29, 78, 216, 0.28) !important;
}

.ai-readiness-pill--missing {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: rgba(153, 27, 27, 0.24) !important;
}

.ai-readiness-pill--empty,
.ai-readiness-pill--archive,
.ai-readiness-pill--system {
  background: rgba(107, 123, 145, 0.13) !important;
  color: var(--text-muted) !important;
  border-color: rgba(107, 123, 145, 0.22) !important;
}


.matter-ai-status-card {
  width: min(920px, calc(100vw - 2rem));
  max-height: min(82vh, 860px);
  overflow: auto;
}

.matter-ai-status-card .modern-row--compact {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr);
}

.matter-ai-status-card .modern-row__main,
.matter-ai-status-card .modern-row__meta {
  min-width: 0;
}

.matter-ai-status-card .modern-row__main small,
.matter-ai-status-card .modern-row__meta span,
.matter-ai-status-card .modern-row__meta small {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 760px) {
  .matter-ai-status-card .modern-row--compact {
    grid-template-columns: 1fr;
  }
}

.matter-ai-status-modal {
  width: min(1180px, calc(100vw - 4rem));
  max-width: none;
  padding: 0;
}

.matter-ai-status-modal::backdrop {
  background: rgba(15, 23, 42, 0.34);
}

.matter-ai-status-card {
  box-sizing: border-box;
  width: 100% !important;
  max-width: none;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.matter-ai-status-card .modern-list {
  overflow: visible;
}

.matter-ai-status-card .modern-row--compact {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px) !important;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.matter-ai-status-card .modern-row__main,
.matter-ai-status-card .modern-row__meta {
  min-width: 0;
  max-width: 100%;
}

.matter-ai-status-card .modern-row__meta {
  justify-items: start;
  text-align: left;
}

.matter-ai-status-card .modern-row__main strong,
.matter-ai-status-card .modern-row__main small,
.matter-ai-status-card .modern-row__meta span,
.matter-ai-status-card .modern-row__meta small {
  white-space: normal !important;
  overflow-wrap: break-word;
  word-break: normal;
}

@media (max-width: 780px) {
  .matter-ai-status-modal {
    width: calc(100vw - 1rem);
  }

  .matter-ai-status-card .modern-row--compact {
    grid-template-columns: 1fr !important;
  }
}

/* Matter AI status modal - operational summary first, technical history second. */
.matter-ai-status-body {
  display: grid;
  gap: 0.75rem;
}

.matter-ai-current-status {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
  border: 1px solid rgba(14, 116, 144, 0.18);
  border-radius: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(236, 254, 255, 0.92), rgba(255, 255, 255, 0.98));
}

.matter-ai-current-status--running,
.matter-ai-current-status--queued {
  border-color: rgba(2, 132, 199, 0.28);
  background: linear-gradient(135deg, rgba(224, 242, 254, 0.96), rgba(255, 255, 255, 0.98));
}

.matter-ai-current-status--done {
  border-color: rgba(22, 163, 74, 0.24);
  background: linear-gradient(135deg, rgba(220, 252, 231, 0.92), rgba(255, 255, 255, 0.98));
}

.matter-ai-current-status--failed {
  border-color: rgba(220, 38, 38, 0.26);
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.88), rgba(255, 255, 255, 0.98));
}

.matter-ai-current-status__main,
.matter-ai-current-status__meta,
.matter-ai-current-status__meta div {
  min-width: 0;
}

.matter-ai-current-status__main p,
.matter-ai-current-status__meta dt {
  margin: 0 0 0.2rem;
  color: #0e7490;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.matter-ai-current-status__main h3 {
  margin: 0 0 0.55rem;
  color: #0f172a;
  font-size: 1.18rem;
}

.matter-ai-current-status__main small {
  display: block;
  color: #64748b;
  overflow-wrap: break-word;
}

.matter-ai-current-status__meta {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.matter-ai-current-status__meta dd {
  margin: 0;
  color: #334155;
  overflow-wrap: break-word;
}

.matter-ai-history-details {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.9rem;
  background: rgba(248, 250, 252, 0.72);
  overflow: hidden;
}

.matter-ai-history-details summary {
  cursor: pointer;
  padding: 0.75rem 0.9rem;
  color: #0f172a;
  font-weight: 800;
  list-style-position: inside;
}

.matter-ai-history-details[open] summary {
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.matter-ai-technical-list {
  padding: 0.75rem;
}

.matter-ai-status-card .matter-ai-technical-list .modern-row--compact {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px) !important;
}

.matter-ai-status-card .matter-ai-technical-list .modern-row__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0.35rem;
  align-content: start;
}

.matter-ai-status-card .matter-ai-token {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.5rem;
  background: rgba(248, 250, 252, 0.86);
  color: #334155;
  padding: 0.24rem 0.42rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.35;
  scrollbar-width: thin;
}

.matter-ai-status-card .matter-ai-token--link {
  text-decoration: none;
}

.matter-ai-status-card .matter-ai-token--link:hover,
.matter-ai-status-card .matter-ai-token--link:focus-visible {
  border-color: rgba(8, 145, 178, 0.55);
  color: #0369a1;
}

.matter-ai-report-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin-top: 0.4rem;
  border: 1px solid rgba(8, 145, 178, 0.28);
  border-radius: 999px;
  background: rgba(236, 254, 255, 0.82);
  color: #0369a1;
  padding: 0.28rem 0.68rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.matter-ai-report-link:hover,
.matter-ai-report-link:focus-visible {
  border-color: rgba(8, 145, 178, 0.55);
  background: #cffafe;
}

.matter-ai-cancel-form {
  display: inline-flex;
  margin: 0.4rem 0 0 0.35rem;
}

.matter-ai-cancel-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: 999px;
  background: rgba(254, 242, 242, 0.88);
  color: #b91c1c;
  padding: 0.28rem 0.68rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.matter-ai-cancel-link:hover,
.matter-ai-cancel-link:focus-visible {
  border-color: rgba(220, 38, 38, 0.58);
  background: #fee2e2;
}

.matter-ai-status-card .modern-row__main .matter-ai-token,
.matter-ai-status-card .modern-row__meta .matter-ai-token {
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  justify-self: stretch;
}

.matter-ai-error-block {
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 0.65rem;
  background: rgba(254, 242, 242, 0.86);
  color: #7f1d1d;
  overflow: hidden;
}

.matter-ai-error-block summary {
  cursor: pointer;
  padding: 0.42rem 0.55rem;
  color: #991b1b;
  font-size: 0.78rem;
  font-weight: 800;
  list-style-position: inside;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-ai-error-block pre {
  max-height: 12rem;
  margin: 0;
  overflow: auto;
  border-top: 1px solid rgba(220, 38, 38, 0.16);
  padding: 0.6rem;
  color: #7f1d1d;
  font: 0.75rem/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  scrollbar-width: thin;
}

html[data-theme="dark"] .matter-ai-status-card .matter-ai-token {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.88);
  color: #cbd5e1;
}

html[data-theme="dark"] .matter-ai-error-block {
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(69, 10, 10, 0.38);
  color: #fecaca;
}

html[data-theme="dark"] .matter-ai-error-block summary,
html[data-theme="dark"] .matter-ai-error-block pre {
  color: #fecaca;
}

html[data-theme="dark"] .matter-ai-error-block pre {
  border-top-color: rgba(248, 113, 113, 0.2);
}

@media (max-width: 900px) {
  .matter-ai-current-status,
  .matter-ai-status-card .matter-ai-technical-list .modern-row--compact {
    grid-template-columns: 1fr !important;
  }
}

.matter-ai-status-actions {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.matter-ai-status-actions [data-folder-status-refresh] {
  min-height: 2.45rem;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 0.75rem;
  padding: 0.55rem 0.85rem;
  background: #ecfeff;
  color: #0e7490;
  font-weight: 800;
}

.matter-ai-status-actions [data-folder-status-refresh]:disabled,
[data-folder-status-body].is-refreshing {
  opacity: 0.68;
}

/* Modal action bars must not inherit the global 32px close-button width. */
.matter-ai-status-card > header,
.matter-file-preview-card > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: start;
  gap: 1rem;
  overflow: visible;
}

.matter-ai-status-card > header > div:first-child,
.matter-file-preview-card > header > div:first-child {
  min-width: 0;
}

.matter-ai-status-actions,
.matter-file-preview-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  justify-self: end;
  max-width: min(52vw, 560px);
  min-width: max-content;
  overflow: visible;
}

.matter-ai-status-actions button,
.matter-file-preview-actions button,
.matter-file-preview-actions a {
  width: auto !important;
  min-width: max-content;
  min-height: 2.35rem;
  white-space: nowrap;
  border-radius: 0.75rem;
  padding: 0.55rem 0.8rem;
  line-height: 1;
  flex: 0 0 auto;
}

.matter-ai-status-actions [data-close-modal],
.matter-file-preview-actions [data-file-preview-close] {
  background: #102033;
  color: #fff;
  border-color: #102033;
}

@media (max-width: 720px) {
  .matter-ai-status-card > header,
  .matter-file-preview-card > header {
    grid-template-columns: 1fr;
  }

  .matter-ai-status-actions,
  .matter-file-preview-actions {
    justify-content: flex-start;
    justify-self: start;
    max-width: 100%;
    min-width: 0;
  }
}

/* Matter analysis sessions */
.matter-analysis-shell {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.matter-analysis-sidebar,
.matter-analysis-main {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(123, 167, 200, 0.26);
    border-radius: 24px;
    box-shadow: 0 18px 48px rgba(25, 55, 89, 0.08);
}

.matter-analysis-sidebar {
    padding: 1rem;
    min-height: 560px;
}

.matter-analysis-sidebar__header,
.matter-analysis-composer__bar,
.matter-analysis-message header,
.matter-analysis-message__summary,
.matter-analysis-message footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.matter-analysis-message__details {
    display: block;
}

.matter-analysis-message__summary {
    list-style: none;
    cursor: pointer;
}

.matter-analysis-message__summary::-webkit-details-marker {
    display: none;
}

.matter-analysis-sidebar button,
.matter-analysis-settings button,
.matter-analysis-composer button,
.matter-analysis-message button {
    border: 0;
    border-radius: 14px;
    padding: 0.65rem 0.9rem;
    color: #08233f;
    background: #e8f8fc;
    font-weight: 800;
    cursor: pointer;
}

.matter-analysis-session-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.matter-analysis-session-list a {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem;
    border-radius: 18px;
    color: #10233f;
    text-decoration: none;
    background: #f6f9fd;
}

.matter-analysis-session-list a.is-active {
    background: linear-gradient(135deg, #dff8fc, #eef8ff);
    box-shadow: inset 4px 0 0 #0898b8;
}

.matter-analysis-session-list small,
.matter-analysis-session-list span,
.matter-analysis-message small,
.matter-analysis-readiness small {
    color: #677891;
}

.matter-analysis-main {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    min-width: 0;
}

.matter-analysis-top {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 1rem;
}

.matter-analysis-settings {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 0.8rem;
}

.matter-analysis-settings label,
.matter-analysis-composer label {
    display: grid;
    gap: 0.35rem;
    color: #56657a;
    font-size: 0.82rem;
    font-weight: 700;
}

.matter-analysis-settings input,
.matter-analysis-settings select,
.matter-analysis-settings textarea,
.matter-analysis-composer textarea,
.matter-analysis-prompt-tools select {
    width: 100%;
    border: 1px solid #cfe0f1;
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
    background: #ffffff;
    color: #10233f;
}

.matter-analysis-settings__wide {
    grid-column: span 3;
}

.toggle-row {
    display: flex !important;
    grid-auto-flow: column;
    grid-template-columns: auto 1fr;
    align-items: center;
}

.matter-analysis-readiness {
    display: grid;
    gap: 1rem;
    border-radius: 22px;
    padding: 1rem;
    border: 1px solid #bee3f8;
    background: linear-gradient(135deg, #e8f7ff, #ffffff);
}

.matter-analysis-readiness.is-ready {
    border-color: #8ddeaa;
    background: linear-gradient(135deg, #e8ffef, #ffffff);
}

.matter-analysis-readiness.is-warning {
    border-color: #ffd08a;
    background: linear-gradient(135deg, #fff8e6, #ffffff);
}

.matter-analysis-readiness.is-blocked {
    border-color: #f5b2b2;
    background: linear-gradient(135deg, #fff0f0, #ffffff);
}

.matter-analysis-readiness span,
.matter-analysis-readiness dt {
    color: #08728a;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.matter-analysis-readiness dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.75rem;
    margin: 0;
}

.matter-analysis-chat {
    display: grid;
    gap: 0.9rem;
    min-height: 260px;
    align-content: start;
    grid-auto-rows: max-content;
}

.matter-analysis-message {
    border: 1px solid #d9e7f5;
    border-radius: 20px;
    padding: 0.85rem 1rem;
    background: #ffffff;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.matter-analysis-message.is-user {
    margin-left: 12%;
    background: linear-gradient(135deg, #f7fbff, #ffffff);
}

.matter-analysis-message.is-assistant {
    margin-right: 8%;
}

.matter-analysis-message p {
    white-space: pre-wrap;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.matter-analysis-message__title {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.matter-analysis-collapse-toggle {
    position: relative;
    width: 1.4rem;
    height: 1.4rem;
    flex: 0 0 1.4rem;
    border: 1px solid #9cb8d4;
    border-radius: 999px;
    padding: 0;
    background: transparent;
    color: #10233f;
    cursor: pointer;
    pointer-events: none;
    box-shadow: none;
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.matter-analysis-collapse-toggle span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0.38rem;
    height: 0.38rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translate(-50%, -62%) rotate(45deg);
}

.matter-analysis-collapse-toggle[aria-expanded="false"] span {
    transform: translate(-58%, -50%) rotate(-45deg);
}

.matter-analysis-collapse-toggle:hover,
.matter-analysis-collapse-toggle:focus-visible {
    border-color: #0b9abd;
    color: #07839f;
    background: rgba(230, 245, 249, 0.52);
    outline: none;
    box-shadow: 0 0 0 2px rgba(11, 154, 189, 0.08);
}

.matter-analysis-collapse-toggle[aria-expanded="true"] {
    border-color: #0b9abd;
    color: #07839f;
    background: transparent;
}

.matter-analysis-message__details[open] .matter-analysis-collapse-toggle {
    border-color: #0b9abd;
    color: #07839f;
    background: transparent;
}

.matter-analysis-message__details:not([open]) .matter-analysis-collapse-toggle span {
    transform: translate(-58%, -50%) rotate(-45deg);
}

.matter-analysis-message__details[open] ~ .matter-analysis-message__content {
    max-height: none !important;
    overflow: visible !important;
}

.matter-analysis-message__details[open] ~ .matter-analysis-message__content > * {
    display: revert !important;
}

.matter-analysis-message__details[open] ~ .matter-analysis-message__content > :first-child {
    display: block !important;
    -webkit-line-clamp: unset !important;
}

.matter-analysis-message__meta {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
    min-width: 0;
}

.matter-analysis-message__meta form {
    margin: 0;
}

.matter-analysis-message__author {
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    background: #e0f2fe;
    color: #075985;
    font-size: 0.76rem;
    font-weight: 900;
    line-height: 1.2;
}

.matter-analysis-message-action {
    border-radius: 999px !important;
    padding: 0.28rem 0.55rem !important;
    background: #edf7fb !important;
    color: #0f5970 !important;
    font-size: 0.78rem !important;
    line-height: 1.15;
    box-shadow: inset 0 0 0 1px rgba(14, 116, 144, 0.18);
}

.matter-analysis-message-action.is-danger {
    background: #fff1f2 !important;
    color: #b91c1c !important;
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35);
}

.matter-analysis-message.is-collapsed {
    padding-block: 0.65rem;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__content {
    display: block;
    max-height: 4.9rem;
    overflow: hidden;
    white-space: normal;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.matter-analysis-message.is-collapsed footer {
    display: flex;
}

.matter-analysis-composer {
    border: 1px solid #cfe8f5;
    border-radius: 24px;
    padding: 0.85rem;
    background: linear-gradient(135deg, #f3fbff, #ffffff);
}

.matter-analysis-composer textarea {
    min-height: 110px;
    resize: vertical;
}

.matter-analysis-prompt-tools {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.matter-analysis-composer .primary-action {
    background: #0797b7;
    color: #ffffff;
}

.matter-analysis-composer .primary-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.matter-analysis-events {
    border: 1px solid #dde9f5;
    border-radius: 18px;
    padding: 0.85rem;
}

.matter-analysis-events div {
    display: grid;
    grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr) auto;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-top: 1px solid #eef3f9;
}

@media (max-width: 980px) {
    .matter-analysis-shell,
    .matter-analysis-top {
        grid-template-columns: 1fr;
    }

    .matter-analysis-settings {
        grid-template-columns: 1fr;
    }

    .matter-analysis-settings__wide {
        grid-column: auto;
    }

    .matter-analysis-message.is-user,
    .matter-analysis-message.is-assistant {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Matter analysis visual refresh */
.matter-analysis-shell {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 1.25rem;
}

.matter-analysis-sidebar,
.matter-analysis-main {
    border: 1px solid rgba(12, 104, 133, 0.13);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 255, 0.9));
    box-shadow: 0 22px 55px rgba(15, 43, 72, 0.08);
}

.matter-analysis-sidebar {
    display: grid;
    align-content: start;
    gap: 0.9rem;
    min-height: 680px;
}

.matter-analysis-sidebar__header span,
.matter-analysis-hero span,
.matter-analysis-readiness span {
    color: #06728b;
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.matter-analysis-sidebar__header strong {
    display: block;
    margin-top: 0.12rem;
    font-size: 1.35rem;
}

.matter-analysis-sidebar__subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-top: 1px solid #e3edf7;
    padding-top: 0.8rem;
}

.matter-analysis-sidebar__subheader small {
    color: #64748b;
    font-weight: 750;
}

.matter-analysis-new-session {
    display: grid;
    gap: 0.65rem;
    border: 1px solid #ccebf5;
    border-radius: 22px;
    padding: 0.8rem;
    background: linear-gradient(135deg, #eafbff, #ffffff 72%);
}

.matter-analysis-new-session label {
    display: grid;
    gap: 0.35rem;
    color: #52647a;
    font-size: 0.78rem;
    font-weight: 850;
}

.matter-analysis-new-session select,
.matter-analysis-settings input,
.matter-analysis-settings select,
.matter-analysis-settings textarea,
.matter-analysis-composer textarea,
.matter-analysis-prompt-tools select {
    border-color: #bcd9ed;
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.matter-analysis-new-session button,
.matter-analysis-settings button,
.matter-analysis-composer button,
.matter-analysis-message button {
    border-radius: 18px;
    background: #0b9abd;
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(11, 154, 189, 0.18);
}

.matter-analysis-session-list a {
    border: 1px solid transparent;
    background: rgba(248, 251, 254, 0.92);
}

.matter-analysis-session-list a.is-active {
    border-color: #9bdded;
    background: linear-gradient(135deg, #dff8fc, #ffffff);
    box-shadow: inset 4px 0 0 #0898b8, 0 12px 28px rgba(8, 152, 184, 0.12);
}

.matter-analysis-main {
    gap: 1.1rem;
    padding: 1.1rem;
}

.matter-analysis-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid #cbe8f5;
    border-radius: 26px;
    padding: 1rem 1.1rem;
    background:
        radial-gradient(circle at 12% 20%, rgba(11, 154, 189, 0.12), transparent 28%),
        linear-gradient(135deg, #f2fbff, #ffffff 68%);
}

.matter-analysis-empty-session {
    min-height: 360px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.75rem;
    text-align: center;
    border: 1px dashed #bfe3ef;
    border-radius: 26px;
    padding: 3rem 1.5rem;
    background:
        radial-gradient(circle at 50% 10%, rgba(11, 154, 189, 0.13), transparent 32%),
        linear-gradient(135deg, #f8fdff, #ffffff);
}

.matter-analysis-empty-session span {
    color: #06728a;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.matter-analysis-empty-session h3 {
    margin: 0;
    font-size: 1.5rem;
}

.matter-analysis-empty-session p {
    max-width: 540px;
    margin: 0;
    color: #64748b;
    line-height: 1.45;
}
.matter-analysis-hero h3 {
    margin: 0.15rem 0;
    font-size: 1.35rem;
}

.matter-analysis-hero p {
    margin: 0;
    color: #64748b;
    font-weight: 750;
}

.matter-analysis-hero__badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    gap: 0.45rem;
}

.matter-analysis-hero__badges span {
    border: 1px solid #bfe3ef;
    border-radius: 999px;
    background: #ffffff;
    padding: 0.35rem 0.6rem;
    color: #075b70;
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: none;
}

.matter-analysis-top {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
}

.matter-analysis-settings {
    grid-template-columns: minmax(180px, 1fr) minmax(190px, 0.95fr) minmax(260px, 1.35fr);
    align-items: end;
    border: 1px solid #e2edf7;
    border-radius: 24px;
    padding: 0.9rem;
    background: #ffffff;
}

.matter-analysis-settings small {
    color: #738399;
    font-size: 0.72rem;
    line-height: 1.25;
}

.matter-analysis-settings__wide {
    grid-column: span 3;
}

.matter-analysis-settings .toggle-row {
    align-self: center;
    border: 1px dashed #d5e7f3;
    border-radius: 18px;
    padding: 0.65rem 0.75rem;
    background: #f7fbff;
}

.matter-analysis-settings button[type="submit"] {
    min-height: 52px;
    align-self: stretch;
}

.matter-analysis-readiness {
    min-height: 100%;
    border-radius: 24px;
}

.matter-analysis-chat {
    border: 1px solid #edf3f9;
    border-radius: 24px;
    padding: 0.75rem;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.matter-analysis-message {
    box-shadow: 0 10px 30px rgba(15, 43, 72, 0.06);
}

.matter-analysis-composer {
    position: sticky;
    bottom: 1rem;
    border: 1px solid #bfe5f2;
    box-shadow: 0 20px 50px rgba(8, 74, 103, 0.12);
}

.matter-analysis-composer textarea {
    min-height: 150px;
    font-size: 1rem;
}

.matter-analysis-composer__bar {
    align-items: end;
}

.matter-analysis-prompt-tools select {
    min-width: min(420px, 44vw);
}


.matter-analysis-temperature {
    min-width: 132px;
}

.matter-analysis-temperature span {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.matter-analysis-temperature input {
    width: 100%;
    border: 1px solid #cbe4f2;
    border-radius: 16px;
    padding: 0.72rem 0.8rem;
    background: #ffffff;
    color: #10213a;
    font: inherit;
    font-weight: 850;
}
.matter-analysis-composer .primary-action {
    min-height: 44px;
    padding-inline: 1.35rem;
    background: #0797b7;
}


.matter-analysis-window-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #91d9ed;
    border-radius: 999px;
    background: #e8fbff;
    color: #075b70;
    padding: 0.35rem 0.75rem;
    font-size: 0.74rem;
    font-weight: 950;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(8, 152, 184, 0.12);
}

.matter-layout--analysis-focus {
    grid-template-columns: 1fr;
    max-width: none;
}

.matter-layout--analysis-focus .matter-content {
    width: 100%;
    max-width: none;
}

.matter-layout--analysis-focus .matter-analysis-shell {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    min-height: calc(100vh - 8rem);
}

.matter-layout--analysis-focus .matter-analysis-main {
    min-height: calc(100vh - 9rem);
}

.matter-workspace--analysis-focus .matter-hero,
.matter-workspace--analysis-focus .matter-tabs {
    display: none;
}
@media (max-width: 1180px) {
    .matter-analysis-settings {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .matter-analysis-settings__wide {
        grid-column: span 2;
    }
}

@media (max-width: 980px) {
    .matter-analysis-sidebar {
        min-height: auto;
    }

    .matter-analysis-hero,
    .matter-analysis-composer__bar {
        align-items: stretch;
        flex-direction: column;
    }

    .matter-analysis-settings,
    .matter-analysis-settings__wide {
        grid-column: auto;
        grid-template-columns: 1fr;
    }
}

/* Matter analysis interaction refresh */
.matter-analysis-session-item {
    border: 1px solid transparent;
    border-radius: 18px;
    background: rgba(248, 251, 254, 0.92);
}

.matter-analysis-session-item.is-active {
    border-color: #9bdded;
    background: linear-gradient(135deg, #dff8fc, #ffffff);
    box-shadow: inset 4px 0 0 #0898b8, 0 12px 28px rgba(8, 152, 184, 0.12);
}

.matter-analysis-session-item.is-loading {
    opacity: 0.72;
    pointer-events: none;
}

.matter-analysis-session-item a {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem;
    color: #10233f;
    text-decoration: none;
}

.matter-analysis-session-cost {
    width: max-content;
    border-radius: 999px;
    padding: 0.16rem 0.5rem;
    background: #e8fbff;
    color: #075b70;
    font-size: 0.76rem;
    font-style: normal;
    font-weight: 900;
}

.matter-analysis-cost-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid #d4edf6;
    border-radius: 16px;
    padding: 0.72rem 0.8rem;
    background: #f4fcff;
}

.matter-analysis-cost-summary > div {
    display: grid;
    gap: 0.18rem;
}

.matter-analysis-cost-summary span,
.matter-analysis-cost-summary small {
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 800;
}

.matter-analysis-cost-summary strong {
    color: #0f2742;
    font-size: 1rem;
}

.matter-analysis-cost-help {
    width: 2rem;
    height: 2rem;
    border: 1px solid #9bdff0;
    border-radius: 999px;
    background: #ffffff;
    color: #075b70;
    font-weight: 900;
    cursor: pointer;
}

.matter-analysis-cost-help:hover,
.matter-analysis-cost-help:focus-visible {
    background: #e8fbff;
}

.matter-analysis-cost-card {
    max-width: 680px;
}

.matter-analysis-cost-breakdown {
    display: grid;
    gap: 0.6rem;
}

.matter-analysis-cost-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.18rem 0.85rem;
    align-items: start;
    border: 1px solid #dbeaf2;
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    background: #f8fcff;
}

.matter-analysis-cost-line span {
    color: #0f2742;
    font-weight: 900;
}

.matter-analysis-cost-line strong {
    color: #075b70;
    font-size: 1rem;
}

.matter-analysis-cost-line small {
    grid-column: 1 / -1;
    color: #64748b;
    font-weight: 700;
}

.matter-analysis-cost-line--total {
    background: #ecfeff;
    border-color: #9bdff0;
}

.matter-analysis-hero__badges .matter-analysis-cost-pill {
    border-color: #8fd9ea;
    background: #e8fbff;
    color: #075b70;
}

.matter-analysis-session-list a,
.matter-analysis-session-list a.is-active {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.matter-analysis-new-session-trigger {
    width: 100%;
    justify-content: center;
}

.matter-analysis-top,
.matter-analysis-readiness {
    display: none;
}

.matter-layout--analysis-focus {
    position: fixed;
    inset: 0.5rem;
    z-index: 80;
    overflow: auto;
    padding: 0.5rem;
    background: rgba(241, 247, 251, 0.98);
}

.matter-layout--analysis-focus .matter-analysis-shell {
    min-height: calc(100vh - 1rem);
}

.matter-analysis-message__content {
    display: grid;
    gap: 0.55rem;
    line-height: 1.6;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.matter-analysis-message__content p,
.matter-analysis-message__content ul,
.matter-analysis-message__content ol,
.matter-analysis-message__content h4 {
    margin: 0;
}

.matter-analysis-message__content ul,
.matter-analysis-message__content ol {
    padding-left: 1.25rem;
}

.matter-analysis-citation-link {
    display: inline;
    margin-inline: 0.02rem;
    border: 0;
    border-bottom: 1px dotted currentColor;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: #075b70;
    font: inherit;
    font-size: 0.9em;
    font-weight: 800;
    line-height: inherit;
    vertical-align: baseline;
    cursor: pointer;
}

.matter-analysis-citation-link:hover,
.matter-analysis-citation-link:focus {
    color: #0e7490;
    outline: 1px solid rgba(8, 145, 178, 0.28);
    outline-offset: 2px;
}

.matter-analysis-message .matter-analysis-message__content button.matter-analysis-citation-link {
    display: inline;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0 0.02rem;
    border: 0;
    border-bottom: 1px dotted currentColor;
    border-radius: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    color: #075b70;
    font: inherit;
    font-size: 0.9em;
    font-weight: 800;
    line-height: inherit;
    vertical-align: baseline;
    appearance: none;
}

.matter-analysis-message .matter-analysis-message__content button.matter-analysis-citation-link:hover,
.matter-analysis-message .matter-analysis-message__content button.matter-analysis-citation-link:focus {
    background: transparent;
    box-shadow: none;
    color: #0e7490;
}

.matter-analysis-source-legend {
    border: 1px solid #d7edf6;
    border-radius: 8px;
    background: #f8fcff;
    padding: 0.65rem 0.75rem;
}

.matter-analysis-source-legend summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    color: #075b70;
    font-weight: 900;
}

.matter-analysis-source-legend summary::-webkit-details-marker {
    display: none;
}

.matter-analysis-source-legend summary::before {
    content: ">";
    display: inline-grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 999px;
    background: #dff7fd;
    color: #0b88a6;
    font-size: 0.75rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.16s ease;
}

.matter-analysis-source-legend[open] summary::before {
    transform: rotate(90deg);
}

.matter-analysis-source-legend summary span {
    flex: 1;
}

.matter-analysis-source-legend summary small {
    color: #64748b;
    font-weight: 800;
}

.matter-analysis-source-legend__list {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.65rem;
}

.matter-analysis-source-legend__item {
    display: grid;
    grid-template-columns: 2.7rem minmax(0, 1fr);
    gap: 0.45rem 0.65rem;
    border-top: 1px solid #e2eff6;
    padding: 0.55rem 0.35rem 0.55rem 0;
}

.matter-analysis-source-legend__item.is-openable {
    cursor: pointer;
}

.matter-analysis-source-legend__item.is-openable:hover,
.matter-analysis-source-legend__item.is-openable:focus {
    border-radius: 8px;
    background: #eefaff;
    outline: none;
}

.matter-analysis-source-legend__index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 1.6rem;
    border-radius: 999px;
    background: #e6f8fe;
    color: #075b70;
    font-size: 0.78rem;
    font-weight: 950;
}

.matter-analysis-source-legend__item strong {
    display: block;
    color: #0f172a;
    font-size: 0.9rem;
}

.matter-analysis-source-legend__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: center;
    margin-top: 0.18rem;
    color: #475569;
    font-size: 0.82rem;
    line-height: 1.35;
}

.matter-analysis-source-legend__meta span {
    border-radius: 999px;
    padding: 0.12rem 0.45rem;
    background: #e6f8fe;
    color: #075b70;
    font-weight: 850;
}

.matter-analysis-source-legend__meta small {
    color: #475569;
    font: inherit;
}

.matter-analysis-source-legend__item p {
    margin: 0.28rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.45;
}

.matter-analysis-message.is-collapsed {
    padding-block: 0.65rem;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__content {
    display: block !important;
    max-height: 4.9rem !important;
    overflow: hidden !important;
    line-height: 1.55;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__content > * {
    display: none;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__content > :first-child {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.matter-analysis-table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.matter-analysis-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.matter-analysis-table th,
.matter-analysis-table td {
    border: 1px solid #dbeafe;
    padding: 0.55rem 0.65rem;
    text-align: left;
    vertical-align: top;
}

.matter-analysis-table th {
    background: #eaf8fd;
    color: #0f5970;
    font-weight: 900;
}

.matter-analysis-table td {
    background: #ffffff;
}

.matter-analysis-message footer small {
    color: #64748b;
    font-weight: 750;
}

.matter-analysis-important-toggle {
    display: inline-flex !important;
    grid-template-columns: none;
    grid-auto-flow: column;
    gap: 0.5rem;
    align-items: center;
    color: #334155;
    font-weight: 850;
}

.matter-analysis-important-toggle button {
    position: relative;
    width: 46px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    padding: 0;
    background: #cbd5e1;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
}

.matter-analysis-important-toggle button span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.matter-analysis-message footer form:has(input[name="isImportant"][value="False"]) .matter-analysis-important-toggle button,
.matter-analysis-message footer form:has(input[name="isImportant"][value="false"]) .matter-analysis-important-toggle button {
    background: #0b9abd;
}

.matter-analysis-message footer form:has(input[name="isImportant"][value="False"]) .matter-analysis-important-toggle button span,
.matter-analysis-message footer form:has(input[name="isImportant"][value="false"]) .matter-analysis-important-toggle button span {
    left: 23px;
}

.matter-analysis-wait {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.65rem 0;
    border: 1px solid #91d9ed;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    background: #e8fbff;
    color: #075b70;
    font-weight: 900;
}

.matter-analysis-wait[hidden] {
    display: none;
}

.matter-analysis-wait.is-error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.matter-analysis-question-chain {
    display: grid;
    gap: 0.35rem;
    border: 1px solid #cfe8f5;
    border-radius: 14px;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.82);
}

.matter-analysis-question-chain[hidden] {
    display: none;
}

.matter-analysis-question-chain__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: #0b6880;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.matter-analysis-question-chain__items {
    display: grid;
    gap: 0.28rem;
}

.matter-analysis-question-chain__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid #d7e8f4;
    border-radius: 10px;
    padding: 0.34rem 0.45rem;
    background: #f8fcff;
    color: #17324d;
    font-size: 0.82rem;
}

.matter-analysis-question-chain__cancel {
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 0;
    background: #eef6fb;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 950;
    line-height: 1;
    cursor: pointer;
}

.matter-analysis-question-chain__cancel:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.matter-analysis-question-chain__cancel:disabled {
    opacity: 0.32;
    cursor: default;
}

.matter-analysis-question-chain__index {
    width: 1.45rem;
    height: 1.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #e7f6fb;
    color: #087596;
    font-weight: 900;
}

.matter-analysis-question-chain__text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matter-analysis-question-chain__status {
    color: #56657a;
    font-size: 0.74rem;
    font-weight: 850;
    white-space: nowrap;
}

.matter-analysis-question-chain__item[data-status="sending"],
.matter-analysis-question-chain__item[data-status="waiting"] {
    border-color: #8fd8ec;
    background: #eefbff;
}

.matter-analysis-question-chain__item[data-status="asked"] .matter-analysis-question-chain__status,
.matter-analysis-question-chain__item[data-status="done"] .matter-analysis-question-chain__status {
    color: #047857;
}

.matter-analysis-question-chain__item[data-status="retry"] .matter-analysis-question-chain__status {
    color: #b45309;
}

.matter-analysis-question-chain__item[data-status="failed"] {
    border-color: #fecaca;
    background: #fff1f2;
}

.matter-analysis-question-chain__item[data-status="failed"] .matter-analysis-question-chain__status {
    color: #be123c;
}

.matter-analysis-switch {
    display: inline-flex !important;
    grid-template-columns: none;
    grid-auto-flow: column;
    gap: 0.5rem;
    align-items: center;
}

.matter-analysis-switch input {
    position: absolute;
    opacity: 0;
}

.matter-analysis-switch > span {
    position: relative;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #cbd5e1;
}

.matter-analysis-switch > span::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
    transition: transform 0.18s ease;
}

.matter-analysis-switch input:checked + span {
    background: #0b9abd;
}

.matter-analysis-switch input:checked + span::after {
    transform: translateX(20px);
}

.matter-analysis-run-settings summary {
    list-style: none;
    border-radius: 18px;
    padding: 0.65rem 0.9rem;
    background: #172033;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.matter-analysis-run-settings[open] {
    display: grid;
    gap: 0.55rem;
    min-width: min(460px, 70vw);
    border: 1px solid #cbe4f2;
    border-radius: 20px;
    padding: 0.65rem;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 43, 72, 0.14);
}

.matter-analysis-session-modal .modal-card {
    max-width: 620px;
}

.matter-analysis-session-modal label {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.7rem;
    color: #52647a;
    font-size: 0.78rem;
    font-weight: 850;
}

.matter-analysis-session-modal input,
.matter-analysis-session-modal select,
.matter-analysis-session-modal textarea {
    width: 100%;
    border: 1px solid #bcd9ed;
    border-radius: 16px;
    padding: 0.75rem 0.85rem;
}

.matter-analysis-session-menu {
    position: fixed;
    z-index: 7000;
    display: grid;
    gap: 0.25rem;
    border: 1px solid #d8e7f3;
    border-radius: 16px;
    padding: 0.4rem;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 43, 72, 0.18);
}

.matter-analysis-session-menu[hidden] {
    display: none;
}

.matter-analysis-session-menu button {
    border: 0;
    border-radius: 12px;
    padding: 0.65rem 0.8rem;
    background: #fff;
    color: #10233f;
    font-weight: 850;
    text-align: left;
}

.matter-analysis-session-menu .danger-action {
    color: #be123c;
}

.matter-analysis-events {
    max-height: 280px;
    overflow: auto;
}

/* Matter analysis admin/debug refinements */
.matter-analysis-sidebar__toggle {
    width: 34px;
    height: 34px;
    border: 1px solid #bfdfef;
    border-radius: 999px;
    padding: 0;
    background: transparent;
    color: #0d6178;
    font-weight: 950;
    position: relative;
    font-size: 0;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.matter-analysis-sidebar__toggle::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translate(-35%, -50%) rotate(135deg);
}

.matter-analysis-sidebar.is-collapsed .matter-analysis-sidebar__toggle::before {
    transform: translate(-65%, -50%) rotate(-45deg);
}

.matter-analysis-sidebar__toggle:hover,
.matter-analysis-sidebar__toggle:focus-visible {
    border-color: #0b9abd;
    color: #07839f;
    outline: none;
    box-shadow: 0 0 0 3px rgba(11, 154, 189, 0.08);
}

.matter-analysis-sidebar.is-collapsed {
    width: 72px;
    min-width: 72px;
    overflow: hidden;
}

.matter-analysis-sidebar.is-collapsed .matter-analysis-sidebar__header div,
.matter-analysis-sidebar.is-collapsed .matter-analysis-sidebar__subheader,
.matter-analysis-sidebar.is-collapsed .matter-analysis-new-session-trigger,
.matter-analysis-sidebar.is-collapsed .matter-analysis-session-list,
.matter-analysis-sidebar.is-collapsed .matter-analysis-cost-summary {
    display: none;
}

.matter-analysis-message footer form.is-important .matter-analysis-important-toggle button {
    background: #0b9abd;
}

.matter-analysis-message footer form.is-important .matter-analysis-important-toggle button span {
    left: 23px;
}

.matter-analysis-admin-link {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.matter-layout--analysis-focus .app-sidebar,
.matter-layout--analysis-focus .topbar,
.matter-layout--analysis-focus .matter-hero,
.matter-layout--analysis-focus .matter-tabs {
    display: none;
}

.matter-layout--analysis-focus {
    inset: 0;
    padding: 0;
}

/* Matter analysis focus/sidebar controls */
.matter-analysis-session-panel-action {
    cursor: pointer;
    font: inherit;
}

.matter-analysis-shell.is-session-sidebar-hidden {
    grid-template-columns: minmax(0, 1fr);
}

.matter-analysis-shell.is-session-sidebar-hidden .matter-analysis-sidebar {
    display: none;
}

.matter-layout--analysis-focus {
    z-index: 5000;
}

.matter-layout--analysis-focus .matter-analysis-shell.is-session-sidebar-hidden {
    grid-template-columns: minmax(0, 1fr);
}

.matter-layout--analysis-focus .matter-analysis-main {
    max-width: none;
}

/* Matter analysis technical event log */
.matter-analysis-events > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.45rem;
    padding: 0.45rem 0.55rem 0.7rem;
}

.matter-analysis-event-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) minmax(180px, auto);
    gap: 0.75rem;
    align-items: center;
    min-width: 0;
    width: 100%;
    border: 1px solid #d7e8f3;
    border-radius: 14px;
    padding: 0.65rem 0.8rem;
    background: rgba(255, 255, 255, 0.9);
    color: #10233f;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.matter-analysis-event-row:hover,
.matter-analysis-event-row:focus-visible {
    border-color: #91d9ed;
    background: #eefbff;
    outline: none;
}

.matter-analysis-event-row__stage {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #0f2742;
    font-weight: 950;
    white-space: nowrap;
}

.matter-analysis-event-row__detail {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matter-analysis-event-row__meta {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    min-width: 0;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.matter-analysis-event-row__meta span {
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    background: #e8fbff;
    color: #075b70;
}

.matter-analysis-event-modal {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1180px, 94vw);
    max-height: 88vh;
    border: 1px solid #bfe8f4;
    border-radius: 24px;
    padding: 0;
    overflow: hidden;
    background: #ffffff !important;
    color: #10233f;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.matter-analysis-event-modal:not([open]) {
    display: none !important;
}

.matter-analysis-event-modal__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid #d7e8f3;
    padding: 1rem 1.1rem;
    background: #ffffff;
}

.matter-analysis-event-modal__header span,
.matter-analysis-event-modal__body h4 {
    color: #0d6f88;
    font-size: 0.75rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.matter-analysis-event-modal__header h3,
.matter-analysis-event-modal__header p,
.matter-analysis-event-modal__body h4,
.matter-analysis-event-modal__body p {
    margin: 0;
}

.matter-analysis-event-modal__header p {
    color: #64748b;
    overflow-wrap: anywhere;
}

.matter-analysis-event-modal__body {
    display: grid;
    gap: 1rem;
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.1rem 1.2rem;
    background: #ffffff;
}

.matter-analysis-event-modal__body section {
    display: grid;
    gap: 0.55rem;
}

.matter-analysis-event-modal pre {
    max-height: 58vh;
    overflow: auto;
    border: 1px solid #d7e8f3;
    border-radius: 16px;
    padding: 0.9rem;
    background: #f8fbfe;
    color: #10233f;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 900px) {
    .matter-analysis-event-row {
        grid-template-columns: 1fr;
    }

    .matter-analysis-event-row__detail {
        white-space: normal;
    }

    .matter-analysis-event-row__meta {
        justify-content: flex-start;
    }
}

/* Matter analysis composer redesign from C:/tmp/lay chat */
.matter-analysis-composer--studio {
    position: sticky;
    bottom: 1rem;
    display: grid;
    gap: 0.75rem;
    border: 1px solid rgba(38, 174, 214, 0.34);
    border-radius: 28px;
    padding: 0.95rem;
    background: linear-gradient(135deg, rgba(244, 252, 255, 0.96), rgba(255, 255, 255, 0.96));
    box-shadow: 0 22px 55px rgba(7, 101, 133, 0.1);
}

.matter-analysis-composer--studio .matter-analysis-composer__surface {
    border: 1px solid #bfe0ee;
    border-radius: 21px;
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    overflow: hidden;
}

.matter-analysis-composer--studio textarea {
    min-height: 132px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    resize: vertical;
    font-size: 1rem;
    line-height: 1.55;
}

.matter-analysis-composer--studio textarea:focus {
    outline: 2px solid rgba(10, 170, 203, 0.22);
    outline-offset: -2px;
}

.matter-analysis-composer--studio .matter-analysis-composer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.matter-analysis-composer__left,
.matter-analysis-composer__right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.matter-analysis-composer__left {
    min-width: 0;
    flex: 1 1 auto;
}

.matter-analysis-composer__right {
    flex: 0 0 auto;
    justify-content: flex-end;
}

.matter-analysis-template-select {
    width: min(520px, 100%);
    min-width: min(360px, 100%);
    border: 1px solid #c6e1ef;
    border-radius: 16px;
    padding: 0.74rem 0.9rem;
    background: #ffffff;
    color: #10233f;
    font: inherit;
    font-weight: 750;
}

.matter-analysis-switch--composer {
    display: inline-flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 0.5rem !important;
    margin: 0;
    color: #51677e !important;
    white-space: nowrap;
}

.matter-analysis-composer--studio .matter-analysis-run-settings {
    position: relative;
}

.matter-analysis-composer--studio .matter-analysis-run-settings[open] {
    display: inline-block;
    min-width: 0;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.matter-analysis-composer--studio .matter-analysis-run-settings summary,
.matter-analysis-composer--studio [data-analysis-speech],
.matter-analysis-composer--studio .primary-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-radius: 16px;
    padding: 0.72rem 1rem;
    font-weight: 900;
    line-height: 1;
}

.matter-analysis-composer--studio .matter-analysis-run-settings summary {
    background: #14233b;
    border: 1px solid #14233b;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(20, 35, 59, 0.16);
}

.matter-analysis-composer--studio [data-analysis-speech] {
    background: #0b9abd;
    color: #ffffff;
}

.matter-analysis-composer--studio .primary-action {
    background: linear-gradient(135deg, #0aaacb, #027c9a);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(2, 132, 164, 0.22);
}

.matter-analysis-tools-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    z-index: 20;
    width: min(380px, 88vw);
    display: grid;
    gap: 0.85rem;
    border: 1px solid #c7e7f3;
    border-radius: 22px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 20px 50px rgba(13, 91, 120, 0.18);
}

.matter-analysis-tools-panel .matter-analysis-temperature,
.matter-analysis-tools-panel .matter-analysis-switch {
    margin: 0;
}

.matter-analysis-tools-panel .matter-analysis-switch--compact {
    display: inline-flex !important;
    grid-template-columns: none !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem !important;
    width: 100%;
}

.matter-analysis-wait {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid #bfe5f3;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: #e8fbff;
    color: #075b70;
    font-size: 0.82rem;
    font-weight: 900;
}

.matter-analysis-wait[hidden] {
    display: none;
}

.matter-analysis-wait.is-error {
    justify-self: stretch;
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.matter-analysis-composer--studio .matter-analysis-question-chain {
    border-color: #c7e6f4;
    background: rgba(255, 255, 255, 0.9);
}

@media (max-width: 980px) {
    .matter-analysis-composer--studio .matter-analysis-composer__bar,
    .matter-analysis-composer__left,
    .matter-analysis-composer__right {
        align-items: stretch;
        flex-direction: column;
    }

    .matter-analysis-composer__right {
        width: 100%;
    }

    .matter-analysis-template-select,
    .matter-analysis-composer--studio .matter-analysis-run-settings,
    .matter-analysis-composer--studio [data-analysis-speech],
    .matter-analysis-composer--studio .primary-action {
        width: 100%;
    }

    .matter-analysis-tools-panel {
        position: static;
        width: 100%;
        margin-top: 0.75rem;
    }
}

/* Matter analysis composer: prompt library and icon actions */
.matter-analysis-composer--studio .matter-analysis-icon {
    width: 1.12rem;
    height: 1.12rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.matter-analysis-prompt-library {
    position: relative;
}

.matter-analysis-composer--studio .matter-analysis-template-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.matter-analysis-tool-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid #bfe5f3;
    border-radius: 16px;
    padding: 0.72rem 1rem;
    background: #ffffff;
    color: #0b2943;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(13, 91, 120, 0.08);
    cursor: pointer;
}

.matter-analysis-prompt-library__trigger {
    background: #ffffff;
    color: #087d9a;
}

.matter-analysis-prompt-library__trigger[aria-expanded="true"] {
    background: #e8faff;
    border-color: #55c7df;
}

.matter-analysis-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(13, 145, 178, 0.13);
}

.matter-analysis-popover-head strong {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #0b2943;
    font-weight: 950;
}

.matter-analysis-popover-head small {
    color: #688095;
    font-size: 0.78rem;
    font-weight: 800;
}

.matter-analysis-prompt-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.75rem);
    z-index: 25;
    width: min(445px, 88vw);
    border: 1px solid #c7e7f3;
    border-radius: 22px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 22px 70px rgba(13, 91, 120, 0.18);
}

.matter-analysis-prompt-popover[hidden] {
    display: none;
}

.matter-analysis-prompt-search {
    margin: 0.75rem 0.85rem 0.45rem;
    min-height: 40px;
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 0.55rem !important;
    border: 1px solid #cee7f1;
    border-radius: 14px;
    padding: 0 0.75rem;
    background: #ffffff;
    color: #7b8ea1 !important;
}

.matter-analysis-prompt-search input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #10233f;
    font: inherit;
    font-weight: 700;
}

.matter-analysis-prompt-grid {
    max-height: min(420px, 58vh);
    display: grid;
    gap: 0.7rem;
    padding: 0.65rem 0.85rem 1rem;
    overflow: auto;
}

.matter-analysis-prompt-scope {
    display: flex;
    gap: 0.35rem;
    margin: 0.7rem 0.85rem 0;
    padding: 0.25rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.86);
}

.matter-analysis-prompt-scope button {
    flex: 1;
    border: 0;
    border-radius: 9px;
    padding: 0.42rem 0.55rem;
    background: transparent;
    color: #4b5874;
    font-weight: 800;
    cursor: pointer;
}

.matter-analysis-prompt-scope button.is-active {
    background: #ffffff;
    color: #10233f;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.matter-analysis-agent-levels {
    display: grid;
    gap: 0.55rem;
    margin: 0.75rem 0;
}

.matter-analysis-agent-levels label {
    display: grid !important;
    grid-template-columns: auto 1fr;
    column-gap: 0.6rem !important;
    row-gap: 0.18rem;
    align-items: start;
    border: 1px solid #d6ebf2;
    border-radius: 14px;
    padding: 0.65rem 0.75rem;
    background: #f8fcff;
    color: #10233f !important;
}

.matter-analysis-agent-levels input {
    margin-top: 0.18rem;
}

.matter-analysis-agent-levels span,
.matter-analysis-agent-levels small {
    grid-column: 2;
}

.matter-analysis-agent-levels span {
    font-weight: 900;
}

.matter-analysis-agent-levels small {
    color: #668095;
    font-weight: 700;
}

.matter-analysis-agent-levels--inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0;
    min-width: min(760px, 100%);
}

.matter-analysis-agent-levels--inline label {
    min-height: 44px;
    display: inline-flex !important;
    grid-template-columns: none;
    align-items: center;
    gap: 0.42rem !important;
    border-color: #c8e5f0;
    border-radius: 16px;
    padding: 0.55rem 0.72rem;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(13, 91, 120, 0.07);
    cursor: pointer;
}

.matter-analysis-agent-levels--inline label:has(input:checked) {
    border-color: #1aa5c3;
    background: #e8faff;
    color: #075d72 !important;
}

.matter-analysis-agent-levels--inline input {
    margin: 0;
}

.matter-analysis-agent-levels--inline span {
    grid-column: auto;
    white-space: nowrap;
}

.matter-analysis-length-select {
    display: grid !important;
    gap: 0.4rem !important;
    margin: 0;
    padding: 0.85rem 1rem;
    color: #10233f !important;
    font-weight: 850;
}

.matter-analysis-length-select select {
    width: 100%;
    border: 1px solid #cfe5ef;
    border-radius: 12px;
    padding: 0.65rem 0.7rem;
    background: #fff;
    color: #10233f;
    font: inherit;
    font-weight: 800;
}

.matter-analysis-switch--modal {
    display: flex !important;
    align-items: center;
    gap: 0.75rem !important;
    color: #10233f !important;
}

.matter-analysis-prompt-item {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 0.75rem !important;
    border: 1px solid transparent !important;
    border-radius: 15px !important;
    padding: 0.72rem !important;
    background: #f3fbff !important;
    color: #10233f !important;
    text-align: left;
    box-shadow: none !important;
}

.matter-analysis-prompt-item[hidden] {
    display: none !important;
}

.matter-analysis-prompt-item:hover,
.matter-analysis-prompt-item:focus-visible {
    border-color: #47c2df !important;
    outline: 0;
}

.matter-analysis-prompt-item__icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: #dff6fc;
    color: #087d9a;
}

.matter-analysis-prompt-item strong,
.matter-analysis-prompt-item small {
    display: block;
}

.matter-analysis-prompt-item small {
    margin-top: 0.18rem;
    color: #6b7e92;
    font-size: 0.77rem;
    font-weight: 700;
    line-height: 1.35;
}

.matter-analysis-composer--studio .matter-analysis-run-settings summary {
    list-style: none;
}

.matter-analysis-composer--studio .matter-analysis-run-settings summary::-webkit-details-marker {
    display: none;
}

.matter-analysis-composer--studio .matter-analysis-run-settings[open] summary {
    background: #17243a;
    color: #ffffff;
}

.matter-analysis-composer--studio .matter-analysis-tools-panel {
    width: min(356px, 88vw);
    padding: 0;
    overflow: hidden;
    text-align: left;
}

.matter-analysis-tool-row {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(13, 145, 178, 0.11);
}

.matter-analysis-tool-row > strong {
    display: grid;
    gap: 0.18rem;
    margin-right: auto;
    color: #10233f;
    font-style: normal;
    text-align: left;
}

.matter-analysis-tool-row em {
    font-style: normal;
}

.matter-analysis-tool-row small {
    color: #6b7e92;
    font-size: 0.76rem;
    font-weight: 700;
}

.matter-analysis-tools-panel .matter-analysis-temperature {
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(13, 145, 178, 0.11);
}

.matter-analysis-speech-button {
    background: #0b9abd;
    border-color: #0b9abd;
    color: #ffffff;
}

.matter-analysis-run-button {
    min-width: 170px;
    padding-inline: 1.15rem !important;
}

.matter-analysis-run-button kbd {
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    padding: 0.25rem 0.42rem;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 900;
}

@media (max-width: 980px) {
    .matter-analysis-prompt-library,
    .matter-analysis-prompt-library__trigger {
        width: 100%;
    }

    .matter-analysis-agent-levels--inline {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .matter-analysis-agent-levels--inline label {
        justify-content: flex-start;
    }

    .matter-analysis-prompt-popover {
        position: static;
        width: 100%;
        margin-top: 0.75rem;
    }
}

@media (max-width: 620px) {
    .matter-analysis-agent-levels--inline {
        grid-template-columns: 1fr;
    }
}

/* Matter analysis dark theme */
html[data-theme="dark"] .matter-layout--analysis-focus {
    background: rgba(8, 18, 26, 0.98);
}

html[data-theme="dark"] .matter-analysis-sidebar,
html[data-theme="dark"] .matter-analysis-main,
html[data-theme="dark"] .matter-analysis-chat,
html[data-theme="dark"] .matter-analysis-composer,
html[data-theme="dark"] .matter-analysis-composer--studio,
html[data-theme="dark"] .matter-analysis-settings,
html[data-theme="dark"] .matter-analysis-new-session,
html[data-theme="dark"] .matter-analysis-empty-session {
    border-color: rgba(125, 211, 252, 0.2);
    background: linear-gradient(180deg, rgba(13, 27, 39, 0.98), rgba(10, 22, 34, 0.96));
    color: #eaf6ff;
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .matter-analysis-hero {
    border-color: rgba(125, 211, 252, 0.24);
    background:
        radial-gradient(circle at 12% 20%, rgba(14, 165, 200, 0.18), transparent 30%),
        linear-gradient(135deg, rgba(14, 28, 42, 0.98), rgba(8, 18, 28, 0.98));
    color: #eaf6ff;
}

html[data-theme="dark"] .matter-analysis-sidebar__subheader {
    border-top-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .matter-analysis-sidebar__subheader small,
html[data-theme="dark"] .matter-analysis-session-list small,
html[data-theme="dark"] .matter-analysis-session-list span,
html[data-theme="dark"] .matter-analysis-message small,
html[data-theme="dark"] .matter-analysis-readiness small,
html[data-theme="dark"] .matter-analysis-hero p,
html[data-theme="dark"] .matter-analysis-empty-session p,
html[data-theme="dark"] .matter-analysis-settings small,
html[data-theme="dark"] .matter-analysis-temperature span,
html[data-theme="dark"] .matter-analysis-popover-head small,
html[data-theme="dark"] .matter-analysis-prompt-item small,
html[data-theme="dark"] .matter-analysis-tool-row small,
html[data-theme="dark"] .matter-analysis-message footer small,
html[data-theme="dark"] .matter-analysis-cost-summary span,
html[data-theme="dark"] .matter-analysis-cost-summary small,
html[data-theme="dark"] .matter-analysis-cost-line small,
html[data-theme="dark"] .matter-analysis-event-row__meta,
html[data-theme="dark"] .matter-analysis-event-modal__header p {
    color: #a9bbce;
}

html[data-theme="dark"] .matter-analysis-sidebar__header span,
html[data-theme="dark"] .matter-analysis-hero span,
html[data-theme="dark"] .matter-analysis-readiness span,
html[data-theme="dark"] .matter-analysis-empty-session span,
html[data-theme="dark"] .matter-analysis-event-modal__header span,
html[data-theme="dark"] .matter-analysis-event-modal__body h4 {
    color: #67e8f9;
}

html[data-theme="dark"] .matter-analysis-session-item,
html[data-theme="dark"] .matter-analysis-session-list a,
html[data-theme="dark"] .matter-analysis-message,
html[data-theme="dark"] .matter-analysis-message.is-assistant,
html[data-theme="dark"] .matter-analysis-message.is-user,
html[data-theme="dark"] .matter-analysis-composer--studio .matter-analysis-composer__surface,
html[data-theme="dark"] .matter-analysis-settings .toggle-row,
html[data-theme="dark"] .matter-analysis-cost-summary,
html[data-theme="dark"] .matter-analysis-cost-line,
html[data-theme="dark"] .matter-analysis-event-row {
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(15, 27, 40, 0.94);
    color: #eaf6ff;
}

html[data-theme="dark"] .matter-analysis-message-action {
    background: rgba(8, 47, 73, 0.92) !important;
    color: #bae6fd !important;
    box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.24);
}

html[data-theme="dark"] .matter-analysis-message-action.is-danger {
    background: rgba(69, 10, 10, 0.82) !important;
    color: #fecaca !important;
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.32);
}

html[data-theme="dark"] .matter-analysis-source-legend {
    border-color: rgba(125, 211, 252, 0.22);
    background: rgba(8, 23, 35, 0.78);
}

html[data-theme="dark"] .matter-analysis-source-legend summary,
html[data-theme="dark"] .matter-analysis-source-legend__item strong {
    color: #eaf6ff;
}

html[data-theme="dark"] .matter-analysis-source-legend summary::before,
html[data-theme="dark"] .matter-analysis-source-legend__index {
    background: rgba(14, 165, 200, 0.2);
    color: #67e8f9;
}

html[data-theme="dark"] .matter-analysis-source-legend__item {
    border-top-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .matter-analysis-source-legend__item.is-openable:hover,
html[data-theme="dark"] .matter-analysis-source-legend__item.is-openable:focus {
    background: rgba(14, 165, 200, 0.12);
}

html[data-theme="dark"] .matter-analysis-source-legend__meta span {
    background: rgba(14, 165, 200, 0.2);
    color: #67e8f9;
}

html[data-theme="dark"] .matter-analysis-source-legend__item p,
html[data-theme="dark"] .matter-analysis-source-legend__meta {
    color: #a9bbce;
}

html[data-theme="dark"] .matter-analysis-session-item.is-active,
html[data-theme="dark"] .matter-analysis-session-list a.is-active,
html[data-theme="dark"] .matter-analysis-agent-levels--inline label:has(input:checked) {
    border-color: rgba(34, 211, 238, 0.55);
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.24), rgba(14, 28, 42, 0.98));
    color: #eaf6ff !important;
    box-shadow: inset 4px 0 0 #22d3ee, 0 12px 28px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .matter-analysis-session-item a,
html[data-theme="dark"] .matter-analysis-cost-summary strong,
html[data-theme="dark"] .matter-analysis-cost-line span,
html[data-theme="dark"] .matter-analysis-event-row__stage,
html[data-theme="dark"] .matter-analysis-popover-head strong,
html[data-theme="dark"] .matter-analysis-tool-row > strong,
html[data-theme="dark"] .matter-analysis-length-select,
html[data-theme="dark"] .matter-analysis-switch--modal,
html[data-theme="dark"] .matter-analysis-important-toggle,
html[data-theme="dark"] .matter-analysis-switch--composer {
    color: #eaf6ff !important;
}

html[data-theme="dark"] .matter-analysis-new-session label,
html[data-theme="dark"] .matter-analysis-settings label,
html[data-theme="dark"] .matter-analysis-composer label,
html[data-theme="dark"] .matter-analysis-session-modal label {
    color: #c9d8e8;
}

html[data-theme="dark"] .matter-analysis-new-session select,
html[data-theme="dark"] .matter-analysis-settings input,
html[data-theme="dark"] .matter-analysis-settings select,
html[data-theme="dark"] .matter-analysis-settings textarea,
html[data-theme="dark"] .matter-analysis-composer textarea,
html[data-theme="dark"] .matter-analysis-template-select,
html[data-theme="dark"] .matter-analysis-temperature input,
html[data-theme="dark"] .matter-analysis-length-select select,
html[data-theme="dark"] .matter-analysis-session-modal input,
html[data-theme="dark"] .matter-analysis-session-modal select,
html[data-theme="dark"] .matter-analysis-session-modal textarea {
    border-color: rgba(125, 211, 252, 0.24);
    background: #071522;
    color: #f1f8ff;
    box-shadow: none;
}

html[data-theme="dark"] .matter-analysis-composer textarea::placeholder,
html[data-theme="dark"] .matter-analysis-prompt-search input::placeholder {
    color: #8fa4b8;
}

html[data-theme="dark"] .matter-analysis-hero__badges span,
html[data-theme="dark"] .matter-analysis-hero__badges .matter-analysis-cost-pill,
html[data-theme="dark"] .matter-analysis-session-cost,
html[data-theme="dark"] .matter-analysis-cost-help,
html[data-theme="dark"] .matter-analysis-window-action,
html[data-theme="dark"] .matter-analysis-event-row__meta span {
    border-color: rgba(34, 211, 238, 0.34);
    background: rgba(8, 145, 178, 0.16);
    color: #a5f3fc;
}

html[data-theme="dark"] .matter-analysis-cost-line--total {
    border-color: rgba(34, 211, 238, 0.45);
    background: rgba(8, 145, 178, 0.2);
}

html[data-theme="dark"] .matter-analysis-cost-line strong,
html[data-theme="dark"] .matter-analysis-cost-help:hover,
html[data-theme="dark"] .matter-analysis-cost-help:focus-visible {
    color: #67e8f9;
}

html[data-theme="dark"] .matter-analysis-table th,
html[data-theme="dark"] .matter-analysis-table td {
    border-color: rgba(125, 211, 252, 0.22);
}

html[data-theme="dark"] .matter-analysis-table th {
    background: rgba(8, 145, 178, 0.22);
    color: #a5f3fc;
}

html[data-theme="dark"] .matter-analysis-table td {
    background: rgba(12, 24, 37, 0.98);
    color: #eaf6ff;
}

html[data-theme="dark"] .matter-analysis-prompt-popover,
html[data-theme="dark"] .matter-analysis-tools-panel,
html[data-theme="dark"] .matter-analysis-run-settings[open],
html[data-theme="dark"] .matter-analysis-session-menu,
html[data-theme="dark"] .matter-analysis-event-modal {
    border-color: rgba(125, 211, 252, 0.24);
    background: #0d1b27 !important;
    color: #eaf6ff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .matter-analysis-popover-head,
html[data-theme="dark"] .matter-analysis-tool-row,
html[data-theme="dark"] .matter-analysis-tools-panel .matter-analysis-temperature,
html[data-theme="dark"] .matter-analysis-event-modal__header {
    border-color: rgba(148, 163, 184, 0.2);
    background: #0d1b27;
}

html[data-theme="dark"] .matter-analysis-prompt-search {
    border-color: rgba(125, 211, 252, 0.24);
    background: #071522;
    color: #a9bbce !important;
}

html[data-theme="dark"] .matter-analysis-prompt-search input {
    color: #f1f8ff;
}

html[data-theme="dark"] .matter-analysis-prompt-item,
html[data-theme="dark"] .matter-analysis-tool-button,
html[data-theme="dark"] .matter-analysis-agent-levels label,
html[data-theme="dark"] .matter-analysis-agent-levels--inline label,
html[data-theme="dark"] .matter-analysis-session-menu button {
    border-color: rgba(125, 211, 252, 0.2) !important;
    background: rgba(15, 27, 40, 0.96) !important;
    color: #eaf6ff !important;
    box-shadow: none;
}

html[data-theme="dark"] .matter-analysis-prompt-item:hover,
html[data-theme="dark"] .matter-analysis-prompt-item:focus-visible,
html[data-theme="dark"] .matter-analysis-event-row:hover,
html[data-theme="dark"] .matter-analysis-event-row:focus-visible,
html[data-theme="dark"] .matter-analysis-tool-button:hover,
html[data-theme="dark"] .matter-analysis-tool-button:focus-visible {
    border-color: rgba(34, 211, 238, 0.58) !important;
    background: rgba(8, 145, 178, 0.22) !important;
}

html[data-theme="dark"] .matter-analysis-prompt-item__icon {
    background: rgba(8, 145, 178, 0.24);
    color: #67e8f9;
}

html[data-theme="dark"] .matter-analysis-run-settings summary,
html[data-theme="dark"] .matter-analysis-composer--studio .matter-analysis-run-settings summary {
    border-color: rgba(125, 211, 252, 0.24);
    background: #071522;
    color: #f1f8ff;
    box-shadow: none;
}

html[data-theme="dark"] .matter-analysis-composer--studio .matter-analysis-run-settings[open] summary {
    background: rgba(8, 145, 178, 0.26);
}

html[data-theme="dark"] .matter-analysis-speech-button,
html[data-theme="dark"] .matter-analysis-composer--studio [data-analysis-speech],
html[data-theme="dark"] .matter-analysis-composer--studio .primary-action {
    border-color: #0891b2;
    background: linear-gradient(135deg, #0891b2, #036985);
    color: #ffffff;
}

html[data-theme="dark"] .matter-analysis-wait {
    border-color: rgba(34, 211, 238, 0.38);
    background: rgba(8, 145, 178, 0.18);
    color: #a5f3fc;
}

html[data-theme="dark"] .matter-analysis-wait.is-error {
    border-color: rgba(248, 113, 113, 0.38);
    background: rgba(127, 29, 29, 0.26);
    color: #fecaca;
}

html[data-theme="dark"] .matter-analysis-event-modal::backdrop {
    background: rgba(2, 6, 12, 0.66);
    backdrop-filter: blur(2px);
}

html[data-theme="dark"] .matter-analysis-event-modal__body {
    background: #0d1b27;
}

html[data-theme="dark"] .matter-analysis-event-modal pre {
    border-color: rgba(125, 211, 252, 0.22);
    background: #071522;
    color: #eaf6ff;
}

html[data-theme="dark"] .matter-analysis-session-menu .danger-action {
    color: #fca5a5 !important;
}

/* UI remediation audit fixes: legacy modules dark mode + mobile foundation */
html[data-theme="dark"] .task-workspace,
html[data-theme="dark"] .kanban-column,
html[data-theme="dark"] .calendar-legaldesk,
html[data-theme="dark"] .calendar-legaldesk-sidebar,
html[data-theme="dark"] .calendar-legaldesk-main,
html[data-theme="dark"] .calendar-legaldesk-board,
html[data-theme="dark"] .calendar-legaldesk-list,
html[data-theme="dark"] .calendar-day-plan,
html[data-theme="dark"] .calendar-source-panel,
html[data-theme="dark"] .lead-workspace,
html[data-theme="dark"] .work-panel,
html[data-theme="dark"] .activities-register,
html[data-theme="dark"] .activities-inbox,
html[data-theme="dark"] .case-registry,
html[data-theme="dark"] .registry-toolbar,
html[data-theme="dark"] .invoice-queue,
html[data-theme="dark"] .detail-pane,
html[data-theme="dark"] .module-filters,
html[data-theme="dark"] .user-settings-shell,
html[data-theme="dark"] .user-settings-nav,
html[data-theme="dark"] .user-settings-panel,
html[data-theme="dark"] .settings-form-card,
html[data-theme="dark"] .settings-table,
html[data-theme="dark"] .client-form-section,
html[data-theme="dark"] .client-form-panel {
  background: #0d1b27 !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #eef6ff !important;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .calendar-legaldesk-day,
html[data-theme="dark"] .calendar-day-plan article,
html[data-theme="dark"] .calendar-legaldesk-event,
html[data-theme="dark"] .module-table,
html[data-theme="dark"] .module-table header,
html[data-theme="dark"] .module-table > a,
html[data-theme="dark"] .module-table-row,
html[data-theme="dark"] .work-row,
html[data-theme="dark"] .lead-summary-row,
html[data-theme="dark"] .invoice-row,
html[data-theme="dark"] .activity-grid-header,
html[data-theme="dark"] .activity-grid-row,
html[data-theme="dark"] .workload-row,
html[data-theme="dark"] .compact-register div,
html[data-theme="dark"] .team-side-section,
html[data-theme="dark"] .settings-table header,
html[data-theme="dark"] .settings-table label,
html[data-theme="dark"] .lead-modal-section,
html[data-theme="dark"] .wizard-panel,
html[data-theme="dark"] .admin-danger-card,
html[data-theme="dark"] .settings-grid label,
html[data-theme="dark"] .audit-row {
  background: rgba(15, 27, 40, 0.96) !important;
  border-color: rgba(148, 163, 184, 0.22) !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .module-table > a strong,
html[data-theme="dark"] .module-table-row strong,
html[data-theme="dark"] .modern-row__main strong,
html[data-theme="dark"] .workflow-item__content strong,
html[data-theme="dark"] .timeline-item__body strong,
html[data-theme="dark"] .work-row strong,
html[data-theme="dark"] .workload-row strong,
html[data-theme="dark"] .audit-row strong,
html[data-theme="dark"] .invoice-row strong,
html[data-theme="dark"] .invoice-row em,
html[data-theme="dark"] .activity-grid-row strong,
html[data-theme="dark"] .calendar-day-plan article strong,
html[data-theme="dark"] .calendar-legaldesk-event strong,
html[data-theme="dark"] .calendar-legaldesk-day > strong,
html[data-theme="dark"] .detail-pane h2,
html[data-theme="dark"] .work-panel h2,
html[data-theme="dark"] .invoice-queue h2,
html[data-theme="dark"] .activities-inbox h2,
html[data-theme="dark"] .user-settings-heading p,
html[data-theme="dark"] .client-form-title h1,
html[data-theme="dark"] .client-form-title h2 {
  color: #f8fbff !important;
}

html[data-theme="dark"] .module-table > a small,
html[data-theme="dark"] .module-table-row small,
html[data-theme="dark"] .modern-row__main small,
html[data-theme="dark"] .modern-row__meta small,
html[data-theme="dark"] .workflow-item__content small,
html[data-theme="dark"] .workflow-item__owner,
html[data-theme="dark"] .timeline-item__body small,
html[data-theme="dark"] .timeline-item__body em,
html[data-theme="dark"] .work-row small,
html[data-theme="dark"] .work-row span,
html[data-theme="dark"] .audit-row small,
html[data-theme="dark"] .audit-row span,
html[data-theme="dark"] .invoice-row span,
html[data-theme="dark"] .invoice-row small,
html[data-theme="dark"] .activity-grid-row span,
html[data-theme="dark"] .activity-grid-row small,
html[data-theme="dark"] .calendar-day-plan article span,
html[data-theme="dark"] .calendar-day-plan article small,
html[data-theme="dark"] .calendar-day-plan p,
html[data-theme="dark"] .calendar-legaldesk-event span,
html[data-theme="dark"] .detail-pane p,
html[data-theme="dark"] .detail-pane dt,
html[data-theme="dark"] .module-filters button,
html[data-theme="dark"] .user-settings-heading span,
html[data-theme="dark"] .client-form-section > aside h3 {
  color: #a9bbce !important;
}

html[data-theme="dark"] .module-filters button.is-active,
html[data-theme="dark"] .module-filters button:hover,
html[data-theme="dark"] .registry-tabs button.is-active,
html[data-theme="dark"] .registry-tabs button:hover,
html[data-theme="dark"] .activity-filter-strip button.is-active,
html[data-theme="dark"] .calendar-type-switches button.is-active,
html[data-theme="dark"] .calendar-view-buttons button.is-active,
html[data-theme="dark"] .client-form-section > aside a.is-active,
html[data-theme="dark"] .client-form-section > aside a:hover,
html[data-theme="dark"] .user-settings-nav a.is-active,
html[data-theme="dark"] .user-settings-nav a:hover {
  background: rgba(8, 145, 178, 0.22) !important;
  border-color: rgba(34, 211, 238, 0.45) !important;
  color: #a5f3fc !important;
}

html[data-theme="dark"] .registry-search,
html[data-theme="dark"] .activity-search,
html[data-theme="dark"] .task-search-group input,
html[data-theme="dark"] .calendar-search input,
html[data-theme="dark"] .module-shell input[type="search"],
html[data-theme="dark"] .settings-grid input,
html[data-theme="dark"] .settings-grid select,
html[data-theme="dark"] .settings-grid textarea,
html[data-theme="dark"] .form-grid input,
html[data-theme="dark"] .form-grid select,
html[data-theme="dark"] .form-grid textarea,
html[data-theme="dark"] .legaldesk-field-grid input,
html[data-theme="dark"] .legaldesk-field-grid select,
html[data-theme="dark"] .legaldesk-field-grid textarea {
  background: #071522 !important;
  border-color: rgba(125, 211, 252, 0.24) !important;
  color: #f1f8ff !important;
}

html[data-theme="dark"] .module-table > a:hover,
html[data-theme="dark"] .module-table-row:hover,
html[data-theme="dark"] .work-row:hover,
html[data-theme="dark"] .invoice-row:hover,
html[data-theme="dark"] .activity-grid-row:hover,
html[data-theme="dark"] .workload-row:hover,
html[data-theme="dark"] .audit-row:hover {
  background: rgba(8, 145, 178, 0.18) !important;
}

html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .lead-decision-modal,
html[data-theme="dark"] .matter-file-preview-modal {
  background: #0d1b27 !important;
  color: #eef6ff !important;
}

html[data-theme="dark"] .lead-decision-actions {
  background: rgba(13, 27, 39, 0.96) !important;
  border-top-color: rgba(148, 163, 184, 0.24) !important;
}

@media (max-width: 760px) {
  body {
    min-width: 320px;
  }

  .app-shell,
  .app-shell--v2 {
    --menu-width: 0px;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-main {
    min-width: 0;
  }

  .topbar,
  .topbar--v2 {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: auto;
    padding: 0.55rem;
  }

  .topbar-start,
  .topbar-search-wrap,
  .topbar-actions,
  .topbar-actions--v2 {
    min-width: 0;
    width: 100%;
  }

  .topbar-search-wrap {
    order: 3;
  }

  .topbar-search {
    width: 100%;
    max-width: none;
  }

  .topbar-search-hints {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .topbar-actions,
  .topbar-actions--v2 {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .module-page,
  .matter-workspace,
  .dashboard--premium,
  .user-settings-page {
    width: 100%;
    min-width: 0;
    padding: 0.65rem;
  }

  .page-header,
  .case-hero,
  .workspace-header {
    padding: 0.75rem;
  }

  .page-header h1,
  .workspace-header h1,
  .case-hero h1 {
    font-size: 1.45rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .tab-strip,
  .case-tabs,
  .matter-tabs,
  .admin-tabs,
  .registry-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .tab-strip a,
  .case-tabs a,
  .matter-tabs a,
  .admin-tabs a,
  .registry-tabs button {
    flex: 0 0 auto;
  }

  .matter-edit-grid {
    grid-template-columns: 1fr;
  }

  .matter-edit-grid .span-2,
  .matter-edit-grid .span-3 {
    grid-column: auto;
  }

  .matter-edit-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .registry-toolbar,
  .registry-toolbar--legaldesk,
  .registry-modern__controls,
  .registry-filter-stack,
  .activities-register-top,
  .calendar-legaldesk-header,
  .calendar-legaldesk-tools,
  .work-grid,
  .lead-workspace,
  .user-settings-shell,
  .client-form-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.65rem;
    min-width: 0;
  }

  .registry-search,
  .registry-search--compact,
  .registry-filter-stack .registry-search,
  .registry-filter-stack .registry-search--compact {
    width: 100%;
    min-width: 0;
  }

  .module-table header,
  .activity-grid-header {
    display: none !important;
  }

  .module-table,
  .activities-register,
  .invoice-queue,
  .calendar-legaldesk-board {
    overflow-x: visible !important;
  }

  .module-table > a,
  .module-table-row,
  .invoice-row,
  .activity-grid-row,
  .workload-row,
  .audit-row,
  .modern-row--case,
  .modern-row--doc,
  .modern-row--document,
  .modern-row--team-member {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
    gap: 0.35rem;
    align-items: start;
  }

  .module-table--clients header,
  .module-table--clients > a,
  .module-table--costs header,
  .module-table--costs > a,
  .module-table--correspondence header,
  .module-table--correspondence .module-table-row,
  .activity-grid,
  .activity-grid-header,
  .activity-grid-row {
    min-width: 0 !important;
  }

  .module-table > a > *,
  .module-table-row > *,
  .invoice-row > *,
  .activity-grid-row > *,
  .workload-row > *,
  .audit-row > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .report-grid,
  .report-status-grid,
  .kpi-grid,
  .dashboard-grid--main,
  .dashboard-grid--secondary,
  .quick-actions-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .calendar-legaldesk {
    grid-template-columns: minmax(0, 1fr);
  }

  .calendar-legaldesk-weekdays,
  .calendar-legaldesk-grid {
    min-width: 0 !important;
    grid-template-columns: repeat(7, minmax(38px, 1fr));
  }

  .calendar-legaldesk-day {
    min-height: 78px;
    padding: 0.32rem;
  }

  .calendar-legaldesk-event {
    min-width: 0;
  }

  .calendar-legaldesk-event span:not(.event-dot) {
    display: none;
  }

  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0;
  }

  .modal-card,
  .modal-card--wide,
  .modal--intake-decision .modal-card--wide {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100dvh;
    border-radius: 0;
    overflow: auto;
  }

  .modal-card header,
  .modal-card footer,
  .lead-decision-actions,
  .user-settings-actions {
    position: sticky;
    z-index: 2;
    flex-wrap: wrap;
    background: inherit;
  }

  .modal-card header {
    top: 0;
  }

  .modal-card footer,
  .lead-decision-actions,
  .user-settings-actions {
    bottom: 0;
  }

  .lead-modal-grid,
  .compact-definition-list,
  .form-grid,
  .legaldesk-field-grid,
  .stack-form--inline,
  .automation-rule-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .lead-decision-actions button,
  .user-settings-actions a,
  .user-settings-actions button {
    width: 100%;
  }
}
.ai-usage-report {
  gap: 14px;
}

.ai-usage-filters {
  display: grid;
  grid-template-columns: 260px 260px auto;
  gap: 12px;
  align-items: end;
  justify-content: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfd;
}

.ai-usage-filters label {
  display: grid;
  gap: 6px;
}

.ai-usage-custom-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.ai-usage-custom-range[hidden] {
  display: none;
}

.ai-usage-filters span,
.ai-usage-totals dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-usage-filters input,
.ai-usage-filters select {
  width: 100%;
  min-height: 42px;
  border: 2px solid #d7edf4;
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 2.35rem 0 0.8rem;
  font-weight: 760;
}

.ai-usage-filters select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #07566a 50%),
    linear-gradient(135deg, #07566a 50%, transparent 50%);
  background-position:
    calc(100% - 1.08rem) 52%,
    calc(100% - 0.78rem) 52%;
  background-size: 0.34rem 0.34rem, 0.34rem 0.34rem;
  background-repeat: no-repeat;
}

.ai-usage-filters select:focus,
.ai-usage-filters input:focus {
  border-color: #0ea5c6;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(14, 165, 198, 0.12);
}

.ai-usage-filters [data-ai-usage-apply] {
  min-height: 42px;
  border-color: #cfe0eb;
  background: #fff;
  padding-inline: 18px;
  white-space: nowrap;
}

.ai-usage-filters [data-ai-usage-apply]:hover,
.ai-usage-filters [data-ai-usage-apply]:focus-visible {
  border-color: #0ea5c6;
  color: var(--brand-dark);
  outline: none;
}

html[data-theme="dark"] .ai-usage-filters {
  background: rgba(15, 31, 43, 0.78);
  border-color: rgba(51, 65, 85, 0.9);
}

html[data-theme="dark"] .ai-usage-filters input,
html[data-theme="dark"] .ai-usage-filters select {
  border-color: rgba(34, 211, 238, 0.28);
  background-color: #0b1721;
}

html[data-theme="dark"] .ai-usage-filters select {
  background-image:
    linear-gradient(45deg, transparent 50%, #a5f3fc 50%),
    linear-gradient(135deg, #a5f3fc 50%, transparent 50%);
}

.ai-usage-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.ai-usage-totals div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.ai-usage-totals dd {
  margin: 6px 0 2px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 850;
}

.ai-usage-totals small {
  color: var(--muted);
  font-weight: 700;
}

.ai-usage-monthly,
.ai-usage-tables {
  display: grid;
  gap: 12px;
}

.ai-usage-monthly h3,
.ai-usage-tables h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.admin-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: var(--surface);
}

.admin-data-table th,
.admin-data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.admin-data-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.admin-data-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 920px) {
  .ai-usage-filters,
  .ai-usage-totals {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .ai-usage-custom-range {
    grid-template-columns: 1fr;
  }
}

/* Final override: collapsed AI answers must keep the importance toggle visible. */
.matter-analysis-message.is-assistant.is-collapsed footer {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-top: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(207, 232, 245, 0.74);
}

.matter-analysis-message.is-assistant.is-collapsed footer > small {
  display: none;
}

.matter-analysis-message.is-assistant.is-collapsed [data-analysis-importance-form] {
  margin: 0;
}

.matter-analysis-message.is-assistant.is-collapsed .matter-analysis-important-toggle {
  gap: 0.4rem;
  font-size: 0.8rem;
}

.matter-analysis-message.is-assistant.is-collapsed .matter-analysis-important-toggle button {
  width: 40px;
  height: 22px;
}

.matter-analysis-message.is-assistant.is-collapsed .matter-analysis-important-toggle button span {
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
}

.matter-analysis-message.is-assistant.is-collapsed footer form.is-important .matter-analysis-important-toggle button span {
  left: 21px;
}

.matter-analysis-message__preview {
  color: #334155;
  margin-bottom: 0.35rem;
}

.matter-analysis-message__lazy-note {
  color: #64748b;
  font-size: 0.82rem;
  margin: 0;
}

.matter-analysis-message__lazy-note.is-error {
  color: #b91c1c;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__details[open] ~ .matter-analysis-message__content {
  display: grid !important;
  max-height: none !important;
  overflow: visible !important;
}

.matter-analysis-message.is-collapsed .matter-analysis-message__details[open] ~ .matter-analysis-message__content > * {
  display: revert !important;
  max-height: none !important;
  overflow: visible !important;
  -webkit-line-clamp: unset !important;
}

.workspace-card__subsection {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.workspace-card__subsection > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.workspace-card__subsection h3 {
  margin: 0;
  font-size: 1rem;
}

.inline-editor {
  margin-bottom: 1rem;
}

.inline-editor > summary,
.row-actions > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.row-actions form {
  display: grid;
  gap: 0.5rem;
  min-width: min(22rem, 78vw);
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

/* Matter internal questions */
.matter-questions-panel header {
  align-items: flex-start;
}

.matter-question-attention {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(14, 165, 233, 0.24);
  border-radius: 14px;
  background: rgba(236, 254, 255, 0.82);
  color: #075985;
}

.matter-question-list {
  gap: 8px;
}

.matter-question-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.matter-question-row--attention {
  border-color: rgba(14, 165, 233, 0.55);
  background: linear-gradient(90deg, rgba(236, 254, 255, 0.86), rgba(255, 255, 255, 0.94));
}

.matter-question-modal {
  max-height: min(88vh, 920px);
  overflow: auto;
}

.matter-question-form-grid fieldset {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(248, 250, 252, 0.78);
  min-width: 0;
}

.matter-question-form-grid > label {
  align-self: start;
}

.matter-question-form-grid select,
.matter-question-form-grid input {
  min-height: 44px;
}

.matter-question-form-grid select:not([multiple]) {
  height: 44px;
}

.matter-question-form-grid legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matter-question-check-list {
  display: grid;
  gap: 8px;
  max-height: 150px;
  overflow: auto;
}

.matter-question-check-list label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(203, 213, 225, 0.72);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.matter-question-check-list--roles label {
  grid-template-columns: auto minmax(0, 1fr);
}

.matter-question-check-list small {
  color: var(--muted);
  font-size: 0.74rem;
}

.matter-question-recipient-builder {
  display: grid;
  gap: 10px;
}

.matter-question-recipient-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.matter-question-recipient-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.78);
}

.matter-question-recipient-selected p {
  margin: auto 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.matter-question-recipient-chip {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 8px;
  align-items: center;
  min-height: 36px;
  max-width: min(100%, 260px);
  border: 1px solid rgba(14, 165, 233, 0.32);
  border-radius: 999px;
  background: #ecfeff;
  color: #075985;
  padding: 5px 10px 5px 12px;
  text-align: left;
}

.matter-question-recipient-chip--role {
  border-color: rgba(124, 58, 237, 0.26);
  background: #f5f3ff;
  color: #5b21b6;
}

.matter-question-recipient-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-question-recipient-chip small {
  grid-column: 1;
  color: currentColor;
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.72;
}

.matter-question-recipient-chip span {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  font-weight: 900;
}

.matter-question-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.matter-question-summary div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.78);
}

.matter-question-summary dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matter-question-summary dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.matter-question-thread {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.matter-question-message {
  padding: 12px 14px;
  border: 1px solid rgba(186, 230, 253, 0.82);
  border-radius: 16px;
  background: rgba(240, 249, 255, 0.76);
}

.matter-question-message header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.matter-question-message p {
  margin: 0;
  white-space: pre-wrap;
}

.matter-question-reply {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.matter-question-reply label:not(.matter-question-close-toggle) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.matter-question-reply textarea {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.matter-question-close-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.matter-question-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.workflow-item--question {
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(236, 254, 255, 0.78);
}

html[data-theme="dark"] .matter-question-attention,
html[data-theme="dark"] .matter-question-row--attention,
html[data-theme="dark"] .workflow-item--question {
  background: rgba(8, 47, 73, 0.5);
  color: #bae6fd;
}

html[data-theme="dark"] .matter-question-form-grid fieldset,
html[data-theme="dark"] .matter-question-summary div,
html[data-theme="dark"] .matter-question-check-list label,
html[data-theme="dark"] .matter-question-recipient-selected,
html[data-theme="dark"] .matter-question-reply textarea {
  background: rgba(15, 23, 42, 0.86);
}

html[data-theme="dark"] .matter-question-recipient-chip {
  background: rgba(8, 47, 73, 0.72);
  color: #bae6fd;
}

html[data-theme="dark"] .matter-question-recipient-chip--role {
  background: rgba(46, 16, 101, 0.56);
  color: #ddd6fe;
}

html[data-theme="dark"] .matter-question-message {
  background: rgba(8, 47, 73, 0.42);
}

@media (max-width: 900px) {
  .matter-question-recipient-picker {
    grid-template-columns: 1fr;
  }

  .matter-question-summary {
    grid-template-columns: 1fr;
  }
}
