:root {
  --bg: #f7f8fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --ink: #1f1f23;
  --muted: #667085;
  --line: #e5e7ef;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --amber: #f29900;
  --shadow: 0 18px 46px rgba(31, 31, 35, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(66, 133, 244, 0.16), transparent 34rem),
    radial-gradient(circle at top right, rgba(52, 168, 83, 0.12), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(247, 248, 251, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(229, 231, 239, 0.8);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #4285f4, #34a853, #fbbc04);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: rgba(238, 242, 248, 0.92);
  border: 1px solid rgba(229, 231, 239, 0.9);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(31, 31, 35, 0.06);
}

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.nav a:hover {
  background: #fff;
}

.nav .nav-primary {
  color: #fff;
  background: linear-gradient(135deg, #1a73e8, #34a853);
  box-shadow: 0 8px 20px rgba(26, 115, 232, 0.2);
}

.nav .nav-primary:hover {
  background: linear-gradient(135deg, #1558b0, #188038);
}

.page {
  width: min(1080px, calc(100% - 28px));
  margin: 18px auto 40px;
}

.home-shell,
.detail-shell,
.proposal-book {
  display: grid;
  gap: 16px;
}

.hero-panel,
.composer-card,
.content-card,
.project-hero,
.proposal-cover,
.proposal-section,
.regenerate-card,
.panel {
  border: 1px solid rgba(229, 231, 239, 0.92);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 24px 18px;
  background:
    linear-gradient(140deg, rgba(232, 240, 254, 0.96), rgba(255, 255, 255, 0.9) 52%, rgba(230, 244, 234, 0.9));
}

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

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 19px;
}

h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.hero-copy,
.muted,
.prompt {
  color: var(--muted);
  line-height: 1.65;
}

.hero-copy {
  margin: 12px 0 0;
}

.composer-card,
.content-card,
.regenerate-card {
  padding: 16px;
}

.tabs {
  display: grid;
  gap: 14px;
}

.tabs > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tab-labels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2f8;
}

.tab-labels label,
.tab-labels span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

#tab-input:checked ~ .tab-labels label[for="tab-input"],
#tab-output:checked ~ .tab-labels label[for="tab-output"],
#detail-output:checked ~ .tab-labels label[for="detail-output"],
#detail-input:checked ~ .tab-labels label[for="detail-input"] {
  color: var(--blue);
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 31, 35, 0.08);
}

.tab-panels,
.tab-panel {
  display: grid;
  gap: 16px;
}

.home-tabs .tab-panel,
.detail-tabs .tab-panel {
  display: none;
}

#tab-input:checked ~ .tab-panels .input-panel,
#tab-output:checked ~ .tab-panels .output-panel,
#detail-output:checked ~ .tab-panels .output-panel,
#detail-input:checked ~ .tab-panels .input-panel {
  display: grid;
}

.form,
.field-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: #30323a;
  font-weight: 700;
}

input[type="text"],
input[type="file"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.module-drawer {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.module-drawer summary {
  cursor: pointer;
  padding: 14px;
  font-weight: 800;
}

.module-grid {
  padding: 0 14px 14px;
}

.module-grid ul {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.module-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.composer-actions {
  display: grid;
  gap: 12px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: #1558b0;
}

.button.secondary {
  background: var(--green);
}

.button.print {
  background: var(--amber);
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.message {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #b9ddc8;
  background: #edf7f0;
}

.message.error {
  border-color: #efb7ad;
  background: #fff1ee;
}

.recent-strip {
  padding: 8px 2px 0;
}

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

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

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

.project-list.compact {
  opacity: 0.74;
}

.results-card {
  display: grid;
  gap: 12px;
}

.search-box {
  gap: 7px;
}

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

.project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  text-decoration: none;
}

.project-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  touch-action: pan-y;
}

.swipe-actions {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  min-width: 302px;
  background: linear-gradient(135deg, #1a73e8, #188038 62%, #d93025);
}

.swipe-actions a,
.swipe-actions button {
  display: grid;
  place-items: center;
  min-width: 58px;
  padding: 0 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.swipe-actions .delete-form {
  display: grid;
}

.swipe-actions .delete-form button {
  min-height: 100%;
  min-width: 64px;
  background: rgba(217, 48, 37, 0.88);
}

.swipe-content {
  position: relative;
  z-index: 1;
  transition: transform 180ms ease;
  will-change: transform;
}

.swipe-row.is-open .swipe-content {
  transform: translateX(-302px);
}

.project-hero {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.actions .button {
  min-height: 40px;
  padding: 10px 15px;
}

.stats,
.proposal-metrics,
.mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stats div,
.proposal-metrics div,
.mini-grid div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: var(--surface-solid);
}

.stats span,
.proposal-metrics span,
.mini-grid span,
.item-card dt {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.stats strong,
.proposal-metrics strong,
.mini-grid strong {
  font-size: 17px;
}

.hero-image,
.proposal-figure {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.item-cards {
  display: grid;
  gap: 10px;
}

.item-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.item-card strong,
.item-card small {
  display: block;
}

.item-card small {
  color: var(--blue);
  margin-top: 4px;
}

.item-card p {
  margin: 10px 0;
  color: var(--muted);
  line-height: 1.55;
}

.item-card dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.item-card dd {
  margin: 0;
  font-weight: 800;
  font-size: 13px;
}

.desktop-table {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: #30323a;
  background: var(--blue-soft);
}

.quote-table {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.quote-table th {
  color: var(--section-color);
  background: var(--section-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.quote-table tbody tr:nth-child(even):not(.total-row):not(.grand-total-row) td {
  background: rgba(247, 248, 251, 0.72);
}

.quote-table td:first-child {
  font-weight: 700;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.45;
}

.proposal-cover,
.proposal-section {
  padding: 16px;
}

.quote-section {
  --section-color: var(--blue);
  --section-soft: var(--blue-soft);
  overflow: hidden;
  border-left: 5px solid var(--section-color);
}

.section-core_equipment {
  --section-color: #1a73e8;
  --section-soft: #e8f0fe;
}

.section-auxiliary_materials {
  --section-color: #188038;
  --section-soft: #e6f4ea;
}

.section-engineering_services {
  --section-color: #a142f4;
  --section-soft: #f3e8fd;
}

.section-logistics_customs {
  --section-color: #f29900;
  --section-soft: #fff4df;
}

.section-investment_summary {
  --section-color: #d93025;
  --section-soft: #fce8e6;
}

.quote-section h3 {
  color: var(--section-color);
}

.proposal-cover {
  background:
    linear-gradient(135deg, rgba(232, 240, 254, 0.96), rgba(255, 255, 255, 0.96));
}

.proposal-cover h2 {
  margin-bottom: 8px;
}

.proposal-cover p {
  color: var(--muted);
  line-height: 1.6;
}

.total-row td {
  color: var(--section-color);
  font-weight: 800;
  background: var(--section-soft);
  border-top: 2px solid var(--section-color);
}

.grand-total-row td {
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #d93025, #ea4335);
  border-bottom: 0;
}

.summary-table .total-row td {
  color: #b3261e;
  background: #fce8e6;
}

.proposal-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.75;
}

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

.reference-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.reference-item img,
.reference-item video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.reference-item small {
  display: block;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.prompt {
  margin: 10px 0 0;
  word-break: break-word;
}

.config-list {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 12px;
}

.config-list dt {
  color: var(--muted);
}

.config-list dd {
  margin: 0;
  word-break: break-all;
}

.hidden {
  display: none;
}

.small-button {
  min-height: 36px;
  margin-left: 8px;
  padding: 7px 11px;
  background: var(--amber);
}

@media (min-width: 700px) {
  .page {
    margin-top: 28px;
  }

  .hero-panel,
  .project-hero {
    padding: 28px;
  }

  h1 {
    font-size: 42px;
  }

  .composer-card,
  .content-card,
  .regenerate-card,
  .proposal-cover,
  .proposal-section {
    padding: 22px;
  }

  .composer-actions,
  .project-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .stats,
  .proposal-metrics,
  .mini-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

@media (min-width: 1000px) {
  .home-shell {
    grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
    align-items: start;
  }

  .recent-strip {
    grid-column: 1 / -1;
  }

  .detail-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-cards {
    display: none;
  }

  .desktop-table {
    display: block;
  }

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