/* Compact card/table columns for Toppo quotation generator backends.
   Goal: cards hug text width; no large empty horizontal gaps. */

/* Tables hug content; multiplier fills its card so zebra reaches the edge. */
.peak-height-table,
.calc-table,
.ref-table,
.parameter-group-grid .peak-height-table,
.parameter-group-grid .height-tax-card .calc-table,
.constants-group-grid table{
  width:max-content !important;
  max-width:100% !important;
  min-width:0 !important;
  table-layout:auto !important;
}
.multiplier-table,
.parameter-group-grid .multiplier-table{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  table-layout:auto !important;
}

/* Label / short value columns shrink to text. */
.multiplier-table th,
.peak-height-table th,
.calc-table th,
.calc-table td:nth-child(1),
.calc-table td:nth-child(2),
.ref-table th,
.ref-table td,
.decoiler-price-card .calc-table th,
.decoiler-price-card .calc-table td,
.parameter-group-grid .multiplier-table th,
.parameter-group-grid .height-tax-card .calc-table th:nth-child(1),
.parameter-group-grid .height-tax-card .calc-table td:nth-child(1),
.parameter-group-grid .height-tax-card .calc-table td:nth-child(2){
  width:1% !important;
  white-space:nowrap !important;
}

/* Input / number cells stay compact. */
.multiplier-table td,
.peak-height-table td,
.parameter-group-grid .multiplier-table td{
  width:1% !important;
  white-space:nowrap !important;
}

.multiplier-input,
.multiplier-result,
.peak-height-input,
.parameter-group-grid .multiplier-input,
.parameter-group-grid .multiplier-result{
  width:72px !important;
  min-width:72px !important;
  max-width:88px !important;
  box-sizing:border-box !important;
}

/* Long formula / description columns wrap within a modest width. */
.calc-table td:nth-child(3),
.enhance-price-card .calc-table td:nth-child(3),
.height-tax-card .calc-table td:nth-child(3),
.price-calc-card .calc-table td:nth-child(3),
.parameter-group-grid .height-tax-card .calc-table td:nth-child(3){
  width:auto !important;
  max-width:280px !important;
  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
}

/* Kill legacy huge min-widths that create empty stretch. */
.height-tax-card .calc-table,
.enhance-price-card .calc-table,
.price-calc-card .calc-table,
.decoiler-price-card .calc-table,
.g550-card .ref-table{
  min-width:0 !important;
}

.calc-table th,
.calc-table td,
.ref-table th,
.ref-table td,
.multiplier-table th,
.multiplier-table td,
.peak-height-table th,
.peak-height-table td,
.existing-quotes-table th,
.existing-quotes-table td{
  padding:8px 10px !important;
}

/* Parameter grid: 峰高/报价/文件名 288px（报价+20%）；倍率/高度按内容 */
.parameter-group-grid{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  grid-template-columns:288px max-content max-content !important;
  justify-content:start !important;
  column-gap:14px !important;
  row-gap:12px !important;
}
.parameter-group-grid > .card{
  max-width:100% !important;
  min-width:0 !important;
  box-sizing:border-box !important;
  justify-self:start !important;
}
/* 峰高 / 文件名 / 报价 同宽（报价 +20% → 288） */
.parameter-group-grid .peak-height-card,
.parameter-group-grid .filename-card,
.parameter-group-grid .generator-action-card{
  width:288px !important;
  min-width:0 !important;
  max-width:288px !important;
  box-sizing:border-box !important;
  justify-self:start !important;
}
/* 倍率：贴合文字；表宽拉满卡片，隔行色到头 */
.parameter-group-grid .multiplier-card{
  width:max-content !important;
  max-width:320px !important;
  min-width:0 !important;
  justify-self:start !important;
  overflow:hidden !important;
}
.parameter-group-grid .multiplier-table-wrap,
.parameter-group-grid .multiplier-table{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  table-layout:auto !important;
}
.parameter-group-grid .exchange-rate-status{
  max-width:100% !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  white-space:normal !important;
}
/* 高度计算：贴合文字，不吃掉整列剩余宽度 */
.parameter-group-grid .height-tax-card{
  width:max-content !important;
  max-width:100% !important;
  min-width:0 !important;
  justify-self:start !important;
}
/* 现存报价单：宽度随表格；grid 位置见 existing-quotes-layout.css（IBR 等页内联样式） */
.parameter-group-grid .existing-quotes-card{
  width:max-content !important;
  min-width:0 !important;
  max-width:100% !important;
  justify-self:start !important;
  overflow-x:auto !important;
  box-sizing:border-box !important;
}
.parameter-group-grid .existing-quotes-table-wrap{
  width:max-content !important;
  max-width:100% !important;
  overflow-x:auto !important;
}

/* Constants：全部按文字宽度，禁止 flex 拉伸 / 固定大宽 */
.constants-group-grid{
  display:flex !important;
  flex-wrap:wrap !important;
  justify-content:flex-start !important;
  align-items:flex-start !important;
  gap:14px !important;
}
.constants-group-grid > .card,
.constants-group-grid .decoiler-price-card,
.constants-group-grid .enhance-price-card,
.constants-group-grid .g550-card,
.constants-group-grid .constant-values-card,
.constants-group-grid .height-rows-card,
.constants-group-grid .packing-card,
.constants-group-grid .size-weight-card,
.constants-group-grid .price-calc-card{
  width:max-content !important;
  min-width:0 !important;
  max-width:100% !important;
  flex:0 0 auto !important;
  box-sizing:border-box !important;
}
.constants-group-grid .calc-table-wrap,
.constants-group-grid .ref-table-wrap{
  width:max-content !important;
  max-width:100% !important;
  overflow:visible !important;
}
.constants-group-grid .g550-card,
.constants-group-grid .g550-card .ref-table-wrap,
.constants-group-grid .g550-card .ref-table{
  width:max-content !important;
  min-width:0 !important;
  max-width:max-content !important;
  table-layout:auto !important;
  overflow:visible !important;
  flex:0 0 auto !important;
  align-self:flex-start !important;
}
.constants-group-grid .g550-card .ref-table th,
.constants-group-grid .g550-card .ref-table td{
  width:1% !important;
  white-space:nowrap !important;
  text-align:center !important;
  overflow:visible !important;
}

/* 现存报价单：整表按内容收缩 */
.existing-quotes-table{
  width:max-content !important;
  max-width:100% !important;
  table-layout:auto !important;
}
.existing-quotes-table th,
.existing-quotes-table td{
  width:1% !important;
  white-space:nowrap !important;
}
.existing-quotes-table th:nth-child(5),
.existing-quotes-table td:nth-child(5){
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace !important;
  font-size:12.5px !important;
}
.existing-quotes-table .existing-quote-action{
  width:auto !important;
  white-space:nowrap !important;
}

@media (max-width:900px){
  .parameter-group-grid{
    grid-template-columns:minmax(0,1fr) !important;
  }
  .parameter-group-grid .peak-height-card,
  .parameter-group-grid .generator-action-card,
  .parameter-group-grid .multiplier-card,
  .parameter-group-grid .height-tax-card,
  .parameter-group-grid .existing-quotes-card,
  .parameter-group-grid .filename-card,
  .constants-group-grid > .card{
    width:100% !important;
    min-width:0 !important;
    max-width:100% !important;
    justify-self:stretch !important;
    flex:1 1 100% !important;
  }
  .parameter-group-grid .existing-quotes-card{
    width:100% !important;
    min-width:0 !important;
    max-width:100% !important;
  }
  .parameter-group-grid .existing-quotes-table-wrap,
  .existing-quotes-table{
    width:100% !important;
    max-width:100% !important;
  }
  .multiplier-input,
  .multiplier-result,
  .peak-height-input,
  .parameter-group-grid .multiplier-input,
  .parameter-group-grid .multiplier-result{
    width:100% !important;
    max-width:100% !important;
  }
  .calc-table,
  .ref-table,
  .constants-group-grid table{
    width:100% !important;
  }
  .calc-table td:nth-child(3),
  .enhance-price-card .calc-table td:nth-child(3),
  .height-tax-card .calc-table td:nth-child(3),
  .price-calc-card .calc-table td:nth-child(3){
    max-width:none !important;
  }
}
