:root {
  --bg: #f3f0ea;
  --panel: #fffdf8;
  --ink: #1d2a2e;
  --muted: #647174;
  --line: #ddd4c8;
  --primary: #0f6f64;
  --primary-dark: #0a5048;
  --accent: #bd5638;
  --field: #fbfaf6;
  --soft: #f7efe5;
  --shadow: 0 18px 45px rgba(35, 43, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

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

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(29, 42, 46, 0.42);
}

.login-modal.visible {
  display: grid;
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 32px;
}

.staff-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 2px 0 0;
  padding: 8px 12px;
  border: 1px solid rgba(221, 212, 200, 0.9);
  border-radius: 8px;
  background: #edf6f4;
}

.staff-bar strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.staff-bar span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(221, 212, 200, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel,
.result-panel,
.records-panel {
  padding: 18px;
}

.result-panel {
  position: sticky;
  top: 20px;
}

.panel-header,
.records-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel-header {
  display: grid;
  gap: 8px;
}

.eyebrow,
p,
h1,
h2 {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1;
}

h2 {
  font-size: 28px;
  line-height: 1.15;
}

.subtext {
  color: var(--muted);
  font-size: 15px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #354246;
  font-size: 13px;
  font-weight: 800;
}

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

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 111, 100, 0.14);
}

.input-with-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  overflow: hidden;
}

.input-with-unit input {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.input-with-unit span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

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

.dimension-table {
  display: grid;
  gap: 4px;
}

.dimension-head,
.dimension-row {
  display: grid;
  grid-template-columns: 36px minmax(84px, 1.6fr) minmax(84px, 1.6fr) 94px minmax(100px, 1.1fr) 150px;
  gap: 6px;
  align-items: center;
}

.dimension-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 0 2px;
}

.dimension-row {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.dimension-row > span,
.dimension-row > strong {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.dimension-row input {
  min-height: 29px;
  padding: 5px 7px;
  background: #fffdf8;
}

.dimension-row input::-webkit-outer-spin-button,
.dimension-row input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.dimension-row input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.hidden {
  display: none !important;
}

.dimension-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 2px;
}

.dimension-controls button {
  min-height: 34px;
  margin: 0;
  border: 1px dashed var(--primary);
  background: rgba(15, 111, 100, 0.08);
  color: var(--primary-dark);
  font-size: 22px;
}

.dimension-controls button:hover {
  background: rgba(15, 111, 100, 0.14);
}

.dimension-controls button:disabled {
  border-color: var(--line);
  background: #ece7df;
  color: var(--muted);
  cursor: not-allowed;
}

.quick-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(140px, 0.8fr) minmax(160px, 0.8fr);
  gap: 6px;
  align-items: stretch;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 111, 100, 0.05);
}

.quick-load {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 6px;
}

.quick-tools button {
  min-height: 36px;
  margin: 0;
}

.quick-tools input {
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
}

.quick-note {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 90px minmax(0, 1fr) 86px;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-weight: 900;
}

.quick-note span {
  color: #354246;
}

.shape-toggle,
.base-color-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

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

.shape-toggle button,
.base-color-toggle button {
  min-height: 29px;
  margin: 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.1;
  padding: 2px 3px;
}

.shape-toggle button.selected {
  border-color: var(--primary);
  background: rgba(15, 111, 100, 0.12);
  color: var(--primary-dark);
}

.shape-toggle button[data-shape-value="有"].selected,
.shape-toggle button[data-shape-value="是"].selected,
.base-color-toggle button.selected {
  border-color: #c92828;
  background: #c92828;
  color: #ffffff;
}

.pattern-input {
  width: 100%;
  min-height: 29px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.pattern-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 132, 120, 0.14);
}

.shop-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.shop-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  color: #354246;
  font-size: 13px;
  font-weight: 800;
}

.current-shop-badge {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 2px solid rgba(201, 40, 40, 0.28);
  border-radius: 8px;
  background: #fff1ee;
  color: #80321f;
  font-size: 13px;
  font-weight: 900;
}

.current-shop-badge strong {
  color: #c92828;
  font-size: 15px;
}

.shop-picker button {
  min-height: 34px;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.12;
  white-space: normal;
}

.shop-picker button:hover {
  background: #fff7ec;
}

.shop-picker button.selected {
  position: relative;
  border: 3px solid #c92828;
  background: #c92828;
  color: #ffffff;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(201, 40, 40, 0.25);
  transform: translateY(-1px) scale(1.02);
}

.shop-picker button.selected::after {
  content: "已选";
  position: absolute;
  top: -9px;
  right: -7px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #fffdf8;
  color: #c92828;
  border: 1px solid #c92828;
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
}

.switch {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

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

.switch span {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c8cbc4;
  position: relative;
  flex: 0 0 auto;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.quote-preview {
  display: grid;
  gap: 16px;
}

.sheet-block {
  display: grid;
  gap: 12px;
}

.quote-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.quote-top h2 {
  margin-top: 4px;
  font-size: 42px;
}

.price-tag {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(15, 111, 100, 0.12);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
}

.summary-grid,
.breakdown {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

.summary-grid div,
.breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(221, 212, 200, 0.74);
}

.summary-grid dt,
.breakdown dt {
  color: var(--muted);
}

.summary-grid dd,
.breakdown dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

.customer-note {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
  color: #3f332d;
  line-height: 1.55;
}

.quote-sheet {
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.confirmation-sheet {
  border-color: rgba(15, 111, 100, 0.28);
}

.quote-sheet h2 {
  margin: 0;
  padding: 18px 12px;
  color: var(--ink);
  font-family: inherit;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  background: #edf6f4;
  border-bottom: 1px solid var(--line);
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: inherit;
  font-size: 14px;
}

.quote-table th,
.quote-table td {
  min-height: 38px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
  vertical-align: middle;
}

.quote-table th {
  color: var(--muted);
  background: #fffaf0;
  font-weight: 900;
  text-align: center;
}

.quote-table td {
  background: var(--panel);
  text-align: center;
}

.quote-table td[colspan] {
  background: var(--soft);
  color: #3f332d;
  font-weight: 750;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  line-height: 1.55;
  padding-top: 14px;
  padding-bottom: 14px;
}

.quote-table .notice-title-cell {
  text-align: center;
}

.quote-table .quote-label-cell {
  background: var(--soft);
  color: #3f332d;
  font-weight: 750;
  text-align: center;
}

.quote-table .quote-price-row .quote-label-cell,
.quote-table td.quote-price-cell {
  background: #fff3dd;
}

.quote-table td.quote-price-cell {
  width: auto;
  text-align: left;
  white-space: nowrap;
}

.quote-price-label {
  display: inline;
}

.quote-price-value {
  display: inline-block;
}

.quote-price-amount {
  color: #c92828;
  font-weight: 900;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button,
.record-link {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

button:hover,
.record-link:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #334247;
}

button.secondary:hover {
  background: #1e2b30;
}

button.compact {
  width: auto;
  min-width: 112px;
  margin: 0;
}

.action-grid {
  margin-top: 18px;
}

.sheet-actions {
  margin-top: 0;
}

.copy-status {
  min-height: 20px;
  margin-top: 10px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
}

.records-panel {
  margin-top: 20px;
}

.search-box {
  width: min(420px, 100%);
}

.records-list {
  display: grid;
  gap: 12px;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.record-title {
  font-weight: 900;
  margin-bottom: 6px;
}

.record-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.record-actions {
  display: grid;
  grid-template-columns: 120px 120px;
  gap: 8px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fffaf0;
}

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

.audit-row {
  display: grid;
  grid-template-columns: 130px 180px 180px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
}

.audit-row strong {
  color: var(--ink);
}

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.admin-grid h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
}

.admin-settings-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 111, 100, 0.05);
}

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

.admin-section-title h3,
.settings-card h4 {
  margin: 0;
  color: var(--ink);
}

.admin-section-title button {
  width: auto;
  min-width: 150px;
}

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

.settings-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.settings-text-card {
  grid-column: 1 / -1;
}

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

.settings-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px 92px;
  gap: 8px;
  align-items: center;
}

.settings-card textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  padding: 10px;
  outline: none;
}

.settings-card textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 111, 100, 0.14);
}

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

.admin-user-card {
  display: grid;
  grid-template-columns: 1fr 1fr 100px 100px 130px 110px;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.admin-user-card strong {
  display: block;
  color: var(--ink);
}

.admin-user-card small {
  display: block;
  color: var(--muted);
}

.admin-user-card input,
.admin-user-card select,
.admin-create-form input,
.admin-create-form select {
  min-height: 38px;
  padding: 8px 10px;
}

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

  .result-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding: 10px 0;
  }

  .form-panel,
  .result-panel,
  .records-panel {
    padding: 18px;
  }

  .field-row,
  .switch-row,
  .summary-grid,
  .records-header,
  .record-card,
  .record-actions,
  .staff-bar,
  .audit-row,
  .dimension-head,
  .dimension-row,
  .quick-tools,
  .quick-load,
  .quick-note {
    grid-template-columns: 1fr;
  }

  .dimension-head {
    display: none;
  }

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

  .staff-bar {
    display: grid;
  }

  .records-header {
    display: grid;
  }

  .admin-create-form,
  .admin-grid,
  .admin-user-card,
  .settings-grid,
  .settings-item {
    grid-template-columns: 1fr;
  }

  .admin-section-title {
    display: grid;
  }

  .quote-top h2 {
    font-size: 34px;
  }
}
