:root {
  --bg-page: #faf8f5;
  --bg-surface: #ffffff;
  --bg-sidebar: #f2eee8;
  --bg-subtle: #f6f3ee;
  --bg-active: #fff4ee;

  --text-primary: #1c2430;
  --text-secondary: #4e5a68;
  --text-muted: #768290;

  --accent: #d95b26;
  --accent-hover: #be4b1b;
  --accent-soft: #fdebe2;

  --success: #1d6f57;
  --success-soft: #e6f4ef;
  --danger: #c53030;
  --danger-soft: #fdecec;
  --warning: #b76e00;
  --warning-soft: #fff5e0;

  --border: #e5dfd5;
  --border-strong: #d3cabd;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 2px 8px rgba(28, 36, 48, 0.05);
  --shadow-md: 0 10px 28px rgba(28, 36, 48, 0.14);

  --touch-min: 48px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ========== 登录页 ========== */
.login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top right, #f5e6d8 0%, var(--bg-page) 55%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-md);
}

.login-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 15px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .text-input {
  padding-right: 72px;
}

.btn-inline-toggle {
  position: absolute;
  right: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

/* ========== 通用按钮与表单 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch-min);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: transparent;
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-sm {
  min-height: 40px;
  padding: 0 12px;
  font-size: 15px;
}

.btn-lg {
  min-height: 54px;
  font-size: 18px;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

.btn-ghost-sm {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.btn-link-sm {
  min-height: 36px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.field-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.text-input,
.text-select,
.text-area {
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 17px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.text-select:focus,
.text-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 91, 38, 0.14);
}

.text-input-lg {
  min-height: 54px;
  font-size: 18px;
}

.text-area {
  min-height: 82px;
  resize: vertical;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
}

.form-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 14px;
  font-weight: 600;
}

/* ========== 主应用壳 ========== */
.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部固定栏 */
.topbar {
  flex: 0 0 auto;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand-row {
  justify-content: space-between;
}

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

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.view-switcher {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.view-tab {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
}

.view-tab.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* 人群大号分段切换 */
.gender-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gender-tab {
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 700;
}

.gender-tab.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

/* 搜索栏 */
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 46px;
  padding: 8px 38px 8px 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-page);
  font-size: 16px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.topbar-add-btn {
  min-height: 46px;
  padding: 0 14px;
  font-size: 15px;
}

/* ========== 主体双栏区 ========== */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* 左侧种类栏 */
.sidebar {
  width: 33%;
  min-width: 112px;
  max-width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 6px;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.sidebar-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 12px;
}

.sidebar-item {
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 12px 10px 12px 14px;
  border: none;
  border-bottom: 1px solid rgba(211, 202, 189, 0.45);
  background: transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.sidebar-item.active {
  background: var(--bg-surface);
  color: var(--accent);
}

.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 5px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.sidebar-item-name {
  font-size: 17px;
  font-weight: 700;
  word-break: break-all;
}

.sidebar-item-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.sidebar-item.active .sidebar-item-meta {
  color: var(--accent-hover);
}

.sidebar-sort-controls {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.sort-mini-btn {
  flex: 1;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.sidebar-footer {
  flex: 0 0 auto;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
}

/* 右侧内容区 */
.content-pane {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
}

.pane-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 顶部当前种类概览卡 */
.parent-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parent-banner-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.parent-banner-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.parent-banner-note {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tag-accent {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: transparent;
}

.tag-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.tag-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

/* 品种网格卡片 */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
}

.section-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.sub-card,
.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-card-head,
.product-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sub-card-name {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.sub-card-note {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.card-actions .btn {
  flex: 1 1 auto;
}

/* 添加卡片虚线框 */
.add-card-btn {
  min-height: 76px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg-active);
  color: var(--accent-hover);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* 产品库筛选胶囊 */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
}

.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.product-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.product-code {
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.product-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.product-meta {
  font-size: 14px;
  color: var(--text-secondary);
}

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

.price-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.price-chip-size {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

.price-chip-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-hover);
}

.price-chip-pending {
  font-size: 14px;
  font-weight: 700;
  color: var(--warning);
}

/* 空状态 */
.empty-box {
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 26px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.empty-desc {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
}

/* ========== 底部抽屉 Bottom Sheet ========== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 48, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.sheet-panel {
  width: 100%;
  max-width: 620px;
  max-height: 90dvh;
  background: var(--bg-surface);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.sheet-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.btn-icon-close {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
}

/* 快捷选项按钮组 */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.chip-btn.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

/* 尺码标签编辑器 */
.size-tags-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.size-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 15px;
}

.size-tag-remove {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(217, 91, 38, 0.18);
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 700;
  padding: 0;
}

.inline-add-row {
  display: flex;
  gap: 8px;
}

.inline-add-row .text-input {
  flex: 1;
}

/* 品牌联想下拉 */
.suggest-wrap {
  position: relative;
}

.suggest-list {
  margin-top: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  max-height: 180px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.suggest-item {
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background: var(--bg-active);
}

/* 产品价格行编辑 */
.price-rows-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.price-row-item {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 8px;
  align-items: center;
}

.batch-price-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  margin-bottom: 10px;
}

.batch-price-bar .text-input {
  min-height: 42px;
  font-size: 16px;
}

.sheet-footer-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-footer-actions .btn {
  flex: 1;
}

/* ========== Toast 与撤销条 ========== */
.toast-container {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  width: 100%;
  max-width: 480px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-undo-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: none;
  background: #fff;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ========== 平板横屏与桌面端适配 ========== */
@media (min-width: 768px) {
  .topbar {
    padding: 12px 20px;
  }

  .sidebar {
    width: 220px;
  }

  .content-pane {
    padding: 18px 20px 36px;
  }

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

  .sheet-backdrop {
    align-items: center;
    padding: 20px;
  }

  .sheet-panel {
    border-radius: var(--radius-lg);
    max-height: 86dvh;
  }
}

@media (min-width: 1120px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
