:root {
  --bg-1: #232a31;
  --bg-2: #1b2127;
  --bg-3: #151a1f;
  --card: #d9dee3;
  --card-strong: #eef2f5;
  --line: rgba(255, 255, 255, 0.14);
  --text: #11181f;
  --muted: #52606d;
  --accent: #bb3a30;
  --accent-soft: rgba(187, 58, 48, 0.1);
  --good: #217a4a;
  --good-soft: rgba(33, 122, 74, 0.12);
  --warn: #8a6a18;
  --warn-soft: rgba(138, 106, 24, 0.13);
  --bad: #b3483a;
  --bad-soft: rgba(179, 72, 58, 0.13);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 22px 48px rgba(8, 11, 14, 0.34);
  --metal-top: rgba(255, 255, 255, 0.52);
  --metal-low: rgba(123, 136, 148, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 18%),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(145deg, #323b44 0%, var(--bg-1) 20%, var(--bg-2) 58%, var(--bg-3) 100%);
  font-family: "Aptos", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

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

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(53, 62, 71, 0.96), rgba(27, 33, 39, 0.98)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 24%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
}

.brand {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
}

.logo {
  width: min(220px, 100%);
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}

.logo img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.08) saturate(1.05) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(221, 228, 235, 0.72);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.sidebar .muted,
.sidebar h1,
.sidebar h2,
.sidebar h3,
.sidebar h4,
.sidebar label,
.sidebar .nav-button {
  color: #eef3f7;
}

.sidebar .muted {
  color: rgba(225, 232, 238, 0.74);
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-button {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  color: #eef3f7;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-button.active,
.nav-button:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border-color: rgba(187, 58, 48, 0.28);
  transform: translateY(-1px);
}

.sidebar-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.content {
  padding: 24px;
}

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

.content .eyebrow {
  color: #707d89;
}

.topbar-status {
  display: grid;
  gap: 8px;
  justify-items: end;
}

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

.pill,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #56616c, #414a53);
  color: #f5f8fb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.pill.good {
  background: linear-gradient(180deg, #2f8e58, #246d43);
  color: var(--good);
}

.pill.warn {
  background: linear-gradient(180deg, #a48126, #7e631b);
  color: #fff6d9;
}

.pill.bad {
  background: linear-gradient(180deg, #c25849, #983f33);
  color: #fff0eb;
}

.ghost-button {
  cursor: pointer;
  color: #f5f8fb;
}

.status-text {
  margin: 0;
  max-width: 460px;
  text-align: right;
  color: rgba(230, 236, 242, 0.9);
  font-size: 13px;
  line-height: 1.45;
}

.alert-banner {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(17, 24, 31, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.alert-banner-compact {
  padding: 12px 14px;
}

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

.alert-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(17, 24, 31, 0.08);
  color: #1e2933;
}

.alert-banner-summary,
.alert-banner-detail,
.alert-banner-action,
.alert-banner-meta {
  margin: 0;
  color: #22303b;
  line-height: 1.5;
}

.alert-banner-action {
  font-weight: 600;
}

.alert-banner-meta {
  color: #4b5a67;
  font-size: 13px;
}

.alert-success {
  border-color: rgba(33, 122, 74, 0.24);
  background: linear-gradient(180deg, rgba(237, 247, 241, 0.96), rgba(221, 239, 228, 0.9));
}

.alert-success .alert-chip {
  background: rgba(33, 122, 74, 0.14);
  color: #1d6940;
}

.alert-warning {
  border-color: rgba(138, 106, 24, 0.26);
  background: linear-gradient(180deg, rgba(252, 246, 226, 0.97), rgba(245, 233, 192, 0.9));
}

.alert-warning .alert-chip {
  background: rgba(138, 106, 24, 0.14);
  color: #75560f;
}

.alert-danger {
  border-color: rgba(179, 72, 58, 0.28);
  background: linear-gradient(180deg, rgba(252, 236, 233, 0.98), rgba(244, 214, 209, 0.92));
}

.alert-danger .alert-chip {
  background: rgba(179, 72, 58, 0.16);
  color: #9f3427;
}

.alert-info {
  border-color: rgba(82, 96, 109, 0.22);
  background: linear-gradient(180deg, rgba(239, 243, 247, 0.96), rgba(226, 232, 238, 0.9));
}

.alert-info .alert-chip {
  background: rgba(82, 96, 109, 0.15);
  color: #43515e;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 18px;
}

.hero,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::before,
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--metal-top), transparent);
  pointer-events: none;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  padding: 28px;
}

.metrics,
.stack,
.report-grid {
  display: grid;
  gap: 12px;
}

.metric,
.stack-item,
.report-block {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(250, 252, 253, 0.92), rgba(214, 220, 225, 0.88));
  border: 1px solid rgba(74, 85, 95, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.settlement-hint-success {
  border-left: 4px solid rgba(58, 122, 78, 0.5);
}

.settlement-hint-warning {
  border-left: 4px solid rgba(196, 132, 39, 0.75);
  background: linear-gradient(180deg, rgba(252, 248, 239, 0.96), rgba(236, 223, 195, 0.9));
}

.settlement-hint-danger {
  border-left: 4px solid rgba(176, 62, 52, 0.78);
  background: linear-gradient(180deg, rgba(252, 241, 239, 0.96), rgba(235, 206, 201, 0.9));
}

.report-risk-strip {
  margin-bottom: 14px;
  border-left: 4px solid rgba(187, 58, 48, 0.55);
}

.json-preview {
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  border-radius: 14px;
  background: rgba(31, 37, 44, 0.9);
  color: #e6edf3;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.stack-list p {
  margin: 0;
  line-height: 1.55;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

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

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

.card {
  padding: 22px;
}

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

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

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(98, 109, 120, 0.18);
  background: linear-gradient(180deg, #f6f8fa, #e7ebef);
  color: var(--text);
}

.span-2 {
  grid-column: span 2;
}

.primary-button {
  padding: 14px 18px;
  border-radius: 999px;
  border: 1px solid rgba(92, 103, 114, 0.28);
  background: linear-gradient(180deg, #eef2f5 0%, #c6ced6 48%, #9aa5b0 100%);
  color: #172029;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 10px 24px rgba(20, 25, 30, 0.2);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.42);
}

.report.empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(71, 84, 97, 0.16);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.summary {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(245, 247, 249, 0.98), rgba(212, 218, 224, 0.92));
  border: 1px solid rgba(93, 104, 115, 0.14);
  margin-bottom: 14px;
}

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

.bullet-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.link-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(110, 118, 128, 0.4);
  text-underline-offset: 3px;
}

.link-button:hover {
  color: var(--ink);
  text-decoration-color: rgba(187, 58, 48, 0.65);
}

.tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(187, 58, 48, 0.12);
  color: #7c2b24;
}

.process-hero-grid,
.process-signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.process-hero-card,
.process-signal-card,
.process-zone-card,
.process-flow-indicator {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(73, 84, 95, 0.16);
  background: linear-gradient(180deg, rgba(247, 249, 251, 0.98), rgba(222, 227, 232, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 10px 20px rgba(18, 23, 28, 0.08);
}

.process-hero-card .metric-value,
.process-signal-card .metric-value,
.process-flow-indicator .metric-value {
  margin-top: 8px;
  font-size: 26px;
}

.process-zone-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.process-zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.process-zone-risk {
  border-color: rgba(179, 72, 58, 0.24);
  background: linear-gradient(180deg, rgba(255, 245, 243, 0.98), rgba(245, 220, 214, 0.94));
}

.process-zone-safe {
  border-color: rgba(33, 122, 74, 0.22);
  background: linear-gradient(180deg, rgba(242, 250, 246, 0.98), rgba(219, 238, 228, 0.92));
}

.process-zone-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(17, 24, 31, 0.08);
}

.process-zone-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.process-zone-fill-risk {
  background: linear-gradient(90deg, #df7969, #b3483a);
}

.process-zone-fill-safe {
  background: linear-gradient(90deg, #5fb986, #217a4a);
}

.process-flow-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
}

.process-tuning-card {
  gap: 14px;
}

.process-tuning-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.process-tuning-inline input[type="range"] {
  flex: 1;
  min-width: 220px;
  accent-color: var(--accent);
}

.process-plan-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.process-plan-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(73, 84, 95, 0.16);
  background: linear-gradient(180deg, rgba(245, 247, 249, 0.98), rgba(219, 225, 231, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.process-plan-card-highlight {
  border-color: rgba(187, 58, 48, 0.28);
  background: linear-gradient(180deg, rgba(255, 247, 245, 0.98), rgba(238, 219, 214, 0.94));
}

.stack-item .tag {
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(92, 103, 114, 0.18);
  box-shadow: var(--shadow);
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  .hero,
  .grid.two,
  .report-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .topbar-status {
    justify-items: start;
  }

  .status-text {
    text-align: left;
  }

  .process-plan-compare {
    grid-template-columns: 1fr;
  }
}
