/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  /* 底部导航高度与安全区：移动端媒体查询会覆盖 --nav-h；
     --safe-bottom 用 @supports 单独赋值，避免在不支持 env() 的
     WebView（企业微信/旧安卓）里 calc() 整条失效导致定位错乱 */
  --nav-h: 0px;
  --safe-bottom: 0px;
}

@supports (bottom: env(safe-area-inset-bottom)) {
  :root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶部导航 ===== */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

/* ===== 产品线选择器 ===== */
.product-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 56px;
  z-index: 99;
  overflow-x: auto;
}

.product-tabs {
  display: flex;
  gap: 4px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 0;
}

.product-tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
}

.product-tab:hover {
  background: var(--bg);
  color: var(--text);
}

.product-tab.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.navbar-brand {
  font-size: 16px;
  font-weight: 700;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand .navbar-logo {
  height: 36px;
  width: auto;
  display: block;
}

.navbar-brand .navbar-divider {
  width: 1px;
  height: 26px;
  background: #dc2626;
}

.navbar-brand .navbar-company {
  color: #dc2626;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-tab:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-tab.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== 主容器 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 96px 20px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== 表单 ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label .hint {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 400;
}

.form-input,
.form-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.with-suffix {
  padding-right: 56px;
}

.input-wrapper {
  position: relative;
}

.input-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-light);
  pointer-events: none;
}

/* ===== 大号输入框卡片 ===== */
.big-input-card {
  padding: 16px 20px;
}

.big-input-card.big-input-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
}

.big-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.big-input-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.big-input-title::before {
  content: '';
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
}

.big-input-primary .big-input-title::before {
  background: rgba(255, 255, 255, 0.9);
}

.big-input-subtitle {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}

.big-input-body {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.big-input-primary .big-input-body {
  background: rgba(255, 255, 255, 0.2);
}

.big-input-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.big-input-grid.big-input-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.big-input-field {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 76px;
}

.big-input-primary .big-input-field {
  background: rgba(255, 255, 255, 0.2);
}

.big-input-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.big-input-primary .big-input-label {
  color: rgba(255, 255, 255, 0.85);
}

.big-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  outline: none;
  line-height: 1.2;
  padding: 0 40px 0 0;
}

.big-input::placeholder {
  color: var(--text-light);
  opacity: 0.6;
}

.big-input-primary .big-input {
  color: white;
}

.big-input-primary .big-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.big-input-unit {
  position: absolute;
  right: 12px;
  bottom: 14px;
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

.big-input-grid-4 .big-input-field {
  align-items: center;
  text-align: center;
}

.big-input-grid-4 .big-input {
  text-align: center;
  font-size: 26px;
}

.big-input-grid-4 .big-input-unit {
  position: static;
  font-size: 12px;
  margin-top: 2px;
}

/* 单字段大卡片（母卷单价/利润率） */
.big-input-single {
  display: flex;
  justify-content: center;
}

.big-input-single .big-input-field {
  width: 100%;
  max-width: 320px;
  align-items: center;
  text-align: center;
  min-height: 64px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.big-input-single .big-input {
  text-align: center;
  font-size: 30px;
  padding-right: 50px;
}

.big-input-single .big-input-unit {
  position: absolute;
  right: 16px;
  bottom: 18px;
  font-size: 14px;
}

.big-input-primary .big-input-unit {
  color: rgba(255, 255, 255, 0.8);
}

/* 配比显示 */
.ratio-display {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  text-align: center;
}

/* ===== 规格网格 ===== */
.spec-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.spec-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ratio-display strong {
  font-size: 15px;
}

/* 费率选项按钮组 */
.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.option-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.option-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-btn .rate {
  font-size: 11px;
  color: var(--text-light);
  margin-left: 4px;
}

.option-btn.active .rate {
  color: rgba(255, 255, 255, 0.8);
}

/* ===== 结果展示 ===== */
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.result-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  padding: 20px;
  color: white;
  text-align: center;
}

.result-card.full-width {
  grid-column: 1 / -1;
}

.result-card .label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.result-card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.result-card .unit {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.85;
}

/* 明细表 */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.detail-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.detail-table td.num {
  text-align: right;
  font-family: "SF Mono", "Consolas", monospace;
  font-weight: 500;
}

.detail-table tr:last-child td {
  border-bottom: none;
}

/* 公式展示 */
.formula-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.formula-box code {
  background: var(--card-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 12px;
  color: var(--primary);
}

/* ===== 按钮 ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-success:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ===== 历史记录 ===== */
.history-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: box-shadow 0.2s;
}

.history-item:hover {
  box-shadow: var(--shadow-lg);
}

.history-info {
  flex: 1;
}

.history-info .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.history-info .meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.history-info .meta span {
  display: flex;
  align-items: center;
  gap: 2px;
}

.history-prices {
  text-align: right;
  margin-right: 16px;
}

.history-prices .main-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.history-prices .sub-price {
  font-size: 12px;
  color: var(--text-light);
}

.history-actions {
  display: flex;
  gap: 6px;
}

/* 搜索栏 */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-bar .form-input {
  flex: 1;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ===== 设置页面 ===== */
.config-section {
  margin-bottom: 24px;
}

.config-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid var(--primary);
}

.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.config-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 500;
  border: 1px solid var(--border);
}

.config-table td {
  padding: 6px 12px;
  border: 1px solid var(--border);
}

.config-table .form-input {
  padding: 6px 10px;
  font-size: 13px;
}

.config-table td:first-child {
  width: 40px;
  text-align: center;
  color: var(--text-light);
}

/* ===== 底部导航（默认隐藏，手机端显示） ===== */
.bottom-nav {
  display: none;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  :root {
    --nav-h: 56px;
  }

  /* ---- 顶部导航 ---- */
  .navbar {
    padding: 0 12px;
    height: 50px;
  }

  .navbar-brand {
    font-size: 14px;
    gap: 8px;
  }

  .navbar-brand .navbar-logo {
    height: 30px;
  }

  .navbar-brand .navbar-divider {
    height: 22px;
  }

  .navbar-brand .navbar-company {
    font-size: 14px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 隐藏顶部导航tabs，改用底部导航 */
  .nav-tabs-top {
    display: none;
  }

  /* ---- 底部导航 ---- */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  }

  .bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-btn.active {
    color: var(--primary);
  }

  .bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
  }

  .bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
  }

  /* ---- 底部实时报价栏（手机端改两列网格，避免横排挤压截断） ---- */
  .quote-bar {
    bottom: calc(var(--nav-h) + var(--safe-bottom));
    padding: 8px 12px;
    gap: 4px 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .quote-bar.show {
    display: grid;
  }

  .quote-bar .qb-item {
    min-width: 0;
  }

  .quote-bar .qb-label {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .quote-bar .qb-value {
    font-size: 15px;
  }

  .quote-bar .qb-value.strong {
    font-size: 17px;
  }

  /* ---- 主容器（预留底部导航 + 报价栏空间） ---- */
  .container {
    padding: 12px 12px calc(var(--nav-h) + var(--safe-bottom) + 130px) 12px;
  }

  /* ---- 产品线选择器 ---- */
  .product-bar {
    padding: 0 8px;
    top: 50px;
  }

  .product-tabs {
    gap: 4px;
    padding: 6px 0;
  }

  .product-tab {
    padding: 8px 14px;
    font-size: 13px;
    flex-shrink: 0;
  }

  /* ---- 卡片 ---- */
  .card {
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 10px;
  }

  .card-title {
    font-size: 15px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  /* ---- 表单 ---- */
  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .form-group {
    gap: 4px;
  }

  .form-group.full {
    grid-column: 1 / -1;
  }

  .form-label {
    font-size: 13px;
  }

  /* 大号输入框 */
  .big-input-card {
    padding: 14px 16px;
  }

  .big-input-grid {
    gap: 8px;
  }

  .big-input-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .spec-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .spec-grid-2 {
    gap: 10px;
  }

  .big-input-single .big-input {
    font-size: 26px;
  }

  .big-input-grid-4 .big-input {
    font-size: 22px;
    padding-right: 0;
  }

  .big-input-field {
    min-height: 68px;
    padding: 8px 10px;
  }

  .big-input-label {
    font-size: 12px;
  }

  .big-input {
    font-size: 24px;
    padding-right: 36px;
  }

  .big-input-unit {
    font-size: 11px;
    right: 10px;
    bottom: 11px;
  }

  /* 输入框：16px防止iOS聚焦缩放 */
  .form-input,
  .form-select {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
    min-height: 44px;
  }

  .form-input.with-suffix {
    padding-right: 60px;
  }

  .input-suffix {
    right: 10px;
    font-size: 12px;
  }

  /* 配比显示 */
  .ratio-display {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* ---- 选项按钮组（增大触摸区域） ---- */
  .option-group {
    gap: 8px;
  }

  .option-btn {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 40px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
  }

  .option-btn .rate {
    font-size: 12px;
  }

  /* ---- 结果展示 ---- */
  .result-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .result-card {
    padding: 16px 12px;
    border-radius: 10px;
  }

  .result-card.full-width {
    grid-column: 1 / -1;
  }

  .result-card .label {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .result-card .value {
    font-size: 22px;
  }

  .result-card .unit {
    font-size: 13px;
  }

  /* ---- 明细表 ---- */
  .detail-table {
    font-size: 13px;
  }

  .detail-table th,
  .detail-table td {
    padding: 8px 10px;
  }

  /* ---- 操作按钮栏 ---- */
  .action-bar {
    flex-direction: column;
    gap: 8px;
  }

  .action-bar-main {
    min-width: 0;
    padding: 14px;
    font-size: 16px;
    min-height: 48px;
  }

  .action-bar-side {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }

  .action-bar-side .btn {
    padding: 12px 8px;
    font-size: 14px;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }

  /* ---- 按钮 ---- */
  .btn {
    padding: 10px 16px;
    font-size: 15px;
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 13px;
  }

  .btn-block {
    width: 100%;
  }

  /* ---- 历史记录 ---- */
  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }

  .history-info .title {
    font-size: 15px;
  }

  .history-info .meta {
    font-size: 12px;
    gap: 8px;
  }

  .history-prices {
    text-align: left;
    margin-right: 0;
    width: 100%;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .history-prices .main-price {
    font-size: 20px;
  }

  .history-prices .sub-price {
    font-size: 12px;
  }

  .history-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .history-actions .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* 搜索栏 */
  .search-bar {
    flex-direction: row;
    gap: 8px;
    margin-bottom: 12px;
  }

  .search-bar .form-input {
    flex: 1;
  }

  .search-bar .btn {
    white-space: nowrap;
    padding: 10px 14px;
  }

  /* 空状态 */
  .empty-state {
    padding: 48px 20px;
  }

  .empty-state .icon {
    font-size: 40px;
  }

  /* ---- 设置页面 ---- */
  .config-section {
    margin-bottom: 16px;
  }

  /* 配置表横向滚动 */
  .config-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .config-table thead,
  .config-table tbody,
  .config-table tr {
    display: table;
    width: 100%;
    table-layout: auto;
  }

  .config-table .form-input {
    padding: 8px 10px;
    font-size: 15px;
    min-height: 40px;
  }

  .config-table td:first-child {
    width: 36px;
  }

  /* ---- 弹窗（手机端全屏化） ---- */
  .modal-overlay {
    align-items: stretch;
  }

  .modal-box {
    border-radius: 0;
    padding: 16px;
    max-height: 100vh;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-box-sm {
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: 100vh;
    padding: 24px 20px;
    border-radius: 0;
    margin: auto;
  }

  .modal-box-lg {
    max-width: 100%;
    width: 100%;
  }
}

/* ===== 超小屏（≤375px）进一步优化 ===== */
@media (max-width: 375px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .result-card .value {
    font-size: 20px;
  }

  .action-bar-side {
    grid-template-columns: 1fr 1fr;
  }

  .action-bar-side .btn:last-child {
    grid-column: 1 / -1;
  }
}

/* ===== 横屏适配 ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-box-sm {
    max-width: 400px;
    height: auto;
    max-height: 90vh;
    border-radius: var(--radius);
    margin: auto;
  }
}

/* ===== 工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-light); }
.font-bold { font-weight: 700; }
.font-mono { font-family: "SF Mono", "Consolas", monospace; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }

/* ===== 弹窗（通用） ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-box-sm {
  max-width: 360px;
  width: 90%;
  padding: 32px;
}

.modal-box-lg {
  max-width: 600px;
  width: 90%;
}

/* ===== 底部实时报价栏 ===== */
.quote-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  z-index: 99;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

.quote-bar.show {
  display: flex;
}

.quote-bar .qb-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.quote-bar .qb-label {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}

.quote-bar .qb-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-bar .qb-value.strong {
  font-size: 20px;
}

.quote-bar .qb-unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
  margin-left: 2px;
}

/* 纸管达标徽标 */
.tube-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

.tube-badge.ok {
  background: var(--success-light, #dcfce7);
  color: var(--success, #16a34a);
}

.tube-badge.warn {
  background: #fef3c7;
  color: #b45309;
}

/* ===== 操作按钮栏 ===== */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: stretch;
}

.action-bar-main {
  flex: 1;
  min-width: 120px;
}

.action-bar-side {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-bar-side .btn {
  white-space: nowrap;
}

/* Toast 提示 */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}

/* 加载动画 */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 特殊处理选项弹出动画 */
.pop-in {
  animation: popIn 0.28s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 缠绕膜检测数值 - 框线展示 ===== */
.spec-box {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 14px;
  background: var(--surface-2, rgba(0,0,0,0.02));
}
.spec-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-left: 2px;
}
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.spec-cell {
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface, #fff);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.spec-cell:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.spec-name {
  font-size: 11px;
  color: var(--text-secondary);
}
.spec-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* ===== 特种胶 幅宽利用 / 排刀浪费率 醒目面板（基础参数框底部） ===== */
.cut-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--primary-light);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(37,99,235,0.06), rgba(37,99,235,0.02));
}
.cut-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.cut-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.cut-stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}
.cut-stat .v {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.cut-stat .v .u {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-light);
  margin-left: 1px;
}
.cut-stat .v.primary { color: var(--primary); }
.cut-stat .v.danger { color: var(--danger); }
.cut-stat .k {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.cut-bar {
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  background: var(--border);
}
.cut-bar .used { background: var(--primary); }
.cut-bar .waste { background: var(--danger); }
.cut-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.cut-bar-label .waste-text { color: var(--danger); font-weight: 600; }
.cut-empty {
  font-size: 12px;
  color: var(--text-secondary);
}
.cut-empty strong { color: var(--text); }

@media (max-width: 520px) {
  .cut-stats { grid-template-columns: repeat(2, 1fr); }
}

