:root {
  --ink: #1c1914;
  --muted: #6b6458;
  --line: #d8cfc0;
  --paper: #f4efe6;
  --sheet: #fffaf2;
  --accent: #8c2f1b;
  --accent-soft: #f3ddd4;
  --focus: #2b4c6f;
  --shadow: 0 18px 50px rgba(48, 36, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ec 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #efe4d2 0%, transparent 50%),
    var(--paper);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sheet {
  width: min(1080px, calc(100% - 32px));
  margin: 40px auto 64px;
  padding: 40px 40px 32px;
  background: var(--sheet);
  border: 1px solid #eadfcd;
  box-shadow: var(--shadow);
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: 0 -40px;
  padding: 10px 40px 14px;
  /* Keep opaque so rows don't show through; same token as .sheet so grain overlays match */
  background-color: var(--sheet);
}

.masthead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.22em;
  font-size: 11px;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.lede {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.print-tab {
  display: none;
  margin: 8px 0 0;
  font-family: "Shippori Mincho", "Yu Mincho", serif;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.tabs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.tab-list {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.tab {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  max-width: 100%;
  padding: 0 4px 0 2px;
  border: 1px solid #e8dfd0;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #efe6d6;
  color: #7a7264;
  opacity: 0.9;
}

.tab.is-active,
.tab.is-selected {
  opacity: 1;
  border-color: var(--line);
  color: var(--ink);
}

.tab.is-active {
  background: var(--sheet);
  box-shadow: inset 0 -1px 0 var(--sheet);
  position: relative;
  z-index: 1;
}

.tab.is-selected {
  background: #e6d7bf;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.tab.is-active.is-selected {
  background: var(--sheet);
  box-shadow: inset 0 -1px 0 var(--sheet), inset 0 -3px 0 var(--accent);
}

.tab.drag-over {
  opacity: 1;
  box-shadow: inset 0 -3px 0 var(--accent);
  color: var(--accent);
}

.tab.dragging {
  opacity: 0.45;
}

.tab-label {
  display: block;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 9px 10px;
  cursor: pointer;
}

.tab-label[hidden] {
  display: none;
}

.tab-rename {
  width: 8.5em;
  margin: 6px 6px 6px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.tab-rename:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.tab-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
}

.tab-close[hidden] {
  display: none;
}

.tab-close:hover,
.tab-close:focus-visible {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.tab-add {
  appearance: none;
  flex: 0 0 auto;
  margin-bottom: 6px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-add:hover,
.tab-add:focus-visible {
  color: var(--ink);
  border-color: #c9bda8;
  outline: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
}

.controls .tab-add {
  margin-bottom: 0;
  margin-left: auto;
}

.search {
  flex: 1 1 240px;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 999px;
}

.search input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.result-count {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.head-tools {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 2px 4px;
  width: 100%;
  min-height: 28px;
}

.col-handle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 28px;
}

.col-handle[hidden] {
  display: none;
}

.data-head.dragging {
  opacity: 0.45;
}

.data-head.drag-over,
th.col-action.drag-over {
  box-shadow: inset 2px 0 0 var(--accent);
}

.sort-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.sort-btn:hover,
.sort-btn.is-active {
  color: var(--ink);
}

.sort-btn:disabled {
  cursor: default;
  color: inherit;
}

.sort-mark {
  font-size: 10px;
  margin-left: 2px;
}

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

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

.excel-actions {
  margin-left: auto;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover {
  border-color: #c9bda8;
}

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

.btn.ghost {
  background: transparent;
}

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

body.is-multi-select .price-row {
  cursor: pointer;
}

body.is-multi-select .price-row .field input:read-only {
  cursor: pointer;
}

.table-wrap {
  padding-top: 2px;
}

.price-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
}

.price-table th,
.price-table td {
  border-right: 1px solid var(--line);
  vertical-align: middle;
}

.price-table th:last-child,
.price-table td:last-child {
  border-right: 0;
}

.price-table th {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 10px;
  border-bottom: 2px solid var(--ink);
  background: #f8f1e6;
}

.price-table thead th {
  position: sticky;
  top: var(--sticky-head-offset, 0px);
  z-index: 6;
  text-align: center;
  background: #f8f1e6;
  box-shadow: 0 1px 0 var(--ink);
}

.price-row td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.price-row:hover {
  background: #fbf6ec;
}

.price-row.is-selected {
  background: #f3e8d4;
}

.price-row.is-selected:hover {
  background: #efe2ca;
}

.field {
  display: block;
}

.field input {
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: default;
}

.field input[type="text"] {
  width: auto;
  min-width: 5em;
  field-sizing: content;
}

.field input:read-only {
  caret-color: transparent;
}

.field input.is-editing,
.field input:not(:read-only) {
  cursor: text;
}

.field input.is-editing:hover,
.field input:not(:read-only):hover {
  background: #fff;
  border-color: #eadfcd;
}

.field input.is-editing:focus,
.field input:not(:read-only):focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  background: #fff;
}

.col-order {
  width: 4.5em;
  min-width: 4.5em;
  white-space: nowrap;
}

th.col-order,
td.col-order,
th.col-action,
th.col-no {
  text-align: center;
}

.drag-handle {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #a39684;
  font-size: 16px;
  letter-spacing: -2px;
  line-height: 1;
  cursor: grab;
  border-radius: 6px;
}

.drag-handle:hover,
.drag-handle:focus-visible {
  color: var(--ink);
  background: #efe6d6;
  outline: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:disabled {
  opacity: 0.28;
  cursor: default;
}

.price-row.dragging {
  opacity: 0.45;
}

.price-row.drag-over {
  box-shadow: inset 0 2px 0 var(--accent);
}

.price-row.drag-over.copy-drop {
  box-shadow: inset 0 2px 0 var(--focus);
}

body.is-copy-drag,
body.is-copy-drag .drag-handle {
  cursor: copy;
}

.col-size {
  min-width: 7em;
  white-space: nowrap;
}

.col-size input {
  font-weight: 600;
  overflow: visible;
}

.col-dim {
  min-width: 12em;
  white-space: nowrap;
}

.dim-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field.dim {
  width: 4.5em;
  flex: 0 0 auto;
}

.field.dim input {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.times {
  color: var(--muted);
  font-size: 13px;
}

.col-price {
  min-width: 7em;
}

th.col-price {
  text-align: center;
  white-space: nowrap;
}

.field.price {
  width: 6em;
}

.field.price input {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.col-no {
  width: 6%;
  min-width: 4.5em;
  text-align: center;
  white-space: nowrap;
}

.col-no .head-tools {
  flex-wrap: nowrap;
  justify-content: center;
}

.col-no .sort-label {
  white-space: nowrap;
}

.row-no {
  display: block;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.col-note {
  min-width: 8em;
}

.col-note input {
  color: var(--muted);
  font-size: 13px;
  min-width: 6em;
}

.col-action {
  white-space: nowrap;
}

td.col-action {
  text-align: right;
}

.icon-btn:disabled {
  opacity: 0.28;
  cursor: default;
  background: transparent;
  color: var(--muted);
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
}

.hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.empty-row td {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 720px) {
  .sheet {
    margin-top: 16px;
    padding: 24px 16px 20px;
  }

  .sticky-head {
    margin: 0 -16px;
    padding: 8px 16px 12px;
  }

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

  .field.dim {
    width: 4em;
  }
}

@media print {
  body {
    background: #fff;
  }

  .grain,
  .toolbar,
  .controls,
  .tabs,
  .hint,
  .col-order,
  .col-action,
  .col-handle {
    display: none !important;
  }

  .print-tab {
    display: block;
  }

  .sheet {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .sticky-head {
    position: static;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .field input {
    border: 0;
  }
}
