:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #14202b;
  --muted: #667789;
  --line: #d9e1e8;
  --brand: #116149;
  --brand-strong: #0b4635;
  --blue: #235cc8;
  --amber: #a86400;
  --red: #b42318;
  --green: #117546;
  --shadow: 0 8px 24px rgba(21, 34, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-box h1,
.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.login-box p {
  margin: 8px 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

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

.field label {
  color: #314254;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.btn {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.btn:hover {
  background: var(--brand-strong);
}

.btn.secondary {
  background: #e9eef3;
  color: #1f3142;
}

.btn.secondary:hover {
  background: #dfe7ef;
}

.btn.danger {
  background: var(--red);
}

.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.layout {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 8px;
}

.tab {
  min-height: 42px;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  color: #26394b;
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

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

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

.metric strong {
  display: block;
  font-size: 24px;
  margin-bottom: 4px;
}

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

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

.item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.item:hover,
.item.active {
  border-color: var(--brand);
}

.item-title {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
}

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

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #edf2f7;
  color: #2e4154;
  font-size: 12px;
  font-weight: 800;
}

.badge.pass {
  background: #e8f6ef;
  color: var(--green);
}

.badge.review,
.badge.missing-rule {
  background: #fff1d8;
  color: var(--amber);
}

.badge.fail {
  background: #fde8e6;
  color: var(--red);
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

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

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 14px 0;
}

.search-row input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}

.scope-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scope-hero h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.scope-hero p,
.scope-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.scope-actions,
.tag-row,
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-pill,
.tag-button,
.check-item {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: #26394b;
  font-size: 13px;
}

.scope-pill,
.tag-button {
  cursor: pointer;
}

.scope-pill.active,
.tag-button:hover {
  border-color: var(--brand);
  background: #e8f6ef;
  color: var(--brand-strong);
}

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

.scope-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.scope-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.check-item {
  border-radius: 6px;
  background: var(--panel-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

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

th {
  background: var(--panel-soft);
  color: #314254;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.line-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 88px minmax(130px, 0.6fr) 42px;
  gap: 8px;
  margin-bottom: 8px;
}

.line-editor select,
.line-editor input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
}

.ingredient-line {
  grid-template-columns: minmax(180px, 1fr) 130px minmax(160px, 0.8fr) 42px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #edf2f7;
  color: #26394b;
  cursor: pointer;
  font-weight: 900;
}

.status-box {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 14px;
  background: var(--panel-soft);
}

.status-box.pass {
  border-color: #b9dfcb;
  background: #effaf4;
}

.status-box.review {
  border-color: #f0c97b;
  background: #fff8e8;
}

.status-box.fail {
  border-color: #f1a09a;
  background: #fff0ef;
}

.status-box h3 {
  margin: 0 0 8px;
}

.callout {
  border-left: 4px solid var(--blue);
  background: #eef4ff;
  padding: 12px;
  border-radius: 6px;
  color: #243b63;
  line-height: 1.6;
}

.callout.compact {
  margin: 8px 0 14px;
  padding: 10px 12px;
  font-size: 13px;
}

.callout.warning {
  margin-bottom: 12px;
  border-left-color: var(--amber);
  background: #fff8e8;
  color: #6f4700;
}

.component-editors,
.component-results {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

.component-editor,
.component-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.component-editor-head,
.component-result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.component-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.mode-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: #26394b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.mode-btn.active {
  border-color: var(--brand);
  background: #e8f6ef;
  color: var(--brand-strong);
}

.field-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.readonly-line {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--panel-soft);
  color: #314254;
}

.component-lines {
  margin: 4px 0 10px;
}

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

.add-component-row select {
  min-height: 34px;
  min-width: min(260px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  background: #fff;
}

.compact-grid {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) 130px;
}

.component-result.pass {
  border-color: #b9dfcb;
}

.component-result.review {
  border-color: #f0c97b;
}

.component-result.fail {
  border-color: #f1a09a;
}

.component-result h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.basis-text {
  margin: 8px 0 0;
  line-height: 1.6;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
}

.error-text {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

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

.section-gap {
  margin-top: 18px;
}

.danger-text {
  color: var(--red);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .layout,
  .grid-2,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .layout {
    padding: 12px 14px 24px;
  }

  .sidebar,
  .form-grid,
  .line-editor {
    grid-template-columns: 1fr;
  }

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