:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #687470;
  --line: #dbe2df;
  --soft: #f2f5f3;
  --paper: #ffffff;
  --green: #123d34;
  --green-2: #1e6b59;
  --mint: #a6d8c7;
  --orange: #d96d22;
  --blue: #427aa1;
  --danger: #a63d40;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #eef2ef;
}

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

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
}

.workspace-nav {
  min-height: 56px;
  color: #f2f4f7;
  background: #111214;
  border-bottom: 1px solid #2a2c30;
}

.workspace-nav-inner {
  width: min(100%, 1500px);
  min-height: 56px;
  margin: 0 auto;
  padding: 9px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.workspace-brand {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 760;
  white-space: nowrap;
}

.workspace-links {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: #25272a;
  border-radius: 6px;
}

.workspace-links a {
  min-width: 92px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: #a6a9b0;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.workspace-links a.active {
  color: #fff;
  background: #3a3c40;
}

.topbar {
  min-height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: var(--green);
  border-bottom: 3px solid var(--orange);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  color: var(--green);
  background: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand div > span {
  margin-top: 3px;
  color: #bad3cb;
  font-size: 10px;
}

.engine-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8e6e1;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f0a15f;
}

.engine-state.is-ready .status-dot {
  background: #75d0af;
}

.workspace-tabs {
  height: 48px;
  padding: 0 28px;
  display: flex;
  align-items: stretch;
  gap: 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

body[data-entry-mode="team"] .workspace-nav,
body[data-entry-mode="team"] .workspace-tabs {
  display: none;
}

body[data-entry-mode="team"] .topbar {
  min-height: 72px;
}

.tab {
  position: relative;
  padding: 0 2px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

.tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: transparent;
}

.tab.is-active {
  color: var(--ink);
  font-weight: 700;
}

.tab.is-active::after {
  background: var(--orange);
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.workspace {
  display: none;
}

.workspace.is-active {
  display: grid;
}

#calculatorView {
  min-height: calc(100vh - 172px);
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.control-panel {
  padding: 28px;
  background: #f7f9f8;
  border-right: 1px solid var(--line);
}

.section-heading,
.result-header,
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading p,
.result-header p,
.page-heading p {
  margin: 0 0 6px;
  color: var(--green-2);
  font-size: 10px;
  font-weight: 800;
}

.section-heading h1,
.section-heading h2,
.result-header h2,
.page-heading h1 {
  margin: 0;
  line-height: 1.25;
}

.section-heading h1,
.page-heading h1 {
  font-size: 24px;
}

.section-heading h2,
.result-header h2 {
  font-size: 18px;
}

.tag {
  padding: 5px 7px;
  color: #8c4c20;
  background: #fff1e6;
  border: 1px solid #f4c79f;
  border-radius: 4px;
  font-size: 11px;
}

form {
  margin-top: 28px;
  display: grid;
  gap: 17px;
}

label {
  display: grid;
  gap: 7px;
  color: #4e5c57;
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: white;
  border: 1px solid #cbd5d1;
  border-radius: 5px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(30, 107, 89, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
}

.switch-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--green-2);
}

.primary-button {
  height: 44px;
  border: 1px solid var(--green);
  border-radius: 5px;
  color: white;
  background: var(--green);
  font-weight: 700;
}

.primary-button:hover {
  background: #0e312a;
}

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

.form-note {
  margin: 20px 0 0;
  padding-top: 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.65;
}

.result-panel {
  min-width: 0;
  padding: 28px 32px 42px;
  background: var(--paper);
}

.version-block {
  min-width: 150px;
  text-align: right;
}

.version-block span,
.version-block strong {
  display: block;
}

.version-block span {
  color: var(--muted);
  font-size: 11px;
}

.version-block strong {
  margin-top: 5px;
  font-size: 12px;
}

.metric-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.metric-grid > div {
  min-height: 92px;
  padding: 17px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}

.metric-grid > div:last-child {
  border-right: 0;
}

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

.metric-grid strong {
  font-size: 22px;
}

.chart-section,
.table-section {
  margin-top: 30px;
}

.section-heading.compact {
  align-items: center;
}

.legend {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 11px;
}

.legend span::before {
  content: "";
  width: 16px;
  height: 3px;
  margin-right: 6px;
  display: inline-block;
  vertical-align: middle;
  background: var(--blue);
}

.legend .value::before {
  background: var(--orange);
}

#valueChart {
  width: 100%;
  height: 330px;
  margin-top: 14px;
  display: block;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.table-scroll {
  width: 100%;
  margin-top: 13px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 12px;
}

th,
td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid #e8edeb;
  white-space: nowrap;
}

th {
  color: #53605c;
  background: var(--soft);
  font-weight: 700;
}

th:first-child,
td:first-child {
  text-align: left;
}

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

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center !important;
}

.data-workspace {
  min-height: calc(100vh - 116px);
  padding: 34px 28px 50px;
  background: var(--paper);
}

.data-workspace.is-active {
  display: block;
}

.page-heading {
  display: block;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.page-heading > span {
  margin-top: 8px;
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.product-list {
  margin-top: 8px;
}

.product-item {
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) minmax(160px, 1fr) minmax(180px, 1fr) 120px;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.product-item h2,
.limitations h2 {
  margin: 0;
  font-size: 16px;
}

.product-item p,
.product-item span {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  width: max-content;
  padding: 5px 8px;
  border: 1px solid #e8b07e;
  border-radius: 4px;
  color: #8c4c20 !important;
  background: #fff3e8;
  font-weight: 700;
}

.limitations {
  margin-top: 34px;
  padding: 22px;
  background: #f7f9f8;
  border-left: 4px solid var(--orange);
}

.limitations ul {
  margin: 14px 0 0;
  padding-left: 20px;
  color: #53605c;
  font-size: 13px;
  line-height: 1.9;
}

.validation-summary {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.validation-summary > div {
  min-height: 85px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.validation-summary > div:last-child {
  border-right: 0;
}

.validation-summary span,
.validation-summary strong {
  display: block;
}

.validation-summary span {
  color: var(--muted);
  font-size: 11px;
}

.validation-summary strong {
  margin-top: 11px;
  font-size: 20px;
}

.validation-table {
  margin-top: 24px;
}

.pass {
  color: var(--green-2);
  font-weight: 700;
}

.pending {
  color: #a45620;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 14px;
  display: none;
  color: white;
  background: var(--ink);
  border-radius: 5px;
  box-shadow: 0 14px 32px rgba(20, 40, 34, 0.22);
  font-size: 13px;
}

.toast.is-visible {
  display: block;
}

.calculator-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.calculator-actions .primary-button {
  margin: 0;
}

.calculator-actions .secondary-button {
  min-width: 0;
}

.delivery-section {
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.download-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 12px;
}

.delivery-stage {
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 18px;
  background: #e8edea;
  border: 1px solid #d3dcd7;
}

.delivery-stage img {
  display: block;
  width: min(100%, 560px);
  height: auto;
  box-shadow: 0 10px 26px rgba(20, 42, 34, 0.16);
}

.delivery-empty,
.delivery-note {
  color: var(--muted);
  font-size: 12px;
}

.delivery-note {
  margin: 10px 0 0;
}

.editor-workspace {
  padding: 32px;
  background: #f7f9f8;
}

.editor-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.version-context {
  min-width: 520px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  color: white;
  background: #18211f;
  border: 1px solid #2f3d38;
  border-radius: 6px;
}

.version-context-item {
  min-width: 0;
  padding: 14px 16px;
}

.version-context-item span,
.version-context-item small,
.version-context-item strong {
  display: block;
}

.version-context-item span {
  color: #aab8b3;
  font-size: 10px;
  font-weight: 700;
}

.version-context-item strong {
  margin: 4px 0;
  font-size: 18px;
}

.version-context-item small {
  color: #b9c4c0;
  font-size: 10px;
}

.version-context-item.is-draft strong {
  color: #f2b779;
}

.version-context-item.is-live strong {
  color: #9cd7c2;
}

.version-context-arrow {
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: #82908b;
  border-right: 1px solid #34413d;
  border-left: 1px solid #34413d;
  font-size: 10px;
  white-space: nowrap;
}

.draft-guard {
  min-height: 48px;
  margin-bottom: 18px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #4b5a55;
  background: #fff8ee;
  border: 1px solid #ecd8bb;
  border-left: 4px solid #c68137;
  font-size: 12px;
}

.draft-guard strong {
  flex: none;
  color: #8b541d;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(520px, 0.95fr) minmax(420px, 1.05fr);
  gap: 24px;
  align-items: start;
}

.template-form,
.preview-pane {
  min-width: 0;
}

.form-section {
  margin-bottom: 26px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.form-section-title {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-section-title span {
  color: var(--orange);
  font: 700 11px/1 Inter, sans-serif;
}

.form-section-title h2,
.version-panel h2 {
  margin: 0;
  font-size: 15px;
}

.template-form label {
  margin-bottom: 14px;
  display: grid;
  gap: 7px;
  color: #52605b;
  font-size: 12px;
  font-weight: 700;
}

.template-form label small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.template-form input:not([type="checkbox"]):not([type="color"]),
.template-form textarea,
.version-panel select {
  width: 100%;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #cdd7d2;
  border-radius: 4px;
  outline: 0;
}

.template-form input:focus,
.template-form textarea:focus,
.version-panel select:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(30, 107, 89, 0.1);
}

.template-form textarea {
  resize: vertical;
  line-height: 1.65;
}

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

.template-form input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  background: white;
  border: 1px solid #cdd7d2;
  border-radius: 4px;
}

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

.template-form .switch-row {
  min-height: 42px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
}

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

.secondary-button,
.icon-button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--ink);
  background: white;
  border: 1px solid #cbd5d0;
  border-radius: 4px;
  font-weight: 700;
}

.editor-actions .primary-button {
  width: auto;
  margin: 0 0 0 auto;
  padding: 0 22px;
}

.preview-pane {
  position: sticky;
  top: 18px;
}

.preview-toolbar,
.version-panel,
.rollback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-toolbar {
  min-height: 52px;
  padding: 0 14px;
  color: white;
  background: #262a29;
  border-radius: 6px 6px 0 0;
}

.preview-toolbar span,
.preview-toolbar small {
  display: block;
}

.preview-toolbar span {
  font-size: 13px;
  font-weight: 700;
}

.preview-toolbar small {
  margin-top: 3px;
  color: #adb5b2;
  font-size: 10px;
}

.preview-switch {
  display: flex;
  align-items: center;
  gap: 2px;
}

.preview-switch button {
  min-height: 30px;
  padding: 0 11px;
  color: #aeb8b4;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.preview-switch button.is-active {
  color: #fff;
  background: #424947;
  border-color: #59615e;
}

.preview-toolbar .icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: white;
  background: transparent;
  border-color: #555b58;
  font-size: 20px;
}

.poster-stage {
  height: min(64vh, 720px);
  min-height: 500px;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 20px;
  background: #dde2df;
  border: 1px solid #cbd3cf;
  border-top: 0;
}

.poster-stage img {
  display: block;
  width: min(100%, 540px);
  height: auto;
  box-shadow: 0 12px 28px rgba(29, 39, 35, 0.18);
}

.poster-empty {
  color: #6d7773;
  font-size: 13px;
}

.version-panel {
  margin-top: 14px;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.version-panel > div:first-child span {
  color: var(--muted);
  font-size: 10px;
}

.rollback-row {
  flex: 1;
  justify-content: flex-end;
}

.rollback-row select {
  max-width: 270px;
}

@media (max-width: 900px) {
  #calculatorView {
    grid-template-columns: 1fr;
  }

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

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid > div:nth-child(2) {
    border-right: 0;
  }

  .metric-grid > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .product-item {
    grid-template-columns: 1fr 1fr;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    position: static;
  }
}

@media (max-width: 600px) {
  .workspace-nav-inner {
    padding: 9px 14px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .workspace-links {
    width: 100%;
    overflow-x: auto;
  }

  .workspace-links a {
    flex: 0 0 auto;
    min-width: 88px;
  }

  .topbar {
    min-height: 62px;
    padding: 0 16px;
  }

  .engine-state {
    max-width: 130px;
    text-align: right;
    font-size: 11px;
  }

  .workspace-tabs {
    padding: 0 16px;
    gap: 22px;
  }

  .control-panel,
  .result-panel,
  .data-workspace,
  .editor-workspace {
    padding: 22px 16px 34px;
  }

  .editor-heading,
  .version-panel,
  .rollback-row {
    align-items: stretch;
    flex-direction: column;
  }

  .version-context {
    width: 100%;
    min-width: 0;
  }

  .color-grid,
  .toggle-grid {
    grid-template-columns: 1fr 1fr;
  }

  .editor-actions {
    flex-wrap: wrap;
  }

  .editor-actions .primary-button {
    width: 100%;
    margin: 0;
  }

  .calculator-actions {
    grid-template-columns: 1fr;
  }

  .version-context {
    grid-template-columns: 1fr;
  }

  .version-context-arrow {
    min-height: 30px;
    border: 0;
    border-top: 1px solid #34413d;
    border-bottom: 1px solid #34413d;
  }

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

  .poster-stage {
    height: 62vh;
    min-height: 420px;
    padding: 12px;
  }

  .rollback-row select {
    max-width: none;
  }

  .field-row,
  .product-item {
    grid-template-columns: 1fr;
  }

  .result-header {
    display: block;
  }

  .version-block {
    margin-top: 12px;
    text-align: left;
  }

  .metric-grid,
  .validation-summary {
    grid-template-columns: 1fr 1fr;
  }

  .validation-summary > div:nth-child(2) {
    border-right: 0;
  }

  .validation-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .metric-grid strong {
    font-size: 18px;
  }

  #valueChart {
    height: 250px;
  }

  .legend {
    display: none;
  }
}
