/* Wholesale admin: plain and dense, works on a phone. Colours follow the Japan FunPop site. */
:root {
  --bg: #f6f3f1;
  --surface: #fff;
  --ink: #2f2a28;
  --muted: #7a6f6c;
  --rule: #eadfdd;
  --accent: #d7263d;
  --accent-ink: #fff;
  --ok: #2f7d57;
  --ok-bg: #e4f4ec;
  --warn: #9a6400;
  --warn-bg: #fff3d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --info-bg: #eef1fb;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2rem; }
a { color: var(--accent); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid #d8cecb; border-radius: 8px; background: #fff; color: var(--ink); }
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f3a6b6; border-color: #e98aa0; }
label { display: grid; gap: .25rem; font-size: .86rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .84rem; margin: .5rem 0 0; }
.error { color: var(--bad); min-height: 1.2em; margin: .4rem 0 0; }
.note { color: var(--muted); font-size: .9rem; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid #d8cecb; background: #fff; border-radius: 999px;
  padding: .5rem 1rem; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #faf6f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: #efc2be; }
.btn.small { padding: .3rem .75rem; font-size: .86rem; }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: .2rem .3rem; }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); padding: 1.6rem; border-radius: 16px; box-shadow: 0 10px 30px rgba(80,30,40,.12); display: grid; gap: .8rem; }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card p { margin: 0; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; flex-wrap: wrap; }
.brand { font-weight: 800; color: var(--accent); white-space: nowrap; }
.brand span { color: var(--ink); font-weight: 600; margin-left: .3rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: .5rem .8rem; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: #fde7ec; color: var(--accent); }
.count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-left: .2rem; }
.who { font-size: .86rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 720px) { .tabs { order: 3; flex-basis: 100%; } }
.warning { margin: 1rem; padding: .7rem 1rem; background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); }

.panel { padding: 1rem; max-width: 1280px; margin: 0 auto; display: grid; gap: 1rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 220px; width: auto; }
.toolbar select { width: auto; }
.bulk { display: flex; gap: .5rem; align-items: center; background: var(--info-bg); padding: .5rem .8rem; border-radius: var(--radius); flex-wrap: wrap; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.row input { flex: 1 1 220px; width: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border-radius: var(--radius); padding: 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); min-width: 0; }
.card p { margin: 0 0 .5rem; }
.card form { display: grid; gap: .7rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); }
.card .table-wrap { margin-top: .6rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .6rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.products tbody tr { cursor: pointer; }
.products tbody tr:hover { background: #fcf8f7; }
.products td { vertical-align: middle; }
.products td:nth-child(4) { min-width: 9rem; }
.phone-only { display: none !important; }
@media (max-width: 640px) { .phone-only { display: block !important; } }
/* phone: drop category and unit so the name has room */
@media (max-width: 640px) {
  .products th:nth-child(n+5), .products td:nth-child(n+5) { display: none; }
  .products .thumb { width: 40px; height: 40px; }
  .products th, .products td { padding: .45rem .4rem; }
  .top { gap: .4rem 1rem; }
}
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #f1ebe9; display: block; }
.sku { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86rem; white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: .84rem; }
.table input, .table select { padding: .35rem .5rem; }

.pill { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.pill.ok, .pill.create, .pill.created, .pill.approved, .pill.done { background: var(--ok-bg); color: var(--ok); }
.pill.update, .pill.updated, .pill.pending, .pill.running { background: var(--info-bg); color: #3949ab; }
.pill.off, .pill.unchanged, .pill.preview { background: #efebea; color: var(--muted); }
.pill.error, .pill.failed, .pill.rejected, .pill.suspended { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.seg { display: inline-flex; background: #fff; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 999px; padding: .3rem .8rem; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* import */
.stats { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.stat { background: #faf6f5; border-radius: 10px; padding: .5rem .9rem; min-width: 7rem; }
.stat b { display: block; font-size: 1.4rem; }
.stat.create b { color: var(--ok); } .stat.update b { color: #3949ab; } .stat.error b { color: var(--bad); }
.details { margin: 0; padding-left: 1rem; font-size: .88rem; }
.details li.err { color: var(--bad); }
.details li.warn { color: var(--warn); }
.bar { height: 10px; background: #efe7e5; border-radius: 999px; overflow: hidden; margin: .4rem 0; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* accounts */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.account h2 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.account dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .4rem 0 .8rem; font-size: .9rem; }
.account dt { color: var(--muted); }
.account dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.account .grid { margin-bottom: .6rem; }
@media (max-width: 400px) { .accounts { grid-template-columns: 1fr; } }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .7rem; }
.grid .wide { grid-column: 1 / -1; }

/* product editor */
.editor { width: min(860px, 100vw); max-height: 100vh; padding: 0; border: 0; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.editor::backdrop { background: rgba(40, 20, 25, .45); }
@media (max-width: 640px) { .editor { width: 100vw; height: 100vh; max-width: 100vw; border-radius: 0; margin: 0; } }
.editor form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
@media (max-width: 640px) { .editor form { max-height: 100vh; height: 100%; } }
.ed-head, .ed-foot { display: flex; align-items: center; gap: .5rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--rule); }
.ed-head h2 { margin: 0; flex: 1; }
.ed-foot { border-bottom: 0; border-top: 1px solid var(--rule); }
.ed-body { overflow-y: auto; padding: 1rem 1.1rem; }
.ed-body .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .ed-body .grid { grid-template-columns: 1fr; } }
.photos { display: flex; gap: .5rem; flex-wrap: wrap; }
.photo { position: relative; width: 96px; }
.photo img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: #f1ebe9; display: block; }
.photo .main { position: absolute; left: 4px; top: 4px; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 6px; padding: 0 .3rem; }
.photo .acts { display: flex; justify-content: space-between; }
.photo .acts button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: .1rem .3rem; }
.photo .acts button:hover { color: var(--accent); }
.internal { border: 1px dashed #d8cecb; border-radius: var(--radius); margin: 1.2rem 0 0; padding: .6rem .9rem .9rem; background: #faf8f7; }
.internal legend { color: var(--muted); font-size: .84rem; font-weight: 700; padding: 0 .3rem; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: #2f2a28; color: #fff; padding: .6rem 1rem; border-radius: 999px; z-index: 100; max-width: calc(100vw - 32px); }

/* Products: list or thumbnails (S / M / L) */
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; }
.seg .btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.p-tiles { --tile: 170px; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: .7rem; margin-top: .8rem; }
.p-tiles.size-s { --tile: 110px; }
.p-tiles.size-l { --tile: 250px; }
.tile { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: .45rem; cursor: pointer; display: grid; gap: .25rem; align-content: start; min-width: 0; }
.tile:hover, .tile:focus-visible { border-color: #e98aa0; outline: none; }
.tile.picked { border-color: var(--accent); box-shadow: 0 0 0 2px #f3a6b6; }
.tile.off img, .tile.off .noimg { opacity: .45; }
.tile img, .tile .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #f1ebe9; display: block; }
.tile .noimg { display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.tile .pick { position: absolute; top: .7rem; left: .7rem; width: 1.1rem; height: 1.1rem; }
.tile .name { font-size: .86rem; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.tile .sku { font-size: .76rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.p-tiles.size-s .name { font-size: .78rem; }
