:root {
  color-scheme: light;
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-muted: #f6f8f7;
  --surface-strong: #e7ecea;
  --ink: #172022;
  --ink-soft: #344246;
  --muted: #667276;
  --line: #cfd8d5;
  --line-strong: #aebbb8;
  --brand: #0f766e;
  --brand-dark: #0b5d58;
  --brand-soft: #e2f3f0;
  --amber: #996100;
  --amber-bg: #fff5dd;
  --red: #b42318;
  --red-bg: #fff0ee;
  --green: #237346;
  --green-bg: #eaf7ef;
  --blue: #2563a5;
  --blue-bg: #edf5ff;
  --shadow: 0 1px 2px rgba(23, 32, 34, 0.06), 0 12px 32px rgba(23, 32, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8faf9 0, var(--bg) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1520px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.topbar h1,
.panel-heading h2,
.summary-band h2,
.empty-state h2,
.section-block h3,
.risk-title h4 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.14;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill,
.risk-badge,
.review-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-soft {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #b9dbd5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.86fr) minmax(480px, 1.14fr);
  gap: 16px;
  align-items: stretch;
}

.input-panel,
.result-panel {
  min-height: calc(100vh - 126px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.result-panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 18px;
}

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

textarea {
  width: 100%;
  flex: 1;
  min-height: 392px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 15px;
  color: var(--ink);
  background: #fbfcfc;
  line-height: 1.7;
  outline: none;
}

textarea::placeholder,
input::placeholder {
  color: #9aa4a6;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

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

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

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input[type="file"] {
  padding-top: 8px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  margin-top: 22px;
}

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

.billing-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #b9dbd5;
  border-radius: 6px;
  padding: 12px;
  background: var(--brand-soft);
}

.billing-preview div {
  display: grid;
  gap: 3px;
  min-width: 110px;
}

.billing-label {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 850;
}

.billing-preview strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.billing-preview p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
}

.payment-panel {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.payment-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.payment-panel-head div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.payment-panel strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.25;
}

.payment-panel p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.payment-panel .secondary-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.payment-action-box {
  display: grid;
  gap: 9px;
  border: 1px solid #b9dbd5;
  border-radius: 6px;
  padding: 11px;
  background: var(--brand-soft);
}

.payment-action-box strong {
  display: block;
  font-size: 15px;
}

.payment-action-box .secondary-button {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--brand-dark);
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

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

.secondary-button,
.ghost-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.ghost-button {
  min-height: 34px;
  padding: 0 11px;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.inline-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  min-height: calc(100vh - 126px);
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.empty-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 4px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #b7d8d2;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 28px;
  font-weight: 800;
}

.empty-state h2 {
  color: var(--ink);
  font-size: 21px;
}

.empty-state p {
  max-width: 430px;
  margin: 0;
  line-height: 1.65;
}

.results {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.is-hidden {
  display: none;
}

.summary-band {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  padding: 15px;
  background: linear-gradient(90deg, var(--surface-muted), #fff);
}

.summary-band h2 {
  font-size: 26px;
}

.risk-heading.critical,
.risk-heading.high {
  color: var(--red);
}

.risk-heading.medium {
  color: var(--amber);
}

.risk-heading.low {
  color: var(--green);
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-stats span {
  min-height: 31px;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 850;
}

.summary-text {
  margin: 0;
  padding: 0 2px;
  color: var(--ink-soft);
  line-height: 1.75;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.toolbar label {
  width: min(190px, 100%);
}

.export-report-button {
  margin-left: auto;
}

.section-block {
  display: grid;
  gap: 11px;
}

.section-block h3 {
  font-size: 16px;
}

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

.risk-item,
.compact-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.risk-item {
  display: grid;
  gap: 11px;
  padding: 13px;
}

.risk-item:hover {
  border-color: var(--line-strong);
}

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

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

.risk-title h4 {
  color: var(--ink);
  font-size: 15px;
}

.risk-badge.critical,
.risk-badge.high {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f4bbb5;
}

.risk-badge.medium {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: #ebc776;
}

.risk-badge.low {
  background: var(--green-bg);
  color: var(--green);
  border-color: #b7dfc5;
}

.review-badge {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: #bdd5f2;
}

.risk-copy {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.clause-excerpt {
  margin: 0;
  border-left: 3px solid var(--brand);
  padding: 10px 12px;
  background: #f3f6f5;
  color: #374447;
  line-height: 1.65;
}

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

.risk-detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-muted);
}

.risk-detail-grid strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.risk-detail-grid p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

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

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

.compact-item {
  padding: 12px;
}

.compact-item strong {
  display: block;
  margin-bottom: 6px;
}

.compact-item p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.disclaimer {
  margin: 0;
  padding: 12px;
  border: 1px solid #e2c16f;
  border-radius: 6px;
  color: var(--amber);
  background: var(--amber-bg);
  line-height: 1.6;
}

.empty-list {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-muted);
}

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

  .input-panel,
  .result-panel,
  .empty-state {
    min-height: auto;
  }

  textarea {
    min-height: 360px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-heading,
  .summary-band,
  .risk-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .summary-stats {
    justify-content: flex-start;
  }

  .control-grid,
  .two-column,
  .risk-detail-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-line {
    margin-top: 0;
  }

  .billing-preview {
    align-items: stretch;
    flex-direction: column;
  }

  .billing-preview p {
    text-align: left;
  }

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

  .payment-action-box {
    grid-template-columns: 1fr;
  }

  .toolbar label {
    width: 100%;
  }

  .export-report-button {
    width: 100%;
    margin-left: 0;
  }
}
