@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;

  --bg: #f6f7fb;
  --bg-subtle: #eef2f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f9fafc;
  --text: #131722;
  --text-soft: #3b4556;
  --muted: #697386;
  --line: #dde3ec;
  --line-strong: #c9d2df;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1ff;
  --success-bg: #eaf8f0;
  --success-text: #167046;
  --success-line: #bce8cd;
  --warning-bg: #fff7e6;
  --warning-text: #946200;
  --warning-line: #f3d48a;
  --danger-bg: #fff0f0;
  --danger-text: #b42318;
  --danger-line: #f4b3ad;
  --neutral-bg: #eef1f5;
  --neutral-text: #566174;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 12px 32px rgb(15 23 42 / 8%);
  --shadow-lg: 0 24px 70px rgb(15 23 42 / 12%);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;
  --text-3xl: 36px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1118;
  --bg-subtle: #121824;
  --surface: #151b26;
  --surface-raised: #192130;
  --surface-muted: #111722;
  --text: #eef2f8;
  --text-soft: #c9d2df;
  --muted: #8d99aa;
  --line: #293242;
  --line-strong: #354154;
  --accent: #7aa2ff;
  --accent-strong: #9dbaff;
  --accent-soft: #17284a;
  --success-bg: #10291d;
  --success-text: #87d8a9;
  --success-line: #215b3b;
  --warning-bg: #2b210f;
  --warning-text: #f5cc72;
  --warning-line: #70511a;
  --danger-bg: #321717;
  --danger-text: #ff9a91;
  --danger-line: #79302b;
  --neutral-bg: #242c39;
  --neutral-text: #b5bfce;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 24%);
  --shadow-md: 0 16px 40px rgb(0 0 0 / 24%);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / 34%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 14% 4%, rgb(37 99 235 / 7%), transparent 28rem),
    linear-gradient(180deg, var(--bg-subtle), var(--bg) 34rem);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

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

h1 {
  max-width: 880px;
  margin-bottom: var(--space-2);
  font-size: clamp(28px, 4vw, var(--text-3xl));
  line-height: 1.12;
  font-weight: 800;
}

h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
  line-height: 1.25;
  font-weight: 750;
}

p {
  color: var(--text-soft);
}

button,
input,
select {
  font: inherit;
}

button,
.button-primary,
.button-secondary,
.button-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

button:hover,
.button-primary:hover,
.button-secondary:hover,
.button-small:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

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

.button-primary,
button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgb(37 99 235 / 18%);
}

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

.button-secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.button-secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.button-small {
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-size: var(--text-sm);
  box-shadow: none;
}

.button-danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger-text);
  box-shadow: none;
}

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

.button-compact {
  min-height: 38px;
}

.button-icon {
  display: inline-flex;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.small,
.field-hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.eyebrow {
  margin-bottom: var(--space-2);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  height: 100vh;
  min-width: 0;
  padding: var(--space-6);
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand,
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  font-weight: 800;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #12b981);
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: 850;
  box-shadow: 0 12px 24px rgb(37 99 235 / 22%);
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-title {
  font-size: var(--text-lg);
}

.brand-subtitle {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 42px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 650;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item.is-disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.72;
}

.nav-icon {
  display: inline-flex;
  color: var(--muted);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 72px;
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
}

.topbar-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.topbar-title strong {
  font-size: var(--text-lg);
}

.page-kicker {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 750;
  text-transform: uppercase;
}

.topbar-actions,
.actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.topbar-actions {
  justify-content: flex-end;
  min-width: 0;
}

.theme-toggle {
  min-height: 38px;
  padding: 0 var(--space-3);
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0 50%, var(--surface-muted) 50% 100%);
  border: 1px solid var(--line-strong);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-3) 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 850;
}

.user-meta {
  display: grid;
  line-height: 1.15;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
}

.user-meta small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.page {
  width: min(1180px, calc(100% - 48px));
  margin: var(--space-10) auto;
}

.auth-shell {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--space-6);
}

.auth-theme-toggle {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 2;
}

.auth-page {
  width: min(480px, 100%);
  margin: 0;
}

.auth-panel,
.form-card,
.detail-panel,
.table-panel,
.delete-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-md);
}

.auth-panel {
  padding: var(--space-8);
}

.auth-brand {
  margin-bottom: var(--space-8);
}

.auth-footer {
  margin-top: var(--space-4);
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  align-items: flex-start;
  margin-bottom: var(--space-8);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 220px;
  padding: var(--space-6);
}

.summary-card > :last-child {
  margin-top: auto;
}

.summary-card .button-primary,
.summary-card .button-secondary,
.summary-card .badge {
  align-self: flex-start;
}

.summary-card.is-primary {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 48%, transparent), transparent 72%),
    var(--surface);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.metric-card,
.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-md);
}

.metric-card {
  display: grid;
  gap: var(--space-1);
  min-height: 136px;
  padding: var(--space-5);
}

.metric-card strong {
  color: var(--text);
  font-size: var(--text-2xl);
  line-height: 1.1;
}

.metric-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.metric-note {
  color: var(--text-soft);
  font-size: var(--text-sm);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.chart-card {
  padding: var(--space-5);
}

.chart-wrap {
  height: 300px;
  margin-top: var(--space-5);
}

.chart-wrap.is-compact {
  height: 240px;
}

.mode-card {
  margin-bottom: var(--space-5);
}

.mode-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.card-icon,
.empty-icon,
.danger-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.danger-icon {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge,
.status,
.sensitive-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 800;
}

.badge {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.status-ready {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-indexing,
.status-pending {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.status-indexing .status-dot,
.status-pending .status-dot {
  animation: pulse 1.5s ease-in-out infinite;
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.status-doc-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-doc-disabled {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.role-badge {
  display: inline-flex;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 800;
}

.role-admin {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.role-teamlead {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.role-employee {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sensitive-pill {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.sensitive-pill.is-sensitive {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.toast,
.notice,
.error {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 650;
}

.notice {
  border: 1px solid var(--success-line);
  background: var(--success-bg);
  color: var(--success-text);
}

.error {
  border: 1px solid var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.form-card {
  width: min(720px, 100%);
  padding: var(--space-8);
}

.form {
  display: grid;
  gap: var(--space-5);
}

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

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

label {
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

input[type="file"] {
  height: auto;
  padding: 12px;
}

input:hover,
select:hover {
  border-color: var(--line-strong);
}

input::file-selector-button {
  margin-right: var(--space-3);
  padding: 8px var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
}

.table-panel {
  overflow: hidden;
}

.table-panel table {
  width: 100%;
  border-collapse: collapse;
}

.document-table-panel {
  overflow-x: auto;
  overflow-y: visible;
}

.documents-table {
  table-layout: fixed;
  min-width: 860px;
}

.documents-table .col-title {
  width: 21%;
}

.documents-table .col-department {
  width: 11%;
}

.documents-table .col-format {
  width: 6%;
}

.documents-table .col-version {
  width: 6%;
}

.documents-table .col-index {
  width: 12%;
}

.documents-table .col-status {
  width: 10%;
}

.documents-table .col-chunks {
  width: 6%;
}

.documents-table .col-date {
  width: 11%;
}

.documents-table .col-actions {
  width: 17%;
}

.chunks-panel table {
  min-width: 900px;
}

.users-table-panel,
.invites-table-panel,
.analytics-table-panel {
  overflow-x: auto;
}

.users-table {
  table-layout: fixed;
  min-width: 840px;
}

.invites-table {
  min-width: 1120px;
}

.analytics-table {
  table-layout: fixed;
  min-width: 680px;
}

.users-table .col-user {
  width: 28%;
}

.users-table .col-role {
  width: 12%;
}

.users-table .col-department {
  width: 17%;
}

.users-table .col-status {
  width: 13%;
}

.users-table .col-date {
  width: 20%;
}

.users-table .col-actions {
  width: 10%;
}

th,
td {
  padding: 14px var(--space-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: var(--text-md);
  min-width: 0;
}

.documents-table th,
.documents-table td,
.users-table th,
.users-table td,
.analytics-table th,
.analytics-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.documents-table th:last-child,
.documents-table td:last-child,
.users-table th:last-child,
.users-table td:last-child {
  overflow: visible;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
}

tr:last-child td {
  border-bottom: 0;
}

.row-disabled {
  background: color-mix(in srgb, var(--neutral-bg) 62%, transparent);
  color: var(--muted);
}

.document-title {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-subtitle,
.cell-error {
  display: block;
  max-width: 100%;
  margin-top: var(--space-1);
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-subtitle {
  color: var(--muted);
}

.cell-error {
  color: var(--danger-text);
}

.question-cell,
.answer-preview {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.compact-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}

.compact-actions .icon-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
}

.row-actions form,
.actions form,
.danger-actions form,
.user-actions form,
.action-menu form {
  margin: 0;
}

.user-actions {
  display: grid;
  gap: var(--space-2);
  min-width: 360px;
}

.cell-actions {
  text-align: right;
}

.action-menu {
  position: relative;
  display: grid;
  justify-items: end;
  width: 100%;
}

.action-menu summary {
  list-style: none;
}

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

.menu-trigger {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.action-menu[open] .menu-trigger {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.action-menu-panel {
  display: grid;
  gap: var(--space-3);
  width: min(320px, calc(100vw - 56px));
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  text-align: left;
  transform: translateX(calc(-100% + 32px));
}

.menu-form {
  display: grid;
  gap: var(--space-2);
}

.menu-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: var(--space-2);
  align-items: center;
}

.menu-form-row select {
  min-height: 34px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
}

.menu-action-row {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-1);
  border-top: 1px solid var(--line);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 34px;
  gap: var(--space-2);
  align-items: center;
}

.inline-form select {
  min-height: 34px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.panel-head,
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: center;
}

.panel-head {
  padding: var(--space-5) var(--space-5) 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.detail-panel {
  padding: var(--space-6);
}

.meta-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: var(--space-3) var(--space-5);
  margin: var(--space-5) 0 0;
}

.meta-list dt {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 800;
}

.meta-list dd {
  min-width: 0;
  margin: 0;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.compact-form {
  margin-top: var(--space-5);
}

.chunks-panel {
  overflow-x: auto;
}

.chunk-preview {
  max-width: 520px;
  color: var(--text-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding: var(--space-10);
  text-align: center;
}

.empty-state.compact {
  padding: var(--space-8);
}

.delete-card {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: var(--space-8);
}

.danger-actions {
  margin-top: var(--space-8);
}

.code-inline,
.code-large {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 800;
}

.code-inline {
  padding: 4px 8px;
  font-size: var(--text-sm);
}

.invite-result {
  display: grid;
  gap: var(--space-3);
  width: min(720px, 100%);
  margin-bottom: var(--space-6);
  padding: var(--space-6);
  border: 1px solid var(--success-line);
  border-radius: var(--radius-lg);
  background: var(--success-bg);
  box-shadow: var(--shadow-md);
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.code-large {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 var(--space-4);
  font-size: var(--text-xl);
  letter-spacing: 0.04em;
}

.compact-copy {
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.invite-link {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-link-large {
  max-width: min(100%, 640px);
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.45;
    transform: scale(0.72);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-subtitle {
    display: none;
  }

  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar {
    padding: var(--space-4);
  }

  .summary-grid,
  .metric-grid,
  .detail-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

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

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

  .page {
    width: min(calc(100% - 24px), 1180px);
    margin: var(--space-6) auto;
  }

  .page-head,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .actions,
  .form-actions {
    align-items: stretch;
  }

  .topbar-actions > *,
  .actions > *,
  .form-actions > *,
  .actions form,
  .actions button {
    width: 100%;
  }

  .user-chip {
    justify-content: flex-start;
  }

  .theme-toggle,
  .button-primary,
  .button-secondary,
  .button-small {
    width: 100%;
  }

  .compact-actions .icon-button,
  .compact-copy .icon-button,
  .menu-trigger,
  .menu-form-row .icon-button,
  .menu-action-row .icon-button {
    width: 32px;
    min-width: 32px;
    flex: 0 0 auto;
  }

  .menu-form-row .icon-button {
    width: 34px;
    min-width: 34px;
  }

  .auth-panel,
  .form-card,
  .detail-panel,
  .delete-card,
  .summary-card {
    padding: var(--space-5);
    border-radius: var(--radius-md);
  }

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

  .row-actions {
    min-width: 0;
  }

  .documents-table {
    min-width: 860px;
  }

  .theme-toggle-text,
  .user-meta {
    display: inline-grid;
  }
}
