:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --text: #172131;
  --muted: #6b7280;
  --faint: #98a2b3;
  --line: #e3e8ef;
  --line-soft: #eef1f5;
  --blue: #1e3a5f;
  --blue-deep: #0f2942;
  --cyan: #4f8da5;
  --green: #3f806b;
  --red: #9b5c63;
  --amber: #967642;
  --gold: #c5a45d;
  --shadow: 0 4px 24px rgba(16, 24, 40, 0.045);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Alibaba PuHuiTi 2.0", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  background:
    linear-gradient(180deg, rgba(15, 23, 38, 0.88), rgba(10, 17, 30, 0.94)),
    url("./assets/sidebar-texture.png") 30% top / auto 100% no-repeat,
    #0f1726;
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 2px 8px 17px;
}

.brand-logo {
  width: 184px;
  height: 48px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.1));
}

.nav-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  overflow: auto;
  padding-right: 2px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 12px;
  border-radius: 8px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item:hover,
.nav-item.active,
.nav-child:hover,
.nav-child.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.055);
}

.nav-item.active,
.nav-child.active {
  box-shadow: inset 2px 0 0 var(--gold);
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-toggle {
  position: relative;
}

.nav-label {
  min-width: 0;
  flex: 1;
  line-height: 20px;
}

.chevron {
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  opacity: 0.7;
}

.nav-group.open .chevron {
  transform: rotate(225deg);
}

.nav-children {
  display: none;
  gap: 1px;
  margin-left: 20px;
  padding: 3px 0 7px 18px;
  border-left: 1px solid rgba(203, 213, 225, 0.14);
}

.nav-group.open .nav-children {
  display: grid;
}

.nav-child {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 0 10px 0 12px;
  border-radius: 6px;
  color: #aeb8c7;
  background: transparent;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.nav-child::before {
  content: "";
  position: absolute;
  left: -18px;
  width: 10px;
  height: 1px;
  border-radius: 0;
  background: currentColor;
  opacity: 0.36;
}

.nav-icon,
.tool-icon,
.icon-button span,
.primary-button span,
.ghost-button span,
.search span,
.upload-box > span {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-icon {
  width: 18px;
  height: 18px;
  overflow: visible;
}

.nav-icon::before {
  width: 13px;
  height: 13px;
}

.nav-icon::before,
.tool-icon::before,
.icon-button span::before,
.primary-button span::before,
.ghost-button span::before,
.search span::before,
.upload-box > span::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-home::before {
  border-radius: 3px 3px 6px 6px;
  transform: rotate(45deg) scale(0.85);
}

.icon-plan::before {
  border-radius: 2px;
  background:
    linear-gradient(currentColor, currentColor) 3px 4px / 8px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 8px / 6px 1.5px no-repeat;
  box-shadow: none;
  transform: none;
}

.nav-icon.icon-plan::before {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
}

.icon-cube::before {
  transform: skewY(-18deg);
  border-radius: 2px;
}

.icon-image::before {
  border-radius: 4px;
  background: linear-gradient(135deg, transparent 45%, currentColor 46% 54%, transparent 55%);
}

.icon-template::before {
  width: 12px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 4px 4px 0 -1px currentColor;
}

.icon-score::before {
  border-radius: 50%;
  border-right-color: transparent;
}

.icon-search::before {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.icon-search::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(7px, 7px) rotate(45deg);
}

.icon-bell::before {
  width: 13px;
  height: 13px;
  border-radius: 8px 8px 4px 4px;
}

.icon-add::before {
  border: 0;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) center / 14px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 14px no-repeat;
}

.icon-upload::before {
  border: 0;
  border-bottom: 2px solid currentColor;
  border-radius: 0;
  background:
    linear-gradient(currentColor, currentColor) center 1px / 2px 12px no-repeat,
    linear-gradient(135deg, transparent 46%, currentColor 47% 53%, transparent 54%) 3px 1px / 9px 9px no-repeat,
    linear-gradient(45deg, transparent 46%, currentColor 47% 53%, transparent 54%) 2px 1px / 9px 9px no-repeat;
}

.icon-magic::before {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border-color: currentColor;
  box-shadow: 9px -5px 0 -5px currentColor, -5px 8px 0 -5px currentColor;
}

.icon-zoom::before {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.icon-zoom::after,
.icon-print::after,
.icon-download::after,
.icon-star::after,
.icon-play::after {
  content: "";
  position: absolute;
}

.icon-zoom::after {
  width: 7px;
  height: 2px;
  background: currentColor;
  transform: translate(7px, 7px) rotate(45deg);
}

.icon-download::before {
  border: 0;
  border-bottom: 2px solid currentColor;
  border-radius: 0;
  background:
    linear-gradient(currentColor, currentColor) center 0 / 2px 12px no-repeat,
    linear-gradient(135deg, transparent 47%, currentColor 48% 55%, transparent 56%) 4px 7px / 7px 7px no-repeat,
    linear-gradient(45deg, transparent 47%, currentColor 48% 55%, transparent 56%) 3px 7px / 7px 7px no-repeat;
}

.icon-print::before {
  width: 14px;
  height: 10px;
  border-radius: 3px;
}

.icon-print::after {
  width: 10px;
  height: 6px;
  border: 2px solid currentColor;
  border-bottom: 0;
  transform: translateY(-7px);
}

.icon-star::before {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.icon-play::before {
  border: 0;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
  border-radius: 0;
}

.side-note {
  margin-top: auto;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(203, 213, 225, 0.12);
}

.side-note span {
  display: inline-flex;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(197, 164, 93, 0.14);
  color: #dec27c;
  font-size: 12px;
}

.side-note strong {
  display: block;
  margin-top: 9px;
  font-size: 14px;
}

.side-note p {
  margin: 7px 0 0;
  color: #96a2b2;
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: #7b8494;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 34px;
  font-weight: 750;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 750;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search {
  width: min(360px, 34vw);
  min-width: 220px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--faint);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  white-space: nowrap;
}

.primary-button {
  min-height: 38px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(15, 41, 66, 0.18);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.tool-card:hover {
  transform: translateY(-1px);
}

.primary-button.wide {
  width: 100%;
}

.ghost-button {
  padding: 0 12px;
  color: var(--blue);
  background: #f6f8fb;
  border: 1px solid var(--line);
}

.icon-button {
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.panel {
  min-width: 0;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.metric-card {
  min-height: 116px;
  padding: 17px 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 34px;
  font-weight: 760;
  color: #111827;
}

.metric-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.metric-card.accent-blue {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #1e3a5f 0%, #0f2942 100%);
}

.metric-card.accent-blue span,
.metric-card.accent-blue p {
  color: rgba(255, 255, 255, 0.76);
}

.metric-card.accent-blue strong {
  color: #fff;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  gap: 14px;
  margin-bottom: 14px;
}

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

.tool-card {
  min-height: 146px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 17px;
  text-align: left;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, border 0.18s ease, box-shadow 0.18s ease;
}

.tool-card strong {
  font-size: 17px;
  font-weight: 750;
}

.tool-card small {
  color: var(--muted);
  font-size: 13px;
}

.tool-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.tint-blue {
  background: #f4f7fb;
  color: #1e3a5f;
}

.tint-red {
  background: #fbf5f5;
  color: #8f4f58;
}

.tint-green {
  background: #f3f8f5;
  color: #3f806b;
}

.tint-amber {
  background: #faf7ef;
  color: #8b6b35;
}

.chart-row {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
}

.bar-chart,
.line-chart {
  height: 260px;
  padding: 18px;
  border-radius: 8px;
  background: #fafbfc;
  border: 1px solid var(--line-soft);
}

.bar-chart {
  display: flex;
  align-items: end;
  justify-content: space-around;
  gap: 12px;
}

.bar-chart span {
  width: 28px;
  min-height: 18px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #7aa8bc, #1e3a5f);
}

.line-chart svg {
  width: 100%;
  height: 100%;
}

.grid-line {
  fill: none;
  stroke: #e8edf3;
  stroke-width: 1;
}

.line-fill {
  fill: rgba(79, 141, 165, 0.1);
}

.line-stroke {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-dots circle {
  fill: #fff;
  stroke: var(--cyan);
  stroke-width: 2.5;
}

.workflow-panel {
  margin-bottom: 14px;
}

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

.workflow-step {
  position: relative;
  min-height: 118px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.workflow-step span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 700;
}

.workflow-step strong {
  display: block;
  margin-top: 10px;
  font-weight: 700;
}

.workflow-step p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workflow-step.done span {
  color: #fff;
  background: #3f806b;
  border-color: #3f806b;
}

.workflow-step.active {
  border-color: #b8c7d7;
  background: #f6f8fb;
}

.workflow-step.active span {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

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

.control-panel {
  position: sticky;
  top: 18px;
}

.upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px dashed #b8c7d7;
  border-radius: 8px;
  color: var(--blue);
  background: #f7f9fb;
}

.upload-box strong {
  display: block;
  color: var(--text);
}

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

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

.form-grid.one-line {
  grid-template-columns: 0.8fr 1.2fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 122px;
  resize: vertical;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8fa4b8;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.prompt-box {
  margin-top: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  border-radius: 8px;
  background: #f4f6f8;
  border: 1px solid var(--line-soft);
}

.segmented button {
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segmented button.active {
  color: var(--blue);
  background: #fff;
  box-shadow: 0 3px 10px rgba(16, 24, 40, 0.055);
}

.template-select,
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.template-chip,
.chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  cursor: pointer;
}

.template-chip.active,
.chip.active {
  color: var(--blue);
  background: #f3f6fa;
  border-color: #c8d2de;
}

.template-chip span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
}

.template-chip:nth-child(2) span {
  background: var(--green);
}

.template-chip:nth-child(3) span {
  background: #222;
}

.generation-status {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
}

.generation-status > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.generation-status span,
.generation-status p {
  color: var(--muted);
}

.generation-status strong {
  color: var(--text);
}

.progress {
  height: 8px;
  overflow: hidden;
  margin: 10px 0;
  border-radius: 999px;
  background: #e8edf5;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6f9fb3, var(--blue));
  transition: width 0.4s ease;
}

.generation-status p {
  margin: 0;
  font-size: 12px;
}

.preview-panel {
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.paper-preview {
  width: 100%;
  min-height: 640px;
  padding: 14px;
  border: 1px solid #b8c4d6;
  border-radius: 8px;
  background: #fffdf4;
  box-shadow: inset 0 0 0 5px #f2f6fb;
}

.paper-preview.template-green {
  background: #f7fff8;
  box-shadow: inset 0 0 0 5px #e3f5eb;
}

.paper-preview.template-mono {
  background: #ffffff;
  box-shadow: inset 0 0 0 5px #eef0f2;
}

.paper-header,
.paper-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-height: 36px;
  padding: 8px 10px;
  border-top: 4px solid #164f85;
  border-bottom: 1px solid #97a7ba;
  color: #113e69;
  font-weight: 700;
}

.paper-header strong {
  margin-left: auto;
}

.template-green .paper-header,
.template-green .paper-footer {
  border-top-color: #23805b;
  color: #176346;
}

.template-mono .paper-header,
.template-mono .paper-footer {
  border-top-color: #111;
  color: #111;
}

.ruler {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 10px 0 4px;
  border: 1px solid #cbd5e1;
  background: #faf7df;
}

.template-green .ruler {
  background: #eefaf1;
}

.template-mono .ruler {
  background: #f7f7f7;
}

.ruler span {
  min-height: 28px;
  display: grid;
  place-items: center;
  border-right: 1px solid #cbd5e1;
  color: #6b6f43;
  font-size: 12px;
}

.ruler span:last-child {
  border-right: 0;
}

.network-preview {
  margin-top: 8px;
  border: 1px solid #cbd5e1;
  background:
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(144, 164, 190, 0.2) 39px 40px),
    #fffef7;
}

.network-preview svg {
  width: 100%;
  height: auto;
  min-height: 240px;
}

.network-grid {
  stroke: #dbe4ef;
  stroke-width: 1;
}

.critical,
.normal,
.float {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  marker-end: url("#arrow");
}

.critical {
  stroke: var(--red);
}

.normal {
  stroke: var(--cyan);
}

.float {
  stroke: #7a93aa;
  stroke-dasharray: 7 6;
}

.nodes circle {
  fill: #fff;
  stroke: #7890a8;
  stroke-width: 2;
}

.node-labels text {
  fill: #3f5368;
  font-size: 12px;
  font-weight: 700;
}

.work-labels text {
  fill: #116b55;
  font-size: 14px;
}

.gantt-preview {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.gantt-table {
  min-width: 820px;
  display: grid;
  grid-template-columns: 52px 220px 62px minmax(440px, 1fr);
  font-size: 12px;
}

.gantt-table > div {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid #d9e1ea;
  border-bottom: 1px solid #d9e1ea;
}

.gantt-table > div:nth-child(4n) {
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 48px, #e6edf5 49px 50px),
    linear-gradient(180deg, transparent, transparent);
}

.timeline-head {
  justify-content: center;
  color: #607087;
  background: #f7f9fc !important;
}

.gantt-bar {
  position: absolute;
  top: 8px;
  height: 17px;
  display: flex;
  align-items: center;
  min-width: 18px;
  padding-left: 6px;
  border-radius: 2px;
  color: #183247;
  font-size: 11px;
  white-space: nowrap;
  overflow: visible;
}

.gantt-bar.key {
  background: repeating-linear-gradient(45deg, #f08493 0 3px, #e34b5f 4px 6px);
  border: 1px solid #c73448;
}

.gantt-bar.normal {
  background: repeating-linear-gradient(45deg, #95d8e4 0 3px, #49b7c9 4px 6px);
  border: 1px solid #2497aa;
}

.paper-footer {
  margin-top: 10px;
  border-top-width: 1px;
  font-size: 12px;
}

.legend-line {
  width: 42px;
  height: 3px;
  display: inline-block;
  border-radius: 999px;
}

.legend-line.key {
  background: var(--red);
}

.legend-line.normal {
  background: var(--cyan);
}

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

.ref-card {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #fff;
  cursor: pointer;
}

.ref-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.ref-card img {
  width: 100%;
  height: 104px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
}

.ref-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

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

.bim-card {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.bim-visual {
  position: relative;
  height: 130px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #dff3ff 0 48%, #c8e5d3 49% 100%);
}

.bim-visual::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -20px;
  width: 110px;
  height: 180px;
  transform: translateX(-50%) rotate(58deg);
  background:
    linear-gradient(90deg, transparent 0 42%, #fff 43% 45%, transparent 46% 54%, #fff 55% 57%, transparent 58%),
    #58606c;
  box-shadow: 0 0 0 10px #6b7480;
}

.bim-visual::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(24, 164, 184, 0.32);
  filter: blur(4px);
}

.bim-card:nth-child(3n) .bim-visual {
  background:
    linear-gradient(180deg, #e9f5ff 0 44%, #d7dfe8 45% 100%);
}

.bim-card:nth-child(3n) .bim-visual::before {
  width: 170px;
  height: 52px;
  bottom: 30px;
  transform: translateX(-50%) rotate(-8deg);
  background: #76899a;
  box-shadow: 0 16px 0 #384c5a, 40px -22px 0 -10px #f6d365;
}

.bim-card:nth-child(4n) .bim-visual::before {
  width: 60px;
  height: 150px;
  bottom: -28px;
  background:
    radial-gradient(circle at 50% 20%, #23a8bd 0 18px, transparent 19px),
    linear-gradient(90deg, #334155 0 42%, #f9fafb 43% 57%, #334155 58%);
  box-shadow: 44px 20px 0 -16px #263445, -44px 20px 0 -16px #263445;
}

.bim-meta {
  padding: 10px;
}

.bim-meta strong {
  display: block;
  font-size: 13px;
}

.bim-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  gap: 14px;
}

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

.gallery-card {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.gallery-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.gallery-card img {
  width: 100%;
  height: 210px;
  object-fit: cover;
}

.gallery-card div {
  padding: 12px;
}

.gallery-card strong,
.gallery-card span {
  display: block;
}

.gallery-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.asset-list {
  display: grid;
  gap: 10px;
}

.asset-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 38px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.asset-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.asset-thumb {
  height: 58px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #dff3ff, #b5c7d9);
}

.asset-thumb.road {
  background:
    linear-gradient(135deg, transparent 45%, #475569 46% 62%, transparent 63%),
    linear-gradient(180deg, #dff3ff, #b7e1c4);
}

.asset-thumb.drain {
  background:
    radial-gradient(circle at 50% 58%, transparent 0 16px, #64748b 17px 21px, transparent 22px),
    linear-gradient(180deg, #e6f7ff, #c8d4df);
}

.asset-thumb.light {
  background:
    linear-gradient(90deg, transparent 0 45%, #334155 46% 52%, transparent 53%),
    radial-gradient(circle at 52% 22%, #f6d365 0 14px, transparent 15px),
    linear-gradient(180deg, #eef6ff, #c9d6df);
}

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

.template-card {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.template-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.template-card strong {
  display: block;
  margin-top: 12px;
  font-size: 16px;
}

.template-card p {
  min-height: 40px;
  margin: 6px 0 12px;
  color: var(--muted);
}

.doc-mini {
  height: 190px;
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.doc-mini span {
  height: 10px;
  border-radius: 999px;
  background: #d7e2ef;
}

.doc-mini span:nth-child(1) {
  width: 62%;
}

.doc-mini span:nth-child(2) {
  width: 84%;
}

.doc-mini span:nth-child(3) {
  width: 72%;
}

.doc-mini div {
  margin-top: 8px;
  border: 1px solid #c7d0dc;
  background:
    linear-gradient(90deg, transparent 0 28%, rgba(30, 58, 95, 0.14) 29% 31%, transparent 32%),
    repeating-linear-gradient(0deg, transparent 0 18px, #edf2f7 19px 20px);
}

.blue-doc {
  border-top: 5px solid var(--blue);
}

.green-doc {
  border-top: 5px solid var(--green);
}

.gold-doc {
  border-top: 5px solid var(--gold);
}

.score-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 12px;
}

.score-summary {
  display: grid;
}

.score-ring {
  --score: 87;
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  place-self: center;
  margin: 10px 0 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 58%, transparent 59%),
    conic-gradient(var(--green) calc(var(--score) * 1%), #e8edf5 0);
}

.score-ring strong,
.score-ring span {
  grid-area: 1 / 1;
}

.score-ring strong {
  margin-top: -16px;
  font-size: 44px;
  font-weight: 800;
}

.score-ring span {
  margin-top: 54px;
  color: var(--muted);
}

.score-bars {
  display: grid;
  gap: 12px;
}

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

.score-bars span,
.score-bars em {
  color: var(--muted);
  font-style: normal;
}

.score-bars i {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.score-bars b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

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

.risk-row {
  display: grid;
  grid-template-columns: 150px 210px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.risk-row:last-child {
  border-bottom: 0;
}

.risk-row span {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.risk-row span:last-child {
  border-right: 0;
}

.risk-row.header {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
}

.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.5fr);
  gap: 12px;
  align-items: start;
}

.module-hero {
  min-height: 360px;
}

.module-description {
  max-width: 760px;
  margin: 0 0 16px;
  color: var(--muted);
}

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

.module-action {
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.module-action strong,
.module-action span {
  display: block;
}

.module-action strong {
  font-size: 16px;
  font-weight: 700;
}

.module-action span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.permission-grid {
  display: grid;
  gap: 10px;
}

.permission-grid div {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.permission-grid strong,
.permission-grid span {
  display: block;
}

.permission-grid span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .metric-grid,
  .workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .workspace-grid,
  .workspace-grid.compact-left,
  .two-column,
  .score-layout,
  .module-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .bim-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .side-note {
    display: none;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .top-actions .primary-button {
    width: 100%;
  }

  .tool-cards,
  .chart-row,
  .gallery-grid,
  .template-grid,
  .module-actions {
    grid-template-columns: 1fr;
  }

  .reference-strip {
    grid-template-columns: 1fr;
  }

  .paper-preview {
    min-height: auto;
  }

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

  .risk-row span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .risk-row span:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 12px;
  }

  .nav-list,
  .metric-grid,
  .workflow,
  .form-grid,
  .form-grid.one-line,
  .bim-grid {
    grid-template-columns: 1fr;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .paper-header strong {
    margin-left: 0;
  }

  .score-bars div {
    grid-template-columns: 1fr;
  }
}
