:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #151515;
  --muted: #777f8c;
  --line: #dce1e8;
  --soft: #f7f8fa;
  --accent: #ffd83d;
  --accent-ink: #202020;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(25, 30, 38, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 216, 61, 0.18), transparent 28rem),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 780px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 14px 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 14px;
  background: linear-gradient(to bottom, var(--bg) 82%, rgba(243, 244, 246, 0));
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 7vw, 32px);
  line-height: 1.05;
}

h2 {
  font-size: 16px;
}

.quote-strip {
  position: sticky;
  top: 76px;
  z-index: 9;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.quote-strip div,
.result-main div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: #171717;
  color: #ffffff;
  padding: 12px;
  min-width: 0;
}

.quote-strip span,
.result-main span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.quote-strip strong,
.result-main strong {
  font-size: clamp(18px, 5vw, 28px);
  line-height: 1.15;
  word-break: break-all;
}

.panel,
.result-panel {
  margin: 12px 0;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.result-panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 800;
}

.panel-title.inline {
  margin-bottom: 0;
}

.mark {
  width: 5px;
  height: 18px;
  border-radius: 3px;
  background: var(--accent);
  flex: 0 0 auto;
}

details.panel {
  padding: 0;
}

summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary > span:last-child {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

details[open] summary {
  border-bottom: 1px solid var(--line);
}

details > .form-grid,
details > .process-list {
  padding: 14px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

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

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

.field.is-hidden {
  display: none;
}

.field span {
  color: #4e5663;
  font-size: 13px;
  font-weight: 700;
}

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

input,
select {
  height: 42px;
}

textarea {
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

input:disabled,
textarea:read-only {
  background: var(--soft);
  color: #4b5563;
}

.quick-qty,
.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quick-qty button,
.soft-button,
.ghost-button,
.danger-button,
.primary-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 12px;
  font-weight: 800;
}

.quick-qty button,
.soft-button {
  background: var(--soft);
  border-color: var(--line);
  color: #222;
}

.quick-qty button.is-active {
  background: var(--accent);
  border-color: #e6c52f;
}

.template-status {
  align-self: center;
  color: #176b3a;
  font-size: 13px;
  font-weight: 800;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.template-status.is-visible {
  opacity: 1;
}

.primary-button {
  background: #171717;
  color: #fff;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
}

.danger-button {
  background: #fff5f5;
  border-color: #ffd6d3;
  color: var(--danger);
}

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

.process-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.process-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  min-height: 46px;
}

.process-head input {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 auto;
}

.process-name {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  color: #242a33;
}

.process-name-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border-color: transparent;
  background: transparent;
  padding: 0;
  font-weight: 800;
}

.process-name-input:focus {
  border-color: var(--line);
  background: #fff;
  padding: 0 8px;
}

.process-total {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.process-options {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 12px;
}

.process-chip.is-selected {
  border-color: #c5b35d;
  background: #fffdf3;
}

.process-chip.is-selected .process-options {
  display: grid;
}

.mini-field {
  display: grid;
  gap: 5px;
}

.mini-field span {
  color: #606977;
  font-size: 12px;
  font-weight: 700;
}

.mini-field input,
.mini-field select {
  height: 38px;
  background: #fff;
}

.result-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  background: #fff;
}

.breakdown {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-top: 1px solid rgba(220, 225, 232, 0.62);
}

.breakdown-row:first-child {
  border-top: 0;
}

.breakdown-row strong {
  font-size: 14px;
}

.breakdown-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.45;
}

.breakdown-row span:last-child {
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .app-shell {
    padding-inline: 20px;
  }

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

  .quick-qty,
  .button-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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