:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0b152b;
  --muted: #5f6d84;
  --line: #dbe4f0;
  --custody-navy: #000a22;
  --custody-navy-soft: #06183b;
  --custody-cyan: #19d9ef;
  --custody-blue: #0b84ff;
  --accent: #0b84ff;
  --accent-strong: #075ec2;
  --gold: #b7791f;
  --red: #b42318;
  --blue: #0b84ff;
  --focus: #19d9ef;
  --shadow: 0 18px 50px rgba(0, 10, 34, 0.1);
}

* {
  box-sizing: border-box;
}

*:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.large-text {
  font-size: 18px;
}

body.high-contrast {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #1f2937;
  --line: #111827;
  --accent: #004fb3;
  --accent-strong: #003875;
  --shadow: none;
}

body.high-contrast .sidebar {
  background: #000000;
}

body.high-contrast .record,
body.high-contrast .decision,
body.high-contrast .queue-item,
body.high-contrast .agent-card,
body.high-contrast .memory-card,
body.high-contrast .fallback-card {
  background: #ffffff;
}

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

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 1000;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #ffffff;
  font-weight: 800;
  transform: translateY(-180%);
  transition: transform 0.15s ease;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--custody-navy), var(--custody-navy-soft));
  color: #f8fbf8;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 52px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.side-panel p {
  color: #b9c5be;
  font-size: 13px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  object-position: center;
  border-radius: 50%;
}

.auth-corner-logo {
  display: none;
}

.nav-list {
  display: grid;
  gap: 6px;
  max-height: 46vh;
  overflow: auto;
  padding-right: 4px;
}

.nav-item {
  display: block;
  background: transparent;
  border: 0;
  color: #d9e5de;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  padding: 11px 12px;
  border-left: 3px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--custody-cyan);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.topbar-search {
  position: relative;
}

.global-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  max-height: min(420px, 70vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(2, 11, 35, 0.22);
  color: var(--ink);
  padding: 8px;
}

.search-result-group {
  display: grid;
  gap: 4px;
  padding: 4px 0;
}

.search-result-group > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  padding: 4px 8px;
  text-transform: uppercase;
}

.search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 8px;
  text-align: left;
}

.search-result:hover,
.search-result.active {
  border-color: rgba(18, 139, 126, 0.28);
  background: rgba(18, 139, 126, 0.08);
}

.search-result small {
  color: var(--muted);
}

.search-result mark {
  border-radius: 3px;
  background: rgba(241, 191, 87, 0.42);
  color: inherit;
  padding: 0 1px;
}

.search-empty {
  color: var(--muted);
  padding: 10px;
}

.sidebar-command {
  justify-content: center;
  width: 100%;
}

.recent-matters {
  display: grid;
  gap: 6px;
}

.recent-matter {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #d9e5de;
  cursor: pointer;
  font: inherit;
  padding: 8px 10px;
  text-align: left;
}

.recent-matter:hover,
.recent-matter:focus-visible {
  background: rgba(21, 203, 221, 0.18);
  outline: 2px solid rgba(21, 203, 221, 0.45);
}

.settings-nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d9e5de;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  padding: 10px 12px;
  border-left: 3px solid transparent;
}

.settings-nav-button.active,
.settings-nav-button:hover,
.settings-nav-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--custody-cyan);
  outline: none;
}

.nav-icon {
  width: 18px;
  text-align: center;
}

body.surface-client-portal {
  --bg: #f7f9fd;
  --accent: #0b84ff;
  --accent-strong: #075ec2;
}

body.surface-client-portal .sidebar {
  background: var(--custody-navy);
}

body.surface-client-portal .side-panel,
body.surface-client-portal #run-autonomous,
body.surface-client-portal #run-learning,
body.surface-client-portal #new-matter {
  display: none;
}

body.surface-client-portal .nav-item {
  padding: 14px 12px;
  font-weight: 750;
}

body.surface-platform-command .sidebar {
  background: #020817;
}

body.surface-platform-command .nav-item.active,
body.surface-platform-command .nav-item:hover {
  border-left-color: var(--custody-cyan);
}

body.auth-required .sidebar,
body.auth-required .view:not(#command-view),
body.auth-required #user-selector,
body.auth-required #logout,
body.auth-required #new-matter,
body.auth-required #run-learning,
body.auth-required [data-write-action],
body.auth-required .topbar-search,
body.auth-required #resume-work,
body.auth-required #quick-create,
body.auth-required #voice-input,
body.auth-required #hearing-countdown,
body.auth-required #language-selector,
body.auth-required #role-status,
body.auth-required #api-status,
body.auth-required #plain-language-toggle,
body.auth-required #large-text-toggle,
body.auth-required #contrast-toggle,
body.auth-required .metric-grid,
body.auth-required .two-col,
body.auth-required #command-view > :not(.auth-required-panel) {
  display: none !important;
}

body.auth-required {
  background:
    radial-gradient(circle at 18% 18%, rgba(25, 217, 239, 0.16), transparent 28rem),
    radial-gradient(circle at 92% 8%, rgba(11, 132, 255, 0.25), transparent 34rem),
    linear-gradient(135deg, #000a22 0%, #03143a 50%, #001f6f 100%);
}

body.auth-required .auth-corner-logo {
  display: block;
  position: fixed;
  top: 22px;
  left: 22px;
  z-index: 20;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 50%;
}

body.auth-required .app-shell {
  grid-template-columns: 1fr;
  min-height: 100vh;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.05), transparent 28%),
    transparent;
}

body.auth-required .main {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 0.82fr);
  gap: clamp(32px, 6vw, 86px);
  align-items: center;
  max-width: 1320px;
  min-height: 100vh;
  width: 100%;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 72px);
  overflow: hidden;
}

body.auth-required .topbar {
  grid-column: 2;
  grid-row: 1;
  align-items: stretch;
  background: transparent;
  margin: 0;
  position: relative;
  z-index: 2;
}

body.auth-required .topbar > div:first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body.auth-required .login-form {
  width: 100%;
  max-width: none;
  grid-template-columns: 1fr;
  gap: 18px;
}

body.auth-required .top-actions {
  flex: none;
  width: 100%;
  justify-content: center;
}

.auth-required-panel {
  grid-column: 1;
  grid-row: 1;
  max-width: 560px;
  overflow: hidden;
  color: #ffffff;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  position: relative;
  z-index: 1;
}

.auth-required-panel::before {
  content: "";
  position: absolute;
  left: -80px;
  top: -120px;
  width: 560px;
  height: 560px;
  border: 2px solid rgba(25, 217, 239, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.auth-hero {
  display: block;
}

.auth-copy {
  display: grid;
  gap: 22px;
}

.auth-brand-lockup {
  width: min(210px, 46vw);
  height: auto;
  margin-bottom: 8px;
  filter: drop-shadow(0 20px 38px rgba(0, 10, 34, 0.28));
}

.auth-kicker {
  color: var(--custody-cyan);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-kicker::before {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-bottom: 26px;
  background: linear-gradient(90deg, var(--custody-cyan), var(--custody-blue));
  border-radius: 999px;
}

.auth-copy h2 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.auth-copy p {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.08rem;
  line-height: 1.6;
}

.auth-value-grid,
.auth-trust-grid {
  display: grid;
  gap: 0;
}

.auth-value-grid {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.auth-value,
.auth-trust-item {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  padding: 22px 0 22px 92px;
  position: relative;
}

.auth-value::before,
.auth-trust-item::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 22px;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: var(--custody-cyan);
  background: rgba(11, 132, 255, 0.16);
  border: 1px solid rgba(25, 217, 239, 0.18);
}

.auth-value strong,
.auth-trust-item strong {
  display: block;
  margin-bottom: 5px;
  color: #ffffff;
  font-size: 1.04rem;
}

.auth-value small,
.auth-trust-item small {
  color: rgba(255, 255, 255, 0.66);
  line-height: 1.45;
}

.auth-path {
  display: none;
}

.auth-path h3 {
  margin: 0 0 10px;
}

.auth-path ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.auth-path li strong {
  color: var(--ink);
}

.auth-required-panel ul {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

.auth-required-panel li + li {
  margin-top: 8px;
}

.auth-form-card {
  width: min(100%, 610px);
  min-height: 610px;
  display: grid;
  gap: 22px;
  padding: clamp(30px, 4vw, 64px);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(0, 10, 34, 0.36);
}

.auth-card-copy {
  display: grid;
  gap: 8px;
}

.auth-card-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.auth-card-copy p,
.dialog-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-field {
  display: grid;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
}

.input-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 16px;
}

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

.input-icon {
  color: #8a94a6;
  margin-right: 14px;
}

.login-form .input-shell input:focus {
  outline: 0;
}

.password-toggle {
  color: #718096;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.auth-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.remember-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.remember-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--custody-blue);
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 650;
  padding: 0;
  cursor: pointer;
}

.auth-submit,
.google-btn {
  min-height: 58px;
  width: 100%;
  justify-content: center;
}

.auth-submit {
  border: 0;
  background: linear-gradient(90deg, #0aa5ff, #004ee8);
  box-shadow: 0 14px 28px rgba(0, 78, 232, 0.25);
}

.auth-status-message {
  min-height: 22px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
}

.auth-status-message[data-state="error"] {
  color: #b42318;
}

.auth-status-message[data-state="success"] {
  color: #047857;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  color: #8a94a6;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.google-btn span {
  color: #ea4335;
  font-weight: 850;
}

.auth-create-copy {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.auth-request-steps {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f8fbff;
}

.side-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.eyebrow {
  color: #92e5d9;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.main {
  padding: 24px;
  min-width: 0;
  overflow: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: -24px -24px 22px;
  padding: 24px 24px 16px;
  background: rgba(246, 248, 251, 0.96);
  border-bottom: 1px solid rgba(219, 228, 240, 0.88);
  backdrop-filter: blur(10px);
}

body.auth-required .topbar {
  position: static;
  margin: 0;
  padding: 0;
  background: transparent;
  border-bottom: 0;
  backdrop-filter: none;
}

.topbar > div:first-child {
  flex: 1 1 260px;
  min-width: 240px;
}

.topbar-search {
  flex: 1 1 280px;
  min-width: min(100%, 260px);
}

.topbar-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
}

.view,
.panel,
.metric,
.record,
.decision,
.queue-item,
.agent-card,
.memory-card,
.fallback-card {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.topbar p,
.panel p,
small {
  color: var(--muted);
}

.widget-fallback-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.widget-fallback-card strong {
  display: block;
  margin-bottom: 4px;
}

.top-actions,
.panel-head,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  flex: 1 1 420px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) minmax(9rem, 13rem) minmax(4.75rem, 6rem) auto;
  gap: 8px;
  align-items: center;
}

.login-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.58rem 0.7rem;
  background: var(--panel);
  color: var(--ink);
}

.login-form input[hidden] {
  display: none;
}

.login-form .mfa-input {
  max-width: 6rem;
}

.review-task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.review-packet {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

#action-handoff > .queue-item {
  grid-column: 1 / -1;
}

#action-handoff .review-packet small {
  overflow-wrap: anywhere;
}

.review-command {
  display: block;
  margin-top: 3px;
  color: var(--accent-strong);
  font-size: 12px;
}

.packet-action-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  align-items: end;
  margin: 6px 0;
}

.packet-action-filters label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.packet-action-filters button {
  min-height: 38px;
}

.risk-note {
  color: var(--red);
}

.compact-action {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.panel-head {
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.segment {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 750;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn:hover,
.icon-btn:hover,
.segment:hover {
  border-color: var(--accent);
}

.active-toggle {
  border-color: var(--accent);
  background: #e7f6f3;
  color: var(--accent-strong);
  font-weight: 800;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 26px 1fr 40px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.step-list span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.step-list .step-active span,
.step-list .step-complete span {
  border-color: var(--accent);
  background: #e7f6f3;
  color: var(--accent-strong);
}

.step-list .step-complete small {
  color: var(--ink);
  font-weight: 700;
}

.improvement-note {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.metric {
  padding: 16px;
  min-height: 118px;
}

.metric span,
.metric small {
  display: block;
}

.metric strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 34px;
}

.metric-link {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.metric-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.dashboard-metric-list {
  margin-top: 14px;
}

.dashboard-metric-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
}

.metric-detail-row {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.metric-detail-row:first-of-type {
  margin-top: 10px;
}

.panel {
  padding: 18px;
}

body.auth-required .auth-required-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

body.auth-required .auth-copy h2 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1.06;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.two-col,
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
}

.stack,
.record-list,
.learning-list,
.ledger {
  display: grid;
  gap: 10px;
}

.record,
.decision,
.queue-item,
.agent-card,
.memory-card,
.fallback-card {
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 13px;
}

.record {
  display: grid;
  gap: 7px;
}

.operating-workspace {
  display: grid;
  gap: 16px;
}

.operating-head {
  align-items: flex-start;
}

.operating-head p {
  max-width: 820px;
}

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

.operating-metric {
  border: 1px solid var(--line);
  background: #fbfcfb;
  border-radius: 8px;
  min-height: 104px;
  padding: 14px;
}

.operating-metric span,
.operating-metric small {
  color: var(--muted);
  display: block;
}

.operating-metric strong {
  display: block;
  font-size: 26px;
  margin: 8px 0 2px;
}

.operating-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.operating-section {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.operating-section h3 {
  margin: 0;
}

.operating-record {
  min-width: 0;
}

.operating-record.row-link {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.operating-record.row-link:hover,
.operating-record.row-link:focus-visible {
  border-color: var(--custody-blue);
  box-shadow: 0 0 0 2px rgba(11, 132, 255, 0.12);
}

.phase-two-note {
  border: 1px dashed rgba(20, 49, 78, 0.24);
  background: #f8fbfb;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 13px;
}

.roadmap-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.roadmap-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 12px;
}

.roadmap-step.current {
  border-color: var(--accent);
  background: #eef9f6;
}

.roadmap-dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.resource-link {
  color: var(--accent-strong);
  font-weight: 750;
  text-decoration: none;
}

.resource-link:hover {
  text-decoration: underline;
}

.matter-button.selected {
  border-color: var(--accent);
  background: #eef9f6;
}

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.draft-body-disclosure {
  margin-top: 8px;
}

.draft-body-disclosure pre {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status-pill,
.risk,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
  background: #e7f6f3;
  color: var(--accent-strong);
}

.risk.high {
  background: #fef3f2;
  color: var(--red);
}

.risk.medium {
  background: #fff7ed;
  color: var(--gold);
}

.api-online {
  background: #e7f6f3;
  color: var(--accent-strong);
}

.api-local {
  background: #fff7ed;
  color: var(--gold);
}

.queue-grid,
.board-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.board-grid {
  grid-template-columns: 1fr;
}

.advisor-board-dashboard {
  display: grid;
  gap: 16px;
}

.advisor-hero,
.advisor-summary-grid,
.judge-card-grid,
.advisor-report-grid,
.scenario-grid {
  display: grid;
  gap: 12px;
}

.advisor-hero {
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.5fr);
  align-items: stretch;
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 16px;
}

.advisor-hero h3 {
  margin: 10px 0 6px;
  font-size: 22px;
}

.advisor-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.advisor-summary-grid article,
.confidence-card,
.advisor-panel,
.judge-card,
.scenario-grid article,
.advisor-empty-state {
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 13px;
}

.advisor-summary-grid span,
.confidence-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.advisor-summary-grid strong,
.confidence-card strong {
  display: block;
  margin: 6px 0;
  font-size: 20px;
}

.confidence-track {
  height: 8px;
  background: #e7ece8;
  overflow: hidden;
}

.confidence-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #1d79e6);
}

.judge-card-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.judge-card {
  display: grid;
  gap: 9px;
  min-height: 260px;
}

.judge-card dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.judge-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.judge-card dd {
  margin: 0;
  font-size: 12px;
}

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

.advisor-panel.wide {
  grid-column: 1 / -1;
}

.advisor-panel h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.risk-heat-map,
.influence-map {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prediction-list,
.attack-row {
  display: grid;
  gap: 8px;
}

.prediction-list div,
.attack-row {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.prediction-list div:first-child,
.attack-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.prediction-list strong,
.prediction-list span {
  display: block;
}

.scenario-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.queue-item strong,
.agent-card strong,
.memory-card strong {
  display: block;
  margin-bottom: 6px;
}

.queue-item p,
.agent-card p,
.memory-card p,
.fallback-card p {
  margin-bottom: 0;
  font-size: 13px;
}

.detail-panel {
  min-height: 520px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.detail-stat {
  background: #f4f7f5;
  padding: 12px;
  border: 1px solid var(--line);
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-stat strong {
  display: block;
  margin-top: 4px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  background: #f8faf8;
}

.segment {
  border: 0;
  border-right: 1px solid var(--line);
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

.evidence-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(310px, 0.8fr);
  gap: 18px;
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-date {
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
}

.timeline-body strong {
  display: block;
}

.timeline-body p {
  margin: 4px 0 7px;
}

.insights {
  display: grid;
  gap: 10px;
  align-content: start;
}

.mini-chronology {
  display: grid;
  gap: 8px;
}

.chronology-card {
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px;
}

.chronology-card p {
  margin: 6px 0;
}

.draft-form,
.evidence-form,
.communication-form {
  display: grid;
  gap: 12px;
}

.communication-form {
  margin-bottom: 12px;
}

.evidence-form {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

.evidence-file-field,
.evidence-folder-field,
.matter-evidence-email,
.evidence-upload-queue,
.evidence-drop-zone {
  grid-column: span 2;
}

.matter-evidence-email {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

.evidence-drop-zone {
  display: grid;
  gap: 4px;
  min-height: 92px;
  border: 1px dashed rgba(18, 139, 126, 0.48);
  border-radius: 8px;
  background: rgba(18, 139, 126, 0.07);
  color: var(--ink);
  cursor: pointer;
  padding: 12px;
}

.evidence-drop-zone.drag-over,
.evidence-drop-zone:focus-visible {
  border-color: var(--accent);
  background: rgba(18, 139, 126, 0.12);
}

.evidence-drop-zone small {
  color: var(--muted);
}

.evidence-drop-zone progress {
  width: 100%;
}

.evidence-upload-queue {
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow: auto;
}

.evidence-upload-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
}

.evidence-upload-row span,
.evidence-upload-row small {
  overflow-wrap: anywhere;
}

.evidence-upload-row[data-upload-state="error"],
.evidence-upload-row[data-upload-state="duplicate"] {
  border-color: rgba(179, 45, 45, 0.35);
}

.checkbox-line {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.inline-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.checkbox-line input {
  width: auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px;
}

.login-form .input-shell input {
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: 56px;
  width: 100%;
}

#user-selector,
#language-selector {
  min-height: 38px;
  max-width: 230px;
}

textarea {
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  color: var(--ink);
}

.draft-preview {
  min-height: 210px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: #f7f8f5;
  padding: 14px;
  overflow: auto;
  margin-bottom: 14px;
}

.law-head {
  margin-top: 6px;
}

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

.settings-shortcut-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: #f8fbff;
  padding: 14px;
}

.settings-shell {
  display: grid;
  gap: 16px;
}

.settings-title-row p {
  margin-top: 6px;
}

.settings-search input {
  width: 100%;
  min-height: 44px;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 16px;
}

.settings-category-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.settings-category-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  font-weight: 750;
}

.settings-category-button.active,
.settings-category-button:hover,
.settings-category-button:focus-visible {
  border-color: var(--accent);
  background: #eef9f6;
  outline: none;
}

.settings-content {
  display: grid;
  gap: 12px;
}

.settings-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.settings-card,
.document-source-card,
.document-check-card {
  border: 1px solid var(--line);
  background: #fbfcfb;
  padding: 13px;
}

.settings-card.locked {
  background: #f6f7f5;
  opacity: 0.74;
}

.settings-actions,
.document-workflow-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

#document-dialog {
  width: min(980px, calc(100vw - 32px));
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.document-workflow-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
}

.workflow-steps,
.document-type-picker,
.document-sources,
.document-safety-grid,
.document-output-grid {
  display: grid;
  gap: 8px;
}

.workflow-step {
  border: 1px solid var(--line);
  background: #f7f8f5;
  padding: 10px;
  color: var(--muted);
  font-weight: 750;
}

.workflow-step.active {
  background: #eef9f6;
  border-color: var(--accent);
  color: var(--ink);
}

.document-type-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 12px;
  text-align: left;
}

.document-type-button.active,
.document-type-button:hover,
.document-type-button:focus-visible {
  border-color: var(--accent);
  background: #eef9f6;
  outline: none;
}

.workflow-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.document-context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.document-source-card label {
  color: var(--ink);
  font-weight: 750;
}

.document-draft-preview {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: #f7f8f5;
  padding: 14px;
  max-height: 340px;
  overflow: auto;
}

.agent-card {
  min-height: 150px;
}

.agent-card.lawyer {
  border-color: #d9c8a3;
  background: #fffaf0;
}

dialog {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
}

dialog.wide-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: min(88vh, 920px);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

dialog form {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.conflict-check-note {
  border: 1px solid rgba(183, 121, 31, 0.35);
  border-radius: 8px;
  background: rgba(183, 121, 31, 0.09);
  color: var(--ink);
  padding: 10px 12px;
}

.law-firm-signup-form {
  gap: 18px;
}

.signup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.signup-section {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.signup-section.full-width {
  grid-column: 1 / -1;
}

.signup-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.signup-section textarea {
  resize: vertical;
}

.signup-policy-note,
.auth-request-steps {
  display: grid;
  gap: 4px;
  border: 1px solid #d8e3f5;
  border-radius: 8px;
  padding: 12px;
  background: #f6f9ff;
  color: var(--ink);
}

.signup-policy-note span,
.auth-request-steps span {
  color: var(--muted);
  line-height: 1.45;
}

.app-legal-strip {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  gap: 10px 18px;
  justify-content: space-between;
  margin-top: 10px;
  padding: 14px 2px 4px;
}

.app-legal-strip nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.app-legal-strip a,
.policy-back-link,
.policy-footer a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.app-legal-strip a:hover,
.app-legal-strip a:focus-visible,
.policy-back-link:hover,
.policy-back-link:focus-visible,
.policy-footer a:hover,
.policy-footer a:focus-visible {
  text-decoration: underline;
}

.policy-page {
  background: #f7f9fd;
}

.policy-document {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 32px auto;
  max-width: 920px;
  padding: 32px;
}

.policy-eyebrow {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 24px 0 8px;
  text-transform: uppercase;
}

.policy-summary {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 18px;
}

.policy-review-banner {
  background: #f6f9ff;
  border: 1px solid #d8e3f5;
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.5;
  margin: 0 0 24px;
  padding: 12px 14px;
}

.policy-body h1 {
  font-size: 2rem;
  margin: 0 0 14px;
}

.policy-body h2 {
  font-size: 1.18rem;
  margin: 24px 0 8px;
}

.policy-body p {
  color: var(--ink);
  line-height: 1.65;
  margin: 0 0 12px;
}

.policy-body .policy-note {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  padding-left: 12px;
}

.policy-list-item {
  padding-left: 14px;
  position: relative;
}

.policy-list-item::before {
  content: "";
  background: var(--accent);
  border-radius: 999px;
  height: 5px;
  left: 0;
  position: absolute;
  top: 0.8em;
  width: 5px;
}

.policy-footer {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 28px;
  padding-top: 18px;
}

.signup-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 16px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 1700px) {
  .two-col,
  .workspace-grid,
  .evidence-layout {
    grid-template-columns: 1fr;
  }

  .queue-grid,
  .board-grid,
  .judge-card-grid,
  .scenario-grid,
  .operating-metric-grid,
  .operating-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .advisor-summary-grid,
  .advisor-report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.auth-required .main {
    grid-template-columns: 1fr;
    align-items: start;
    overflow: auto;
  }

  body.auth-required .topbar,
  body.auth-required .auth-required-panel {
    grid-column: 1;
  }

  body.auth-required .topbar {
    grid-row: 2;
  }

  body.auth-required .auth-required-panel {
    grid-row: 1;
    max-width: none;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    overscroll-behavior: auto;
  }

  .advisor-hero,
  .advisor-summary-grid,
  .judge-card-grid,
  .advisor-report-grid,
  .scenario-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-bottom {
    margin-top: 0;
  }

  .side-panel {
    display: none;
  }

  .metric-grid,
  .queue-grid,
  .board-grid,
  .operating-metric-grid,
  .operating-grid,
  .login-form,
  .evidence-form,
  .two-col,
  .workspace-grid,
  .evidence-layout,
  .auth-hero,
  .auth-value-grid,
  .settings-layout,
  .signup-grid,
  .document-workflow-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .operating-section,
  .record-list {
    max-width: 100%;
    overflow-x: auto;
  }

  .panel table {
    min-width: 680px;
  }

  .calendar-month-grid {
    grid-template-columns: repeat(7, minmax(84px, 1fr));
    min-width: 640px;
  }

  .evidence-file-field,
  .evidence-folder-field,
  .matter-evidence-email,
  .evidence-upload-queue,
  .evidence-drop-zone {
    grid-column: 1;
  }

  .global-search-results {
    left: 0;
    right: auto;
    width: min(100%, calc(100vw - 32px));
    max-height: min(360px, 60vh);
  }

  .top-actions {
    flex: 0 1 auto;
    justify-content: flex-start;
    width: 100%;
  }

  .topbar > div:first-child {
    flex: 0 1 auto;
  }

  .brand {
    min-height: 52px;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  body.auth-required .auth-corner-logo {
    top: 14px;
    left: 14px;
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 620px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    justify-content: flex-start;
  }

  .topbar .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.auth-required .topbar .top-actions {
    display: block;
  }

  .topbar .login-form {
    grid-column: 1 / -1;
  }

  .topbar .primary-btn,
  .topbar .ghost-btn,
  .topbar .icon-btn,
  .topbar select,
  .topbar input {
    width: 100%;
  }

  .topbar .status-pill {
    justify-content: center;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

  .settings-shortcut-strip,
  .settings-actions,
  .document-workflow-actions,
  .app-legal-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .policy-document {
    margin: 16px;
    padding: 22px;
  }

  h1 {
    font-size: 24px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}
