.demo-wholesale {
  --navy: #1B3A4B;
  --teal: #2A9D8F;
  --teal-deep: #1D7167;
  --white: #FAFAF7;
  --paper: #F2F0E8;
  --ink: #233138;
  --ink-soft: #5C6B70;
  --line: #DCD8CC;
  --profit: #3C8C5C;
  --loss: #C44545;
  background: var(--paper);
}
.demo-wholesale * { box-sizing: border-box; }
.demo-wholesale main { max-width: 1040px; margin: 0 auto; padding: 32px 20px 80px; }
.demo-wholesale h1 { font-size: 22px; margin: 0 0 4px; }
.demo-wholesale .subhead { color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 24px;
}
.tab-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 22px;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transform: translateY(2px);
  transition: color 0.15s ease;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--teal-deep); border-bottom-color: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.profit-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 28px;
}
.profit-cell { background: var(--white); padding: 18px 20px; text-align: center; }
.profit-cell .label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.profit-cell .value { font-size: 22px; font-weight: 700; color: var(--ink); }
.profit-cell.net { background: #F4FAF6; }
.profit-cell.net .value { color: var(--profit); }
.profit-cell.net .value.minus { color: var(--loss); }

section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 28px;
  overflow: hidden;
}
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #FBFAF6;
  flex-wrap: wrap;
  gap: 8px;
}
.sec-head h2 { font-size: 15px; margin: 0; }
.sec-head .date { font-size: 12px; color: var(--ink-soft); }
.sec-head .add-btn {
  background: var(--teal);
  color: var(--white);
  border: none;
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.sec-head .add-btn:hover { background: var(--teal-deep); }

table.stock { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.stock th, table.stock td { padding: 11px 18px; text-align: left; border-bottom: 1px solid var(--line); }
table.stock th { background: #F4F2EA; font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
table.stock th.col-amt,
table.stock th.col-yen,
table.stock td.amt,
table.stock td.yen {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.stock th.col-amt,
table.stock td.amt { width: 100px; }
table.stock th.col-yen,
table.stock td.yen { width: 130px; }
table.stock td.amt { font-weight: 700; color: var(--teal-deep); }
table.stock td.yen { font-weight: 700; color: var(--ink); }
table.stock tr:last-child td { border-bottom: none; }
table.stock tr.new-row { animation: flashIn 1.1s ease; }
@keyframes flashIn { 0% { background: #DCEFEC; } 100% { background: transparent; } }

.chart-wrap { padding: 20px 24px 8px; }
.stacked-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.stacked-row .label { color: var(--ink); font-weight: 600; line-height: 1.4; }
.stacked-bar-area {
  background: #EFEDE3;
  border-radius: 3px;
  height: 22px;
  overflow: hidden;
}
.stacked-track {
  display: flex;
  height: 100%;
  min-width: 0;
  transition: width 0.7s ease;
}
.stack-seg {
  height: 100%;
  min-width: 3px;
  transition: opacity 0.15s ease;
}
.stack-seg:first-child { border-radius: 3px 0 0 3px; }
.stack-seg:last-child { border-radius: 0 3px 3px 0; }
.stack-seg:only-child { border-radius: 3px; }
.stack-seg:hover { opacity: 0.85; }
.stacked-row .val {
  text-align: right;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 0 18px;
  font-size: 12px;
  color: var(--ink-soft);
}
.chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
@media (max-width: 600px) {
  .stacked-row {
    grid-template-columns: 1fr 90px;
    grid-template-rows: auto auto;
    gap: 6px 12px;
  }
  .stacked-row .label { grid-column: 1 / -1; }
  .stacked-bar-area { grid-column: 1; }
  .stacked-row .val { grid-column: 2; grid-row: 2; }
}

.hint { padding: 10px 24px 18px; font-size: 12px; color: var(--ink-soft); }

.batch-list { padding: 4px 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.batch-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.batch-card:hover { box-shadow: 0 4px 14px rgba(27,58,75,0.08); transform: translateY(-1px); }
.batch-card.new-row { animation: flashIn 1.2s ease; }
.batch-top {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.batch-top .b-title { font-size: 14.5px; font-weight: 700; }
.batch-top .b-margin { font-size: 12.5px; font-weight: 700; }
.batch-top .b-margin.minus { color: var(--loss); }
.batch-top .b-margin.plus { color: var(--profit); }
.batch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  font-size: 12px;
}
@media (max-width: 760px) {
  .batch-grid { grid-template-columns: repeat(2, 1fr); }
}
.batch-grid .bg-item .bg-label { color: var(--ink-soft); font-size: 11px; margin-bottom: 3px; }
.batch-grid .bg-item .bg-value { font-weight: 700; font-size: 13px; color: var(--ink); }
.batch-grid .bg-item.yield .bg-value { color: var(--teal-deep); }
.empty-state { padding: 32px 20px; text-align: center; color: var(--ink-soft); font-size: 13px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 75, 0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 6px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
  margin: auto;
}
.modal-head {
  background: var(--navy);
  color: var(--white);
  padding: 16px 20px;
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close { background: none; border: none; color: var(--white); font-size: 18px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-body .field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.field select, .field input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px;
  font-size: 13.5px; background: var(--white); color: var(--ink); font-family: inherit;
}
.field select:focus, .field input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px 20px; }
button.btn-cancel {
  background: none; border: 1px solid var(--line); color: var(--ink-soft);
  padding: 9px 18px; border-radius: 4px; font-size: 13px; cursor: pointer; font-family: inherit;
}
button.btn-submit {
  background: var(--teal); color: var(--white); border: none;
  padding: 9px 20px; border-radius: 4px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background 0.15s ease;
}
button.btn-submit:hover { background: var(--teal-deep); }
button.btn-submit:disabled { background: #B9CFCB; cursor: default; }

.calc-preview {
  grid-column: 1 / -1;
  background: #F4FAF6;
  border: 1px solid #CFE6D6;
  border-radius: 4px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
  font-size: 12px;
}
.calc-preview .cp-item .cp-label { color: var(--ink-soft); font-size: 11px; }
.calc-preview .cp-item .cp-value { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.calc-preview .cp-item.margin .cp-value.plus { color: var(--profit); }
.calc-preview .cp-item.margin .cp-value.minus { color: var(--loss); }

.detail-modal-body { display: flex; flex-direction: column; gap: 0; padding: 4px 20px 8px; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.detail-row:last-child { border-bottom: none; }
.d-label { color: var(--ink-soft); font-size: 12.5px; }
.d-value { font-weight: 700; color: var(--ink); text-align: right; }
.d-value.plus { color: var(--profit); }
.d-value.minus { color: var(--loss); }

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: var(--white); padding: 12px 22px; border-radius: 6px;
  font-size: 13px; opacity: 0; transition: all 0.25s ease; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  .profit-bar { grid-template-columns: 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .calc-preview { grid-template-columns: 1fr; }
}
