:root {
  --bg: #f7f3ec;
  --paper: #fffdf8;
  --paper-soft: #fffdf9;
  --ink: #20302d;
  --muted: #6d7a76;
  --line: #dfd8cb;
  --green: #2f6f61;
  --green-dark: #1f5148;
  --blue: #426f8f;
  --mint: #dceee5;
  --coral: #bf6d55;
  --amber: #f2c66d;
  --danger: #9d4f48;
  --shadow: 0 18px 50px rgba(47, 64, 57, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(220, 238, 229, 0.65), rgba(247, 243, 236, 0.2) 35%),
    var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    sans-serif;
}

button,
input,
select {
  font: inherit;
  min-width: 0;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.gate-shell {
  width: min(720px, 100%);
  display: grid;
  gap: 18px;
}

.gate-title {
  display: grid;
  gap: 10px;
}

.gate-title h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 72px);
  line-height: 1.02;
  letter-spacing: 0;
}

.gate-title .privacy-note,
.title-block .privacy-note {
  max-width: none;
  width: fit-content;
}

.gate-card {
  padding: 22px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 22px;
}

.title-block {
  display: grid;
  gap: 10px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
}

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

.privacy-note {
  max-width: 340px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px;
  border: 1px solid rgba(47, 111, 97, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
}

.account-chip span {
  color: var(--green-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.account-chip button {
  min-height: 34px;
  white-space: nowrap;
  padding: 7px 12px;
}

.auth-card {
  border: 1px solid rgba(47, 111, 97, 0.22);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  padding: 12px;
  min-width: 0;
}

.auth-status {
  color: var(--green-dark);
  font-weight: 800;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.auth-tip {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-fields input {
  min-height: 38px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.auth-actions button {
  min-height: 36px;
  padding: 8px 14px;
}

#registerBtn {
  min-width: 120px;
}

.secondary-button {
  border: 1px solid rgba(47, 111, 97, 0.24);
  background: var(--mint);
  color: var(--green-dark);
}

.secondary-button:hover {
  background: var(--green);
  color: #fffefa;
}

.ghost-button {
  border: 1px solid rgba(66, 111, 143, 0.24);
  background: #eef6f8;
  color: var(--blue);
}

.ghost-button:hover {
  background: var(--blue);
  color: #fffefa;
}

.auth-footnote {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-message {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result-card,
.section-block,
.tracker-band {
  border: 1px solid rgba(114, 126, 118, 0.24);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.left-panel,
.form-panel,
.result-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.section-block,
.result-card,
.tracker-band {
  padding: 20px;
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.section-heading span {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.section-heading h2,
.result-card h2,
.result-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 21px;
}

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

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

.compact-fields {
  margin-top: 16px;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  outline: none;
  padding: 9px 11px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

select:invalid,
select:has(option[value=""]:checked) {
  color: var(--muted);
}

.unit-input {
  position: relative;
  display: block;
}

.unit-input input {
  padding-right: 54px;
}

.unit-input span {
  position: absolute;
  right: 14px;
  bottom: 11px;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 111, 97, 0.13);
  background: #ffffff;
}

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

.condition-list {
  grid-template-columns: 1fr;
}

.check-grid label {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--ink);
  font-weight: 600;
}

.check-grid input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(320px, 0.55fr) 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.upload-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.upload-control {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.upload-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-drop {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px dashed var(--green);
  border-radius: 8px;
  background: var(--mint);
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 800;
  padding: 10px 16px;
  white-space: nowrap;
}

.file-drop:hover {
  background: var(--green);
  color: #fffefa;
}

.file-name {
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.has-file {
  color: var(--green-dark);
}

.result-panel {
  position: static;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.result-card {
  border-color: rgba(66, 111, 143, 0.22);
  background: #fbfefd;
  box-shadow: none;
}

.result-card h3 {
  font-size: 18px;
}

.summary-card {
  border-color: rgba(47, 111, 97, 0.22);
  background:
    linear-gradient(135deg, rgba(220, 238, 229, 0.56), rgba(250, 253, 251, 0.99)),
    #f6fbf8;
  box-shadow: 0 14px 34px rgba(47, 111, 97, 0.07);
}

.summary-card h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green-dark);
  font-size: 20px;
}

.result-section-primary h3 {
  font-size: 24px;
}

.unified-result-card {
  display: grid;
  gap: 0;
}

.result-section {
  padding: 22px 0;
  border-top: 1px solid rgba(47, 111, 97, 0.12);
}

.result-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.result-section:last-child {
  padding-bottom: 0;
}

.unified-result-card .plan-list p {
  border-left-color: var(--green-dark);
  color: var(--ink);
}

.result-section-primary .plan-list p {
  font-size: 18px;
  font-weight: 700;
}

.result-card ol {
  margin: 0;
  padding-left: 22px;
}

.result-card li {
  margin: 8px 0;
  line-height: 1.6;
}

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

.plan-list p {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--mint);
  color: #31433f;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.tracker-band {
  margin-top: 0;
}

.followup-notice {
  margin: -4px 0 16px;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.chart-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 14px;
}

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

.chart-head h3 {
  margin: 0;
  font-size: 16px;
}

.chart-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.trend-chart {
  min-height: 260px;
  overflow: hidden;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: min(28vw, 300px);
  min-height: 240px;
}

.chart-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
  text-align: center;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fffefa;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 18px;
}

button:hover {
  background: var(--green-dark);
}

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

  .result-panel {
    position: static;
  }

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

  .condition-list {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .upload-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .upload-control {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .auth-fields {
    grid-template-columns: 1fr;
  }

  .workspace,
  .field-grid,
  .lab-grid,
  .check-grid,
  .condition-list {
    grid-template-columns: 1fr;
  }

  .section-block,
  .result-card {
    padding: 16px;
  }
}
