:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d8dee8;
  --accent: #2563eb;
  --accent-2: #0f766e;
  --warn: #b45309;
  --good: #15803d;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.locked {
  visibility: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #eef2f8;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
  font-weight: 700;
}

.brand-mark img {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

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

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sidebar-actions .primary-btn {
  grid-column: span 2;
}

#accountBtn {
  grid-column: span 2;
}

.store-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.store-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
}

.store-chip.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 700;
}

.primary-btn,
.ghost-btn {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 12px;
  white-space: nowrap;
}

.primary-btn {
  color: white;
  background: var(--accent);
}

.ghost-btn {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
}

.ghost-btn.compact {
  min-height: 32px;
  padding: 0 10px;
}

.import-btn {
  position: relative;
  display: grid;
  place-items: center;
}

.import-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.product-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  text-align: left;
}

.product-item.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.product-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

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

.product-item span span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill {
  min-width: 44px;
  padding: 4px 6px;
  border-radius: 999px;
  color: var(--accent-2);
  background: #dff7f2;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

.product-title-input {
  width: min(520px, 52vw);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  background: transparent;
  font-size: 22px;
  font-weight: 700;
}

.product-title-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.product-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.meta-select,
.series-input {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--text);
  background: #fff;
  font-size: 12px;
}

.series-input {
  width: 180px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 8px;
  min-width: 520px;
}

.summary-card {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

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

.content-grid {
  display: grid;
  grid-template-columns: minmax(520px, 0.96fr) minmax(460px, 1.04fr);
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.editor-panel,
.chart-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.tab {
  min-height: 36px;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

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

.field-input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  text-align: right;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field.calculated {
  background: #f8fafc;
}

.field.calculated .field-input {
  color: #334155;
  background: #eef2f7;
}

.field.full {
  grid-column: span 2;
}

.chart-panel {
  display: flex;
  min-height: 640px;
  flex-direction: column;
  padding: 14px;
}

.chart-toolbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-toolbar h2 {
  margin: 0;
  font-size: 18px;
}

.chart-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.radar-chart {
  min-height: 480px;
  flex: 1;
}

.formula-box {
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 10px 12px;
  background: #eef2ff;
}

.formula-box h3 {
  margin: 0 0 4px;
  color: #1e3a8a;
  font-size: 13px;
}

.formula-box p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.45;
}

.readonly-table {
  grid-column: span 2;
  width: 100%;
  border-collapse: collapse;
}

.readonly-table th,
.readonly-table td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

.readonly-table th {
  background: #f2f4f7;
  color: #334155;
  font-size: 12px;
}

.readonly-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.auth-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
}

.auth-overlay.hidden,
.modal-backdrop.hidden {
  display: none;
}

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

.auth-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.auth-title h2,
.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.auth-title p,
.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

.auth-field input,
.employee-form input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.auth-error {
  min-height: 18px;
  margin: 4px 0 10px;
  color: #b91c1c;
  font-size: 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 20px;
  line-height: 1;
}

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

.employee-manager.hidden {
  display: none;
}

.employee-manager h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.employee-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.employee-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.employee-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
}

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

.employee-row button {
  border: 0;
  color: #b91c1c;
  background: transparent;
}

.logout-btn {
  width: 100%;
  margin-top: 14px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

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

  .summary-strip {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 360px;
  }

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

  .product-title-input {
    width: 100%;
  }

  .content-grid {
    padding: 10px;
  }

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

  .field.full,
  .readonly-table {
    grid-column: span 1;
  }

  .employee-form {
    grid-template-columns: 1fr;
  }
}
