:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #182018;
  --muted: #667063;
  --line: #dce3d8;
  --accent: #2f6f55;
  --accent-2: #8a5b23;
  --danger: #a33a32;
  --soft: #edf4ec;
  --shadow: 0 10px 28px rgba(32, 45, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 24px;
  font-size: 24px;
}

.login-panel label,
.grid-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

input:focus,
select:focus {
  outline: 2px solid rgba(47, 111, 85, 0.16);
  border-color: var(--accent);
}

.login-panel button {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

#loginError {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
}

.shell {
  min-height: 100vh;
  padding: 18px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.metric b {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

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

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(520px, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 16px;
  margin: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head select {
  width: 120px;
}

.search {
  margin: 12px 14px;
  width: calc(100% - 28px);
}

.sku-list {
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding: 0 8px 10px;
}

.sku {
  width: 100%;
  min-height: 64px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 9px 10px;
  margin-bottom: 4px;
}

.sku.active {
  background: var(--soft);
  border-color: #bed2bf;
}

.sku strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border-color: transparent;
  background: transparent;
}

.tab.active {
  background: var(--soft);
  border-color: #bed2bf;
  color: var(--accent);
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: grid;
}

.grid-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding: 16px;
}

.grid-form h2 {
  grid-column: 1 / -1;
  padding-top: 4px;
}

.wide {
  grid-column: 1 / -1;
}

.component-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.calc-panel {
  padding: 16px;
  position: sticky;
  top: 18px;
}

.calc-result {
  display: grid;
  gap: 8px;
  margin: 12px 0 22px;
}

.calc-line,
.break-line,
.quote-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.calc-line strong {
  font-size: 22px;
}

.breakdown {
  margin-top: 10px;
}

.quote-list {
  padding: 16px;
  gap: 10px;
}

.quote-row {
  align-items: center;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.quote-row b {
  display: block;
}

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

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .calc-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 780px) {
  .shell {
    padding: 10px;
  }

  .topbar {
    display: block;
  }

  .toolbar {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .summary,
  .workspace,
  .grid-form,
  .component-grid {
    grid-template-columns: 1fr;
  }

  .sku-list {
    max-height: 260px;
  }
}
