/* Stitch UI v2 - canonical stylesheet */

/* tokens.css */
:root {
  color-scheme: light;
  --font-sans: system-ui, -apple-system, Segoe UI, Roboto;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-size-base: 16px;
  --font-size-sm: 13px;
  --font-size-lg: 16px;
  --line-height-base: 1.5;
  --line-height-tight: 1.25;

  --color-bg: #f7f9fc;
  --color-surface: #ffffff;
  --color-surface-2: #f1f4f9;
  --color-border: #e3e7ef;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-strong: #1d4ed8;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-on-primary: #ffffff;
  --color-on-dark: #f9fafb;
  --color-primary-soft: rgba(37, 99, 235, 0.2);
  --color-primary-tint: rgba(37, 99, 235, 0.12);
  --color-primary-border: rgba(37, 99, 235, 0.35);
  --color-primary-surface: rgba(37, 99, 235, 0.08);
  --color-primary-border-soft: rgba(37, 99, 235, 0.3);
  --color-success-tint: rgba(22, 163, 74, 0.12);
  --color-success-border: rgba(22, 163, 74, 0.35);
  --color-success-surface: rgba(22, 163, 74, 0.08);
  --color-success-border-soft: rgba(22, 163, 74, 0.3);
  --color-warning-tint: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.35);
  --color-warning-surface: rgba(245, 158, 11, 0.08);
  --color-danger-tint: rgba(220, 38, 38, 0.12);
  --color-danger-border: rgba(220, 38, 38, 0.35);
  --color-danger-surface: rgba(220, 38, 38, 0.08);
  --color-danger-border-soft: rgba(220, 38, 38, 0.3);
  --color-muted-tint: rgba(107, 114, 128, 0.12);
  --color-muted-border: rgba(107, 114, 128, 0.35);
  --color-hover: rgba(15, 23, 42, 0.03);
  --color-log-bg: #0b0f1a;
  --color-log-text: #e2e8f0;
  --color-log-border: rgba(148, 163, 184, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --border-width: 1px;
  --focus-width: 2px;

  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: calc(var(--space-lg) + var(--space-sm));

  --size-icon: 32px;
  --size-icon-radius: 12px;
  --size-dropdown-min: 220px;
  --size-grid-min: 240px;
  --size-grid-min-tight: 200px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.18);
  --shadow-soft: 0 8px 16px rgba(15, 23, 42, 0.08);

  --z-topnav: 100;
  --z-overlay: 200;

  --layout-max-normal: 1080px;
  --layout-max-wide: 1440px;
  --layout-max-full: 100%;
  --layout-gutter: clamp(var(--space-sm), 2vw, var(--space-lg));
  --page-max: var(--layout-max-wide);
  --gutter: var(--layout-gutter);
  --rail-width: 320px;
  --topbar-height: 72px;
  --sidebar-width-expanded: 280px;
  --sidebar-width-collapsed: 72px;
  --sidebar-width: var(--sidebar-width-expanded);
  --color-accent: #7dd3fc;

  --card-radius: var(--radius-md);
  --card-border: var(--color-border);

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

  --control-height: 40px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0f172a;
  --color-surface: #111827;
  --color-surface-2: #1f2937;
  --color-border: #2b364b;
  --color-text: #f3f4f6;
  --color-muted: #9ca3af;
  --color-primary: #60a5fa;
  --color-primary-strong: #3b82f6;
  --color-danger: #f87171;
  --color-success: #4ade80;
  --color-warning: #fbbf24;
  --color-on-primary: #0f172a;
}

/* base.css */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
}

input,
select,
textarea,
button {
  font: inherit;
  line-height: inherit;
}

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

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

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-sm) 0;
  line-height: var(--line-height-tight);
}

p {
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text);
}

main {
  min-width: 0;
}

/* components.css */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: calc(var(--space-xs) + var(--space-sm)) calc(var(--space-md) + var(--space-xs));
  border-radius: var(--radius-pill);
  border: var(--border-width) solid transparent;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-weight: 600;
  min-height: var(--control-height);
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

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

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
}

.btn--danger {
  background: var(--color-danger);
  color: var(--color-on-primary);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-on-primary);
}

.btn--sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
}

.btn--lg {
  padding: var(--space-sm) calc(var(--space-md) + var(--space-xs));
  font-size: var(--font-size-lg);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.field-error {
  color: var(--color-danger);
  margin-top: var(--space-xs);
}

.label {
  font-weight: 600;
  color: var(--color-text);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: inherit;
  line-height: inherit;
  min-height: var(--control-height);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: var(--focus-width) solid var(--color-primary-soft);
  border-color: var(--color-primary);
}

.help-text {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  overflow: visible;
  min-width: 0;
  min-height: 0;
}

.card + .card {
  margin-top: var(--space-md);
}

.card__header,
.card__body,
.card__footer {
  padding: var(--space-lg);
  min-width: 0;
  min-height: 0;
}

.card-header,
.card-body,
.card-footer {
  padding: var(--space-lg);
  min-width: 0;
  min-height: 0;
}

.card__header {
  border-bottom: var(--border-width) solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.card-header {
  border-bottom: var(--border-width) solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.card-header--split {
  align-items: flex-start;
}

.card__footer {
  border-top: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
}

.card-footer {
  border-top: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
}

.card-title {
  font-weight: 600;
  font-size: var(--font-size-lg);
}

.card-sub {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border);
}

.badge--ok {
  background: var(--color-success-tint);
  color: var(--color-success);
  border-color: var(--color-success-border);
}

.badge-ok {
  background: var(--color-success-tint);
  color: var(--color-success);
  border-color: var(--color-success-border);
}

.badge--warn {
  background: var(--color-warning-tint);
  color: var(--color-warning);
  border-color: var(--color-warning-border);
}

.badge-warn {
  background: var(--color-warning-tint);
  color: var(--color-warning);
  border-color: var(--color-warning-border);
}

.badge--danger {
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}

.badge-danger {
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}

.badge-neutral {
  background: var(--color-muted-tint);
  color: var(--color-muted);
  border-color: var(--color-muted-border);
}

.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.flash {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.flash-info {
  border-color: var(--color-primary-border-soft);
  background: var(--color-primary-surface);
}

.flash-error {
  border-color: var(--color-danger-border-soft);
  background: var(--color-danger-surface);
}

.alert--info {
  border-color: var(--color-primary-border-soft);
  background: var(--color-primary-surface);
}

.alert--danger {
  border-color: var(--color-danger-border-soft);
  background: var(--color-danger-surface);
}

.alert--error {
  border-color: var(--color-danger-border-soft);
  background: var(--color-danger-surface);
}

.alert--success {
  border-color: var(--color-success-border-soft);
  background: var(--color-success-surface);
}

.pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.page-title {
  font-size: calc(var(--font-size-lg) * 1.5);
}

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

.page-header h1,
.page-header .page-title {
  margin: 0;
}

.pagehead__title {
  font-size: calc(var(--font-size-lg) * 1.5);
}

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

.pagehead__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.table-wrap,
.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  min-width: 0;
}

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

.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--border-width) solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.table-sm th,
.table-sm td {
  padding: var(--space-xs) var(--space-sm);
}

.table--compact th,
.table--compact td {
  padding: calc(var(--space-xs) + var(--border-width)) var(--space-sm);
  font-size: var(--font-size-sm);
}

.table--nowrap th,
.table--nowrap td {
  white-space: nowrap;
}

.table th {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  background: var(--color-surface-2);
}

.table tbody tr:hover {
  background: var(--color-hover);
}

.table-empty {
  color: var(--color-muted);
  text-align: center;
  padding: var(--space-lg);
}

.table .col-id,
.table .col-date,
.table .col-status,
.table .col-actions,
.table .col--id,
.table .col--date,
.table .col--status,
.table .col--actions {
  white-space: nowrap;
}

.table .col--title {
  width: 28%;
}

.table .col-message,
.table .col--message {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cell--truncate {
  max-width: calc(var(--space-lg) * 12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell--wrap {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table--fixed {
  table-layout: fixed;
}

.table td {
  white-space: normal;
  word-break: break-word;
}

.result-item {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  background: var(--color-surface-2);
}

.result-title {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.result-snippet {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.result-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.result-feedback {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: auto;
}

.cell--clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.cell--clamp.is-expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.gap-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
}

.gap-stats {
  display: flex;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
}

.gap-stat {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.gap-stat-label {
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--font-size-sm);
}

.gap-stat-value {
  color: var(--color-text);
  font-weight: 600;
}

.gap-list {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gap-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.gap-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.1fr);
  gap: var(--space-lg);
  align-items: flex-start;
}

.gap-card-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.gap-topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.gap-topic-title {
  font-weight: 600;
  color: var(--color-text);
  font-size: var(--font-size-lg);
}

.gap-pill {
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: var(--border-width) solid transparent;
}

.gap-pill-open {
  background: var(--color-warning-tint);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

.gap-pill-progress {
  background: var(--color-primary-tint);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

.gap-pill-resolved {
  background: var(--color-success-tint);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

.gap-pill-ignored {
  background: var(--color-muted-tint);
  border-color: var(--color-muted-border);
  color: var(--color-muted);
}

.gap-topic-meta,
.gap-topic-seen {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.gap-card-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: flex-end;
}

.gap-action-form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
}

.gap-note {
  width: 100%;
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.gap-card-footer {
  margin-top: var(--space-sm);
  display: flex;
  justify-content: flex-end;
}

.gap-toggle {
  background: transparent;
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  cursor: pointer;
}

.gap-toggle:hover {
  background: var(--color-surface-2);
}

.gap-questions {
  display: none;
  margin-top: var(--space-sm);
}

.gap-questions.is-open {
  display: block;
}

.gap-questions-inner {
  border-top: var(--border-width) solid var(--color-border);
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.gap-question-row {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.gap-question-text {
  margin-bottom: calc(var(--space-xs) / 2);
}

.gap-question-meta {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.gap-question-note {
  color: var(--color-warning);
}

/* layout.css */
.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  overflow: visible;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl) var(--layout-gutter);
  background:
    radial-gradient(circle at top, rgba(96, 165, 250, 0.2), transparent 40%),
    radial-gradient(circle at 20% 20%, rgba(125, 211, 252, 0.18), transparent 45%),
    var(--color-bg);
}

.auth-shell__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-main {
  width: 100%;
  display: flex;
  justify-content: center;
}

body.login-page {
  background:
    radial-gradient(circle at top, rgba(96, 165, 250, 0.2), transparent 40%),
    radial-gradient(circle at 20% 20%, rgba(125, 211, 252, 0.18), transparent 45%),
    var(--color-bg);
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.login-card {
  background: rgba(255, 255, 255, 0.72);
  border-radius: calc(var(--card-radius) + 4px);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--shadow-lg);
  padding: calc(var(--space-lg) + var(--space-sm));
  backdrop-filter: blur(18px);
}

[data-theme="dark"] .login-card {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.25);
}

.login-header {
  margin-bottom: var(--space-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
}

.login-sub {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.login-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
}

.login-notice--error {
  border-color: var(--color-danger-border-soft);
  background: var(--color-danger-surface);
}

.login-notice--success {
  border-color: var(--color-success-border-soft);
  background: var(--color-success-surface);
}

.login-notice--info {
  border-color: var(--color-primary-border-soft);
  background: var(--color-primary-surface);
}

.login-notice--warning {
  border-color: var(--color-warning-border);
  background: var(--color-warning-surface);
}

.login-input-group {
  position: relative;
}

.login-input-group .input {
  padding-right: 84px;
}

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-sm);
  transform: translateY(-50%);
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text);
}

.login-remember input {
  accent-color: var(--color-primary);
}

.login-link {
  font-weight: 600;
  color: var(--color-primary);
}

.login-link:hover {
  color: var(--color-primary-strong);
}

.login-actions {
  margin-bottom: 0;
}

.login-submit {
  width: 100%;
  justify-content: center;
}

.login-footer {
  margin-top: var(--space-lg);
  text-align: center;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

@media (max-width: 600px) {
  .auth-shell {
    padding: var(--space-lg) var(--layout-gutter);
  }

  .login-card {
    padding: var(--space-lg);
  }

  .login-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  z-index: var(--z-topnav);
  background: var(--color-surface);
  border-bottom: var(--border-width) solid var(--color-border);
}

.topbar-inner {
  width: 100%;
  padding: var(--space-md) var(--layout-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: var(--topbar-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
}

.brand-mark {
  width: var(--size-icon);
  height: var(--size-icon);
  border-radius: var(--size-icon-radius);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.topnav,
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.topnav-item,
.nav-item,
.topnav-trigger {
  font-weight: 600;
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  border-radius: var(--radius-pill);
}

.topnav-item.is-active,
.nav-item.is-active,
.topnav-trigger.is-active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.topnav-dropdown {
  position: relative;
}

details.topnav-dropdown > summary {
  list-style: none;
  cursor: pointer;
}

details.topnav-dropdown > summary::-webkit-details-marker {
  display: none;
}

.topnav-menu,
.nav-menu {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  min-width: var(--size-dropdown-min);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: var(--space-sm) 0;
  display: none;
  z-index: var(--z-overlay);
}

.topnav-dropdown.is-open .topnav-menu,
.topnav-dropdown.is-open .nav-menu {
  display: block;
}

details.topnav-dropdown[open] .topnav-menu,
details.topnav-dropdown[open] .nav-menu {
  display: block;
}

.topnav-menu a,
.nav-menu a {
  display: block;
  padding: var(--space-xs) var(--space-md);
  color: var(--color-text);
}

.topnav-menu a.is-active,
.topnav-menu a:hover,
.nav-menu a.is-active,
.nav-menu a:hover {
  background: var(--color-surface-2);
}

.user-menu {
  margin-left: auto;
}

.topbar-actions .user-menu {
  margin-left: 0;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: var(--border-width) solid var(--color-border);
  color: inherit;
  text-decoration: none;
  font-size: 1.1rem;
}

.notification-bell:hover {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.notification-bell__badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-xs);
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
  box-sizing: border-box;
}

.notifications-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.notifications-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.notification-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  text-decoration: none;
  color: inherit;
}

.notification-item:hover {
  border-color: var(--color-primary-border-soft);
  box-shadow: var(--shadow-card);
}

.notification-item.is-unread {
  border-color: var(--color-primary-border);
  background: var(--color-primary-surface);
}

.notification-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.notification-item__title {
  font-weight: 600;
}

.notification-item__link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.notification-item__body {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.notification-item__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-sm);
  align-items: center;
}

.notification-item__status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.notification-item__actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.notification-item__actions form {
  margin: 0;
}

.notification-priority {
  text-transform: capitalize;
}

.notification-priority--low {
  background: var(--color-muted-tint);
  color: var(--color-muted);
  border-color: var(--color-muted-border);
}

.notification-priority--normal {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border-color: var(--color-primary-border);
}

.notification-priority--high {
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}

.user-menu .topnav-menu {
  left: auto;
  right: 0;
}

.user-pill-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  padding: var(--space-xs) var(--space-md);
  border: var(--border-width) solid var(--color-border);
  font-size: var(--font-size-sm);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.user-pill--link {
  color: inherit;
  text-decoration: none;
}

.user-pill--toggle {
  padding: var(--space-xs) var(--space-sm);
}

.user-pill__name {
  font-weight: 600;
}

.user-pill__role {
  font-size: var(--font-size-xs);
}

.app-frame {
  flex: 1;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  width: 100%;
  min-width: 0;
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  height: auto;
}

body.has-sidebar .app-main {
  margin-left: var(--sidebar-width);
}

body.has-sidebar.is-sidebar-collapsed .app-main {
  margin-left: var(--sidebar-width-collapsed);
}

.app-main--with-rail {
  grid-template-columns: minmax(0, 1fr) var(--rail-width);
  align-items: start;
}

.content-wrap {
  width: 100%;
  min-height: 0;
  min-width: 0;
  padding: var(--space-lg);
  margin: 0 auto;
  max-width: var(--layout-max-wide);
}

.content-wrap[data-width="normal"] {
  max-width: var(--layout-max-normal);
}

.content-wrap[data-width="wide"] {
  max-width: var(--layout-max-wide);
}

.content-wrap[data-width="full"] {
  max-width: var(--layout-max-full);
}

.page-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  margin: 0 0 var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-2);
}

.page-breadcrumb__separator {
  color: var(--text-3);
}

.page-breadcrumb__link {
  color: inherit;
  text-decoration: none;
}

.page-breadcrumb__link:hover,
.page-breadcrumb__link:focus-visible {
  color: var(--text-0);
  text-decoration: underline;
}

.page-breadcrumb__label {
  color: var(--text-0);
}

.content-wrap > .page {
  min-height: calc(100vh - var(--topbar-height));
  height: auto;
}

.sidebar {
  background: var(--color-surface);
  border-right: var(--border-width) solid var(--color-border);
  padding: var(--space-lg);
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  height: calc(100vh - var(--topbar-height));
  width: var(--sidebar-width);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  z-index: calc(var(--z-topnav) - 1);
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.sidebar__content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.sidebar__title {
  font-weight: 700;
}

.sidebar__meta {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.sidebar-toggle {
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  font-size: var(--font-size-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.sidebar.is-collapsed {
  padding: var(--space-md);
}

.sidebar-group {
  margin-bottom: var(--space-md);
}

.sidebar-group__label {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-sm);
}

.sidebar-item {
  display: grid;
  grid-template-columns: var(--size-icon) minmax(0, 1fr);
  column-gap: var(--space-sm);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  position: relative;
  align-items: center;
}

.sidebar-item__icon {
  width: var(--size-icon);
  height: var(--size-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--size-icon-radius);
  background: var(--color-surface-2);
  border: var(--border-width) solid var(--color-border);
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  flex-shrink: 0;
  grid-row: 1 / span 2;
}

.sidebar-item__text {
  min-width: 0;
  grid-column: 2;
}

.sidebar-item__label {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item__desc {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  grid-column: 2;
  margin-top: calc(var(--space-xs) / 2);
}

.sidebar-item.is-active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.sidebar-item.is-active .sidebar-item__icon {
  background: var(--color-primary-tint);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

body.is-sidebar-collapsed {
  --sidebar-width: var(--sidebar-width-collapsed);
}

body.is-sidebar-collapsed .sidebar__title,
body.is-sidebar-collapsed .sidebar__meta {
  display: none;
}

body.is-sidebar-collapsed .sidebar {
  overflow: visible;
  padding: var(--space-sm);
}

body.is-sidebar-collapsed .sidebar__header {
  justify-content: center;
  margin-bottom: var(--space-sm);
}

body.is-sidebar-collapsed .sidebar-toggle {
  width: 100%;
  justify-content: center;
}

body.is-sidebar-collapsed .sidebar-toggle [data-sidebar-label] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.is-sidebar-collapsed .sidebar__content {
  overflow-x: visible;
}

body.is-sidebar-collapsed .sidebar-group__label {
  display: none;
}

body.is-sidebar-collapsed .sidebar-group + .sidebar-group {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: var(--border-width) solid var(--color-border);
}

body.is-sidebar-collapsed .sidebar-item {
  display: flex;
  justify-content: center;
  padding: var(--space-sm);
}

body.is-sidebar-collapsed .sidebar-item.is-active {
  background: var(--color-primary-tint);
  border-radius: var(--radius-md);
}

body.is-sidebar-collapsed .sidebar-item.is-active .sidebar-item__icon {
  background: var(--color-primary-tint);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

body.is-sidebar-collapsed .sidebar-item__text {
  display: none;
}

body.is-sidebar-collapsed .sidebar-item__desc {
  display: none;
}

body.is-sidebar-collapsed .sidebar-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + var(--space-sm));
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: var(--z-overlay);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

body.is-sidebar-collapsed .sidebar-item:hover::after,
body.is-sidebar-collapsed .sidebar-item:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.shell-rail {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.footer {
  border-top: var(--border-width) solid var(--color-border);
  padding: var(--space-md) var(--gutter);
  color: var(--color-muted);
  text-align: center;
  background: var(--color-surface);
}

body.has-sidebar .footer {
  margin-left: var(--sidebar-width);
}

body.has-sidebar.is-sidebar-collapsed .footer {
  margin-left: var(--sidebar-width-collapsed);
}

/* utilities.css */
.u-hidden {
  display: none !important;
}

.u-muted {
  color: var(--color-muted);
}

.u-text-right {
  text-align: right;
}

.u-flex {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.u-ml-sm {
  margin-left: var(--space-xs);
}

.ml-xs {
  margin-left: var(--space-xs);
}

.mt-xs {
  margin-top: var(--space-xs);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.u-wrap {
  flex-wrap: wrap;
}

.u-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.section-intro {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.section-intro summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text);
}

.section-intro[open] summary {
  margin-bottom: var(--space-sm);
}

.profile-accordion > summary {
  cursor: pointer;
  position: relative;
  padding-right: calc(var(--space-lg) + var(--space-md));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-accordion > summary::-webkit-details-marker {
  display: none;
}

.profile-accordion > summary::marker {
  content: '';
}

.profile-accordion > summary::after {
  content: '›';
  position: absolute;
  right: var(--space-lg);
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  font-size: 20px;
  color: var(--color-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.profile-accordion[open] > summary::after {
  transform: translateY(-50%) rotate(90deg);
  color: var(--color-text);
}

.profile-accordion > summary:focus-visible {
  outline: var(--focus-width) solid var(--color-primary-soft);
  outline-offset: 2px;
}

.profile-accordion {
  display: flex;
  flex-direction: column;
  overflow: visible;
  min-width: 0;
}

.profile-accordion__body {
  display: block;
  min-width: 0;
}

.profile-accordion .field label {
  font-weight: 600;
  color: var(--color-text);
}

.profile-accordion input[type="text"],
.profile-accordion input[type="number"],
.profile-accordion input[type="date"],
.profile-accordion input[type="email"],
.profile-accordion input[type="tel"],
.profile-accordion input[type="password"],
.profile-accordion select,
.profile-accordion textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: inherit;
  line-height: inherit;
  min-height: var(--control-height);
}

.profile-accordion textarea {
  min-height: calc(var(--control-height) * 2);
}

.profile-accordion input:focus,
.profile-accordion select:focus,
.profile-accordion textarea:focus {
  outline: var(--focus-width) solid var(--color-primary-soft);
  border-color: var(--color-primary);
}

.uniform-section {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: visible;
  min-width: 0;
}

.uniform-section__header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: var(--border-width) solid var(--color-border);
}

.uniform-section__body {
  padding: var(--space-lg);
}

.uniform-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-grid-min-tight)), 1fr));
  min-width: 0;
}

.field--compact {
  margin-bottom: var(--space-sm);
}

.grid-row {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-grid-min)), 1fr));
  min-width: 0;
}

.list-indent {
  padding-left: calc(var(--space-md) + var(--space-xs));
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.stack--tight {
  gap: var(--space-xs);
}

.uniform-request-items {
  display: grid;
  gap: var(--space-xs) var(--space-md);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-actions {
  display: inline-flex;
  gap: var(--space-xs);
  align-items: center;
}

.field--inline {
  margin: 0;
  flex: 1;
}

.col-qty {
  width: calc(var(--space-lg) * 6);
}

.col-sort {
  width: calc(var(--space-lg) * 5);
}

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

.form-actions--right {
  justify-content: flex-end;
}

.card-actions {
  margin-bottom: var(--space-md);
}

.log-context {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  background: var(--color-log-bg);
  color: var(--color-log-text);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-log-border);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.filter-chip {
  display: inline-flex;
  padding: calc(var(--space-xs) / 2) var(--space-md);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

.filter-chip.is-active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.filter-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-grid-min-tight)), 1fr));
  min-width: 0;
}

.prose {
  color: var(--color-muted);
}

.er-filters-note,
.er-export-links {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.meta-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--size-grid-min-tight)), 1fr));
  min-width: 0;
}

.meta-grid dt {
  font-weight: 600;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.meta-grid dd {
  margin: 0;
}

.feedback-blob {
  position: fixed;
  right: calc(var(--space-lg) + env(safe-area-inset-right));
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-sm);
}

.feedback-blob__button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: calc(var(--space-sm) + 2px) var(--space-lg);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

.feedback-blob__button span {
  font-size: var(--font-size-sm);
}

.feedback-blob__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.feedback-blob__backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.feedback-blob__panel {
  position: fixed;
  right: calc(var(--space-lg) + env(safe-area-inset-right));
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom) + 3.5rem);
  width: min(380px, calc(100vw - 2rem));
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.feedback-blob.is-open .feedback-blob__panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.feedback-blob__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.feedback-blob__title {
  font-weight: 600;
}

.feedback-blob__subtitle {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.feedback-blob__close {
  border: none;
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

.feedback-blob__error {
  display: none;
  margin-bottom: var(--space-sm);
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border: var(--border-width) solid var(--color-danger-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
}

.feedback-blob__error.is-visible {
  display: block;
}

.feedback-toast-host {
  position: fixed;
  right: calc(var(--space-lg) + env(safe-area-inset-right));
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom) + 4.5rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: 51;
}

.feedback-toast {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-md);
  transition: opacity 200ms ease, transform 200ms ease;
}

.feedback-toast.is-hidden {
  opacity: 0;
  transform: translateY(6px);
}

.feedback-screenshot {
  width: 100%;
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.feedback-screenshot-preview {
  display: none;
  margin-top: var(--space-sm);
}

.feedback-screenshot-preview.is-visible {
  display: block;
}

.feedback-screenshot-helper {
  display: none;
  margin-top: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.feedback-screenshot-helper.is-visible {
  display: block;
}

.feedback-screenshot-error {
  display: none;
  margin-top: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-danger);
}

.feedback-screenshot-error.is-visible {
  display: block;
}

.feedback-screenshot-remove {
  display: none;
  margin-top: var(--space-xs);
}

.feedback-screenshot-remove.is-visible {
  display: inline-flex;
}

@media (max-width: 600px) {
  .feedback-blob {
    right: calc(var(--space-md) + env(safe-area-inset-right));
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }

  .feedback-blob__panel {
    right: calc(var(--space-md) + env(safe-area-inset-right));
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom) + 3.5rem);
    width: calc(100vw - 2rem);
  }
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-md);
}

.activity-item {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  background: var(--color-surface-2);
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-xs);
}

.body-text {
  color: var(--color-text);
  line-height: var(--line-height-base);
}

.text-muted {
  color: var(--color-muted);
}

.text-small {
  font-size: var(--font-size-sm);
}

.mt-3 {
  margin-top: var(--space-md);
}

.mt-2 {
  margin-top: var(--space-sm);
}

.mt-5 {
  margin-top: var(--space-xl);
}

.layout-grid {
  display: grid;
  gap: var(--space-lg);
  min-width: 0;
}

.layout-grid > * {
  min-width: 0;
}

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

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

.account-layout {
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  align-items: start;
}

.account-menu {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.account-menu__link {
  display: block;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--color-text);
  text-decoration: none;
  background: transparent;
}

.account-menu__link:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border);
}

.account-menu__link.is-active {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  font-weight: 600;
}

@media (max-width: 900px) {
  .gap-card-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .gap-card-actions {
    align-items: stretch;
  }
}

@media (max-width: 1200px) {
  .app-main--with-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell-rail {
    position: static;
    height: auto;
    max-height: none;
    display: none;
  }

  .profile-page .shell-rail {
    display: none;
  }
}

@media (max-width: 720px) {
  .layout-grid--2,
  .layout-grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .uniform-request-items {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .topnav {
    width: 100%;
  }

  .pagehead {
    align-items: flex-start;
  }
}

.workflow-diagram {
  overflow: auto;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  border: var(--border-width) solid var(--color-border);
  max-height: 70vh;
}

.workflow-diagram .mermaid {
  margin: 0;
  max-width: 100%;
}

.workflow-diagram svg .workflow-node-selected rect,
.workflow-diagram svg .workflow-node-selected polygon {
  stroke: #38bdf8;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.4));
}

.workflow-diagram__actions {
  display: flex;
  align-items: center;
}

.workflow-linked-docs-heading {
  margin-bottom: var(--space-md);
}

.page-header--compact {
  margin-bottom: var(--space-md);
}

.section-intro {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
}

.section-intro summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.section-intro summary::marker,
.section-intro summary::-webkit-details-marker {
  display: none;
}

.section-intro summary::after {
  content: '▾';
  color: var(--color-muted);
  transition: transform 0.2s ease;
}

.section-intro[open] summary::after {
  transform: rotate(180deg);
}

/* Engineroom board */
.er-page {
  display: block;
  width: 100%;
}

.er-page-header {
  margin-bottom: var(--space-lg);
}

.er-page-breadcrumb {
  margin: 0 0 var(--space-sm);
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.er-page-title {
  margin: 0;
  font-size: calc(var(--font-size-lg) * 1.35);
}

.er-page-subtitle {
  margin-top: var(--space-sm);
  color: var(--color-muted);
}

.er-board-toolbar {
  position: sticky;
  top: var(--space-lg);
  z-index: 5;
}

.er-board-toolbar__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg) 0;
}

.er-board-toolbar__filters {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.er-board-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.er-board-tab {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--color-surface);
}

.er-board-tab.is-active {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: transparent;
}

.er-board-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  min-height: 420px;
  max-height: calc(100vh - 360px);
}

.er-board-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
}

.er-board-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: var(--border-width) solid var(--color-border);
}

.er-board-column-header h2 {
  margin: 0;
  font-size: var(--font-size-md);
}

.er-board-column-count {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.er-board-list {
  list-style: none;
  margin: 0;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-y: auto;
}

.er-board-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.er-board-card:hover {
  border-color: var(--color-primary-border-soft);
  box-shadow: var(--shadow-md);
}

.er-board-card-title {
  font-weight: 600;
}

.er-board-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.er-board-card-meta {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.er-board-empty {
  padding: var(--space-md);
  color: var(--color-muted);
}

/* Non-conformance filters + table */
.nc-filters {
  display: grid;
  gap: var(--space-sm);
}

.nc-filters__heading {
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nc-table .col--ref {
  width: 6.5rem;
}

.nc-table .col--title {
  width: 20%;
}

.nc-table .col--classification {
  width: 14%;
}

.nc-table .col--status,
.nc-table .col--occurred,
.nc-table .col--last {
  width: 8.5rem;
}

.nc-table .col--owner {
  width: 10rem;
}

.nc-table .col--risk {
  width: 15%;
}

.nc-table .col--tasks,
.nc-table .col--overdue {
  width: 6rem;
}

.nc-table .col--job {
  width: 9rem;
}

/* Documents */
.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: calc(var(--space-xs) / 2) var(--space-sm);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.doc-review {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.doc-review--overdue {
  color: var(--color-danger);
  font-weight: 600;
}

.doc-review--soon {
  color: var(--color-warning);
  font-weight: 600;
}

.doc-title-link {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: break-word;
}

.doc-columns {
  position: relative;
}

.doc-columns__popover {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-sm));
  width: min(240px, 80vw);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 10;
}

.doc-columns__popover.is-open {
  display: grid;
  gap: var(--space-sm);
}

.doc-columns__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.doc-columns__title {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.doc-columns__list {
  display: grid;
  gap: var(--space-xs);
}

.doc-columns__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
}

.documents-table .is-col-hidden {
  display: none;
}

.documents-table .cell--title {
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.documents-table .cell--nowrap {
  white-space: nowrap;
}

.documents-table .badge {
  padding: 2px 6px;
  font-size: var(--font-size-xs);
}

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

.documents-table .col--tags {
  width: 14%;
}

.documents-table .col--code,
.documents-table .col--version,
.documents-table .col--size,
.documents-table .col--uploaded {
  width: 7rem;
}

.documents-table .col--controlled,
.documents-table .col--ingest {
  width: 10rem;
}

.documents-table .col--review,
.documents-table .col--owner {
  width: 9.5rem;
}

.documents-table .col--original {
  width: 16%;
}

.documents-table .col--by {
  width: 9rem;
}

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

.page--documents,
.page--permissions {
  padding-bottom: calc(var(--space-lg) * 4);
}

/* Cron health */
.cron-latest-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.cron-latest-item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
}

.cron-latest-item--span {
  grid-column: 1 / -1;
}

.cron-latest-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.cron-latest-value {
  font-weight: 600;
  margin-top: var(--space-xs);
}

/* Permissions admin */
.page--permissions {
  --permissions-sticky-top: calc(var(--topbar-height) + var(--space-md));
  padding-bottom: calc(var(--space-6) + 140px);
}

.page--permissions .page-header--compact {
  margin-bottom: var(--space-sm);
}

.page--permissions .page-breadcrumb {
  margin-bottom: var(--space-sm);
}

.page--permissions .page-subtitle {
  margin-top: var(--space-xs);
}

.permissions-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: var(--space-lg);
  overflow: visible;
}

.permissions-toolbar__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.permissions-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.permissions-layout {
  display: block;
}

.permissions-detail {
  display: grid;
  gap: 24px;
  grid-template-columns: 360px minmax(0, 1fr);
  align-items: start;
}

.permissions-role-picker {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
}

.permissions-role-switcher {
  position: relative;
  min-width: 240px;
  z-index: 30;
}

.permissions-role-switcher__control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  padding: 8px 12px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.permissions-role-switcher__control:focus-visible {
  outline: var(--focus-width) solid var(--color-primary-soft);
  outline-offset: 2px;
}

.permissions-role-switcher__value {
  font-weight: 500;
}

.permissions-role-switcher__icon {
  color: var(--color-muted);
}

.permissions-role-switcher__panel {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  z-index: 9999;
  display: none;
  width: 100%;
  padding: var(--space-sm);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.permissions-role-switcher.is-open .permissions-role-switcher__panel {
  display: block;
}

.permissions-role-switcher__search {
  margin-bottom: var(--space-xs);
}

.permissions-role-switcher__input {
  width: 100%;
}

.permissions-role-switcher__list {
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}

.permissions-role-switcher__option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.permissions-role-switcher__option:hover,
.permissions-role-switcher__option.is-active {
  background: var(--color-surface-2);
}

.permissions-role-switcher__option.is-selected .permissions-role-switcher__option-name {
  font-weight: 600;
}

.permissions-role-switcher__option-meta {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

.permissions-role-switcher__empty {
  padding: var(--space-sm);
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.permissions-role-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: 0;
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.permissions-role-summary__name {
  font-weight: 600;
  color: var(--color-text);
}

.permissions-role-summary__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.permissions-create-role {
  margin-top: 0;
}

.permissions-create-role summary {
  cursor: pointer;
  list-style: none;
}

.permissions-create-role summary::-webkit-details-marker {
  display: none;
}

.permissions-create-role__form {
  margin-top: var(--space-sm);
  display: grid;
  gap: var(--space-sm);
}

.permissions-search {
  min-width: 220px;
}

.permissions-filter-bar {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-md));
  z-index: 5;
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-sm);
  background: var(--color-surface);
}

.permission-groups {
  display: grid;
  gap: var(--space-md);
}

.permission-group {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-md);
}

.permission-group__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.permission-group__title {
  font-weight: 600;
}

.permission-group__list {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.permission-select-all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-left: auto;
}

.perm-item {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
}

.perm-item input[type="checkbox"] {
  margin-top: 0.2rem;
}

.perm-item--inline {
  margin-bottom: var(--space-xs);
}

.perm-text-main {
  font-weight: 600;
  display: block;
}

.perm-text-sub {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  display: block;
}

.is-hidden {
  display: none;
}

.permissions-user-layout {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

@media (max-width: 980px) {
  .permissions-toolbar {
    align-items: stretch;
  }

  .permissions-toolbar__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .permissions-detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .permissions-user-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters-form--compact .filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .er-board-grid {
    max-height: none;
  }
}
