:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #68758a;
  --line: #dce3ee;
  --brand: #1d6f8f;
  --brand-dark: #14556e;
  --accent: #2f7d57;
  --warning: #b5651d;
  --danger: #b74343;
  --shadow: 0 18px 48px rgba(38, 52, 75, 0.1);
  --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;
}

body.auth-pending .app-shell {
  visibility: hidden;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #eef5f8 0%, #f8fbfd 55%, #edf4f2 100%);
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

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

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

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

.auth-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-line {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.auth-form label,
.ai-config-grid label,
.edit-form label {
  display: grid;
  gap: 7px;
}

.auth-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-status {
  min-height: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.auth-status.error {
  color: var(--danger);
}

.auth-status.success {
  color: var(--accent);
}

body.auth-required .app-shell {
  display: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #0f2233;
  color: #eaf4f8;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #d9f0f3;
  color: #0d3e4c;
  font-weight: 800;
}

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

.brand span,
.sidebar-panel span {
  color: #b8cad4;
  font-size: 12px;
}

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

.nav-item {
  border: 0;
  color: #d7e5eb;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(217, 240, 243, 0.14);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 4px;
  background: rgba(217, 240, 243, 0.08);
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  text-align: center;
}

.nav-item.active .nav-icon {
  background: rgba(217, 240, 243, 0.18);
}

.sidebar-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.mini-stat {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  gap: 16px;
}

.mini-stat strong {
  color: #ffffff;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-top: 4px;
  font-size: 18px;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 6px;
}

.account-bar span {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.primary-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

.ghost-button {
  min-height: 30px;
  color: var(--brand);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

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

.request-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 20px 0 0;
}

.request-summary .metric-card {
  box-shadow: none;
  background: var(--panel-soft);
}

.request-summary .metric-card strong {
  font-size: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card {
  padding: 16px;
  min-width: 0;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(420px, 1.45fr);
  gap: 18px;
  align-items: start;
}

.left-stack,
.right-stack {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.section-grid {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.status-pill,
.sort-label,
.recommend-badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.status-pill {
  background: #e7f4f1;
  color: var(--accent);
}

.sort-label {
  background: #eef5f7;
  color: var(--brand-dark);
}

.field-label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 8px;
}

.field-row .field-label {
  margin: 0;
}

.field-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.upload-button {
  border: 0;
  border-radius: 999px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  color: var(--brand-dark);
  background: #eef5f7;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.upload-button:hover,
.upload-button:focus {
  background: #dfecef;
  color: var(--brand);
  outline: none;
}

.clear-brief-button {
  border: 0;
}

.request-panel {
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.request-panel.drag-over {
  border-color: var(--brand);
  background: #f7fcfd;
  box-shadow: 0 18px 48px rgba(29, 111, 143, 0.16);
}

.drop-hint {
  margin-top: 8px;
  border: 1px dashed rgba(29, 111, 143, 0.3);
  border-radius: var(--radius);
  background: #f4fafb;
  color: var(--brand-dark);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.request-panel.drag-over .drop-hint {
  border-color: var(--brand);
  background: #e8f4f6;
  font-weight: 800;
}

.upload-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-status.success {
  color: var(--accent);
  font-weight: 700;
}

.upload-status.error {
  color: var(--danger);
  font-weight: 700;
}

.ai-config,
.settings-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 10px 12px;
}

.ai-config summary {
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

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

.ai-config label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-config .wide-field {
  grid-column: 1 / -1;
}

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

.panel-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.prompt-area {
  min-height: 116px;
}

.ai-config-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.ai-config-actions small {
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.text-area {
  resize: vertical;
  min-height: 108px;
  line-height: 1.6;
}

#brief {
  min-height: 40px;
  overflow: hidden;
  resize: none;
}

.weights-panel-left {
  margin-top: 0;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 111, 143, 0.12);
}

.filter-group {
  margin-top: 18px;
}

.filter-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 800;
}

.chip-row,
.tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
}

.chip.active {
  border-color: var(--brand);
  background: #e8f4f6;
  color: var(--brand-dark);
  font-weight: 700;
}

.supplier-list {
  display: grid;
  gap: 12px;
}

.priority-toggle {
  width: 100%;
  min-height: 38px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.priority-toggle:hover,
.priority-toggle:focus {
  border-color: var(--brand);
  background: #e8f4f6;
  outline: none;
}

.supplier-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
}

.supplier-card.selected {
  border-color: var(--brand);
  box-shadow: inset 4px 0 0 var(--brand);
}

.supplier-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.supplier-name {
  font-size: 17px;
  font-weight: 800;
}

.supplier-type {
  color: var(--muted);
  font-size: 12px;
}

.supplier-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin-top: 10px;
  border: 1px solid rgba(29, 111, 143, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  padding: 4px 4px 4px 9px;
}

.supplier-phone {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-phone-button {
  flex: 0 0 auto;
  min-height: 24px;
  border: 1px solid rgba(29, 111, 143, 0.22);
  border-radius: 6px;
  background: #ffffff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 0 8px;
}

.copy-phone-button:hover,
.copy-phone-button:focus {
  border-color: var(--brand);
  background: #e8f4f6;
  outline: none;
}

.supplier-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.small-tag,
.config-tag {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef5f7;
  color: #315766;
}

.config-tag {
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.editable-tag {
  min-height: 28px;
  cursor: grab;
}

.editable-tag:hover,
.editable-tag:focus {
  border-color: var(--brand);
  color: var(--brand-dark);
  outline: none;
}

.editable-tag.dragging {
  opacity: 0.46;
}

.editable-tag.drag-over {
  box-shadow: 0 0 0 2px rgba(29, 111, 143, 0.2);
  background: #e8f4f6;
}

.editable-tag.delete-ready {
  border-color: rgba(183, 67, 67, 0.34);
  background: #fff5f5;
  color: var(--danger);
  cursor: pointer;
}

.tag-edit-input {
  min-height: 28px;
  max-width: 150px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  padding: 4px 10px;
  font-size: 12px;
  outline: none;
}

.new-tag-input {
  min-width: 96px;
  background: #ffffff;
}

.recommend-badge {
  background: #e7f4f1;
  color: var(--accent);
  font-weight: 800;
}

.score-box {
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: var(--radius);
  background: #f0f6f7;
  min-height: 92px;
}

.score-box strong {
  font-size: 28px;
}

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

.reason-text {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.weights {
  display: grid;
  gap: 14px;
}

.weight-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
}

.weight-row label {
  color: var(--muted);
  font-size: 13px;
}

.weight-row input {
  width: 100%;
  accent-color: var(--brand);
}

.weight-row output {
  text-align: right;
  font-weight: 800;
}

.config-tags {
  display: grid;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.config-title {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.config-block-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.config-block-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-block-actions .ghost-button {
  min-height: 28px;
  padding: 0 10px;
}

.config-block-actions .ghost-button.active {
  border-color: rgba(183, 67, 67, 0.35);
  background: #fff5f5;
  color: var(--danger);
}

.wide-panel {
  width: 100%;
}

.directory-grid {
  display: grid;
  gap: 14px;
}

body.content-scroll-lock {
  overflow: hidden;
}

.content-scroll-lock .app-shell {
  height: 100vh;
  min-height: 0;
}

.content-scroll-lock .sidebar {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.content-scroll-lock .workspace {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-scroll-lock .topbar {
  flex: 0 0 auto;
}

.content-scroll-lock .view.active {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  scrollbar-color: rgba(29, 111, 143, 0.42) transparent;
  scrollbar-width: thin;
}

.content-scroll-lock .view.active::-webkit-scrollbar {
  width: 8px;
}

.content-scroll-lock .view.active::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(29, 111, 143, 0.38);
}

.content-scroll-lock .view.active::-webkit-scrollbar-track {
  background: transparent;
}

.library-scroll-lock #libraryView.active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-right: 0;
}

.library-scroll-lock #libraryView .section-grid,
.library-scroll-lock #libraryView .wide-panel {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.library-scroll-lock #libraryView .wide-panel {
  display: flex;
  overflow: hidden;
}

.library-scroll-lock #supplierDirectory {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  align-content: start;
  scrollbar-color: rgba(29, 111, 143, 0.42) transparent;
  scrollbar-width: thin;
}

.library-scroll-lock #supplierDirectory::-webkit-scrollbar {
  width: 8px;
}

.library-scroll-lock #supplierDirectory::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(29, 111, 143, 0.38);
}

.library-scroll-lock #supplierDirectory::-webkit-scrollbar-track {
  background: transparent;
}

.directory-group {
  display: grid;
  gap: 10px;
}

.directory-group + .directory-group {
  margin-top: 18px;
}

.directory-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.directory-group-heading span {
  color: var(--muted);
  font-size: 13px;
}

.directory-collapse-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  font-size: 16px;
  font-weight: 800;
}

.directory-collapse-button:hover,
.directory-collapse-button:focus {
  color: var(--brand);
  outline: none;
}

.collapse-chevron {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(29, 111, 143, 0.22);
  border-radius: 999px;
  background: #e8f4f6;
  display: inline-block;
  position: relative;
  flex: 0 0 22px;
  transition: background 0.16s ease;
}

.collapse-chevron::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--brand-dark);
  border-bottom: 2px solid var(--brand-dark);
  transform: translate(-50%, -65%) rotate(45deg);
  transition: transform 0.16s ease;
}

.directory-group.collapsed .collapse-chevron::after {
  transform: translate(-65%, -50%) rotate(-45deg);
}

.directory-group-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-supplier-button {
  min-height: 30px;
  padding: 0 12px;
}

.delete-group-button.active {
  border-color: rgba(183, 67, 67, 0.35);
  background: #fff5f5;
  color: var(--danger);
}

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

.directory-group.collapsed .directory-group-grid {
  display: none;
}

.directory-card,
.risk-board-card,
.config-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.directory-card {
  position: relative;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.remove-card-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(183, 67, 67, 0.28);
  border-radius: 999px;
  background: #fff5f5;
  color: var(--danger);
  font-size: 20px;
  line-height: 20px;
  place-items: center;
  padding: 0;
}

.directory-group.delete-mode .remove-card-button {
  display: grid;
}

.remove-card-button:hover,
.remove-card-button:focus {
  background: var(--danger);
  color: #ffffff;
  outline: none;
}

.directory-card.inhouse-card {
  border-color: #b9d9d3;
  background: #f3fbf8;
}

.directory-card.vendor-card {
  border-color: #ccd8ee;
  background: #f5f8ff;
}

.directory-card.inhouse-card .recommend-badge {
  background: #dff4ed;
  color: #247455;
}

.directory-card.vendor-card .recommend-badge {
  background: #e7eefc;
  color: #315fba;
}

.directory-card.inhouse-card .directory-stats > div {
  background: #eaf7f2;
}

.directory-card.vendor-card .directory-stats > div {
  background: #ecf2ff;
}

.directory-card:hover,
.directory-card:focus {
  border-color: var(--brand);
  box-shadow: 0 16px 34px rgba(38, 52, 75, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.directory-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.directory-stats > div {
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 10px;
  min-width: 0;
}

.directory-stats span,
.directory-stats strong,
.directory-stats small {
  display: block;
}

.directory-stats span,
.directory-stats small {
  color: var(--muted);
  font-size: 12px;
}

.directory-stats strong {
  margin-top: 4px;
  font-size: 18px;
}

.split-stat strong {
  white-space: nowrap;
}

.inline-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.inline-stepper strong {
  margin-top: 0;
  font-size: 22px;
}

.stepper-actions {
  display: grid;
  gap: 2px;
}

.stepper-button {
  width: 24px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--brand-dark);
  font-size: 9px;
  line-height: 1;
  padding: 0;
}

.stepper-button:hover,
.stepper-button:focus {
  border-color: var(--brand);
  background: #e8f4f6;
  outline: none;
}

.split-stat small {
  margin-top: 8px;
  border: 1px solid rgba(29, 111, 143, 0.16);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand-dark);
  font-weight: 800;
  line-height: 1.4;
  padding: 4px 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 34, 51, 0.42);
  padding: 18px;
  z-index: 20;
}

.modal-backdrop.show {
  display: grid;
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

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

.edit-form label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.config-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.config-block {
  padding: 14px;
  background: var(--panel-soft);
}

.matrix-wrap {
  overflow-x: auto;
}

.capability-matrix-groups {
  display: grid;
  gap: 18px;
}

.capability-matrix-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.inhouse-matrix-group {
  border-color: #b9d9d3;
}

.vendor-matrix-group {
  border-color: #ccd8ee;
}

.capability-matrix-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
}

.inhouse-matrix-group .capability-matrix-group-heading {
  background: #eaf7f2;
  color: #247455;
}

.vendor-matrix-group .capability-matrix-group-heading {
  background: #ecf2ff;
  color: #315fba;
}

.capability-matrix-group-heading span {
  font-size: 12px;
  font-weight: 800;
}

.capability-matrix-group .risk-table th:first-child,
.capability-matrix-group .risk-table td:first-child {
  padding-left: 14px;
}

.capability-table {
  min-width: 980px;
  table-layout: fixed;
}

.capability-table th,
.capability-table td {
  vertical-align: middle;
  padding-left: 6px;
  padding-right: 6px;
}

.capability-table .group-divider {
  border-right: 2px solid rgba(29, 111, 143, 0.22);
  box-shadow: inset -5px 0 0 rgba(29, 111, 143, 0.035);
}

.capability-table th:first-child,
.capability-table td:first-child {
  text-align: center;
  width: 112px;
}

.capability-table td:not(:first-child) {
  text-align: center;
}

.capability-table th:not(:first-child),
.capability-table td:not(:first-child) {
  width: 96px;
  min-width: 96px;
  text-align: center;
}

.star-rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 28px;
  width: 100%;
  white-space: nowrap;
}

.star-rating.color-0 { --dot-color: #1d6f8f; }
.star-rating.color-1 { --dot-color: #8b5cf6; }
.star-rating.color-2 { --dot-color: #d97706; }
.star-rating.color-3 { --dot-color: #2f7d57; }
.star-rating.color-4 { --dot-color: #dc3f6a; }
.star-rating.color-5 { --dot-color: #2563eb; }
.star-rating.color-6 { --dot-color: #c2410c; }
.star-rating.color-7 { --dot-color: #0f766e; }

.dot-button {
  width: 12px;
  height: 12px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.shape-circle .dot-button {
  width: 10px;
  height: 10px;
  border: 1.5px solid #b9c6d5;
  border-radius: 999px;
}

.shape-circle .dot-button.active {
  border-color: var(--dot-color);
  background: var(--dot-color);
}

.shape-triangle .dot-button {
  width: 12px;
  height: 11px;
  background: #d5dde7;
  clip-path: polygon(50% 4%, 98% 96%, 2% 96%);
}

.shape-triangle .dot-button.active {
  background: var(--dot-color);
}

.shape-star .dot-button {
  width: 14px;
  height: 14px;
  color: #cbd5e1;
  font-size: 14px;
}

.shape-star .dot-button.active {
  color: var(--dot-color);
}

.dot-button:hover,
.dot-button:focus {
  outline: none;
  transform: scale(1.18);
}

.shape-circle .dot-button:hover,
.shape-circle .dot-button:focus {
  border-color: var(--dot-color);
}

.shape-triangle .dot-button:hover,
.shape-triangle .dot-button:focus {
  background: color-mix(in srgb, var(--dot-color) 62%, #d5dde7);
}

.shape-star .dot-button:hover,
.shape-star .dot-button:focus {
  color: var(--dot-color);
}

.dot-button.active:hover,
.dot-button.active:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-color) 22%, transparent);
}

.risk-board-list {
  display: grid;
  gap: 12px;
}

.risk-detail-panel {
  margin-top: 18px;
}

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

.risk-table-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.inhouse-risk-group {
  border-color: #b9d9d3;
}

.vendor-risk-group {
  border-color: #ccd8ee;
}

.risk-table-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
}

.inhouse-risk-group .risk-table-group-heading {
  background: #eaf7f2;
  color: #247455;
}

.vendor-risk-group .risk-table-group-heading {
  background: #ecf2ff;
  color: #315fba;
}

.risk-table-group-heading span {
  font-size: 12px;
  font-weight: 800;
}

.risk-table-group .risk-table-wrap {
  max-height: 360px;
  overflow: auto;
}

.risk-table-group .risk-table {
  min-width: 620px;
}

.risk-monitor-panel {
  margin-top: 18px;
}

.risk-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  margin-bottom: 18px;
}

.chart-panel {
  min-height: 330px;
}

.chart-legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.issue-dot,
.issue-bar,
.issue-fill {
  background: #2d78a0;
}

.overdue-dot,
.overdue-bar,
.overdue-fill {
  background: #d85858;
}

.trend-chart {
  height: 235px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 20px;
  padding: 20px 12px 0;
  border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent 46px, rgba(220, 227, 238, 0.65) 47px);
}

.trend-column {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 26px;
  gap: 8px;
  text-align: center;
}

.trend-column strong {
  color: var(--muted);
  font-size: 12px;
}

.trend-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}

.trend-bar {
  position: relative;
  width: min(30px, 38%);
  min-height: 4px;
  border-radius: 4px 4px 0 0;
}

.trend-bar span {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.comparison-chart {
  display: grid;
  gap: 10px;
  max-height: 245px;
  overflow-y: auto;
  padding-right: 4px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.comparison-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-bars {
  display: grid;
  gap: 4px;
}

.comparison-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--panel-soft);
}

.comparison-fill {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 3px;
  opacity: 0.82;
}

.comparison-track span {
  position: relative;
  z-index: 1;
  display: block;
  padding: 2px 6px;
  color: var(--ink);
  font-size: 11px;
  line-height: 14px;
}

.risk-board-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  align-items: center;
  gap: 14px;
  padding: 14px;
}

.risk-actions {
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 800;
  padding: 12px;
  text-align: center;
}

.risk-table-wrap {
  overflow-x: auto;
}

.risk-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.risk-table th,
.risk-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.risk-table th {
  color: var(--muted);
  background: var(--panel-soft);
}

.risk-low {
  color: var(--accent);
  font-weight: 800;
}

.risk-mid {
  color: var(--warning);
  font-weight: 800;
}

.risk-high {
  color: var(--danger);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #102636;
  color: #ffffff;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.2s ease;
  line-height: 1.55;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .nav-list {
    grid-template-columns: repeat(4, auto);
  }

  .sidebar-panel {
    margin-top: 0;
    margin-left: auto;
    min-width: 220px;
  }

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

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

  .risk-chart-grid {
    grid-template-columns: 1fr;
  }

  .split-risk-tables {
    grid-template-columns: 1fr;
  }

  .directory-group-grid,
  .config-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 680px) {
  body.content-scroll-lock {
    overflow: auto;
  }

  .content-scroll-lock .app-shell,
  .content-scroll-lock .workspace {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .content-scroll-lock .view.active {
    overflow: visible;
    padding-right: 0;
  }

  .library-scroll-lock #libraryView.active,
  .library-scroll-lock #libraryView .wide-panel {
    display: block;
    height: auto;
    overflow: visible;
  }

  .library-scroll-lock #supplierDirectory {
    overflow: visible;
    padding-right: 0;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .primary-button {
    flex: 1;
  }

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

  .nav-list {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-panel {
    width: 100%;
    margin-left: 0;
  }

  .supplier-card {
    grid-template-columns: 1fr;
  }

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

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

  .directory-group-grid,
  .config-board {
    grid-template-columns: 1fr;
  }

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

  .score-box {
    min-height: 72px;
  }

  .weight-row {
    grid-template-columns: 82px minmax(0, 1fr) 38px;
  }

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

  .field-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .ai-config-grid {
    grid-template-columns: 1fr;
  }

  .ai-config-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-config-actions small {
    margin-right: 0;
  }

  .upload-button {
    width: auto;
  }
}
