:root {
  color-scheme: light;
  --background: #fcfafb;
  --surface: #fff;
  --ink: #242028;
  --muted: #6e646e;
  --line: #ebe3e9;
  --rose: #e879a0;
  --rose-soft: #fcebf2;
  --rose-dark: #80284c;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }
button {
  min-height: 42px; padding: 9px 15px; border: 1px solid transparent;
  border-radius: 10px; background: var(--rose); color: #371525;
  font-weight: 700; font-size: .875rem; cursor: pointer;
}
button:hover:not(:disabled) { background: #f095b5; }
button.alt { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.alt:hover:not(:disabled) { background: var(--rose-soft); border-color: #efcad9; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 3px solid #ac436c; outline-offset: 3px; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.6; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1240px; margin: auto; padding: 14px 32px; min-height: 72px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.12rem; font-weight: 800; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--rose-soft); border-radius: 11px; color: var(--rose-dark);
}
.bag { width: 15px; height: 13px; border: 1.7px solid currentColor; border-radius: 2px 2px 4px 4px; position: relative; margin-top: 4px; }
.bag::before { content: ""; position: absolute; width: 5px; height: 5px; border: 1.7px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; left: 3.3px; top: -6px; }
.icon-button { display: inline-grid; place-items: center; min-width: 44px; padding: 0 10px; font-size: 1.3rem; }
main { max-width: 1240px; margin: auto; padding: 38px 32px 64px; }
.overview { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.035em; }
.stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-bottom: 28px; }
.stat, .inventory, .welcome { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.stat { padding: 19px 22px; display: grid; gap: 9px; }
.stat-label { font-size: .85rem; font-weight: 650; color: var(--muted); }
.stat-label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--rose); }
.stat:nth-child(2) .stat-label::before { background: #698d78; }
.stat:nth-child(3) .stat-label::before { background: #9476ad; }
.stat strong { font-size: clamp(1.35rem, 4vw, 2rem); font-variant-numeric: tabular-nums; line-height: 1.15; }
.inventory { overflow: hidden; }
.inventory-head { padding: 20px 22px 16px; }
.inventory-head h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 9px; }
#count { color: var(--rose-dark); background: var(--rose-soft); border-radius: 999px; font-size: .75rem; padding: 4px 9px; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; }
.search { width: min(100%, 350px); }
.toolbar-actions { display: flex; gap: 8px; }
input:not([type=file]), select {
  width: 100%; min-height: 43px; padding: 9px 12px; border: 1px solid #ded3dc;
  border-radius: 9px; color: var(--ink); background: white; font-size: .94rem;
}
input::placeholder { color: #786b76; }
input[readonly] { background: #f7f3f6; }
select { accent-color: var(--rose-dark); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; padding: 12px 10px; overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
th { background: #faf6f8; color: #625763; font-weight: 700; }
td { border-top: 1px solid var(--line); }
td:nth-child(2) { font-weight: 650; }
td button { min-height: 36px; padding: 6px 11px; }
.status { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #f3edf2; color: #5c4c5a; white-space: nowrap; font-size: .75rem; }
.status-listed { background: #e8f4ec; color: #365c45; }
.status-sold { background: var(--rose-soft); color: var(--rose-dark); }
.empty-row td { padding: 32px 22px; text-align: center; color: var(--muted); }
.view-toggle, .pagination { display: flex; align-items: center; gap: 8px; }
.pagination { justify-content: flex-end; padding: 12px 16px; }
.view-toggle { margin-top: 10px; }
.view-toggle button[aria-pressed=true] { background: var(--rose-soft); color: var(--rose-dark); }
.product-cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(175px,1fr)); gap: 14px; padding: 0 16px 16px; }
.product-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list-note { padding: 12px 22px; border-top: 1px solid var(--line); }
.welcome { max-width: 500px; margin: 72px auto; padding: 36px; text-align: center; display: grid; justify-items: center; gap: 14px; }
#msg:not(:empty), #settingsMessage:not(:empty), #editorMessage:not(:empty) {
  padding: 11px 14px; margin-bottom: 15px; border-radius: 9px; background: #eef7f1;
  color: #29533a; font-size: .86rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
#msg.error, #settingsMessage.error, #editorMessage.error { background: var(--rose-soft); color: #802044; }
dialog {
  width: min(100% - 28px, 560px); max-height: calc(100dvh - 28px); padding: 22px;
  border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: white;
  box-shadow: 0 18px 64px #39243629; overflow: auto;
}
dialog::backdrop { background: #30232d66; }
#editor { width: min(100% - 28px, 800px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-section + .dialog-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.dialog-section h3, .photo-zone h3 { font-size: 1rem; margin-bottom: 5px; }
.grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 14px; }
label { display: block; margin: 8px 0 5px; font-size: .84rem; font-weight: 700; }
.actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#mode { margin-bottom: 4px; }
#mode.editing { color: var(--rose-dark); }
.photo-zone { margin-top: 18px; padding: 13px; border: 1px dashed #dfb7c9; border-radius: 12px; background: #fff9fc; }
#photoInput { max-width: 100%; font-size: .85rem; margin-bottom: 6px; }
#photoInput::file-selector-button { border: 1px solid #ebccda; background: white; border-radius: 8px; color: var(--rose-dark); padding: 7px 10px; cursor: pointer; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(115px,1fr)); gap: 8px; margin: 9px 0; }
.photo-item { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 5px; min-width: 0; }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #f8f3f6; border-radius: 5px; }
.photo-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.photo-actions button { flex: 1; min-height: 34px; padding: 4px 6px; font-size: .75rem; }
@media (max-width: 760px) {
  .topbar-inner, main { padding-left: 16px; padding-right: 16px; }
  main { padding-top: 26px; }
  .stats { gap: 8px; margin-bottom: 19px; }
  .stat { padding: 12px 9px; gap: 7px; }
  .stat-label { font-size: .72rem; }
  .stat-label::before { width: 6px; height: 6px; margin-right: 5px; }
  .inventory-head { padding: 15px; }
  .toolbar { flex-wrap: wrap; }
  .search { width: 100%; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; padding: 14px 15px; border-top: 1px solid var(--line); }
  tbody td, tbody td:first-child, tbody td:last-child { padding: 0; border: 0; min-width: 0; }
  tbody td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; margin-bottom: 2px; font-weight: 550; }
  tbody td:nth-child(2) { grid-column: 1/-1; grid-row: 1; font-size: 1.01rem; }
  tbody td:last-child { display: flex; justify-content: flex-end; align-items: end; }
  .empty-row { display: block; }
  .empty-row td:last-child { display: block; }
  .list-note { padding-left: 15px; padding-right: 15px; }
}
@media (max-width: 460px) {
  .brand { font-size: 1rem; }
  .overview { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .welcome { margin-top: 28px; padding: 24px; }
  dialog { padding: 15px; }
  .grid { grid-template-columns: 1fr; }
}
.pagination { flex-wrap: wrap; }
.pagination label { margin: 0; }
.pagination select { width: auto; }
.page-jump { display: flex; align-items: center; gap: 6px; }
.page-jump input { max-width: 7ch; }
#pageNumber { white-space: nowrap; }
.page-links {
  display: flex; flex: 1 0 100%; flex-wrap: wrap; justify-content: flex-end;
  align-items: center; column-gap: 2px; row-gap: 4px;
}
.page-links[hidden] { display: none; }
.page-links button { min-width: 44px; min-height: 44px; padding: 4px; font-variant-numeric: tabular-nums; }
.page-links button[aria-current="page"] {
  background: var(--rose-dark); color: white; border-color: var(--rose-dark); cursor: default;
}
.page-links button[aria-disabled="true"]:not([aria-current]) { opacity: .55; cursor: default; }
.page-links .page-gap { color: var(--muted); }
@media (max-width: 760px) { .page-links { justify-content: center; } }
.product-card { display: block; width: 100%; min-width: 0; padding: 0; text-align: left; }
.product-card.alt:hover:not(:disabled) { background: white; box-shadow: inset 0 0 0 2px var(--rose-soft); }
.product-card:focus-visible { outline-offset: -3px; }
.product-card .thumbnail { position: relative; display: grid; place-items: center; aspect-ratio: 4/3; background: #faf6f8; color: var(--muted); }
.product-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.product-card .card-info { display: grid; gap: 6px; padding: 12px; overflow-wrap: anywhere; }
.product-card .card-edit { justify-self: start; border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px; }
@media (max-width: 760px) {
  tbody tr:not(.empty-row) {
    grid-template-columns: minmax(0,1fr) auto auto; gap: 3px 8px;
    align-items: center; min-height: 100px; padding: 7px 12px;
  }
  tbody td:nth-child(2) { grid-area: 1 / 1 / 2 / 4; font-size: .95rem; }
  tbody td:nth-child(2) span, .product-card strong {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  }
  tbody td[data-label="SKU"] { grid-area: 2 / 1 / 3 / 3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  tbody td[data-label="SKU"]::before, tbody td[data-label="在庫"]::before { content: attr(data-label) " "; display: inline; margin: 0; }
  tbody td[data-label="在庫"] { grid-area: 3 / 1; }
  tbody td[data-label="ステータス"] { grid-area: 3 / 2; }
  tbody td[data-label="仕入価格"], tbody td[data-label="保管場所"],
  tbody td[data-label="eBay状態"], tbody td[data-label="メルカリ状態"] { display: none; }
  tbody tr:not(.empty-row) td:last-child { grid-area: 2 / 3 / 4 / 4; align-items: center; }
  tbody td button { min-width: 48px; min-height: 44px; }
  .product-cards { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; padding: 0 9px 12px; }
  .product-card { border-radius: 8px; }
  .product-card .thumbnail { aspect-ratio: 1; font-size: .75rem; }
  .product-card .card-info { padding: 6px; gap: 4px; }
  .product-card strong { font-size: .8125rem; line-height: 1.3; min-height: 2.6em; }
  .product-card .card-edit, .product-card .card-sku { display: none; }
  .pagination { justify-content: center; padding: 10px 8px; }
}
.price-hint { margin: 4px 0; }

.shop-areas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.shop-areas [aria-pressed="true"], #orderProfitModes [aria-pressed="true"] {
  background: var(--rose-soft); border-color: var(--rose); color: var(--rose-dark);
}
.order-counts { display: grid; gap: 8px; margin: 12px 0; }
.order-counts > div { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.order-counts button { min-height: 40px; }
.order-filters { display: grid; grid-template-columns: minmax(220px,2fr) repeat(3,minmax(120px,1fr)); gap: 8px; margin-top: 12px; }
.order-table td select { min-width: 105px; padding: 6px; font-size: .81rem; }
.order-table small { display: block; color: var(--muted); }
.order-product { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 8px; align-items: end; margin-top: 14px; }
.order-product p { grid-column: 1/-1; }
#orderEditor { width: min(100% - 28px,1050px); }
#orderNotice:not(:empty), #orderEditorNotice:not(:empty) { margin: 10px 0; color: var(--rose-dark); }
.profit-layout { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); gap: 18px; margin-top: 12px; }
.profit-inputs, .profit-output { padding: 16px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.profit-output h3 { margin: 0 0 8px; }
.profit-output dl { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 10px 0; }
.profit-output dd { margin: 0; text-align: right; }
.profit-targets { grid-template-columns: repeat(2,minmax(0,1fr)); }
@media (max-width: 760px) {
  .order-filters, .order-product { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .order-table tbody tr:not(.empty-row) { grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: auto; gap: 8px; }
  .order-table tbody tr:not(.empty-row) td,
  .order-table tbody tr:not(.empty-row) td:last-child { grid-area: auto; font-size: .84rem; }
  .order-table tbody td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); }
  .order-table tbody td:first-child { grid-column: 1/-1; }
  .profit-layout { grid-template-columns: 1fr; }
}
