:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d7e0ea;
  --line-strong: #bfccd9;
  --ink: #111827;
  --muted: #607086;
  --accent: #0f6f8f;
  --accent-strong: #0b4f6c;
  --accent-soft: #e8f4f7;
  --danger: #b42318;
  --ok: #087443;
  --warn: #b76e00;
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  border-radius: 6px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 111, 143, 0.16);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.app-shell {
  min-height: 100vh;
}

.auth-view {
  align-items: center;
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 920px;
  padding: 28px;
  width: 100%;
}

.auth-card h1 {
  font-size: 28px;
  margin: 6px 0 8px;
}

.auth-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 24px;
}

.auth-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  padding: 18px;
}

.auth-form h2 {
  font-size: 18px;
  margin: 0;
}

.topbar {
  align-items: center;
  background: #102436;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 28px rgba(15, 23, 42, 0.18);
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 18;
}

.topbar h1 {
  font-size: 21px;
  line-height: 1.25;
  margin: 3px 0 0;
}

.eyebrow {
  color: #7c8ca0;
  font-size: 12px;
  letter-spacing: 0;
  margin: 0;
}

.topbar .eyebrow {
  color: #a9bbcc;
}

.role-switch {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  flex: 1 1 390px;
  overflow: hidden;
  min-width: 330px;
  width: auto;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
  position: relative;
}

.top-collab-button {
  font-weight: 700;
  white-space: nowrap;
}

.session-card {
  align-items: center;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  color: #fff;
  display: flex;
  flex: 0 1 auto;
  gap: 10px;
  min-height: 40px;
  min-width: 0;
  padding: 0 12px;
}

.session-card span {
  color: #cdd9e5;
  font-size: 12px;
}

.session-card strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card .text-button {
  color: #fff;
}

.role-button {
  background: transparent;
  border: 0;
  color: #d8e4ee;
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 0;
  white-space: nowrap;
}

.role-button.active {
  background: #ffffff;
  color: #0f2437;
  font-weight: 700;
}

.role-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.role-button.is-switching {
  background: #e8f4f7;
  color: var(--accent-strong);
}

.bell-wrap {
  position: relative;
}

.bell-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  min-width: 48px;
  padding: 0 10px;
  position: relative;
}

.bell-shape {
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 11px 11px 4px 4px;
  display: inline-block;
  height: 18px;
  position: relative;
  width: 16px;
}

.bell-shape::before {
  background: currentColor;
  border-radius: 999px;
  bottom: -6px;
  content: "";
  height: 5px;
  left: 5px;
  position: absolute;
  width: 5px;
}

.bell-shape::after {
  background: currentColor;
  bottom: -2px;
  content: "";
  height: 2px;
  left: -3px;
  position: absolute;
  width: 22px;
}

.bell-button strong {
  background: #d92d20;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  min-width: 18px;
  padding: 0 5px;
  position: absolute;
  right: -7px;
  top: -7px;
}

.bell-button.no-unread strong {
  background: #64748b;
}

.bell-popover {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  position: absolute;
  right: 0;
  top: 50px;
  width: 340px;
  z-index: 20;
}

.bell-popover h2 {
  font-size: 15px;
  margin-bottom: 0;
}

.bell-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-top: 8px;
  padding: 10px;
}

.bell-item.unread {
  border-left: 4px solid var(--accent);
}

.workspace {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(280px, 310px) minmax(360px, 0.9fr) minmax(520px, 1.25fr);
  padding: 14px;
}

.panel,
.list-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel {
  margin-bottom: 12px;
  padding: 14px;
}

.role-home {
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  grid-column: 1 / -1;
  padding: 14px 16px 16px;
}

.role-home-head {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.role-home h2 {
  font-size: 19px;
  line-height: 1.25;
  margin: 4px 0 3px;
}

.role-home-kpis {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  min-width: min(520px, 100%);
}

.role-kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  min-height: 58px;
  padding: 10px;
}

.role-kpi strong {
  color: var(--accent-strong);
  display: block;
  font-size: 22px;
  line-height: 1;
}

.role-kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 8px;
}

.role-home-body {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.84fr);
  margin-top: 12px;
}

.role-actions {
  align-content: start;
  display: grid;
  gap: 8px;
  grid-auto-rows: minmax(66px, max-content);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.role-action-card,
.focus-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: inherit;
  min-height: 66px;
  padding: 11px 12px;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.role-action-card strong,
.focus-item strong {
  display: block;
  font-size: 14px;
}

.role-action-card span,
.focus-item small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 6px;
}

.role-action-card:hover,
.focus-item:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(15, 111, 143, 0.11);
  transform: translateY(-1px);
}

.role-focus {
  background: rgba(232, 244, 247, 0.5);
  border: 1px solid #cfe1e8;
  border-radius: 7px;
  padding: 12px;
}

.role-focus .panel-title h3 {
  font-size: 14px;
  margin: 0;
}

.role-focus-list {
  display: grid;
  gap: 8px;
  margin-top: 9px;
}

.focus-item {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 58px;
  width: 100%;
}

.focus-badges {
  align-items: center;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.mobile-nav {
  display: none;
}

.compact {
  padding: 12px;
}

.panel-title,
.section-head,
.detail-header,
.preview-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

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

.panel h2,
.section-head h2,
.detail-header h2 {
  font-size: 16px;
  line-height: 1.35;
  margin-bottom: 4px;
}

.panel h3,
.detail h3 {
  font-size: 14px;
  margin: 18px 0 10px;
}

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

.metric-grid div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: var(--panel-soft);
}

.metric {
  display: block;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.metric-grid small {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cad3df;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  width: 100%;
}

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

textarea {
  resize: vertical;
}

.form-row,
.file-pair {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.file-drop {
  border: 1px dashed #9fb0c3;
  border-radius: 7px;
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 12px 12px 42px;
  background: var(--panel-soft);
  cursor: pointer;
  position: relative;
}

.file-drop span {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.file-drop small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  max-width: 100%;
}

.legacy-ocr-drop {
  background: #f8fbff;
  border-color: #9ec8ef;
}

.legacy-ocr-drop span {
  color: #1f5f99;
}

.file-drop::after {
  align-items: center;
  background: #fff;
  border: 1px solid #cbd7e3;
  border-radius: 6px;
  bottom: 10px;
  color: #475569;
  content: attr(data-file-label);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  height: 28px;
  left: 12px;
  overflow: hidden;
  padding: 0 10px;
  position: absolute;
  right: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop.has-file {
  background: #effaf4;
  border-color: #8bd7ad;
}

.file-drop.has-file::after {
  background: #eaf8f0;
  border-color: #9cddb8;
  color: var(--ok);
}

.file-drop input[type="file"] {
  cursor: pointer;
  inset: 0;
  opacity: 0;
  position: absolute;
}

.cad-upload-slot {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 112px;
  min-width: 0;
}

.upload-inline-thumb {
  background: #fff;
  border: 1px solid #cbd7e3;
  border-radius: 7px;
  color: inherit;
  cursor: zoom-in;
  min-height: 82px;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.upload-inline-thumb:hover,
.upload-local-preview:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(18, 104, 243, 0.12);
}

.upload-inline-thumb .upload-local-preview-media {
  align-content: center;
  aspect-ratio: 16 / 10;
  background-image:
    linear-gradient(rgba(18, 104, 243, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.12) 1px, transparent 1px);
  background-size: 12px 12px;
  justify-items: center;
  min-height: 58px;
  padding: 8px;
}

.upload-inline-thumb .upload-local-preview-media strong {
  color: #1268f3;
  font-size: 16px;
  line-height: 1;
}

.upload-inline-thumb .upload-local-preview-media > span {
  background: transparent;
  bottom: auto;
  color: #587098;
  font-size: 10px;
  left: auto;
  line-height: 1.25;
  margin-top: 6px;
  padding: 0;
  position: static;
  text-align: center;
}

.upload-inline-thumb .upload-local-caption {
  padding: 6px 7px;
}

.upload-inline-thumb .upload-local-caption strong {
  display: none;
}

.global-drop-zone {
  align-items: center;
  background: rgba(7, 27, 69, 0.24);
  backdrop-filter: blur(2px);
  display: grid;
  inset: 0;
  justify-items: center;
  pointer-events: none;
  position: fixed;
  z-index: 90;
}

.global-drop-zone.hidden {
  display: none;
}

.global-drop-card {
  background: #fff;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  color: #071b45;
  max-width: min(420px, calc(100vw - 48px));
  padding: 28px 32px;
  text-align: center;
}

.global-drop-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.3;
}

.global-drop-card p {
  color: #61728f;
  font-size: 14px;
  line-height: 1.55;
  margin: 10px 0 0;
}

.upload-local-previews {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  margin: 2px 0 12px;
}

.upload-local-preview {
  border: 1px solid #cbd7e3;
  border-radius: 7px;
  color: inherit;
  cursor: zoom-in;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  background: #fff;
  text-align: left;
}

.upload-local-preview-media {
  aspect-ratio: 4 / 3;
  background: #f8fbff;
  display: grid;
  overflow: hidden;
  position: relative;
}

.upload-local-preview-media iframe,
.upload-local-preview-media img {
  border: 0;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  width: 100%;
}

.upload-local-preview-media iframe {
  background: #fff;
  transform: scale(1.02);
  transform-origin: center;
}

.upload-inline-thumb .upload-local-preview-media img,
.upload-local-preview.has-generated-preview .upload-local-preview-media img {
  background: #fff;
  object-fit: contain;
}

.upload-local-preview-media > span {
  background: rgba(18, 104, 243, 0.92);
  border-radius: 4px;
  bottom: 6px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  left: 6px;
  line-height: 1;
  padding: 4px 5px;
  position: absolute;
}

.upload-local-preview.is-placeholder .upload-local-preview-media {
  align-content: center;
  background-image:
    linear-gradient(rgba(18, 104, 243, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.12) 1px, transparent 1px);
  background-size: 12px 12px;
  justify-items: center;
  padding: 10px;
}

.upload-local-preview.is-placeholder .upload-local-preview-media strong {
  color: #1268f3;
  font-size: 18px;
  line-height: 1;
}

.upload-local-preview.is-placeholder .upload-local-preview-media span {
  background: transparent;
  bottom: auto;
  color: #587098;
  font-size: 11px;
  left: auto;
  margin-top: 7px;
  padding: 0;
  position: static;
}

.upload-local-caption {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px;
}

.upload-local-caption strong {
  color: #1e293b;
  font-size: 12px;
}

.upload-local-caption small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-dialog.is-local-cad .preview-stage {
  align-items: center;
  background:
    linear-gradient(rgba(18, 104, 243, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.08) 1px, transparent 1px),
    #f8fbff;
  background-size: 22px 22px;
  justify-content: center;
}

.preview-dialog.is-local-cad .preview-zoom-controls {
  display: none;
}

.cad-preview-large {
  align-items: center;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(220px, 360px) minmax(220px, 420px);
  max-width: min(860px, calc(100vw - 80px));
  width: 100%;
}

.cad-preview-large.has-rendered-preview img {
  aspect-ratio: 4 / 3;
  background: #fff;
  border: 1px solid #b9d4ff;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(18, 104, 243, 0.14);
  display: block;
  object-fit: contain;
  width: 100%;
}

.cad-preview-sheet {
  align-content: center;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(rgba(18, 104, 243, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.14) 1px, transparent 1px),
    #ffffff;
  background-size: 18px 18px;
  border: 1px solid #b9d4ff;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(18, 104, 243, 0.14);
  display: grid;
  justify-items: center;
  padding: 20px;
}

.cad-preview-sheet strong {
  color: var(--accent);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1;
}

.cad-preview-sheet span {
  color: #587098;
  font-size: 14px;
  font-weight: 800;
  margin-top: 10px;
}

.cad-preview-meta {
  background: #fff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  padding: 18px;
  text-align: left;
}

.cad-preview-meta strong {
  color: #071b45;
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.cad-preview-meta p,
.cad-preview-meta small {
  color: #667085;
  display: block;
  font-size: 13px;
  line-height: 1.55;
  margin: 8px 0 0;
}

.upload-autofill-card {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px;
}

.upload-autofill-card strong {
  color: #1e293b;
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.upload-autofill-card p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.upload-autofill-card.has-result {
  background: #effaf4;
  border-color: #9cddb8;
}

.upload-autofill-card.has-error {
  background: #fff4f2;
  border-color: #ffc6bd;
}

.upload-autofill-card.has-warning:not(.has-error) {
  background: #fffaf0;
  border-color: #e8c879;
}

.upload-autofill-card.is-loading {
  background: #f3f7fb;
}

.upload-autofill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.upload-autofill-chips span {
  background: #fff;
  border: 1px solid #cbd7e3;
  border-radius: 999px;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
}

.upload-autofill-chips .ai-chip {
  background: #eef6ff;
  border-color: #9ec8ef;
  color: #1f5f99;
}

.upload-autofill-chips .trusted-chip {
  background: #f3fbf6;
  border-color: #91d3ad;
  color: #17623a;
}

.upload-autofill-chips .review-chip {
  background: #fff7e7;
  border-color: #e3bd65;
  color: #7a4c00;
}

.upload-autofill-detail {
  color: #667085;
  line-height: 1.45;
  margin-top: 8px !important;
}

.upload-ai-settings-button {
  margin-top: 4px;
  padding: 0;
}

.ai-readiness-panel {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.ai-readiness-panel p {
  margin: 5px 0 0;
}

.ai-readiness-panel > span,
.ai-runtime-readiness {
  border-radius: 999px;
  font-weight: 700;
}

.ai-readiness-panel > span {
  padding: 6px 10px;
}

.ai-readiness-panel.is-ready,
.ai-runtime-readiness.is-ready {
  background: #f3fbf6;
  border-color: #91d3ad;
  color: #17623a;
}

.ai-readiness-panel.is-blocked,
.ai-runtime-readiness.is-blocked {
  background: #fffaf0;
  border-color: #e8c879;
  color: #7a4c00;
}

.ai-runtime-readiness {
  margin: 0;
  padding: 8px 12px;
}

.autofilled-field {
  background: #f4fbf7;
  border-color: #9cddb8;
}

.autofilled-field-review {
  background: #fffaf0;
  border-color: #e3bd65;
}

.ai-settings-page {
  min-width: 320px;
}

.ai-settings-layout {
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 1180px;
  padding: 16px;
}

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

.ai-settings-auth {
  margin: 0 auto;
  max-width: 520px;
  width: 100%;
}

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

.ai-settings-status-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
}

.ai-settings-status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-settings-status-card strong {
  font-size: 24px;
}

.ai-settings-status-card p,
.ai-settings-policy p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

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

.ai-settings-policy-grid > div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.ai-settings-policy-grid strong {
  display: block;
  margin-bottom: 6px;
}

.ai-settings-form {
  gap: 12px;
}

.ai-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ai-settings-result {
  margin-top: 12px;
}

.ai-settings-result-success {
  border-color: #9cddb8;
}

.ai-settings-result-error {
  border-color: #ffc6bd;
}

.ai-settings-result-pending {
  border-color: #9ec8ef;
}

.ai-config-panel .panel-title h2 {
  order: -1;
}

.ai-config-panel .panel-title a {
  margin-left: auto;
}

@media (max-width: 760px) {
  .ai-settings-status-grid,
  .ai-settings-policy-grid,
  .ai-settings-form .form-row {
    grid-template-columns: 1fr;
  }

  .ai-settings-topbar {
    align-items: stretch;
  }
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

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

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.secondary-button {
  background: #f1f7fb;
  border-color: #c9d8e6;
  color: #12324c;
}

.danger-button {
  background: #fff1f0;
  border-color: #f3b3ae;
  color: var(--danger);
  font-weight: 700;
}

.text-button {
  background: transparent;
  color: var(--accent);
  min-height: 30px;
  padding: 0;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

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

.secondary-button:hover {
  background: #e8f1f7;
  border-color: #aebfd0;
}

.text-button:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-form .primary-button {
  width: 100%;
}

.left-rail .form-row,
.left-rail .file-pair {
  grid-template-columns: 1fr;
}

.left-rail {
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding-right: 2px;
  position: sticky;
  top: 88px;
}

.list-panel,
.detail-panel {
  min-height: calc(100vh - 102px);
  overflow: hidden;
}

.section-head {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: #fbfcfe;
}

.section-head p,
.muted {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 0;
}

.drawing-list {
  max-height: calc(100vh - 162px);
  overflow: auto;
  padding: 12px;
}

.drawing-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 10px;
  padding: 12px;
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.drawing-card.active {
  border-color: var(--accent);
  background: #fbfdff;
  box-shadow: inset 3px 0 0 var(--accent), 0 10px 22px rgba(15, 111, 143, 0.08);
}

.drawing-card:hover {
  border-color: #adc0d0;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
  transform: translateY(-1px);
}

.drawing-card button {
  background: transparent;
  border: 0;
  color: inherit;
  display: block;
  padding: 0;
  text-align: left;
  width: 100%;
}

.drawing-card h3 {
  font-size: 15px;
  line-height: 1.35;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.card-meta {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 5px;
  line-height: 1.45;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  min-height: 26px;
  padding: 4px 10px;
  white-space: nowrap;
}

.status-approved {
  background: #eaf8f0;
  border-color: #bfe7cf;
  color: var(--ok);
}

.status-pending_review {
  background: #fff8e8;
  border-color: #f3d28d;
  color: var(--warn);
}

.status-pending_conversion {
  background: #eef4fa;
  border-color: #bed3e8;
  color: var(--accent-strong);
}

.status-conversion_failed,
.status-obsolete {
  background: #fff1f0;
  border-color: #f3b3ae;
  color: var(--danger);
}

.status-draft,
.status-archived {
  background: #f8fafc;
  border-color: #d8dee6;
  color: var(--muted);
}

.status-rejected {
  background: #fff1f0;
  border-color: #f3b3ae;
  color: var(--danger);
}

.risk-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  min-height: 26px;
  padding: 4px 10px;
  white-space: nowrap;
}

.risk-high {
  background: #fff1f0;
  border-color: #f1a8a1;
  color: var(--danger);
}

.risk-medium {
  background: #fff8e8;
  border-color: #f3d28d;
  color: var(--warn);
}

.risk-low {
  background: #eaf8f0;
  border-color: #bfe7cf;
  color: var(--ok);
}

.detail-panel {
  padding: 0;
}

.detail,
.empty-state {
  padding: 16px;
}

.detail {
  max-height: calc(100vh - 102px);
  overflow: auto;
}

.hidden {
  display: none !important;
}

.detail-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  margin: -16px -16px 14px;
  padding: 15px 16px;
  background: #fbfcfe;
  position: sticky;
  top: 0;
  z-index: 2;
}

.detail-header h2 {
  font-size: 20px;
  line-height: 1.25;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

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

.info-card,
.workflow-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.info-card > strong,
.workflow-card h3,
.association-card strong,
.ai-card strong {
  color: #101828;
}

.collaboration-panel {
  background: transparent;
  border: 0;
  margin: 12px 0 0;
  padding: 0;
}

.collaboration-panel > .panel-title {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 10px;
  padding: 12px;
}

.collab-summary {
  align-items: center;
  background: linear-gradient(135deg, #f8fbff 0%, #eef7f3 100%);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.collab-summary strong,
.collab-card-head strong,
.collab-chat-head strong,
.collab-impact-item strong {
  color: #071b45;
  font-size: 13px;
  line-height: 1.25;
}

.collab-summary p,
.collab-impact-item p,
.collab-step p,
.collab-message p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.collab-summary-badges,
.collab-card-head,
.collab-chat-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.collab-summary-badges span:not(.status-pill),
.collab-card-head span,
.collab-chat-head span {
  background: #eef4fa;
  border: 1px solid #bed3e8;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 9px;
}

.collab-grid,
.collab-impact {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.collab-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.collab-impact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
}

.collab-card,
.collab-impact-item,
.collab-chat {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.collab-progress-track {
  background: #e6edf5;
  border-radius: 999px;
  grid-column: 1 / -1;
  height: 7px;
  margin: 0 0 2px;
  overflow: hidden;
}

.collab-progress-track span {
  background: linear-gradient(90deg, var(--accent), var(--ok));
  display: block;
  height: 100%;
}

.collab-flow-list {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  margin-top: 10px;
}

.collab-step {
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid #dbe7f3;
  border-radius: 7px;
  display: grid;
  gap: 6px;
  grid-template-columns: 10px minmax(0, 1fr);
  min-height: 58px;
  padding: 8px;
}

.collab-step > span {
  background: #d8dee6;
  border-radius: 999px;
  height: 8px;
  margin-top: 4px;
  width: 8px;
}

.collab-step strong {
  display: block;
  font-size: 12px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.collab-step.is-done > span {
  background: var(--ok);
}

.collab-step.is-current > span {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 111, 143, 0.12);
}

.collab-step.is-blocked > span {
  background: var(--danger);
}

.collab-role-list {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(auto-fit, minmax(102px, 1fr));
  margin-top: 10px;
}

.collab-role {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
  padding: 7px 8px;
}

.collab-role strong,
.collab-role span {
  display: block;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.collab-role span {
  color: var(--muted);
  margin-top: 2px;
}

.collab-role.is-current {
  background: #eaf8f0;
  border-color: #bfe7cf;
}

.collab-role.can-send:not(.is-current) {
  border-color: #d7e7f6;
}

.collab-role.is-muted {
  opacity: 0.62;
}

.collab-message-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.collab-message {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
}

.collab-message.is-self {
  background: #e8f4f7;
  border-color: #bed3e8;
}

.collab-message.is-system {
  background: #fff8e8;
  border-color: #f3d28d;
}

.collab-message.is-pending {
  opacity: 0.72;
}

.collab-message-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.collab-message-meta strong {
  font-size: 13px;
}

.collab-message-meta span,
.collab-message-meta time {
  color: var(--muted);
  font-size: 11px;
}

.collab-message-meta .message-pending {
  background: #e8f1ff;
  border: 1px solid #bfd7ff;
  border-radius: 999px;
  color: var(--primary);
  padding: 1px 6px;
}

.collab-message-form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 8px;
}

.collab-message-form textarea {
  min-height: 42px;
  resize: vertical;
}

.collab-open-workspace {
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

body.page-drawings .collaboration-panel .collab-grid,
body.page-drawings .collaboration-panel .collab-impact {
  display: none;
}

body.page-drawings .collaboration-panel .collab-chat {
  margin-top: 10px;
}

@media (max-width: 760px) {
  .collab-summary,
  .collab-message-form {
    grid-template-columns: 1fr;
  }

  .collab-grid,
  .collab-impact {
    grid-template-columns: 1fr;
  }

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

.workflow-card h3 {
  margin-top: 0;
}

.kv-grid {
  display: grid;
  gap: 6px 10px;
  grid-template-columns: 86px minmax(0, 1fr);
  margin-top: 10px;
}

.kv-grid span {
  color: var(--muted);
  font-size: 12px;
}

.kv-grid strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.mini-row {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.mini-row strong {
  display: block;
  font-size: 13px;
}

.mini-row p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.mini-row .text-button {
  display: inline-flex;
  margin: 4px 8px 0 0;
}

.association-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 12px 0;
  padding: 12px;
  background: #fff;
  container-name: association-panel;
  container-type: inline-size;
}

.association-panel h3 {
  font-size: 15px;
  margin: 0 0 4px;
}

.association-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.cad-analysis-box {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
}

.cad-analysis-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.cad-analysis-head strong {
  font-size: 13px;
}

.cad-analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.confidence-missing {
  background: #fff1f0;
  border-color: #efa9a3;
  color: #b42318;
}

.missing-drawing-alerts {
  background: #fff5f4;
  border: 1px solid #e99b94;
  border-left: 4px solid #c62828;
  border-radius: 7px;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.missing-alert-head,
.missing-alert-row,
.missing-dialog-head,
.missing-dialog-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.missing-alert-head strong,
.missing-alert-row strong {
  color: #8f1d17;
}

.missing-alert-head p,
.missing-alert-row p,
.missing-alert-row small,
.missing-dialog-head p {
  color: #7a3935;
  font-size: 12px;
  line-height: 1.45;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.missing-alert-head > span {
  background: #c62828;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  min-width: 30px;
  padding: 5px 8px;
  text-align: center;
}

.missing-alert-list {
  display: grid;
  gap: 8px;
}

.missing-alert-row {
  background: #fff;
  border-top: 1px solid #efc5c1;
  padding: 9px 0 0;
}

.missing-alert-row > div {
  min-width: 0;
}

.missing-complete-button,
.missing-role-hint {
  flex: 0 0 auto;
}

.missing-role-hint {
  color: #8f1d17;
  font-size: 12px;
  font-weight: 800;
}

.association-viewbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin: 12px -12px 0;
  padding: 0 12px 12px;
}

.association-mode-switch {
  background: #eef4fa;
  border: 1px solid #c9d8e6;
  border-radius: 7px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.association-mode-button {
  background: transparent;
  border: 0;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  min-width: 58px;
  padding: 0 12px;
}

.association-mode-button.active {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  color: var(--accent-strong);
}

.association-filter-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.association-filter-row label {
  align-items: center;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.association-filter-row select {
  background: #fff;
  border: 1px solid var(--line);
  color: #12324c;
  min-height: 32px;
  padding: 0 8px;
}

.graph-check {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 32px;
  padding: 0 8px;
}

.association-graph-view {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.association-workspace {
  min-width: 0;
}

.association-workspace.has-preview {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 0.68fr) minmax(0, 1fr);
  margin-top: 12px;
}

.association-workspace.has-preview > .association-graph-view,
.association-workspace.has-preview > .association-list-view {
  grid-column: 1;
  grid-row: 1;
  margin-top: 0;
  min-width: 0;
}

.association-workspace.has-preview .association-graph-shell,
.association-workspace.has-preview .association-grid {
  grid-template-columns: minmax(0, 1fr);
}

.association-workspace.has-preview .association-graph-stage,
.association-workspace.has-preview .association-graph {
  min-height: 350px;
}

.association-workspace.has-preview .association-graph-detail {
  min-height: 0;
}

.association-graph-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.graph-legend {
  align-items: center;
  color: #475569;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.graph-legend span {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
}

.legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.legend-drawing {
  background: #0f6f8f;
}

.legend-part {
  background: #087443;
}

.legend-candidate {
  background: #b76e00;
}

.legend-missing {
  background: #c62828;
}

.graph-legend .legend-missing-item {
  background: #fff1f0;
  border-color: #efa9a3;
  color: #9f2019;
}

.legend-bom {
  background: #7c3aed;
}

.graph-zoom-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.graph-tool-button {
  min-height: 32px;
  min-width: 34px;
  padding: 0 10px;
}

.association-graph-shell {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.34fr);
}

.association-graph-stage {
  background:
    linear-gradient(#edf3f8 1px, transparent 1px),
    linear-gradient(90deg, #edf3f8 1px, transparent 1px),
    #fbfdff;
  background-size: 24px 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 420px;
  overflow: hidden;
  position: relative;
}

.association-graph {
  cursor: grab;
  display: block;
  height: 100%;
  min-height: 420px;
  touch-action: none;
  width: 100%;
}

.association-graph:active {
  cursor: grabbing;
}

.association-graph-bg {
  fill: transparent;
}

#association-arrow path {
  fill: #64748b;
}

.association-edge-group {
  cursor: pointer;
}

.association-edge-hit {
  fill: none;
  pointer-events: stroke;
  stroke: transparent;
  stroke-linecap: round;
  stroke-width: 18;
}

.association-edge-line {
  fill: none;
  stroke: #64748b;
  stroke-linecap: round;
  stroke-width: 2;
}

.association-edge-candidate .association-edge-line {
  stroke: #b76e00;
  stroke-dasharray: 6 6;
}

.association-edge-missing .association-edge-line {
  stroke: #c62828;
  stroke-dasharray: 8 4;
  stroke-width: 3;
}

.association-edge-missing .association-edge-label {
  fill: #a31e18;
}

.association-edge-bom .association-edge-line {
  stroke: #7c3aed;
}

.association-edge-impact .association-edge-line,
.association-edge-department .association-edge-line {
  stroke: #64748b;
  stroke-dasharray: 3 5;
}

.association-edge-group.is-selected .association-edge-line {
  stroke-width: 4;
}

.association-edge-label {
  fill: #334155;
  font-size: 11px;
  font-weight: 800;
  paint-order: stroke;
  pointer-events: none;
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 4px;
  text-anchor: middle;
}

.association-node {
  cursor: pointer;
}

.association-node rect {
  fill: #ffffff;
  stroke: #b9c8d8;
  stroke-width: 1.5;
}

.association-node-title {
  fill: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.association-node-subtitle {
  fill: #607086;
  font-size: 11px;
  font-weight: 700;
}

.association-node-dot {
  fill: #0f6f8f;
}

.association-node-part rect {
  fill: #f1fbf6;
  stroke: #8ccdaf;
}

.association-node-part .association-node-dot {
  fill: #087443;
}

.association-node-department rect {
  fill: #fff8ec;
  stroke: #efc27a;
}

.association-node-department .association-node-dot {
  fill: #b76e00;
}

.association-node.is-candidate rect {
  fill: #fff7ed;
  stroke: #efb164;
  stroke-dasharray: 6 4;
}

.association-node.is-candidate .association-node-dot {
  fill: #b76e00;
}

.association-node.is-missing rect {
  fill: #fff1f0;
  stroke: #c62828;
  stroke-dasharray: 7 4;
  stroke-width: 2.5;
}

.association-node.is-missing .association-node-title,
.association-node.is-missing .association-node-subtitle {
  fill: #9f2019;
}

.association-node.is-missing .association-node-dot {
  fill: #c62828;
}

.association-node.is-bom rect {
  fill: #f7f3ff;
  stroke: #bba7f2;
}

.association-node.is-bom .association-node-dot {
  fill: #7c3aed;
}

.association-node.is-impact rect {
  fill: #f8fafc;
  stroke: #cbd5e1;
}

.association-node.is-current rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.association-node.is-selected rect {
  filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.16));
  stroke: #111827;
  stroke-width: 2.5;
}

.association-graph-detail {
  align-content: start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 10px;
  min-height: 420px;
  padding: 12px;
}

.graph-detail-head {
  display: grid;
  gap: 5px;
}

.graph-detail-head strong {
  color: #0f172a;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.graph-detail-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.association-graph-detail p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  overflow-wrap: anywhere;
}

.graph-detail-action {
  justify-self: start;
}

.association-drawing-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.association-drawing-actions .secondary-button,
.association-drawing-actions .text-button {
  min-height: 32px;
  padding: 0 10px;
}

.association-inline-preview {
  align-content: start;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 10px;
  grid-column: 2;
  grid-row: 1;
  min-height: 520px;
  min-width: 0;
  overflow: hidden;
}

.association-preview-head {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 12px;
}

.association-preview-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.association-preview-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.association-preview-title strong {
  color: #0f172a;
  font-size: 14px;
}

.association-preview-head-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 7px;
}

.association-preview-mode {
  background: #edf2f7;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  display: inline-flex;
  overflow: hidden;
}

.association-preview-mode button {
  background: transparent;
  border: 0;
  color: #475569;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  min-height: 31px;
  padding: 0 10px;
}

.association-preview-mode button.active {
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px #9fc2df;
}

.association-preview-close {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  font-size: 22px;
  height: 32px;
  justify-content: center;
  line-height: 1;
  width: 32px;
}

.association-preview-close:hover {
  background: #eef2f6;
  border-color: #cbd5e1;
  color: #0f172a;
}

.association-preview-versionbar {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(125px, 180px) minmax(0, 1fr);
  padding: 0 12px;
}

.association-preview-versionbar > span {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.association-preview-versionbar select {
  background: #ffffff;
  border: 1px solid var(--line);
  min-height: 32px;
  padding: 0 8px;
  width: 100%;
}

.association-preview-versionbar small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.association-preview-documents {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 0 12px 12px;
}

.association-preview-documents.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.association-preview-documents.is-compare {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.association-preview-document {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

.association-preview-document-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 9px 10px;
}

.association-preview-document-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.association-preview-document-head span,
.association-preview-document-head small {
  color: var(--muted);
  font-size: 11px;
}

.association-preview-document-head strong,
.association-preview-document-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.association-preview-document-head strong {
  color: #0f172a;
  font-size: 12px;
}

.association-preview-document-head .text-button {
  flex-shrink: 0;
  white-space: nowrap;
}

.association-preview-surface {
  align-items: center;
  background:
    linear-gradient(#e8eef5 1px, transparent 1px),
    linear-gradient(90deg, #e8eef5 1px, transparent 1px),
    #f2f5f8;
  background-size: 20px 20px;
  display: flex;
  height: min(58vh, 620px);
  justify-content: center;
  min-height: 440px;
  min-width: 0;
  overflow: hidden;
}

.association-preview-surface iframe,
.association-preview-surface img {
  background: #ffffff;
  border: 0;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.association-preview-empty {
  color: var(--muted);
  display: grid;
  gap: 7px;
  max-width: 260px;
  padding: 24px;
  text-align: center;
}

.association-preview-empty strong {
  color: #334155;
}

.association-preview-empty p {
  font-size: 12px;
  margin: 0;
}

@media (max-width: 980px) {
  .association-workspace.has-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .association-workspace.has-preview > .association-graph-view,
  .association-workspace.has-preview > .association-list-view,
  .association-inline-preview {
    grid-column: 1;
    grid-row: auto;
  }
}

@container association-panel (max-width: 520px) {
  .association-workspace.has-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .association-workspace.has-preview > .association-graph-view,
  .association-workspace.has-preview > .association-list-view,
  .association-inline-preview {
    grid-column: 1;
    grid-row: auto;
  }

  .association-preview-documents.is-compare {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .association-viewbar,
  .association-graph-tools {
    align-items: stretch;
  }

  .association-mode-switch,
  .association-filter-row,
  .graph-legend,
  .graph-zoom-tools {
    width: 100%;
  }

  .association-mode-button {
    flex: 1;
  }

  .association-graph-shell {
    grid-template-columns: 1fr;
  }

  .association-graph-stage,
  .association-graph,
  .association-graph-detail {
    min-height: 320px;
  }

  .association-preview-head,
  .association-preview-head-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .association-preview-versionbar,
  .association-preview-documents.is-compare {
    grid-template-columns: minmax(0, 1fr);
  }

  .association-preview-versionbar small {
    white-space: normal;
  }

  .association-preview-surface {
    height: 480px;
    min-height: 360px;
  }

  .missing-alert-row,
  .missing-alert-head {
    align-items: stretch;
    flex-direction: column;
  }

  .missing-alert-head > span {
    align-self: flex-start;
  }

  .missing-complete-button {
    width: 100%;
  }
}

.association-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 160px;
  padding: 12px;
}

.association-card-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.association-card-head span {
  background: #eef4fa;
  border: 1px solid #bed3e8;
  border-radius: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  min-width: 28px;
  padding: 4px 7px;
  text-align: center;
}

.candidate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.missing-drawing-dialog {
  border: 0;
  border-radius: 7px;
  max-width: min(620px, calc(100vw - 28px));
  padding: 0;
  width: 620px;
}

.missing-drawing-dialog::backdrop {
  background: rgba(15, 23, 42, 0.56);
}

.missing-drawing-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.missing-dialog-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.missing-dialog-head strong {
  color: #8f1d17;
  font-size: 18px;
}

.missing-dialog-actions {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  padding-top: 12px;
}

.confidence-pill {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #334155;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  padding: 3px 6px;
}

.bom-import-form {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.ai-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 12px 0;
  padding: 12px;
  background: #fff;
}

.ai-panel h3 {
  font-size: 15px;
  margin: 0;
}

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

.ai-card,
.ai-answer {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.ai-content {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.ai-content p,
.ai-answer p {
  margin: 0;
}

.ai-content ul {
  margin: 0;
  padding-left: 18px;
}

.ai-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-tags span {
  background: #eef4fa;
  border: 1px solid #bed3e8;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  padding: 4px 7px;
}

.ai-check {
  background: #fff;
  border-radius: 6px;
  border-left: 3px solid var(--warn);
  margin-top: 8px;
  padding: 8px;
}

.ai-check span {
  float: right;
  font-size: 12px;
  font-weight: 700;
}

.ai-check p {
  clear: both;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.ai-pass {
  border-color: var(--ok);
}

.ai-warn {
  border-color: var(--warn);
}

.ai-fail {
  border-color: var(--danger);
}

.ai-question {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.ai-question input {
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 0 10px;
}

.ai-runs {
  margin-top: 12px;
}

.preview-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
  overflow: hidden;
}

.preview-head {
  border-bottom: 1px solid var(--line);
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
}

.preview-head small {
  color: var(--muted);
  font-weight: 400;
}

iframe {
  background: #f8fafc;
  border: 0;
  height: 420px;
  width: 100%;
}

.version-row,
.log-row,
.notification {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 8px;
  padding: 10px;
  background: #fff;
}

.version-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 90px 1fr auto;
}

.version-row.active-version {
  border-color: var(--ok);
}

.notification strong,
.version-row strong {
  display: block;
  font-size: 13px;
}

.notification p,
.log-row p,
.version-row p,
.bell-item p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.bell-item strong {
  display: block;
  font-size: 13px;
}

.agent-status-card {
  display: grid;
  gap: 10px;
}

.agent-status-head {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--panel-soft);
}

.agent-status-head strong {
  display: block;
  font-size: 15px;
}

.agent-status-head p,
.agent-line {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.agent-dot {
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
  height: 14px;
  width: 14px;
}

.agent-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(8, 116, 67, 0.12);
}

.agent-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.12);
}

.agent-stat-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
}

.agent-stat-grid div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.agent-stat-grid strong {
  color: var(--accent-strong);
  display: block;
  font-size: 18px;
  line-height: 1;
}

.agent-stat-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 6px;
}

.agent-mini-list,
.agent-events {
  display: grid;
  gap: 6px;
}

.agent-mini-list code {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #12324c;
  display: block;
  font-size: 12px;
  overflow-wrap: anywhere;
  padding: 7px;
}

.agent-event {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
}

.agent-event strong {
  display: block;
  font-size: 12px;
}

.agent-event p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

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

.agent-dir-list {
  margin-top: 14px;
}

.agent-dir {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 8px;
  padding: 10px;
  background: #fff;
}

.agent-dir strong {
  display: block;
  font-size: 13px;
}

.agent-dir code {
  color: #12324c;
  display: block;
  font-size: 12px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.download-center-card,
.deploy-section {
  display: grid;
  gap: 10px;
}

.deploy-head {
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.deploy-head strong,
.download-card strong,
.agent-device strong {
  display: block;
  font-size: 13px;
}

.deploy-head p,
.download-card p,
.agent-device p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.deploy-head code {
  color: #12324c;
  overflow-wrap: anywhere;
}

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

.download-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 10px;
}

.download-card button {
  align-self: end;
}

.download-status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-ready,
.status-h5-ready {
  color: var(--ok);
}

.status-planned {
  color: var(--warn);
}

.deploy-section {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.deploy-section h3 {
  font-size: 14px;
  margin: 0;
}

.deploy-section ul {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  padding-left: 18px;
}

.agent-device-list {
  display: grid;
  gap: 8px;
}

.agent-device {
  align-items: center;
  display: flex;
  gap: 10px;
}

.empty-state {
  align-content: center;
  color: var(--muted);
  display: grid;
  min-height: calc(100vh - 116px);
  place-items: center;
  text-align: center;
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 360px;
  padding: 18px;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.32);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px 1fr;
  }

  .role-home-body,
  .role-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-focus {
    grid-column: 1 / -1;
  }

  .detail-panel {
    grid-column: 1 / -1;
  }

  .left-rail {
    max-height: none;
    overflow: visible;
    position: static;
  }

  .detail {
    max-height: none;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 68px;
  }

  .auth-view {
    padding: 12px;
  }

  .auth-card {
    padding: 18px;
  }

  .auth-card h1 {
    font-size: 22px;
  }

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 14px;
    position: sticky;
    top: 0;
    z-index: 8;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar-actions {
    align-items: stretch;
    flex-wrap: wrap;
    min-width: 0;
  }

  .role-switch {
    width: 100%;
  }

  .session-card {
    justify-content: space-between;
  }

  .bell-popover {
    left: auto;
    right: 0;
    width: min(340px, calc(100vw - 20px));
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .deploy-head {
    grid-template-columns: 1fr;
  }

  .role-home {
    padding: 12px;
  }

  .role-home-head {
    display: grid;
  }

  .role-home h2 {
    font-size: 18px;
  }

  .role-home-kpis,
  .role-home-body,
  .role-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .role-home-body {
    display: grid;
  }

  .role-focus {
    grid-column: 1 / -1;
  }

  .role-action-card {
    min-height: 78px;
  }

  .focus-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .focus-badges {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .list-panel,
  .detail-panel {
    min-height: auto;
  }

  .drawing-list {
    max-height: none;
  }

  .detail-header {
    position: static;
  }

  .form-row,
  .file-pair,
  .version-row,
  .ai-grid,
  .ai-question,
  .info-grid,
  .association-grid,
  .workflow-grid,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  iframe {
    height: 56vh;
  }

  .mobile-nav {
    background: #ffffff;
    border-top: 1px solid var(--line);
    bottom: 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    left: 0;
    min-height: 58px;
    position: fixed;
    right: 0;
    z-index: 12;
  }

  .mobile-nav button {
    background: transparent;
    border: 0;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    border-radius: 0;
  }
}

@media (max-width: 520px) {
  .role-home-body,
  .role-actions {
    grid-template-columns: 1fr;
  }

  .panel-title,
  .section-head,
  .detail-header,
  .preview-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-badges,
  .focus-badges {
    justify-content: flex-start;
  }
}

/* Workbench redesign: keep primary work actions in reach and make panes scroll independently. */
body.drawer-open {
  overflow: hidden;
}

.top-upload-button {
  background: #19a06b;
  border-color: #19a06b;
  color: #fff;
  min-height: 40px;
  padding: 0 18px;
  white-space: nowrap;
}

.top-upload-button:hover {
  background: #117b53;
  border-color: #117b53;
}

.drawer-backdrop {
  background: rgba(15, 23, 42, 0.36);
  inset: 72px 0 0;
  position: fixed;
  z-index: 21;
}

.workspace {
  gap: 12px;
  grid-template-columns: 300px minmax(360px, 0.88fr) minmax(520px, 1.22fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 72px);
  overflow: hidden;
  padding: 12px;
}

.role-home {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.role-home-head {
  align-items: center;
}

.role-home h2 {
  font-size: 18px;
}

.role-home-subtitle,
#role-home-subtitle {
  max-width: 720px;
}

.role-home-kpis {
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  min-width: min(500px, 100%);
}

.role-kpi {
  min-height: 54px;
  padding: 9px 10px;
}

.role-home-body {
  align-items: start;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.84fr);
  margin-top: 0;
}

.role-actions {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.role-action-card {
  min-height: 42px;
  padding: 8px 10px;
}

.role-action-card span {
  display: none;
}

.role-focus {
  padding: 10px;
}

.role-focus-list {
  gap: 7px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.focus-item {
  align-items: flex-start;
  flex-direction: column;
  min-height: 46px;
  padding: 7px 9px;
}

.focus-item small {
  margin-top: 3px;
}

.focus-badges {
  justify-content: flex-start;
}

.left-rail,
.list-panel,
.detail-panel {
  height: 100%;
  min-height: 0;
}

.left-rail {
  max-height: none;
  overflow: auto;
  padding-right: 0;
  position: static;
}

.drawing-list {
  height: calc(100% - 72px);
  max-height: none;
  overflow: auto;
}

.detail {
  height: 100%;
  max-height: none;
  overflow: auto;
}

.detail-tabs {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin: 0 -16px 12px;
  overflow-x: auto;
  padding: 8px 16px;
  position: sticky;
  top: 75px;
  z-index: 3;
}

.detail-tab-button {
  background: transparent;
  border: 1px solid transparent;
  color: #475569;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  padding: 0 14px;
}

.detail-tab-button.active {
  background: var(--accent-soft);
  border-color: #b7d7e1;
  color: var(--accent-strong);
}

.detail-panel-hidden {
  display: none !important;
}

.detail > .info-grid {
  margin-bottom: 0;
}

.detail > .action-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.section-head {
  min-height: 72px;
}

.upload-panel {
  bottom: 16px;
  display: flex;
  flex-direction: column;
  left: auto;
  margin: 0;
  max-width: calc(100vw - 32px);
  opacity: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 88px;
  transform: translateX(calc(100% + 32px));
  transition: opacity 0.18s ease, transform 0.22s ease;
  width: min(760px, calc(100vw - 32px));
  z-index: 22;
}

.upload-panel.drawer-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.drawer-title {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.drawer-title h2 {
  font-size: 18px;
  margin: 2px 0 0;
}

.drawer-close {
  min-height: 34px;
}

.upload-panel .upload-form {
  display: grid;
  gap: 0;
  overflow: auto;
  padding: 16px 18px 18px;
}

.upload-panel .form-row,
.upload-panel .file-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upload-panel .file-pair {
  order: -3;
}

.upload-panel .upload-form > .file-drop {
  order: -2;
}

.upload-panel .upload-autofill-card {
  order: -1;
}

.upload-panel .file-drop {
  min-height: 68px;
}

.upload-panel .primary-button[type="submit"] {
  bottom: 0;
  box-shadow: 0 -12px 22px rgba(255, 255, 255, 0.94);
  min-height: 44px;
  position: sticky;
}

.import-panel,
.agent-config-panel,
.converter-config-panel,
.ai-config-panel {
  margin-top: 12px;
}

.utility-panel {
  padding: 0;
}

.utility-panel > .panel-title {
  cursor: pointer;
  padding: 13px 14px;
}

.utility-panel > .panel-title::after {
  color: var(--accent);
  content: "展开";
  font-size: 12px;
  font-weight: 700;
}

.utility-panel.expanded > .panel-title {
  border-bottom: 1px solid var(--line);
}

.utility-panel.expanded > .panel-title::after {
  content: "收起";
}

.utility-panel:not(.expanded) > :not(.panel-title) {
  display: none !important;
}

.utility-panel.expanded > :not(.panel-title) {
  margin: 14px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  }

  .role-home-body,
  .role-focus-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-focus {
    grid-column: auto;
  }

  .detail-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .top-upload-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .role-switch {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .role-home-kpis,
  .role-home-body,
  .role-actions,
  .role-focus-list {
    grid-template-columns: 1fr 1fr;
  }

  .left-rail,
  .list-panel,
  .detail-panel,
  .detail {
    height: auto;
  }

  .drawing-list {
    height: auto;
  }

  .drawer-backdrop {
    inset: 0;
    z-index: 30;
  }

  .upload-panel {
    border-radius: 0;
    bottom: 0;
    max-width: none;
    right: 0;
    top: 0;
    width: min(100vw, 640px);
    z-index: 31;
  }

  .upload-panel .form-row,
  .upload-panel .file-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .role-home-kpis,
  .role-home-body,
  .role-actions,
  .role-focus-list {
    grid-template-columns: 1fr;
  }

  .drawer-title {
    align-items: center;
    flex-direction: row;
  }

  .topbar-actions {
    grid-template-columns: 1fr auto;
  }

  .session-card {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .role-home-kpis,
  .role-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-kpi {
    min-height: 52px;
  }

  .role-action-card {
    min-height: 42px;
    padding: 8px 10px;
  }

  .role-action-card span {
    display: none;
  }

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

/* Precision workbench redesign: product-style shell, searchable table, and on-demand detail drawer. */
:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f7faff;
  --line: #dce5f0;
  --line-strong: #b9c7d8;
  --ink: #101828;
  --muted: #667085;
  --accent: #1268f3;
  --accent-strong: #0b4ec2;
  --accent-soft: #edf4ff;
  --success: #12a05c;
  --shadow: 0 12px 34px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 6px 18px rgba(16, 24, 40, 0.06);
}

body {
  background: var(--bg);
  color: var(--ink);
}

body.app-booting .auth-view,
body.app-booting .app-shell {
  display: none !important;
}

body.app-booting::before {
  background:
    linear-gradient(rgba(18, 104, 243, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.04) 1px, transparent 1px),
    #f3f7fb;
  background-size: 28px 28px;
  content: "";
  inset: 0;
  position: fixed;
  z-index: 9998;
}

body.app-booting::after {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  color: #071b45;
  content: "正在加载工作台...";
  font-size: 15px;
  font-weight: 800;
  left: 50%;
  padding: 16px 22px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

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

.app-sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  grid-row: 1 / -1;
  min-height: 100vh;
  padding: 22px 16px;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 48px;
}

.brand-lockup img {
  height: 38px;
  width: 38px;
}

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

.brand-lockup strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: #344054;
  display: flex;
  font-weight: 700;
  gap: 10px;
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
}

.side-nav-item span {
  align-items: center;
  color: #5c6f8f;
  display: inline-flex;
  font-size: 16px;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.side-nav-item.active,
.side-nav-item:hover {
  background: #1268f3;
  border-color: #1268f3;
  color: #fff;
}

.side-nav-item.active span,
.side-nav-item:hover span {
  color: #fff;
}

.sidebar-agent {
  align-items: center;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
}

.sidebar-agent strong,
.sidebar-agent p {
  display: block;
  margin: 0;
}

.sidebar-agent strong {
  font-size: 13px;
}

.sidebar-agent p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.topbar {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
  display: grid;
  gap: 12px 16px;
  grid-column: 2;
  grid-template-columns: minmax(170px, 0.42fr) minmax(180px, 0.58fr) minmax(420px, 1fr);
  min-height: 72px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
}

.topbar h1 {
  color: #101828;
  font-size: 20px;
  margin: 2px 0 0;
}

.topbar .eyebrow {
  color: #667085;
}

.global-search {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 42px;
  padding: 0 10px 0 12px;
}

.global-search span {
  color: #667085;
  font-size: 12px;
  font-weight: 700;
}

.global-search input {
  border: 0;
  min-height: 38px;
  padding: 0;
}

.global-search input:focus {
  outline: 0;
}

.global-search kbd {
  background: #f2f4f7;
  border: 1px solid #d0d5dd;
  border-radius: 5px;
  color: #667085;
  font-size: 11px;
  padding: 2px 6px;
}

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

.session-card,
.bell-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.session-card span {
  color: var(--muted);
}

.session-card .text-button {
  color: var(--accent);
}

.bell-button {
  color: #344054;
}

.topbar .role-switch {
  background: #f5f8fb;
  border-color: var(--line);
}

.topbar .role-button {
  color: #344054;
}

.topbar .role-button.active {
  background: var(--accent);
  color: #fff;
}

.top-upload-button {
  background: var(--success);
  border-color: var(--success);
  border-radius: 7px;
  min-height: 40px;
}

.top-upload-button:hover {
  background: #0d854b;
  border-color: #0d854b;
}

.workspace {
  display: grid;
  gap: 14px;
  grid-column: 2;
  grid-template-areas:
    "hero hero"
    "list side";
  grid-template-columns: minmax(0, 1fr) 430px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 18px 20px;
}

.panel,
.list-panel,
.detail-panel,
.role-home {
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.role-home {
  grid-area: hero;
  min-height: 260px;
  overflow: hidden;
  padding: 18px;
}

.role-home::before {
  background:
    linear-gradient(90deg, rgba(18, 104, 243, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(18, 104, 243, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  inset: 0 42% 0 0;
  opacity: 0.7;
  pointer-events: none;
  position: absolute;
}

.role-home {
  position: relative;
}

.role-home > * {
  position: relative;
}

.role-home-head {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.68fr);
}

.role-home h2 {
  font-size: 30px;
  letter-spacing: 0;
  margin: 8px 0 8px;
}

#role-home-subtitle {
  color: #475467;
  font-size: 14px;
  max-width: 680px;
}

.role-home-kpis {
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
}

.role-kpi {
  background: rgba(255, 255, 255, 0.92);
  border-color: #d8e6fb;
  border-radius: 8px;
  min-height: 76px;
  padding: 13px;
}

.role-kpi strong {
  color: #0b214a;
  font-size: 30px;
}

.role-home-body {
  gap: 14px;
  grid-template-columns: minmax(0, 0.86fr) minmax(420px, 1fr);
  margin-top: 18px;
}

.role-actions {
  gap: 10px;
  grid-template-columns: repeat(5, minmax(124px, 1fr));
}

.role-action-card {
  border-color: #d5e3f6;
  border-radius: 8px;
  min-height: 76px;
  padding: 12px;
}

.role-action-card span {
  display: block;
}

.role-action-card strong {
  color: #101828;
}

.role-action-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(18, 104, 243, 0.1);
}

.role-focus {
  background: #f8fbff;
  border-color: #d5e3f6;
  border-radius: 8px;
  padding: 12px;
}

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

.focus-item {
  border-radius: 8px;
  min-height: 78px;
}

.left-rail {
  grid-area: side;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 0 2px 0 0;
  position: static;
}

.left-rail .panel {
  margin-bottom: 12px;
}

.left-rail .panel:not(.compact):not(.upload-panel) {
  padding: 16px;
}

.metric-grid {
  gap: 10px;
}

.metric-grid div {
  background: #f8fbff;
  border-radius: 8px;
}

.list-panel {
  display: flex;
  flex-direction: column;
  grid-area: list;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.section-head {
  background: #fff;
  min-height: 72px;
  padding: 16px 18px;
}

.section-head h2 {
  font-size: 18px;
}

.drawing-list {
  flex: 1;
  height: auto;
  max-height: none;
  overflow: auto;
  padding: 0;
}

.drawing-table {
  min-width: 900px;
}

.drawing-table-head,
.drawing-row {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1.55fr) minmax(140px, 0.9fr) minmax(130px, 0.75fr) minmax(112px, 0.7fr) minmax(110px, 0.7fr) minmax(110px, 0.66fr) 64px;
  padding: 0 18px;
}

.drawing-table-head {
  align-items: center;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  height: 42px;
}

.drawing-row {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #edf1f6;
  cursor: pointer;
  min-height: 74px;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.drawing-row:hover {
  background: #f8fbff;
}

.drawing-row.active {
  background: #f5f9ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.drawing-row strong,
.drawing-row small {
  display: block;
}

.drawing-row strong {
  color: #101828;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.drawing-row small {
  color: #667085;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.file-cell {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
}

.file-type {
  align-items: center;
  background: #1268f3;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 42px;
}

.row-open-button {
  min-height: 32px;
  padding: 0 8px;
}

.risk-none {
  background: #f2f4f7;
  border-color: #d0d5dd;
  color: #667085;
}

.detail-backdrop {
  inset: 72px 0 0 220px;
  z-index: 34;
}

.detail-panel {
  bottom: 16px;
  display: flex;
  flex-direction: column;
  height: auto;
  max-width: calc(100vw - 252px);
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 88px;
  transform: translateX(calc(100% + 28px));
  transition: opacity 0.18s ease, transform 0.22s ease;
  width: min(820px, calc(100vw - 252px));
  z-index: 35;
}

.detail-panel.drawer-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.detail {
  height: 100%;
  max-height: none;
  overflow: auto;
  padding: 16px;
}

.detail-header {
  background: #fff;
  margin: -16px -16px 0;
  padding: 16px;
  top: 0;
}

.detail-header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.detail-tabs {
  top: 74px;
}

.upload-panel {
  box-shadow: var(--shadow);
  z-index: 42;
}

#upload-drawer-backdrop {
  z-index: 41;
}

.drawer-backdrop {
  background: rgba(16, 24, 40, 0.32);
}

body.drawer-open,
body.detail-drawer-open {
  overflow: hidden;
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: minmax(150px, 0.46fr) minmax(220px, 1fr);
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .topbar .role-switch {
    flex: 1 1 520px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .role-home-head,
  .role-home-body {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .app-sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    display: grid;
    gap: 12px;
    grid-row: auto;
    min-height: 0;
    padding: 12px;
  }

  .brand-lockup {
    min-height: 0;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }

  .side-nav-item {
    flex: 0 0 auto;
  }

  .sidebar-agent {
    display: none;
  }

  .topbar {
    grid-column: 1;
    grid-row: auto;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .workspace {
    grid-column: 1;
    grid-template-areas:
      "hero"
      "list"
      "side";
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .role-home {
    min-height: 0;
  }

  .left-rail,
  .list-panel {
    height: auto;
  }

  .drawing-list {
    overflow-x: auto;
  }

  .detail-backdrop {
    inset: 0;
  }

  .detail-panel {
    bottom: 0;
    max-width: none;
    right: 0;
    top: 0;
    width: min(100vw, 760px);
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 64px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .top-upload-button,
  .global-search {
    grid-column: 1 / -1;
  }

  .role-home h2 {
    font-size: 23px;
  }

  .role-home-kpis,
  .role-focus-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-home-body {
    display: block;
  }

  .role-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .role-actions::-webkit-scrollbar,
  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .role-action-card {
    flex: 0 0 148px;
    min-height: 72px;
  }

  .role-action-card span {
    display: none;
  }

  .role-focus {
    display: none;
  }

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

  .drawing-table-head {
    display: none;
  }

  .drawing-row {
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin: 10px;
    padding: 12px;
  }

  .file-cell {
    grid-template-columns: auto 1fr;
  }

  .detail-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

.left-rail {
  overflow: hidden;
}

.left-rail:has(.utility-panel.expanded) {
  overflow: auto;
}

.left-rail .import-panel:not(.expanded),
.left-rail .download-center-panel:not(.expanded),
.left-rail .agent-status-panel:not(.expanded),
.left-rail .agent-config-panel:not(.expanded),
.left-rail .converter-config-panel:not(.expanded),
.left-rail .ai-config-panel:not(.expanded) {
  display: none !important;
}

.filter-panel {
  padding: 10px 12px;
}

.filter-panel .panel-title {
  margin-bottom: 8px;
}

.filter-panel .field {
  gap: 4px;
  margin-bottom: 8px;
}

.filter-panel .field span {
  font-size: 11px;
}

.filter-panel input,
.filter-panel select {
  min-height: 34px;
  padding-bottom: 6px;
  padding-top: 6px;
}

.left-rail .notification-list {
  max-height: 56px;
  overflow: auto;
}

.left-rail .notifications-panel {
  max-height: 116px;
  overflow: hidden;
  padding: 12px 14px;
}

.left-rail .upload-panel:not(.drawer-open) {
  display: none !important;
}

.left-rail .panel:last-child {
  margin-bottom: 0;
}

/* Reference-matched workbench pass. */
.topbar-title {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-role-tag {
  background: #edf4ff;
  border: 1px solid #b9d4ff;
  border-radius: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  gap: 14px;
  grid-template-areas:
    "hero hero"
    "list side";
  grid-template-columns: minmax(0, 1fr) 430px;
  grid-template-rows: 348px minmax(0, 1fr);
}

.role-home {
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 0.72fr);
  grid-template-rows: 192px 142px auto;
  min-height: 0;
  padding: 0;
}

.role-home::before {
  content: none;
}

.welcome-card,
.ai-workbench-card,
.quick-ops-card,
.status-strip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.welcome-card {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 44%);
  overflow: hidden;
  padding: 28px 28px;
  position: relative;
}

.welcome-copy {
  position: relative;
  z-index: 1;
}

.welcome-card h2 {
  color: #071b45;
  font-size: 32px;
  line-height: 1.18;
  margin: 8px 0 16px;
}

.welcome-card .muted {
  color: #3f5372;
  font-size: 18px;
}

.blueprint-hero {
  height: 100%;
  justify-self: end;
  max-width: 100%;
  object-fit: contain;
  opacity: 0.9;
  pointer-events: none;
}

.ai-workbench-card {
  display: grid;
  gap: 18px;
  padding: 22px 24px;
}

.ai-workbench-head {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.ai-workbench-head h2 {
  color: #071b45;
  font-size: 18px;
  margin: 0 0 8px;
}

.ai-workbench-head h2 span {
  color: var(--accent);
}

.ai-workbench-head p {
  color: #243b60;
  font-size: 14px;
  margin: 0;
}

.ai-workbench-head p strong {
  color: var(--accent);
  font-size: 16px;
}

.ai-shortcut-grid {
  display: grid;
  grid-template-columns: repeat(var(--ai-shortcut-count, 4), minmax(0, 1fr));
}

.ai-shortcut-grid button {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  color: #0f2147;
  display: grid;
  gap: 10px;
  justify-items: center;
  min-height: 86px;
}

.ai-shortcut-grid button:first-child {
  border-left: 0;
}

.ai-shortcut-grid button:hover {
  background: #f7faff;
}

.ai-shortcut-icon {
  align-items: center;
  border: 2px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  display: inline-flex;
  font-size: 16px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.ai-shortcut-grid strong {
  font-size: 14px;
}

.quick-ops-card {
  padding: 14px 16px 16px;
}

.quick-ops-card .panel-title {
  margin-bottom: 10px;
}

.quick-ops-card .panel-title h3 {
  color: #101828;
  font-size: 15px;
  margin: 0;
}

.quick-ops-card .role-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-ops-card .role-action-card {
  align-content: center;
  border-color: #dbe7f6;
  min-height: 74px;
  padding: 10px 12px;
}

.quick-ops-card .role-action-card strong {
  color: #071b45;
}

.quick-ops-card .role-action-card span {
  color: #61728f;
  display: block;
  font-size: 11px;
}

.status-strip {
  align-items: stretch;
  display: grid;
  grid-template-columns: repeat(var(--kpi-count, 5), minmax(0, 1fr));
  padding: 20px 0;
}

.status-strip .role-kpi {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  min-height: 94px;
  padding: 10px 24px;
}

.status-strip .role-kpi:first-child {
  border-left: 0;
}

.status-strip .role-kpi strong {
  color: #071b45;
  font-size: 42px;
  font-weight: 800;
}

.status-strip .role-kpi span {
  color: #667085;
  font-size: 13px;
}

.status-strip .role-kpi-status strong {
  color: #12a05c;
  font-size: 30px;
  margin-top: 8px;
}

.status-strip .role-kpi-danger strong {
  color: #d97706;
}

.home-workbench-grid {
  display: grid;
  gap: 14px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  min-width: 0;
}

.home-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
  padding: 16px;
}

.home-panel .panel-title {
  align-items: flex-start;
  margin-bottom: 12px;
}

.home-panel .panel-title h3 {
  color: #071b45;
  font-size: 16px;
  margin: 0 0 4px;
}

.home-panel .panel-title p {
  color: #667085;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.home-todo-panel,
.home-recent-panel,
.home-purchasing-panel,
.home-primary-panel {
  grid-column: span 7;
}

.home-agent-panel,
.home-ai-panel,
.home-supply-panel,
.home-context-panel {
  grid-column: span 5;
}

.home-events-panel,
.home-run-panel {
  grid-column: span 6;
}

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

.home-ai-panel .home-card-list,
.home-risk-list .page-card-list {
  grid-template-columns: 1fr;
}

.home-card-list .page-drawing-card,
.home-risk-list .page-drawing-card {
  min-height: 78px;
}

.home-recent-list,
.home-message-list,
.home-event-list,
.home-risk-list,
.home-supply-list {
  display: grid;
  gap: 10px;
}

.home-recent-row {
  align-items: center;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 74px;
  padding: 10px;
  text-align: left;
}

.home-recent-row:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(18, 104, 243, 0.09);
}

.home-recent-main,
.home-recent-main strong,
.home-recent-main small,
.home-recent-meta,
.home-recent-meta small {
  display: block;
  min-width: 0;
}

.home-recent-main strong {
  color: #071b45;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-recent-main small,
.home-recent-meta small {
  color: #667085;
  font-size: 12px;
  margin-top: 4px;
}

.home-recent-meta {
  justify-self: end;
  text-align: right;
}

.home-agent-state {
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 12px;
  white-space: nowrap;
}

.home-agent-state.online {
  background: #e9f9f0;
  border-color: #a9e7bf;
  color: #0b9f55;
}

.home-agent-state.offline {
  background: #fff3ed;
  border-color: #ffd0b5;
  color: #c8501e;
}

.home-status-grid,
.home-ai-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-status-line,
.home-ai-summary div {
  background: #f7faff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  min-height: 66px;
  padding: 12px;
}

.home-status-line span,
.home-ai-summary span {
  color: #667085;
  display: block;
  font-size: 12px;
}

.home-status-line strong,
.home-ai-summary strong {
  color: #071b45;
  display: block;
  font-size: 20px;
  margin-top: 8px;
}

.home-status-ok strong {
  color: #0b9f55;
}

.home-status-warn strong {
  color: #d97706;
}

.home-agent-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.home-supply-list {
  margin-top: 12px;
}

.home-supply-row {
  align-items: center;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 64px;
  padding: 10px 12px;
  text-align: left;
}

.home-supply-row:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(18, 104, 243, 0.09);
}

.home-supply-row span {
  min-width: 0;
}

.home-supply-row strong,
.home-supply-row small {
  display: block;
}

.home-supply-row strong {
  color: #071b45;
  font-size: 13px;
}

.home-supply-row small {
  color: #667085;
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-ai-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.home-ai-summary div {
  min-height: 72px;
}

.home-message-row,
.home-event-row {
  align-items: flex-start;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 10px 12px;
}

.home-message-dot {
  background: #c9d4e2;
  border-radius: 999px;
  height: 8px;
  margin-top: 6px;
  width: 8px;
}

.home-message-dot.unread {
  background: #1268f3;
  box-shadow: 0 0 0 4px rgba(18, 104, 243, 0.1);
}

.home-message-row strong,
.home-event-row strong {
  color: #071b45;
  display: block;
  font-size: 13px;
}

.home-message-row p,
.home-event-row p {
  color: #667085;
  display: -webkit-box;
  font-size: 12px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
  margin: 3px 0 0;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.home-message-row small,
.home-event-row small {
  color: #667085;
  font-size: 12px;
  white-space: nowrap;
}

.home-event-row > span:first-child {
  background: #eef5ff;
  border: 1px solid #cfe0ff;
  border-radius: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  min-width: 34px;
  padding: 4px 6px;
  text-align: center;
}

.role-home > .role-focus {
  display: none;
}

.list-panel {
  min-height: 0;
}

.section-head h2 {
  color: #101828;
  font-size: 18px;
}

.drawing-table-head {
  height: 38px;
}

.drawing-row {
  min-height: 58px;
}

.left-rail {
  display: grid;
  gap: 12px;
  grid-template-rows: minmax(230px, auto) minmax(120px, 1fr);
  overflow: hidden;
}

.left-rail > .compact,
.left-rail > .filter-panel {
  display: none !important;
}

.left-rail .agent-status-panel:not(.expanded) {
  display: block !important;
}

.left-rail .agent-status-panel.utility-panel > .panel-title::after {
  content: "";
}

.left-rail .agent-status-panel.utility-panel:not(.expanded) > :not(.panel-title) {
  display: grid !important;
}

.left-rail .agent-status-panel,
.left-rail .notifications-panel {
  margin: 0;
  padding: 16px;
}

.left-rail .agent-status-panel .panel-title h2,
.left-rail .notifications-panel .panel-title h2 {
  font-size: 16px;
}

.left-rail .agent-status-panel {
  max-height: 250px;
  overflow: hidden;
}

.left-rail .agent-status-head {
  border: 0;
  padding: 4px 0 10px;
}

.left-rail .agent-stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.left-rail .agent-stat-grid div {
  padding: 8px 6px;
}

.left-rail .agent-stat-grid strong {
  font-size: 16px;
}

.left-rail .agent-line {
  margin-top: 8px;
}

.left-rail .agent-events {
  display: none;
}

.left-rail .agent-mini-list {
  margin-top: 8px;
}

.left-rail .notifications-panel {
  max-height: none;
}

.left-rail .notification-list {
  max-height: 118px;
}

@media (max-width: 1360px) and (min-width: 1121px) {
  .topbar {
    gap: 12px;
    grid-template-columns: minmax(150px, 0.46fr) minmax(240px, 1fr);
    padding: 12px 16px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    gap: 8px;
    justify-content: flex-start;
    min-width: 0;
  }

  .topbar .role-switch {
    flex: 1 1 520px;
  }

  .session-card {
    padding: 0 10px;
  }

  .session-card span {
    display: none;
  }

  .role-home {
    grid-template-rows: 192px auto auto auto;
  }

  .quick-ops-card,
  .status-strip {
    grid-column: 1 / -1;
  }

  .status-strip {
    min-height: 110px;
    padding: 12px 0;
  }

  .status-strip .role-kpi {
    min-height: 76px;
    padding: 8px 18px;
  }

  .status-strip .role-kpi strong {
    font-size: 34px;
  }

  .status-strip .role-kpi span {
    line-height: 1.25;
  }

  .status-strip .role-kpi-status strong {
    font-size: 28px;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .role-home {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
  }

  .quick-ops-card .role-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 960px) {
  .workspace {
    grid-template-areas:
      "hero"
      "list"
      "side";
  }

  .role-home,
  .left-rail {
    display: grid;
  }

  .home-todo-panel,
  .home-recent-panel,
  .home-purchasing-panel,
  .home-primary-panel,
  .home-agent-panel,
  .home-ai-panel,
  .home-supply-panel,
  .home-context-panel,
  .home-events-panel,
  .home-run-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar-title {
    min-width: 0;
  }

  .welcome-card {
    grid-template-columns: 1fr;
    min-height: 190px;
    padding: 22px;
  }

  .blueprint-hero {
    display: none;
  }

  .welcome-card h2 {
    font-size: 25px;
  }

  .welcome-card .muted {
    font-size: 14px;
  }

  .ai-shortcut-grid,
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-shortcut-grid button {
    border-left: 0;
    border-top: 1px solid var(--line);
    min-height: 74px;
  }

  .ai-shortcut-grid button:nth-child(-n + 2) {
    border-top: 0;
  }

  .status-strip .role-kpi {
    border-left: 0;
    border-top: 1px solid var(--line);
    min-height: 76px;
    padding: 10px 16px;
  }

  .status-strip .role-kpi:nth-child(-n + 2) {
    border-top: 0;
  }

  .status-strip .role-kpi strong {
    font-size: 30px;
  }

  .quick-ops-card .role-actions {
    display: flex;
  }

  .quick-ops-card .role-action-card {
    flex: 0 0 150px;
  }

  .cad-upload-slot,
  .cad-preview-large {
    grid-template-columns: 1fr;
  }

  .upload-inline-thumb {
    min-height: 120px;
  }

  .home-workbench-grid,
  .home-card-list,
  .home-status-grid,
  .home-ai-summary {
    grid-template-columns: 1fr;
  }

  .home-recent-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .home-recent-meta {
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }

  .home-message-row,
  .home-event-row,
  .home-supply-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

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

  .home-supply-row > span:first-child {
    grid-column: 1 / -1;
  }

  .home-message-row small,
  .home-event-row small {
    grid-column: 2;
    white-space: normal;
  }
}

/* Reference polish: dense table, health card first, no desktop side scrolling. */
.brand-lockup img {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
}

.drawing-list {
  overflow-x: hidden;
}

.drawing-table {
  min-width: 0;
  width: 100%;
}

.drawing-table-head,
.drawing-row {
  gap: 10px;
  grid-template-columns:
    minmax(186px, 2fr)
    minmax(118px, 1.08fr)
    minmax(112px, 0.95fr)
    minmax(82px, 0.66fr)
    minmax(86px, 0.66fr)
    minmax(86px, 0.66fr)
    40px;
  padding-left: 16px;
  padding-right: 14px;
}

.drawing-table-head {
  height: 36px;
}

.drawing-row {
  min-height: 62px;
}

.drawing-row strong {
  font-size: 12px;
}

.drawing-row small {
  font-size: 11px;
  margin-top: 2px;
}

.file-cell {
  gap: 8px;
}

.file-type {
  border-radius: 5px;
  font-size: 10px;
  height: 32px;
  width: 38px;
}

.status-pill,
.risk-pill {
  font-size: 11px;
  padding: 4px 8px;
  white-space: nowrap;
}

.row-open-button {
  min-height: 28px;
  padding: 0;
}

.left-rail {
  grid-template-rows: minmax(218px, auto) minmax(120px, 1fr);
}

.left-rail .agent-status-panel {
  order: 1;
}

.left-rail .notifications-panel {
  order: 2;
}

.left-rail .agent-status-panel {
  max-height: 246px;
}

.left-rail .agent-status-panel .panel-title {
  margin-bottom: 10px;
}

.left-rail .agent-status-card {
  display: grid;
  gap: 10px;
}

.left-rail .agent-status-head {
  background: #f8fbff;
  border: 1px solid #e4edf8;
  border-radius: 7px;
  padding: 10px 12px;
}

.left-rail .agent-status-head strong {
  font-size: 14px;
}

.left-rail .agent-status-head p {
  font-size: 11px;
}

.left-rail .agent-stat-grid {
  display: none;
}

.left-rail .agent-line {
  color: #52637d;
  display: -webkit-box;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
}

.left-rail .agent-mini-list {
  display: grid;
  gap: 6px;
  margin-top: 0;
}

.left-rail .agent-mini-list code {
  background: #fff;
  border: 1px solid #e4edf8;
  border-radius: 6px;
  color: #334e73;
  display: block;
  font-size: 11px;
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.left-rail .notifications-panel {
  max-height: 208px;
  overflow: hidden;
}

.left-rail .notification-list {
  max-height: 144px;
}

.notification {
  padding: 9px 10px;
}

.notification strong {
  font-size: 12px;
}

.notification p {
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .drawing-table-head,
  .drawing-row {
    grid-template-columns:
      minmax(178px, 2fr)
      minmax(110px, 1fr)
      minmax(86px, 0.74fr)
      minmax(80px, 0.64fr)
      minmax(82px, 0.64fr)
      40px;
  }

  .drawing-table-head span:nth-child(3),
  .drawing-row > div:nth-child(3) {
    display: none;
  }
}

@media (max-width: 640px) {
  .drawing-list {
    overflow-x: hidden;
  }

  .drawing-table-head {
    display: none;
  }

  .drawing-row {
    display: grid;
    grid-template-columns: 1fr;
    margin: 10px;
    min-height: 0;
    padding: 12px;
  }
}

/* Mobile containment: the desktop right rail must collapse to one column. */
@media (max-width: 960px) {
  html,
  body,
  .app-shell {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .app-sidebar,
  .topbar,
  .workspace,
  .role-home,
  .list-panel,
  .left-rail {
    box-sizing: border-box;
    max-width: 100vw;
    min-width: 0;
    width: 100%;
  }

  .app-sidebar {
    overflow: hidden;
  }

  .side-nav {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .workspace {
    grid-template-areas:
      "hero"
      "list"
      "side";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }

  .role-home {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
  }

  .welcome-card,
  .ai-workbench-card,
  .quick-ops-card,
  .status-strip {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  .left-rail {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 640px) {
  .app-sidebar,
  .topbar,
  .workspace {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-sidebar,
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    left: 0;
    right: 0;
  }

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

  .session-card {
    min-width: 0;
  }

  .role-switch {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-width: 0;
    width: 100%;
  }

  .quick-ops-card .role-actions {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .quick-ops-card .role-action-card {
    flex: initial;
    width: 100%;
  }

  .ai-workbench-head {
    display: grid;
  }

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

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

.global-ai-bar {
  align-items: center;
  background: #fff;
  border: 1px solid #8fb9ff;
  border-radius: 999px;
  bottom: 18px;
  box-shadow: 0 16px 36px rgba(18, 104, 243, 0.16);
  display: flex;
  gap: 10px;
  left: calc(220px + (100vw - 220px) / 2);
  min-height: 52px;
  padding: 6px 8px 6px 10px;
  position: fixed;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 560px));
  z-index: 34;
}

.global-ai-mark {
  align-items: center;
  border: 2px solid #1268f3;
  border-radius: 50%;
  color: #1268f3;
  display: inline-flex;
  flex: 0 0 40px;
  font-size: 16px;
  font-weight: 900;
  height: 40px;
  justify-content: center;
}

.global-ai-bar input {
  border: 0;
  color: #17233f;
  flex: 1;
  font-size: 15px;
  min-width: 0;
  outline: none;
}

.global-ai-send {
  align-items: center;
  background: #1268f3;
  border: 0;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 40px;
  font-size: 20px;
  font-weight: 800;
  height: 40px;
  justify-content: center;
}

body.page-home .global-ai-bar,
body.drawer-open .global-ai-bar,
body.detail-drawer-open .global-ai-bar {
  display: none;
}

@media (max-width: 1180px) {
  .global-ai-bar {
    width: min(560px, calc(100vw - 500px));
  }
}

@media (max-width: 960px) {
  .global-ai-bar {
    display: none;
  }
}

/* Drawing thumbnails and version preview cards. */
.drawing-table-head,
.drawing-row {
  grid-template-columns:
    minmax(250px, 2.25fr)
    minmax(112px, 1fr)
    minmax(104px, 0.86fr)
    minmax(78px, 0.62fr)
    minmax(82px, 0.62fr)
    minmax(82px, 0.62fr)
    40px;
}

.drawing-row {
  min-height: 82px;
}

.drawing-thumb {
  background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
  border: 1px solid #cfe1f6;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  display: grid;
  overflow: hidden;
  position: relative;
}

.drawing-thumb[role="button"] {
  cursor: zoom-in;
}

.drawing-thumb[role="button"]:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 143, 0.18);
  outline: 0;
}

.drawing-thumb.has-preview:hover {
  border-color: var(--accent);
}

.drawing-thumb.has-preview::before {
  color: #6b7f9f;
  content: "加载预览";
  font-size: 10px;
  font-weight: 700;
  inset: 0;
  padding-top: 16px;
  position: absolute;
  text-align: center;
}

.drawing-thumb.has-preview:has([data-secure-loaded="1"])::before {
  content: "";
}

.drawing-thumb.preview-load-error::after {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  color: #b42318;
  content: "预览需登录";
  display: flex;
  font-size: 10px;
  font-weight: 800;
  inset: 0;
  justify-content: center;
  padding: 6px;
  position: absolute;
  text-align: center;
  z-index: 2;
}

.drawing-thumb-list {
  height: 54px;
  width: 78px;
}

.drawing-thumb-detail {
  height: 118px;
  width: 168px;
}

.drawing-thumb iframe,
.drawing-thumb img {
  border: 0;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  width: 100%;
}

.drawing-thumb iframe {
  background: #fff;
  transform: scale(1.02);
  transform-origin: center;
}

.thumb-click-layer {
  cursor: zoom-in;
  inset: 0;
  position: absolute;
  z-index: 3;
}

.thumb-badge {
  background: rgba(18, 104, 243, 0.92);
  border-radius: 4px;
  bottom: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  left: 5px;
  line-height: 1;
  padding: 4px 5px;
  position: absolute;
  z-index: 4;
}

.drawing-thumb.is-placeholder {
  align-content: center;
  color: #1268f3;
  justify-items: center;
  padding: 8px;
}

.drawing-thumb.is-placeholder strong {
  color: #1268f3;
  font-size: 13px;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.drawing-thumb.is-placeholder small {
  color: #587098;
  font-size: 10px;
  line-height: 1.2;
  margin-top: 5px;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 1;
}

.thumb-sheet-lines {
  background-image:
    linear-gradient(rgba(18, 104, 243, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.12) 1px, transparent 1px);
  background-size: 12px 12px;
  inset: 0;
  opacity: 0.8;
  position: absolute;
}

.file-preview-hint {
  color: #1268f3;
  display: block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 4px;
}

.detail-preview-card {
  align-items: center;
  background: #f8fbff;
  border: 1px solid #d8e6f6;
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0 16px 12px;
  padding: 12px;
}

.detail-preview-copy strong {
  color: #101828;
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.detail-preview-copy p {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 5px;
  overflow-wrap: anywhere;
}

.detail-preview-copy small {
  color: #667085;
  display: block;
  font-size: 12px;
  line-height: 1.45;
}

.preview-dialog {
  background: transparent;
  border: 0;
  box-shadow: none;
  height: min(820px, calc(100vh - 32px));
  max-width: none;
  overflow: hidden;
  padding: 0;
  width: min(1180px, calc(100vw - 32px));
}

.preview-dialog.is-fullscreen {
  height: 100vh;
  max-height: none;
  width: 100vw;
}

.preview-dialog::backdrop {
  backdrop-filter: blur(2px);
  background: rgba(5, 13, 24, 0.74);
}

.preview-shell {
  background: #f8fafc;
  border: 1px solid rgba(215, 224, 234, 0.72);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(2, 8, 23, 0.38);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.preview-dialog.is-fullscreen .preview-shell {
  border: 0;
  border-radius: 0;
}

.preview-toolbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 14px;
}

.preview-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.preview-title strong,
.preview-title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-title strong {
  color: var(--ink);
  font-size: 15px;
}

.preview-title small {
  color: var(--muted);
  font-size: 12px;
}

.preview-actions,
.preview-zoom-controls {
  align-items: center;
  display: flex;
  gap: 8px;
}

.preview-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#preview-zoom-label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  min-width: 48px;
  text-align: center;
}

.preview-tool-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #102436;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  min-width: 36px;
  padding: 0 10px;
}

.preview-tool-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.preview-tool-button.active {
  background: #1268f3;
  border-color: #1268f3;
  color: #fff;
}

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

.preview-color-controls {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 2px;
  padding: 2px;
}

.preview-color-controls .preview-tool-button {
  border-color: transparent;
  min-width: 54px;
}

.preview-stage {
  background:
    linear-gradient(rgba(18, 104, 243, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.05) 1px, transparent 1px),
    #f3f7fb;
  background-size: 24px 24px;
  display: grid;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  position: relative;
  touch-action: pan-x pan-y;
}

.preview-dialog.is-force-recolor-preview .preview-stage {
  background:
    linear-gradient(rgba(18, 104, 243, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 243, 0.07) 1px, transparent 1px),
    #eef4fb;
  background-size: 24px 24px;
}

.preview-stage.is-image-stage,
.preview-stage.is-pdf-stage {
  cursor: grab;
  touch-action: none;
}

.preview-stage img {
  height: auto;
  left: 50%;
  max-height: none;
  max-width: none;
  object-fit: contain;
  position: absolute;
  top: 50%;
  transform-origin: center;
  transition: transform 80ms ease;
  user-select: none;
  width: auto;
  will-change: transform;
}

.preview-stage.is-image-stage img {
  cursor: grab;
}

.preview-stage.is-image-stage:active img {
  cursor: grabbing;
}

.preview-stage.is-pdf-stage:active {
  cursor: grabbing;
}

.preview-stage iframe {
  background: #fff;
  border: 0;
  height: 100%;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform-origin: center;
  transition: transform 80ms ease;
  width: 100%;
  will-change: transform;
}

.preview-status {
  background: rgba(16, 24, 40, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  left: 50%;
  padding: 10px 12px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

@media (max-width: 1180px) {
  .drawing-table-head,
  .drawing-row {
    grid-template-columns:
      minmax(235px, 2.2fr)
      minmax(104px, 1fr)
      minmax(78px, 0.62fr)
      minmax(80px, 0.62fr)
      minmax(76px, 0.58fr)
      40px;
  }
}

@media (max-width: 640px) {
  .drawing-table {
    min-width: 0;
    width: 100%;
  }

  .drawing-table-head {
    display: none;
  }

  .drawing-row {
    align-items: start;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin: 10px;
    min-height: 0;
    overflow: hidden;
    padding: 12px;
  }

  .file-cell {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .drawing-row > div {
    min-width: 0;
  }

  .drawing-row > div:nth-child(n + 3) {
    display: none;
  }

  .drawing-thumb-list {
    height: 62px;
    width: 90px;
  }

  .detail-preview-card {
    grid-template-columns: 1fr;
    margin-left: 12px;
    margin-right: 12px;
  }

  .drawing-thumb-detail {
    aspect-ratio: 16 / 10;
    height: auto;
    width: 100%;
  }

  .preview-dialog {
    height: calc(100vh - 16px);
    width: calc(100vw - 16px);
  }

  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .preview-title {
    width: 100%;
  }
}

/* Admin workbench: role-specific command center. */
.role-admin .app-sidebar {
  gap: 18px;
  padding-bottom: 18px;
}

.role-admin .side-nav {
  max-height: calc(100vh - 178px);
  overflow: auto;
  padding-right: 2px;
}

.role-admin .side-nav-item {
  min-height: 40px;
}

.role-admin .side-nav-item span {
  font-size: 12px;
  font-weight: 900;
}

body.role-admin.page-home .workspace {
  grid-template-rows: auto minmax(0, 1fr);
  height: auto;
  min-height: calc(100vh - 72px);
  overflow: auto;
  padding-bottom: 88px;
}

.role-home.admin-home {
  grid-template-columns: minmax(0, 1.04fr) minmax(380px, 0.64fr);
  grid-template-rows: 178px 126px auto;
}

.role-home.admin-home .welcome-card {
  grid-template-columns: minmax(0, 1fr);
  padding: 24px 26px;
}

.role-home.admin-home .welcome-copy {
  max-width: 74%;
}

.role-home.admin-home .blueprint-hero {
  opacity: 0.35;
  position: absolute;
  right: 18px;
  top: 0;
  width: 48%;
}

.role-home.admin-home .welcome-card h2 {
  font-size: 28px;
  margin-bottom: 10px;
}

.role-home.admin-home .welcome-card .muted {
  font-size: 15px;
}

.admin-hero-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  max-width: 420px;
}

.admin-hero-metrics span {
  background: #f7fbff;
  border: 1px solid #dbe9fb;
  border-radius: 7px;
  color: #52637d;
  display: grid;
  font-size: 11px;
  gap: 5px;
  min-height: 52px;
  padding: 9px 10px;
}

.admin-hero-metrics strong {
  color: #071b45;
  font-size: 17px;
  line-height: 1;
}

.role-home.admin-home .quick-ops-card .role-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.role-home.admin-home .quick-ops-card .role-action-card {
  min-height: 54px;
  padding: 8px 10px;
}

.role-home.admin-home .status-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 13px 0;
}

.role-home.admin-home .status-strip .role-kpi {
  min-height: 78px;
  padding: 8px 22px;
}

.role-home.admin-home .status-strip .role-kpi strong {
  font-size: 30px;
}

.role-home.admin-home .status-strip .role-kpi-danger strong {
  color: #ef4444;
}

.role-home.admin-home > .role-focus {
  background: transparent;
  border: 0;
  display: block;
  grid-column: 1 / -1;
  padding: 0;
}

.role-home.admin-home > .role-focus > .panel-title {
  margin: 0 0 10px;
}

.role-home.admin-home > .role-focus > .panel-title h3 {
  color: #101828;
  font-size: 15px;
}

.admin-insight-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.86fr) minmax(0, 0.92fr) minmax(0, 0.92fr);
}

.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
  padding: 14px 16px;
}

.admin-card .panel-title {
  margin-bottom: 10px;
}

.admin-card .panel-title h3 {
  color: #101828;
  font-size: 15px;
  margin: 0;
}

.admin-feed-card {
  grid-column: span 2;
}

.admin-feed-list,
.admin-risk-list,
.admin-role-list {
  display: grid;
  gap: 8px;
}

.admin-feed-item {
  align-items: center;
  border: 1px solid #edf1f7;
  border-radius: 7px;
  display: grid;
  gap: 10px;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  min-height: 48px;
  padding: 8px 10px;
}

.admin-feed-item > span {
  border: 2px solid #1268f3;
  border-radius: 6px;
  height: 20px;
  width: 20px;
}

.admin-feed-item.warn > span {
  border-color: #f59e0b;
}

.admin-feed-item.ok > span {
  border-color: #52c878;
}

.admin-feed-item strong,
.admin-risk-row strong {
  color: #17233f;
  display: block;
  font-size: 12px;
}

.admin-feed-item p {
  color: #667085;
  font-size: 11px;
  line-height: 1.35;
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-feed-item time {
  color: #667085;
  font-size: 11px;
}

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

.admin-health-item {
  background: #f8fbff;
  border: 1px solid #e3edf9;
  border-radius: 7px;
  display: grid;
  gap: 6px;
  min-height: 58px;
  padding: 9px 10px;
}

.admin-health-item span {
  color: #667085;
  font-size: 11px;
}

.admin-health-item strong {
  color: #071b45;
  font-size: 15px;
}

.admin-health-item.ok strong {
  color: #12a05c;
}

.admin-health-item.warn strong {
  color: #b76e00;
}

.admin-health-item.danger strong {
  color: #ef4444;
}

.admin-donut-wrap {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 118px minmax(0, 1fr);
}

.admin-donut {
  align-items: center;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  justify-items: center;
  overflow: hidden;
  position: relative;
}

.admin-donut::before {
  background: #fff;
  border-radius: 50%;
  content: "";
  inset: 22px;
  position: absolute;
}

.admin-donut span,
.admin-donut strong {
  position: relative;
  z-index: 1;
}

.admin-donut span {
  align-self: end;
  color: #667085;
  font-size: 11px;
}

.admin-donut strong {
  align-self: start;
  color: #071b45;
  font-size: 22px;
  margin-top: 3px;
}

.admin-legend {
  display: grid;
  gap: 8px;
}

.admin-legend span {
  align-items: center;
  color: #344054;
  display: flex;
  font-size: 11px;
  gap: 7px;
  min-width: 0;
}

.admin-legend i {
  border-radius: 50%;
  flex: 0 0 8px;
  height: 8px;
  width: 8px;
}

.admin-role-row {
  align-items: center;
  background: #f8fbff;
  border: 1px solid #e3edf9;
  border-radius: 7px;
  display: flex;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 10px;
}

.admin-role-row span {
  color: #52637d;
  font-size: 12px;
}

.admin-role-row strong {
  color: #071b45;
  font-size: 15px;
}

.admin-risk-row {
  align-items: center;
  background: #fff;
  border: 1px solid #edf1f7;
  border-radius: 7px;
  color: inherit;
  display: grid;
  gap: 8px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 37px;
  padding: 6px 8px;
  text-align: left;
}

.admin-risk-row span {
  color: #52637d;
  font-size: 11px;
  font-weight: 800;
}

.admin-risk-row small {
  color: #667085;
  font-size: 11px;
}

.admin-risk-row:hover,
.admin-feed-item:hover,
.admin-role-row:hover {
  border-color: #b9d4ff;
}

.pulse-panel {
  animation: pulse-panel 0.9s ease;
}

@keyframes pulse-panel {
  0% {
    box-shadow: 0 0 0 0 rgba(18, 104, 243, 0.25);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(18, 104, 243, 0);
  }
}

@media (max-width: 1280px) {
  .admin-insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-feed-card {
    grid-column: span 2;
  }
}

@media (max-width: 960px) {
  .role-home.admin-home {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
  }

  .admin-hero-metrics,
  .role-home.admin-home .quick-ops-card .role-actions,
  .role-home.admin-home .status-strip,
  .admin-insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-feed-card {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .role-home.admin-home {
    display: grid;
  }

  .admin-hero-metrics,
  .role-home.admin-home .quick-ops-card .role-actions,
  .role-home.admin-home .status-strip,
  .admin-insight-grid,
  .admin-health-grid,
  .admin-donut-wrap {
    grid-template-columns: 1fr;
  }

  .admin-feed-card {
    grid-column: auto;
  }

  .admin-donut {
    justify-self: center;
    width: 132px;
  }
}

/* Admin layout correction: use the whole canvas for the command center. */
body.role-admin.page-home .workspace {
  grid-template-areas:
    "hero"
    "admin-tools";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  overflow-y: auto;
}

body.role-admin.page-home .list-panel,
body.role-admin.page-home .detail-panel {
  display: none;
}

body.role-admin.page-home .detail-panel.drawer-open {
  display: flex;
}

body.role-admin.page-home .left-rail {
  display: none;
  grid-area: admin-tools;
  max-height: none;
  overflow: visible;
  position: static;
}

body.role-admin.page-home:has(.left-rail .utility-panel.expanded) .left-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.role-admin.page-home .left-rail .utility-panel.expanded {
  display: block !important;
  margin: 0;
}

body.role-admin.page-home .left-rail .notifications-panel,
body.role-admin.page-home .left-rail .agent-status-panel:not(.expanded) {
  display: none !important;
}

.role-home.admin-home {
  grid-template-columns: minmax(0, 1.18fr) minmax(520px, 0.82fr);
  grid-template-rows: minmax(190px, auto) minmax(130px, auto) auto;
  width: 100%;
}

.role-home.admin-home > .role-focus {
  min-width: 0;
}

.role-home.admin-home .quick-ops-card .role-actions {
  grid-template-columns: repeat(3, minmax(170px, 1fr));
}

.role-home.admin-home .status-strip {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.admin-insight-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  width: 100%;
}

.admin-feed-card {
  grid-column: span 4;
  min-height: 266px;
}

.admin-health-card {
  grid-column: span 2;
  min-height: 266px;
}

.admin-chart-card {
  grid-column: span 3;
  min-height: 266px;
}

.admin-users-card {
  grid-column: span 5;
  min-height: 248px;
}

.admin-risk-card {
  grid-column: span 7;
  min-height: 248px;
}

.admin-chart-card .admin-donut-wrap {
  grid-template-columns: minmax(112px, 138px) minmax(0, 1fr);
}

.admin-users-card .admin-role-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-risk-card .admin-risk-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1500px) {
  .admin-insight-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .admin-feed-card,
  .admin-chart-card,
  .admin-risk-card {
    grid-column: span 3;
  }

  .admin-health-card,
  .admin-users-card {
    grid-column: span 3;
  }
}

@media (max-width: 1100px) {
  .role-home.admin-home {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-insight-grid,
  body.role-admin.page-home:has(.left-rail .utility-panel.expanded) .left-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-feed-card,
  .admin-health-card,
  .admin-chart-card,
  .admin-users-card,
  .admin-risk-card {
    grid-column: auto;
  }
}

/* Final admin dashboard containment: the overview itself must occupy the full focus row. */
body.role-admin .role-home.admin-home .role-focus-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100%;
}

body.role-admin .role-home.admin-home .admin-insight-grid {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

@media (max-width: 640px) {
  body.page-drawings .workspace {
    grid-template-areas:
      "list"
      "tools"
      "detail" !important;
    grid-template-rows: auto auto auto;
  }
}

/* Personal work-item controls: extend the existing role queue without changing its visual language. */
.role-task-open {
  background: transparent;
  border: 0;
  border-left: 1px solid #e7edf4;
  color: inherit;
  cursor: pointer;
  font: inherit;
  margin: 0;
  padding: 0 0 0 14px;
  text-align: left;
  width: 100%;
}

.role-task-open:hover strong,
.role-task-open:focus-visible strong {
  color: #1268f3;
}

.role-task-open:focus-visible {
  border-radius: 6px;
  outline: 2px solid rgba(18, 104, 243, 0.3);
  outline-offset: 3px;
}

.role-task-row[aria-busy] {
  opacity: 0.72;
}

.role-task-unassigned {
  background: linear-gradient(90deg, #f8fafc 0, #fff 170px);
  border-left-color: #667085;
}

.role-assignment-chip {
  background: #eef4ff;
  border: 1px solid #c7d7fe;
  border-radius: 999px;
  color: #3448a3;
  font-weight: 700;
  padding: 4px 8px;
}

.work-item-status-line {
  align-items: center;
  color: #667085;
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: 6px;
  margin-top: 2px;
}

.work-item-status {
  background: #f2f4f7;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  color: #475467;
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  padding: 3px 7px;
}

.work-item-status-in_progress {
  background: #eaf2ff;
  border-color: #bfd3ff;
  color: #175cd3;
}

.work-item-status-blocked {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b42318;
}

.work-item-actions {
  align-items: center;
  border-top: 1px solid #e7edf4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 10px;
}

.work-item-action-button,
.work-item-form-actions .primary-button,
.work-item-form-actions .secondary-button,
.work-item-form-actions .danger-button {
  font-size: 12px;
  min-height: 32px;
  padding-left: 11px;
  padding-right: 11px;
}

.work-item-action-note {
  color: #667085;
  font-size: 11px;
  margin-right: auto;
}

.work-item-inline-form {
  align-items: end;
  background: #f8fafc;
  border: 1px solid #dbe4ef;
  border-radius: 7px;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(260px, 2fr) minmax(190px, 1fr) auto;
  padding: 12px;
}

.work-item-inline-form[hidden] {
  display: none;
}

.work-item-assignment-form {
  grid-template-columns: minmax(190px, 1fr) minmax(160px, 0.8fr) minmax(190px, 0.9fr) auto;
}

.work-item-inline-form label,
.work-item-role-readonly {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.work-item-inline-form label > span,
.work-item-role-readonly > span {
  color: #52637d;
  font-size: 11px;
  font-weight: 700;
}

.work-item-role-readonly > strong {
  align-items: center;
  background: #eef2f6;
  border: 1px solid #d5dee9;
  border-radius: 6px;
  color: #344054;
  display: flex;
  font-size: 12px;
  min-height: 36px;
  padding: 7px 9px;
}

.work-item-inline-form label > span em {
  color: #c81e1e;
  font-style: normal;
}

.work-item-inline-form input,
.work-item-inline-form select,
.work-item-inline-form textarea {
  background: #fff;
  border: 1px solid #cdd8e5;
  border-radius: 6px;
  color: #101828;
  font: inherit;
  min-height: 36px;
  min-width: 0;
  padding: 7px 9px;
  resize: vertical;
  width: 100%;
}

.work-item-inline-form input:focus,
.work-item-inline-form select:focus,
.work-item-inline-form textarea:focus {
  border-color: #7aa7ed;
  box-shadow: 0 0 0 3px rgba(18, 104, 243, 0.1);
  outline: 0;
}

.work-item-form-actions {
  align-items: center;
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .role-task-open {
    border-left: 0;
    padding-left: 21px;
  }

  .work-item-inline-form,
  .work-item-assignment-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-item-form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .role-task-open {
    border-left: 0;
    border-top: 1px solid #e7edf4;
    padding: 9px 0 0 21px;
  }

  .work-item-actions {
    justify-content: stretch;
    padding-left: 21px;
  }

  .work-item-action-button {
    flex: 1 1 118px;
  }

  .work-item-action-note {
    flex: 1 0 100%;
  }

  .work-item-inline-form,
  .work-item-assignment-form {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .work-item-form-actions {
    grid-column: auto;
    justify-content: stretch;
  }

  .work-item-form-actions > button {
    flex: 1 1 0;
  }
}

/* Acceptance fixes: reserve room for the fixed AI bar and make mobile navigation actionable. */
@media (min-width: 961px) {
  body:not(.page-home) .drawing-list,
  body:not(.page-home) .detail {
    padding-bottom: 84px;
  }
}

.mobile-nav button.active,
.mobile-nav button[aria-current="page"] {
  color: #1268f3;
  box-shadow: inset 0 3px 0 #1268f3;
}

.mobile-nav-target {
  outline: 2px solid rgba(18, 104, 243, 0.28);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .app-sidebar {
    min-height: 0;
    padding: 10px 12px;
  }

  .app-sidebar .side-nav,
  .app-sidebar .sidebar-agent {
    display: none !important;
  }

  /* Keep the demo role switch available on small screens for system debugging. */
  .topbar .role-switch {
    display: flex;
    grid-column: 1 / -1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    width: 100%;
  }

  .topbar .role-switch .role-button {
    flex: 0 0 64px;
    min-height: 38px;
  }

  .brand-lockup img {
    height: 32px;
    width: 32px;
  }

  .brand-lockup strong {
    font-size: 16px;
  }

  .topbar {
    gap: 8px;
    padding-bottom: 10px;
    padding-top: 10px;
  }

  body.page-drawings .workspace {
    grid-template-areas:
      "list"
      "tools"
      "detail";
    grid-template-rows: auto auto auto;
  }

  body.page-drawings .list-panel {
    scroll-margin-top: 10px;
  }

  body.page-drawings .detail-panel {
    scroll-margin-top: 10px;
  }

  .upload-panel .primary-button[type="submit"] {
    bottom: auto;
    box-shadow: none;
    position: static;
  }
}

/* Role workload summary: keep the existing home style while making ownership and cycle health explicit. */
.role-home:not(.admin-home) > .role-focus {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: block;
  grid-column: 1 / -1;
  padding: 16px;
}

.role-home:not(.admin-home) > .role-focus > .panel-title {
  margin-bottom: 10px;
}

.role-home:not(.admin-home) .role-focus-list,
.role-task-list {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) !important;
  margin-top: 0;
  min-width: 0;
  width: 100%;
}

.role-home .status-strip {
  order: 1;
  overflow: visible;
}

.role-home .quick-ops-card {
  order: 3;
}

.role-home > .role-focus {
  order: 2;
}

.role-home .home-workbench-grid {
  order: 4;
}

.role-home .status-strip .role-kpi {
  align-content: center;
  display: grid;
  gap: 3px;
  justify-items: start;
  overflow: visible;
}

.role-home .status-strip .role-kpi strong {
  line-height: 1.05;
}

.role-home .status-strip .role-kpi .role-kpi-label {
  color: #52637d;
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}

.role-home .status-strip .role-kpi small {
  color: #8390a3;
  display: block;
  font-size: 11px;
  line-height: 1.35;
}

.role-home .status-strip .role-kpi-number-badge {
  align-items: center;
  background: #dc2626;
  border: 4px solid #fee2e2;
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(220, 38, 38, 0.2);
  color: #fff;
  display: inline-flex;
  font-size: 25px;
  font-style: normal;
  height: 54px;
  justify-content: center;
  min-width: 54px;
  padding: 0 12px;
}

.role-home .status-strip .role-kpi-tone-success strong {
  color: #087443;
}

.role-home .status-strip .role-kpi-tone-warning strong {
  color: #b76e00;
}

.role-home .status-strip .role-kpi-tone-danger strong {
  color: #c81e1e;
}

.role-home .status-strip .role-kpi-tone-neutral strong {
  color: #667085;
}

.role-home .status-strip .role-kpi-mine strong {
  color: #fff;
}

.role-task-panel {
  grid-column: 1 / -1;
}

.admin-overview-caption {
  align-items: baseline;
  display: flex;
  gap: 10px;
  margin: 12px 0 2px;
}

.admin-overview-caption strong {
  color: #101828;
  font-size: 15px;
}

.admin-overview-caption span {
  color: #667085;
  font-size: 12px;
}

.role-task-scope {
  align-items: center;
  color: #667085;
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: 8px;
  margin-bottom: 2px;
}

.role-task-scope > span:first-child {
  background: #f4f7fb;
  border: 1px solid #e1e8f0;
  border-radius: 999px;
  padding: 4px 8px;
}

.role-waiting-chip {
  background: #f2f4f7;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  color: #667085;
  padding: 4px 8px;
}

.role-task-row {
  align-items: center;
  background: #fff;
  border: 1px solid #dbe4ef;
  border-left: 4px solid #98a2b3;
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(230px, 1.18fr) minmax(220px, 1.08fr) minmax(220px, 0.94fr) minmax(165px, 0.78fr);
  min-height: 92px;
  padding: 12px 14px 12px 12px;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  width: 100%;
}

.role-task-row:hover {
  border-color: #9cb9e6;
  box-shadow: 0 8px 20px rgba(15, 45, 82, 0.08);
  transform: translateY(-1px);
}

.role-task-row.role-task-success {
  border-left-color: #16a05d;
}

.role-task-row.role-task-warning {
  border-left-color: #e58a00;
}

.role-task-row.role-task-danger {
  background: linear-gradient(90deg, #fff7f7 0, #fff 150px);
  border-left-color: #dc2626;
}

.role-task-main {
  align-items: flex-start;
  display: flex;
  gap: 9px;
  min-width: 0;
}

.role-task-main > span:last-child,
.role-task-context,
.role-task-cycle,
.role-task-next {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.role-task-main strong,
.role-task-context strong,
.role-task-next strong {
  color: #101828;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.role-task-main small,
.role-task-context small,
.role-task-cycle small,
.role-task-next small {
  color: #667085;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.role-task-main small {
  color: #52637d;
}

.role-task-state-dot {
  background: #98a2b3;
  border: 3px solid #eef1f5;
  border-radius: 50%;
  flex: 0 0 auto;
  height: 12px;
  margin-top: 4px;
  width: 12px;
}

.role-task-success .role-task-state-dot {
  background: #16a05d;
  border-color: #dcfce7;
}

.role-task-warning .role-task-state-dot {
  background: #e58a00;
  border-color: #fef3c7;
}

.role-task-danger .role-task-state-dot {
  background: #dc2626;
  border-color: #fee2e2;
}

.role-task-alerts {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-blocker-chip,
.cycle-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  padding: 4px 8px;
  width: fit-content;
}

.role-blocker-chip {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b42318;
}

.cycle-pill.cycle-success {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #087443;
}

.cycle-pill.cycle-warning {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #9a5b00;
}

.cycle-pill.cycle-danger {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b42318;
}

.cycle-pill.cycle-neutral {
  background: #f2f4f7;
  border: 1px solid #d0d5dd;
  color: #667085;
}

.role-task-next {
  border-left: 1px solid #e7edf4;
  padding-left: 14px;
}

.role-task-next strong::after {
  color: #1268f3;
  content: "  →";
}

.role-task-empty {
  background: #f6fbf8;
  border: 1px dashed #a9d7bc;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 18px;
}

.role-task-empty strong {
  color: #087443;
  font-size: 14px;
}

.role-task-empty span,
.role-task-overflow {
  color: #667085;
  font-size: 12px;
}

.role-task-overflow {
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}

@media (max-width: 1180px) {
  .role-task-row {
    grid-template-columns: minmax(250px, 1.2fr) minmax(220px, 1fr);
  }

  .role-task-next {
    border-left: 0;
    padding-left: 21px;
  }
}

@media (max-width: 720px) {
  .role-home .status-strip {
    order: 0;
  }

  .role-home > .role-focus {
    order: 1;
  }

  .role-home .welcome-card {
    order: 2;
  }

  .role-home .ai-workbench-card {
    order: 3;
  }

  .role-home .quick-ops-card {
    order: 4;
  }

  .role-home .home-workbench-grid {
    order: 5;
  }

  .role-home .status-strip .role-kpi {
    min-height: 102px;
    padding: 12px 14px;
  }

  .role-home .status-strip .role-kpi-number-badge {
    border-width: 3px;
    font-size: 20px;
    height: 46px;
    min-width: 46px;
  }

  .role-task-row {
    align-items: start;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
    padding: 13px 12px;
  }

  .role-task-cycle,
  .role-task-next {
    padding-left: 21px;
  }

  .role-task-next {
    border-left: 0;
    border-top: 1px solid #e7edf4;
    padding-top: 9px;
  }
}

/* Drawing library organization: shared taxonomy, personal favorites and safe recycle bin. */
.filter-ai-row,
.category-create-form {
  align-items: center;
  display: flex;
  gap: 8px;
}

.filter-ai-row .secondary-button {
  flex: 0 0 auto;
}

.filter-ai-result {
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}

.filter-check {
  align-items: center;
  display: flex;
  font-size: 13px;
  gap: 8px;
  min-height: 34px;
}

.filter-check input {
  height: 16px;
  margin: 0;
  width: 16px;
}

.category-manager {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.category-manager summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.category-create-form {
  margin-top: 10px;
}

.category-create-form input {
  min-width: 0;
  width: 100%;
}

.category-manager-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.category-manager-row,
.recycle-bin-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 0;
}

.category-manager-row div,
.recycle-bin-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.category-manager-row small,
.recycle-bin-row p,
.recycle-bin-row small {
  color: var(--muted);
  margin: 0;
}

.recycle-bin-button {
  justify-self: start;
}

.drawing-taxonomy,
.ai-match-reason {
  display: block;
  font-size: 11px;
  line-height: 1.45;
  margin-top: 3px;
}

.drawing-taxonomy {
  color: var(--accent-strong);
}

.ai-match-reason {
  color: var(--warn);
}

.favorite-icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  color: #64748b;
  display: inline-flex;
  font-size: 21px;
  height: 32px;
  justify-content: center;
  padding: 0;
  vertical-align: middle;
  width: 32px;
}

.favorite-icon-button.active,
#favorite-button.is-favorite {
  color: #9a6700;
}

.upload-mode-hint {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  padding: 9px 11px;
}

.drawing-organize-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.mark-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.mark-fieldset legend {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.mark-options,
.organization-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mark-options label {
  cursor: pointer;
  position: relative;
}

.mark-options input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.mark-options span,
.organization-chips span {
  background: #f3f6f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #415168;
  display: inline-flex;
  font-size: 12px;
  padding: 5px 9px;
}

.mark-options input:checked + span,
.organization-chips .business-mark {
  background: #fff7e6;
  border-color: #e9c97a;
  color: #8a5a00;
}

.organization-category {
  color: var(--accent-strong);
  font-weight: 700;
  margin: 10px 0 8px;
}

.recycle-bin-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: min(720px, 86vh);
  padding: 0;
  width: min(680px, calc(100vw - 32px));
}

.recycle-bin-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.recycle-bin-shell {
  background: var(--panel);
  padding: 22px;
}

.recycle-bin-shell h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.recycle-bin-list {
  margin-top: 14px;
  max-height: 58vh;
  overflow: auto;
}

@media (max-width: 640px) {
  .filter-ai-row,
  .category-create-form,
  .recycle-bin-row {
    align-items: stretch;
    flex-direction: column;
  }

  .recycle-bin-row .secondary-button {
    width: 100%;
  }
}

/* The upload drawer lives in the left rail, which is hidden on role home pages.
   Keep only the fixed drawer host available while the drawer is open. */
body.drawer-open .left-rail.hidden:has(.upload-panel) {
  display: block !important;
  height: 0;
  left: 0;
  overflow: visible !important;
  position: fixed;
  top: 0;
  width: 0;
  z-index: 42;
}

body.drawer-open .left-rail.hidden:has(.upload-panel) > :not(.upload-panel) {
  display: none !important;
}

/* Page IA pass: real sidebar pages plus an in-page drawing detail workspace. */
body.page-home .workspace {
  grid-template-areas: "hero";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: auto;
}

body.page-home .role-home {
  grid-area: hero;
  height: min-content;
  max-width: none;
  width: 100%;
}

body.page-drawings .workspace {
  grid-template-areas: "tools list detail";
  grid-template-columns: 300px minmax(470px, 1fr) minmax(420px, 0.88fr);
  grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 72px);
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1680px) {
  body.page-drawings:has(.association-workspace.has-preview) .workspace {
    grid-template-columns: 280px minmax(430px, 0.78fr) minmax(700px, 1.22fr);
  }
}

body.page-drawings .left-rail {
  display: block;
  grid-area: tools;
  overflow: auto;
  padding-right: 2px;
}

body.page-drawings .left-rail > .compact,
body.page-drawings .left-rail > .filter-panel,
body.page-drawings .left-rail > .notifications-panel {
  display: block !important;
}

body.page-drawings .left-rail .agent-status-panel:not(.expanded),
body.page-drawings .left-rail .download-center-panel:not(.expanded),
body.page-drawings .left-rail .agent-config-panel:not(.expanded),
body.page-drawings .left-rail .converter-config-panel:not(.expanded),
body.page-drawings .left-rail .ai-config-panel:not(.expanded),
body.page-drawings .left-rail .import-panel:not(.expanded) {
  display: none !important;
}

body.page-drawings .list-panel {
  grid-area: list;
}

body.page-drawings .detail-backdrop {
  display: none !important;
}

body.page-drawings .detail-panel {
  bottom: auto;
  display: flex;
  grid-area: detail;
  height: 100%;
  max-width: none;
  opacity: 1;
  pointer-events: auto;
  position: static;
  right: auto;
  top: auto;
  transform: none;
  transition: none;
  width: auto;
  z-index: auto;
}

body.page-drawings .detail-panel.drawer-open {
  transform: none;
}

body.page-drawings .detail {
  height: 100%;
  max-height: none;
}

body.page-drawings .detail-header-actions .drawer-close {
  display: none;
}

body.page-drawings .detail-preview-card {
  grid-template-columns: 150px minmax(0, 1fr);
}

body.page-drawings .drawing-thumb-detail {
  height: 104px;
  width: 150px;
}

body:not(.page-home):not(.page-drawings) .workspace {
  grid-template-areas: "secondary";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.secondary-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  grid-area: secondary;
  min-height: 0;
  overflow: auto;
}

.page-hero,
.page-panel,
.flow-column {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.page-hero {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 118px;
  padding: 22px 24px;
}

.page-hero h2 {
  color: #071b45;
  font-size: 26px;
  line-height: 1.2;
  margin: 5px 0 8px;
}

.page-hero .muted {
  max-width: 780px;
}

.page-hero-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

.page-metric-row > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  min-height: 92px;
  padding: 16px 18px;
}

.page-metric-row strong {
  color: #071b45;
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.page-metric-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 10px;
}

.page-two-col,
.page-three-col {
  display: grid;
  gap: 14px;
  min-height: 0;
}

.page-two-col {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
}

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

.page-panel {
  min-height: 0;
  padding: 18px;
}

.ai-admin-metrics strong {
  font-size: 23px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-platform-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
}

.ai-platform-list-panel,
.ai-platform-editor-panel,
.ai-runtime-panel {
  align-self: start;
}

.ai-platform-list-panel .panel-title,
.ai-platform-editor-panel .panel-title,
.ai-runtime-panel .panel-title {
  align-items: flex-start;
  margin-bottom: 14px;
}

.ai-platform-list-panel .panel-title h3,
.ai-platform-editor-panel .panel-title h3,
.ai-runtime-panel .panel-title h3 {
  color: #071b45;
  font-size: 17px;
  margin: 0 0 5px;
}

.ai-platform-count,
.ai-platform-badge {
  background: #eef5ff;
  border: 1px solid #c9dcfb;
  border-radius: 999px;
  color: #195eb8;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.ai-platform-badge.current {
  background: #e9f8ef;
  border-color: #a9ddba;
  color: #187740;
}

.ai-platform-list {
  display: grid;
  gap: 12px;
}

.ai-platform-card {
  background: #fbfdff;
  border: 1px solid #dce6f2;
  border-radius: 10px;
  padding: 15px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-platform-card.active {
  background: linear-gradient(135deg, #f7fbff 0%, #f4f8ff 100%);
  border-color: #7eacf3;
  box-shadow: 0 8px 24px rgba(26, 104, 211, 0.09);
}

.ai-platform-card.editing {
  outline: 2px solid rgba(27, 105, 218, 0.12);
  outline-offset: 2px;
}

.ai-platform-card-head {
  align-items: center;
  display: grid;
  gap: 11px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.ai-platform-card-head strong {
  color: #0c2345;
  display: block;
  font-size: 16px;
}

.ai-platform-card-head p {
  color: var(--muted);
  font-size: 11px;
  margin: 3px 0 0;
}

.ai-platform-logo {
  align-items: center;
  background: linear-gradient(145deg, #0c63e7, #55a8ff);
  border-radius: 10px;
  box-shadow: 0 5px 12px rgba(18, 100, 220, 0.2);
  color: #fff;
  display: inline-flex;
  font-size: 17px;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.ai-platform-card-body {
  border-bottom: 1px solid #edf1f6;
  border-top: 1px solid #edf1f6;
  display: grid;
  gap: 8px;
  margin: 13px 0;
  padding: 12px 0;
}

.ai-platform-card-body > div {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 72px minmax(0, 1fr);
}

.ai-platform-card-body span {
  color: var(--muted);
  font-size: 12px;
}

.ai-platform-card-body code,
.ai-platform-card-body strong {
  color: #233b5d;
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-platform-card-body .key-ready {
  color: #187740;
}

.ai-platform-card-body .key-missing {
  color: #b46b00;
}

.ai-platform-card-actions,
.ai-platform-form-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-platform-card-actions .secondary-button,
.ai-platform-card-actions .text-button {
  min-height: 32px;
}

.danger-text {
  color: #c63737 !important;
}

.ai-platform-form,
.ai-runtime-form {
  display: grid;
  gap: 13px;
}

.ai-platform-form .field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ai-secret-input {
  align-items: center;
  display: flex;
  gap: 7px;
}

.ai-secret-input input {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-secret-input button {
  flex: 0 0 auto;
}

.ai-clear-key-field {
  background: #fff8f7;
  border: 1px solid #f1d2cd;
  border-radius: 7px;
  padding: 9px 10px;
}

.ai-platform-form-result {
  min-height: 18px;
}

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

@media (max-width: 1100px) {
  .ai-platform-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .ai-runtime-switches {
    grid-template-columns: 1fr;
  }

  .ai-platform-card-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ai-platform-card-head .ai-platform-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .ai-platform-card-body > div {
    align-items: start;
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.room-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding-bottom: 92px;
}

.room-page-head {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 16px;
}

.room-page-head h2 {
  color: #071b45;
  font-size: 22px;
  line-height: 1.2;
  margin: 3px 0 5px;
}

.room-head-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.room-progress-pill {
  background: #edf7ff;
  border: 1px solid #bfd6ff;
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.room-workspace {
  display: grid;
  gap: 12px;
  grid-template-columns: 280px minmax(420px, 1fr) 360px;
  min-height: min(760px, calc(100vh - 190px));
}

.room-rail,
.room-chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.room-rail {
  gap: 12px;
  padding: 12px;
}

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

.room-section-head strong {
  color: #071b45;
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.room-section-head p,
.room-drawing-card p,
.room-chat-title p,
.room-impact-grid p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 3px 0 0;
}

.room-section-head > span {
  background: #eef4fa;
  border: 1px solid #bed3e8;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.room-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.room-list-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 8px;
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 70px;
  padding: 8px;
  text-align: left;
}

.room-list-item.is-active {
  background: #eef7ff;
  border-color: #7fb4ff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.room-list-item .drawing-thumb-page {
  height: 48px;
  width: 48px;
}

.room-list-item strong,
.room-list-item small,
.room-list-item em {
  display: block;
  overflow-wrap: anywhere;
}

.room-list-item strong {
  color: #071b45;
  font-size: 12px;
}

.room-list-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}

.room-list-item em {
  font-style: normal;
  grid-column: 2;
  justify-self: start;
  margin-top: -4px;
}

.room-drawing-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.room-drawing-card .drawing-thumb-detail {
  height: 112px;
  width: 100%;
}

.room-drawing-card strong {
  color: #071b45;
  display: block;
  font-size: 13px;
}

.room-chat-panel {
  padding: 0;
}

.room-chat-title {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.room-chat-title strong {
  color: #071b45;
  display: block;
  font-size: 15px;
}

.room-chat-title > span {
  background: #eef4fa;
  border: 1px solid #bed3e8;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.room-message-list {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 360px;
  overflow: auto;
  padding: 14px 16px;
}

.room-message-list > .muted {
  align-self: center;
  margin: auto;
  max-width: 360px;
  text-align: center;
}

.room-message-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px 16px 8px;
}

.room-message-form textarea {
  min-height: 68px;
  resize: vertical;
}

.room-permission-note {
  padding: 0 16px 12px;
}

.room-inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.room-inspector .page-panel {
  box-shadow: var(--shadow-soft);
  padding: 12px;
}

.room-progress-track {
  background: #e6edf5;
  border-radius: 999px;
  height: 8px;
  margin: 12px 0;
  overflow: hidden;
}

.room-progress-track span {
  background: linear-gradient(90deg, var(--accent), var(--ok));
  display: block;
  height: 100%;
}

.room-step-list,
.room-role-list {
  display: grid;
  gap: 8px;
}

.room-step-list .collab-step {
  min-height: 48px;
  padding: 7px 8px;
}

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

.room-role {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 46px;
  padding: 7px 8px;
}

.room-role strong,
.room-role span {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.room-role strong {
  color: #071b45;
}

.room-role span {
  color: var(--muted);
  margin-top: 2px;
}

.room-role.is-current {
  background: #eaf8f0;
  border-color: #bfe7cf;
}

.room-role.is-muted {
  opacity: 0.62;
}

.room-impact-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.room-impact-grid > div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
}

.room-impact-grid strong {
  color: #071b45;
  display: block;
  font-size: 12px;
}

.room-empty {
  margin: auto;
  max-width: 520px;
  text-align: center;
}

@media (max-width: 1380px) {
  .room-workspace {
    grid-template-columns: 250px minmax(390px, 1fr) 320px;
  }
}

@media (max-width: 1180px) {
  .room-workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .room-inspector {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .room-page-head,
  .room-chat-title {
    align-items: stretch;
    flex-direction: column;
  }

  .room-head-actions {
    justify-content: flex-start;
  }

  .room-workspace,
  .room-inspector {
    display: grid;
    grid-template-columns: 1fr;
  }

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

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

.flow-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 420px;
  padding: 14px;
}

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

.flow-column-head strong,
.flow-column-head small {
  display: block;
}

.flow-column-head strong {
  color: #071b45;
  font-size: 15px;
}

.flow-column-head small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

.flow-column-head > span {
  background: var(--accent-soft);
  border: 1px solid #bfd6ff;
  border-radius: 7px;
  color: var(--accent);
  font-weight: 800;
  min-width: 30px;
  padding: 4px 8px;
  text-align: center;
}

.page-card-list,
.page-log-list {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.flow-column .page-card-list {
  align-content: start;
  flex: 1;
  overflow: auto;
}

.page-drawing-card {
  align-items: center;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 84px;
  padding: 10px;
  text-align: left;
}

.page-drawing-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(18, 104, 243, 0.09);
}

.page-drawing-card strong,
.page-drawing-card small {
  display: block;
  overflow-wrap: anywhere;
}

.page-drawing-card small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.page-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 2;
}

.drawing-thumb-page {
  height: 54px;
  width: 78px;
}

.profile-card {
  background: #f7faff;
  border: 1px solid #d7e6fb;
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 18px;
}

.profile-card strong,
.profile-card span,
.profile-card p {
  display: block;
}

.profile-card strong {
  color: #071b45;
  font-size: 24px;
}

.profile-card span {
  color: var(--accent);
  font-weight: 800;
  margin-top: 6px;
}

.profile-card p {
  color: var(--muted);
  margin: 10px 0 0;
}

.permission-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.permission-list span {
  background: #fff;
  border: 1px solid #d8e5f4;
  border-radius: 999px;
  color: #243b60;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
}

.admin-user-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(280px, 0.58fr) minmax(340px, 0.82fr);
  min-height: 0;
}

.admin-user-create-form,
.admin-role-matrix,
.admin-user-table {
  display: grid;
  gap: 10px;
}

.admin-user-list-panel {
  grid-column: 1 / -1;
}

.admin-role-matrix-row {
  align-items: center;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  display: grid;
  gap: 5px 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 58px;
  padding: 10px 12px;
}

.admin-role-matrix-row span,
.admin-role-matrix-row strong,
.admin-role-matrix-row small {
  overflow-wrap: anywhere;
}

.admin-role-matrix-row span {
  color: #243b60;
  font-weight: 800;
}

.admin-role-matrix-row strong {
  background: var(--accent-soft);
  border: 1px solid #bfd6ff;
  border-radius: 999px;
  color: var(--accent-strong);
  min-width: 34px;
  padding: 4px 9px;
  text-align: center;
}

.admin-role-matrix-row small {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1 / -1;
}

.admin-user-row-form {
  align-items: end;
  background: #fbfdff;
  border: 1px solid #d8e5f4;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(118px, 0.8fr)) minmax(220px, 1.2fr) minmax(132px, 0.8fr) auto;
  padding: 12px;
}

.admin-user-main strong,
.admin-user-main span,
.admin-demo-credential span,
.admin-demo-credential strong,
.admin-inline-field span {
  display: block;
  overflow-wrap: anywhere;
}

.admin-user-main strong {
  color: #071b45;
  font-size: 15px;
}

.admin-user-main span,
.admin-demo-credential span,
.admin-inline-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.admin-inline-field {
  display: grid;
  gap: 5px;
}

.admin-inline-field input,
.admin-inline-field select {
  background: #fff;
  border: 1px solid var(--line);
  min-height: 38px;
  padding: 0 10px;
  width: 100%;
}

.admin-inline-field input[readonly],
.admin-inline-field select:disabled {
  background: #eef3f8;
  color: #667085;
}

.admin-demo-credential {
  background: #f3f8ff;
  border: 1px solid #cfe0ff;
  border-radius: 7px;
  min-height: 58px;
  padding: 9px 10px;
}

.admin-demo-credential strong {
  color: #243b60;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 1480px) {
  .flow-board,
  .page-three-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-user-row-form {
    grid-template-columns: minmax(160px, 1fr) repeat(2, minmax(140px, 1fr));
  }

  .admin-demo-credential {
    grid-column: span 2;
  }
}

@media (max-width: 980px) {
  .admin-user-layout,
  .admin-user-row-form {
    grid-template-columns: 1fr;
  }

  .admin-demo-credential,
  .admin-user-list-panel {
    grid-column: auto;
  }
}

@media (max-width: 1500px) and (min-width: 1181px) {
  body.page-drawings .workspace {
    grid-template-areas:
      "tools tools"
      "list detail";
    grid-template-columns: minmax(0, 1fr) minmax(390px, 0.72fr);
    grid-template-rows: min-content minmax(0, 1fr);
    height: auto;
    min-height: calc(100vh - 72px);
  }

  body.page-drawings .left-rail {
    align-self: start;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(250px, 0.74fr) minmax(260px, 1fr) minmax(260px, 1fr);
    grid-template-rows: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  body.page-drawings .left-rail .panel {
    align-self: start;
    margin-bottom: 0;
  }

  body.page-drawings .left-rail > .notifications-panel {
    max-height: 190px;
  }

  body.page-drawings .left-rail > .compact .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  body.page-drawings .workspace {
    grid-template-areas:
      "tools"
      "list"
      "detail";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(360px, auto) minmax(520px, auto);
    height: auto;
    overflow: visible;
  }

  body.page-drawings .left-rail,
  body.page-drawings .list-panel,
  body.page-drawings .detail-panel {
    height: auto;
  }

  .page-two-col,
  .page-three-col,
  .flow-board {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 640px) {
  body.page-home .workspace,
  body.page-drawings .workspace,
  body:not(.page-home):not(.page-drawings) .workspace {
    height: auto;
    overflow: visible;
  }

  .page-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .page-hero h2 {
    font-size: 22px;
  }

  .page-hero-actions {
    justify-content: stretch;
  }

  .page-hero-actions > * {
    flex: 1 1 auto;
  }

  .page-metric-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .flow-column {
    min-height: 0;
  }

  body.page-drawings .detail-preview-card {
    grid-template-columns: 1fr;
  }
}

.left-rail .notifications-panel,
body.page-drawings .left-rail > .notifications-panel {
  max-height: none;
  overflow: visible;
}

.left-rail .notification-list {
  max-height: none;
  overflow: visible;
}

/* Last-mile override: admin overview must not inherit normal role-focus columns. */
body.role-admin .role-home.admin-home .role-focus-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100%;
}

body.role-admin .role-home.admin-home .admin-insight-grid {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

@media (max-width: 640px) {
  body.page-drawings .workspace {
    grid-template-areas:
      "list"
      "tools"
      "detail" !important;
    grid-template-rows: auto auto auto;
  }
}
