:root,
[data-theme="light"] {
  color-scheme: light;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --duration-fast: 160ms;
  --color-background: #f8fafc;
  --color-background-secondary: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-secondary: #f8fafc;
  --color-surface-raised: #ffffff;
  --color-header: #ffffff;
  --color-sidebar: #ffffff;
  --color-text-primary: #111827;
  --color-text-secondary: #4b5563;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-border-strong: #cbd5e1;
  --color-accent-primary: #0f172a;
  --color-accent-primary-hover: #1f2937;
  --color-accent-primary-text: #ffffff;
  --color-accent-secondary: #0e7490;
  --color-link: #2563eb;
  --color-success: #16a34a;
  --color-success-bg: #ecfdf5;
  --color-warning: #b45309;
  --color-warning-bg: #fffbeb;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-info: #2563eb;
  --color-info-bg: #eff6ff;
  --color-focus: #0e7490;
  --logo-bg: #0f172a;
  --logo-border: #e5e7eb;
  --input-bg: #ffffff;
  --input-border: #b8c2d0;
  --bg: var(--color-background);
  --panel: var(--color-background-secondary);
  --surface: var(--color-surface);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --soft: var(--color-text-muted);
  --line: var(--color-border);
  --navy: var(--color-accent-primary);
  --teal: var(--color-accent-secondary);
  --blue: var(--color-link);
  --green: var(--color-success);
  --amber: #f59e0b;
  --red: var(--color-error);
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 2px rgb(15 23 42 / 0.06), 0 8px 24px rgb(15 23 42 / 0.06);
  --shadow-raised: 0 16px 40px rgb(15 23 42 / 0.12);
  font-family: var(--font-sans);
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-background: #0b1220;
  --color-background-secondary: #111827;
  --color-surface: #111827;
  --color-surface-secondary: #0f172a;
  --color-surface-raised: #172033;
  --color-header: #111827;
  --color-sidebar: #0f172a;
  --color-text-primary: #f9fafb;
  --color-text-secondary: #d1d5db;
  --color-text-muted: #9ca3af;
  --color-border: #1f2937;
  --color-border-strong: #334155;
  --color-accent-primary: #38bdf8;
  --color-accent-primary-hover: #67e8f9;
  --color-accent-primary-text: #07111f;
  --color-accent-secondary: #06b6d4;
  --color-link: #93c5fd;
  --color-success: #22c55e;
  --color-success-bg: #052e1a;
  --color-warning: #fbbf24;
  --color-warning-bg: #3a2603;
  --color-error: #f87171;
  --color-error-bg: #3b1014;
  --color-info: #60a5fa;
  --color-info-bg: #0b2447;
  --color-focus: #38bdf8;
  --logo-bg: #050b16;
  --logo-border: #334155;
  --input-bg: #0f172a;
  --input-border: #334155;
  --bg: var(--color-background);
  --panel: var(--color-background-secondary);
  --surface: var(--color-surface);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --soft: var(--color-text-muted);
  --line: var(--color-border);
  --navy: var(--color-accent-primary);
  --teal: var(--color-accent-secondary);
  --blue: var(--color-link);
  --green: var(--color-success);
  --amber: var(--color-warning);
  --red: var(--color-error);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 1px 0 rgb(255 255 255 / 0.04), 0 18px 40px rgb(0 0 0 / 0.28);
  --shadow-raised: 0 24px 54px rgb(0 0 0 / 0.42);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--color-background-secondary), transparent 16%), transparent 36rem),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
}

a {
  color: var(--color-link);
}

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

button,
a,
input,
select,
textarea,
summary {
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-focus) 34%, transparent);
}

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

.auth-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 480px);
  gap: 48px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.auth-brand {
  align-self: start;
  padding-top: 28px;
}

.auth-logo-wrap {
  display: grid;
  place-items: center;
  width: 220px;
  max-width: 100%;
  min-height: 64px;
  margin-bottom: 28px;
  border: 1px solid var(--logo-border);
  border-radius: 18px;
  background: var(--logo-bg);
  padding: 12px;
}

.auth-logo-wrap .brand-logo {
  width: 100%;
  max-height: 72px;
  object-fit: contain;
}

.logo-monogram {
  color: #ffffff;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0;
}

.auth-brand h1 {
  max-width: 560px;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-brand p,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.compact {
  margin: 8px 0 0;
  font-size: 15px;
}

.auth-card,
.auth-step,
.info-card,
.search-panel,
.detail-header,
.section-head,
.create-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.auth-card {
  display: grid;
  gap: 14px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.auth-step {
  display: grid;
  gap: 16px;
  padding: 28px;
  box-shadow: var(--shadow-raised);
}

.auth-step h2 {
  font-size: 26px;
  line-height: 1.2;
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--input-bg);
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 11px 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button,
.primary-link {
  background: var(--navy);
  color: var(--color-accent-primary-text);
}

.primary-button:hover,
.primary-link:hover {
  background: var(--color-accent-primary-hover);
}

.secondary-button,
.secondary-link,
.ghost-button {
  background: var(--surface);
  color: var(--navy);
  border-color: var(--color-border-strong);
}

.secondary-button:hover,
.secondary-link:hover,
.ghost-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.danger-button {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: color-mix(in srgb, var(--color-error) 36%, var(--line));
}

.danger-button:hover {
  background: color-mix(in srgb, var(--color-error-bg) 72%, var(--surface));
  border-color: var(--color-error);
}

.link-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--color-link);
  font-weight: 800;
  cursor: pointer;
  padding: 8px 0;
  text-align: left;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.status {
  border: 1px solid color-mix(in srgb, var(--color-info) 30%, var(--line));
  border-radius: 10px;
  padding: 13px 15px;
  color: var(--color-info);
  background: var(--color-info-bg);
  line-height: 1.5;
}

.status.error {
  border-color: color-mix(in srgb, var(--color-error) 34%, var(--line));
  color: var(--color-error);
  background: var(--color-error-bg);
}

.method-grid {
  display: grid;
  gap: 12px;
}

.method-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.method-card h3,
.method-card p {
  margin: 0;
}

.method-card p {
  color: var(--muted);
  line-height: 1.5;
}

.setup-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: start;
}

.qr-box {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  border: 1px dashed var(--color-border-strong);
  border-radius: 10px;
  background: var(--color-surface-secondary);
  color: var(--muted);
  text-align: center;
  padding: 14px;
}

.qr-box span {
  font-size: 22px;
  font-weight: 900;
  color: var(--navy);
}

.code-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.code-list code {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-surface-secondary);
  text-align: center;
  font-size: 16px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: 19px;
  height: 19px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  border-right: 1px solid var(--line);
  background: var(--color-sidebar);
  padding: var(--space-6);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink);
  text-decoration: none;
}

.brand-logo-wrap {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 3.15rem;
  height: 3.15rem;
  overflow: hidden;
  border: 1px solid var(--logo-border);
  border-radius: var(--radius-md);
  background: var(--logo-bg);
  padding: 5px;
}

.brand-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.brand strong {
  font-size: 1rem;
  line-height: 1.2;
}

.brand small,
.security-panel small {
  color: var(--soft);
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: var(--space-2);
}

.side-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}

.side-nav a:hover,
.side-nav a.is-active {
  border-color: var(--line);
  background: var(--color-surface-secondary);
  color: var(--ink);
}

.side-nav a.is-active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.security-panel {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-surface-secondary);
  padding: var(--space-4);
}

.security-panel strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--soft);
}

.status-dot.success {
  background: var(--green);
}

.app-main {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--color-header) 94%, transparent);
  padding: 22px 32px;
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(10px);
}

.topbar > div:first-child {
  min-width: 190px;
}

.eyebrow,
.card-kicker {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 14px;
  font-weight: 850;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  white-space: nowrap;
}

.user-menu {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(360px, 32vw);
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--color-surface-secondary);
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.search-box .nav-svg {
  color: var(--teal);
}

.search-box input {
  min-height: 42px;
  border: 0;
  background: transparent;
  padding: 10px 0;
}

.search-box:focus-within {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus) 16%, transparent);
}

.theme-control {
  width: min(260px, 100%);
  margin-top: 24px;
  font-weight: 800;
}

.theme-control select {
  margin-top: 8px;
}

.compact-theme {
  display: flex;
  width: auto;
  min-width: 220px;
  margin-top: 0;
  align-items: center;
  gap: 8px;
}

.compact-theme select {
  margin-top: 0;
  padding: 10px 12px;
}

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

.portal-pillars article {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.portal-pillars h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.portal-pillars p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.content {
  display: grid;
  gap: 24px;
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 92px;
}

.hero-band {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--teal) 12%, transparent), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-card);
  padding: clamp(22px, 3vw, 34px);
}

.hero-band h2 {
  max-width: 720px;
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-band p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 260px;
}

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

.summary-strip article {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.summary-strip span {
  color: var(--muted);
  font-weight: 700;
}

.summary-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

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

.dashboard-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}

.dashboard-card:hover,
.dashboard-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: var(--shadow-raised);
}

.dashboard-card strong {
  font-size: 20px;
  line-height: 1.25;
}

.dashboard-card p {
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-info-bg);
  color: var(--color-info);
  font-weight: 900;
}

.dashboard-icon.cyan {
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
}

.dashboard-icon.blue {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.dashboard-icon.green {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.dashboard-icon.amber {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.dashboard-icon.slate {
  background: var(--color-surface-secondary);
  color: var(--navy);
}

.dashboard-icon.violet {
  background: color-mix(in srgb, #8b5cf6 14%, var(--surface));
  color: #7c3aed;
}

.icon,
.nav-svg,
.dashboard-svg,
.inline-svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-svg {
  width: 19px;
  height: 19px;
  color: var(--teal);
}

.dashboard-svg {
  width: 24px;
  height: 24px;
}

.inline-svg {
  width: 18px;
  height: 18px;
}

.open-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: end;
  color: var(--teal);
  font-weight: 900;
}

.search-panel,
.detail-header,
.section-head,
.info-card,
.empty-state {
  padding: 22px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.create-panel {
  margin-top: 16px;
  padding: 16px;
  box-shadow: none;
  background: var(--color-surface-secondary);
}

summary {
  cursor: pointer;
  font-weight: 850;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 16px;
}

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

.matter-form {
  margin-top: 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.result-list {
  display: grid;
  gap: 14px;
}

.result-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.result-card:hover {
  border-color: color-mix(in srgb, var(--teal) 46%, var(--line));
  box-shadow: var(--shadow-raised);
}

.result-card h3 {
  margin: 0 0 12px;
  font-size: 21px;
}

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

dt {
  color: var(--soft);
  font-weight: 750;
  font-size: 14px;
}

dd {
  margin: 4px 0 0;
  color: var(--ink);
  line-height: 1.45;
}

.card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 160px;
}

.document-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.compact-actions {
  display: inline-flex;
  margin-top: 0;
  vertical-align: middle;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--navy);
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--teal);
  background: var(--color-info-bg);
  color: var(--teal);
  transform: translateY(-1px);
}

.document-preview-panel {
  display: grid;
  gap: 16px;
}

.document-preview-panel[hidden] {
  display: none !important;
}

.document-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.document-preview-toolbar h3 {
  margin-bottom: 6px;
  font-size: 24px;
}

.document-preview-frame {
  width: 100%;
  min-height: min(72vh, 780px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-surface-secondary);
}

.document-preview-image {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-surface-secondary);
}

.loading-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-surface-secondary);
  color: var(--muted);
  padding: 18px;
  font-weight: 750;
}

.compact-empty {
  min-height: 180px;
  box-shadow: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  background: var(--color-surface-secondary);
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.status-badge.success {
  border-color: color-mix(in srgb, var(--color-success) 34%, var(--line));
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-badge.warning {
  border-color: color-mix(in srgb, var(--color-warning) 34%, var(--line));
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-badge.info {
  border-color: color-mix(in srgb, var(--color-info) 34%, var(--line));
  background: var(--color-info-bg);
  color: var(--color-info);
}

.status-badge.danger {
  border-color: color-mix(in srgb, var(--color-error) 34%, var(--line));
  background: var(--color-error-bg);
  color: var(--color-error);
}

.card-text {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}

.inline-edit {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-header,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.detail-header h2,
.section-head h2 {
  margin-bottom: 12px;
  font-size: 28px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.text-preview {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--color-surface-secondary);
  color: var(--ink);
  padding: 16px;
  line-height: 1.55;
}

.auto-client-preview {
  border: 1px solid color-mix(in srgb, var(--color-info) 34%, var(--line));
  border-radius: 10px;
  background: var(--color-info-bg);
  color: var(--color-info);
  padding: 12px 14px;
  font-weight: 750;
  line-height: 1.5;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.chip.active {
  border-color: var(--teal);
  background: var(--color-info-bg);
  color: var(--color-info);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  min-height: 260px;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  color: var(--muted);
  max-width: 520px;
  line-height: 1.55;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: var(--color-info-bg);
  color: var(--color-info);
  font-weight: 900;
}

.mobile-bottom-nav {
  display: none;
}

.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;
}

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

  .auth-shell {
    padding: 24px 0;
    gap: 20px;
  }

  .auth-brand {
    padding-top: 0;
  }

  .auth-brand h1 {
    font-size: 32px;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 18px;
  }

  .content {
    width: min(100% - 28px, 1180px);
  }

  .hero-band {
    display: grid;
    align-items: start;
  }

  .hero-actions {
    justify-content: start;
    min-width: 0;
  }

  .summary-strip,
  .dashboard-grid,
  .dashboard-grid.four,
  .form-grid,
  .meta-grid,
  .detail-grid,
  .setup-grid {
    grid-template-columns: 1fr;
  }

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

  .result-card,
  .detail-header,
  .section-head {
    display: grid;
  }

  .card-actions,
  .quick-actions {
    align-items: stretch;
    justify-content: start;
    min-width: 0;
  }

  .document-preview-toolbar {
    display: grid;
  }

  .document-preview-frame {
    min-height: 62vh;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-header) 96%, transparent);
    box-shadow: var(--shadow-raised);
    overflow: hidden;
    backdrop-filter: blur(12px);
  }

  .mobile-bottom-nav a {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 10px 4px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
  }

  .mobile-bottom-nav a.is-active {
    background: var(--color-surface-secondary);
    color: var(--ink);
  }

  .compact-theme {
    min-width: 0;
    width: 100%;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .portal-pillars {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-step,
  .search-panel,
  .detail-header,
  .section-head,
  .info-card,
  .empty-state {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
  }

  .user-menu {
    width: 100%;
    display: grid;
    justify-content: space-between;
  }

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