:root {
  --bg: #f7f9f9;
  --panel: #ffffff;
  --line: #d8e1df;
  --text: #182522;
  --muted: #64736f;
  --brand: #0f766e;
  --brand-dark: #0b4f4a;
  --accent: #b45309;
  --soft: #e7f2ef;
  --shadow: 0 18px 50px rgba(16, 34, 31, 0.10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.app-shell {
  padding: 28px;
}

.workspace {
  max-width: 1520px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 26px 28px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 42px rgba(16, 34, 31, 0.10);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.brand-logo {
  display: grid;
  gap: 0;
  padding-right: 28px;
  border-right: 1px solid var(--line);
  line-height: 1;
}

.brand-logo strong {
  color: #12312d;
  font-size: 28px;
  letter-spacing: 1px;
}

.brand-logo span {
  color: #6a7773;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.title-block {
  min-width: 210px;
}

.quote-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #354b47;
  background: #fff;
}

.quote-pill span {
  color: var(--brand);
  font-size: 16px;
}

.quote-pill strong {
  font-size: 14px;
  font-weight: 600;
}

.saved-state {
  display: inline-block;
  margin: 4px 0 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e8f4f1;
  color: var(--brand);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 18px;
  flex-wrap: nowrap;
  align-items: center;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.toolbar-button {
  height: 38px;
  border: 0;
  background: transparent;
  color: #263d39;
  padding: 0 8px;
  cursor: pointer;
  font-size: 14px;
}

.toolbar-button:hover {
  color: var(--brand);
}

.header-tool {
  display: grid;
  gap: 6px;
  place-items: center;
  min-width: 64px;
  border: 0;
  background: transparent;
  color: #263d39;
  cursor: pointer;
  font-size: 13px;
}

.header-tool span {
  font-size: 22px;
  line-height: 1;
}

.header-tool:hover {
  color: var(--brand);
}

.header-print {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  height: 44px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.header-print span {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  white-space: nowrap;
}

h2 {
  font-size: 18px;
}

.layout {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 0;
}

.config-panel,
.result-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 37, 34, 0.05);
}

.config-panel {
  position: sticky;
  top: 18px;
  padding: 24px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.settings-panel {
  margin: 0 0 24px;
  padding: 24px;
}

.settings-subtitle {
  margin-top: 18px;
}

.settings-table-wrap {
  overflow-x: auto;
}

.settings-table-wrap input {
  width: 86px;
  height: 34px;
  padding: 0 8px;
}

.result-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 24px;
  align-items: start;
}

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

.section-title.compact {
  margin-bottom: 10px;
}

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

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

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

.param-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.param-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f1;
}

.param-card h3 {
  margin: 0;
  color: #203a36;
  font-size: 15px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

input[readonly] {
  background: #f1f5f4;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.toggle-row span {
  color: var(--text);
  font-weight: 600;
}

.branch-toggle {
  min-height: 36px;
  align-self: end;
}

.allowance-row {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
  justify-content: flex-end;
}

.allowance-note,
.inline-and {
  color: var(--muted);
  font-size: 12px;
  line-height: 32px;
}

.compact-field {
  display: grid;
  grid-template-columns: auto 64px auto;
  align-items: center;
  gap: 5px;
  width: auto;
}

.compact-field span,
.compact-field em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.compact-field input {
  width: 64px;
  height: 32px;
  padding: 0 8px;
}

.title-toggle {
  flex: 0 0 auto;
  font-size: 12px;
}

.title-toggle span {
  white-space: nowrap;
  font-size: 12px;
}

.branch-editor {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.branch-editor .section-title {
  align-items: flex-start;
}

.branch-editor-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.branch-editor-tools label {
  display: flex;
  align-items: center;
  gap: 5px;
}

.branch-editor-tools span,
.branch-editor-tools em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.branch-editor-tools input {
  width: 70px;
  height: 28px;
  padding: 0 8px;
}

.branch-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

#branchRows {
  display: grid;
  gap: 8px;
}

.branch-head,
.branch-row {
  display: grid;
  grid-template-columns: 30px 72px 72px 70px 92px 78px 82px;
  gap: 8px;
  align-items: center;
  min-width: 560px;
}

.branch-head {
  color: var(--muted);
  font-size: 11px;
}

.branch-row strong {
  color: var(--brand-dark);
  font-size: 13px;
}

.branch-row select,
.branch-row input {
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.mini-check {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  font-size: 12px;
  color: var(--text);
}

.mini-check input {
  width: 14px;
  height: 14px;
  padding: 0;
}

select:focus,
input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--brand);
}

.primary-button {
  min-width: 132px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

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

.small-button {
  min-width: 92px;
  height: 34px;
}

.secondary-button {
  min-width: 96px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 20, 18, 0.36);
}

.password-modal {
  width: min(380px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.password-modal label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

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

.password-modal input {
  height: 40px;
}

.icon-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: #eef5f3;
  color: var(--brand-dark);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.password-error {
  margin: 10px 0 0;
  color: #b91c1c;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

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

.quote-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.quote-summary div {
  padding: 12px 14px;
  background: var(--soft);
  border: 1px solid #bdd8d2;
  border-radius: 6px;
}

.quote-summary div:last-child {
  border-right: 1px solid #bdd8d2;
  background: var(--soft);
}

.quote-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.quote-summary strong {
  font-size: 22px;
  color: var(--brand-dark);
}

.top-summary {
  flex: 1 1 auto;
  min-width: 430px;
  max-width: 560px;
  gap: 0;
}

.top-summary div {
  padding: 0 22px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
}

.top-summary div:last-child {
  border-right: 0;
  background: transparent;
}

.top-summary span {
  font-size: 12px;
  margin-bottom: 4px;
}

.top-summary strong {
  font-size: 26px;
  line-height: 1.1;
}

.drawing-wrap,
.spec-table,
.cost-table,
.quote-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.drawing-wrap {
  grid-column: auto;
  grid-row: auto;
}

.tiny-button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #f4c7c3;
  border-radius: 5px;
  background: #fff7f6;
  color: #b42318;
  cursor: pointer;
  font-size: 12px;
}

.tiny-button:hover {
  background: #fde9e7;
}

.quote-list-table {
  table-layout: fixed;
}

.quote-list-table th:nth-child(1) {
  width: auto;
}

.quote-list-table th:nth-child(2) {
  width: 72px;
  text-align: center;
}

.quote-list-table th:nth-child(3),
.quote-list-table th:nth-child(4) {
  width: 112px;
  text-align: right;
}

.quote-list-table th:nth-child(5) {
  width: 64px;
}

.quote-list-table td {
  vertical-align: middle;
}

.quote-spec {
  font-weight: 600;
  color: #17332f;
  overflow-wrap: anywhere;
}

.quote-number {
  text-align: center;
  font-weight: 600;
  color: var(--brand-dark);
}

.quote-money {
  text-align: right;
  font-weight: 700;
  color: #17332f;
  white-space: nowrap;
}

.quote-action-cell {
  text-align: right;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

#drawing {
  width: 100%;
  min-height: 748px;
  display: block;
  background: #fbfcfc;
  border: 1px solid #cad5d2;
}

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

#specList div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #eef2f1;
  padding: 8px 0;
  min-width: 0;
}

dt {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.35;
}

dd {
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 0;
  border-bottom: 1px solid #eef2f1;
  text-align: left;
  font-size: 13px;
  line-height: 1.35;
}

th:last-child,
td:last-child {
  text-align: right;
}

th {
  color: var(--muted);
  font-weight: 500;
}

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

  .layout,
  .result-panel,
  .field-grid,
  .quote-summary,
  #specList {
    grid-template-columns: 1fr;
  }

  .layout {
    padding: 0;
  }

  .config-panel {
    position: static;
  }

  .drawing-wrap,
  .quote-list,
  .cost-table,
  .spec-table {
    grid-column: auto;
  }

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

  h1 {
    font-size: 24px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    padding: 0;
  }

  .primary-button {
    display: none;
  }

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

  .config-panel,
  .result-panel {
    box-shadow: none;
  }
}
