/* ------------------------------------------------------------------
   発注ポータル モック — 共通スタイル

   スマホ幅を基準に書く。PCから見るときは data-device を切り替えて
   「スマホ表示（端末の枠つき）」と「PC表示（横に広い）」を行き来できる。
   幅は --shell-w 1本で決まる。
   ------------------------------------------------------------------ */

:root {
  --ink: #1E1B24;
  --ink-soft: #55505E;
  --muted: #837D8D;
  --paper: #F5F4F7;
  --surface: #FFFFFF;
  --surface-2: #FAF9FB;
  --line: #E4E1E9;
  --accent: #2E5C4F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7F0EC;
  --ok: #2E7D57;
  --warn: #A8681A;
  --shadow-sm: 0 1px 2px rgba(30, 27, 36, .06);
  --shadow: 0 1px 2px rgba(30, 27, 36, .06), 0 10px 28px -14px rgba(30, 27, 36, .25);
  --r: 12px;
  --bar-h: 68px;
  --shell-w: 560px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #EDEAF2;
    --ink-soft: #B6B0C0;
    --muted: #8B8497;
    --paper: #131117;
    --surface: #1E1B24;
    --surface-2: #26222F;
    --line: #342F3D;
    --accent: #8FC4B0;
    --accent-ink: #101614;
    --accent-soft: #22302B;
    --ok: #6BBF95;
    --warn: #D5A45C;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #EDEAF2;
  --ink-soft: #B6B0C0;
  --muted: #8B8497;
  --paper: #131117;
  --surface: #1E1B24;
  --surface-2: #26222F;
  --line: #342F3D;
  --accent: #8FC4B0;
  --accent-ink: #101614;
  --accent-soft: #22302B;
  --ok: #6BBF95;
  --warn: #D5A45C;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  max-width: var(--shell-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
}

/* ---------------------------------------------------- ログイン画面 */

.login-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 20px;
  gap: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.login-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--accent);
  margin: 0 0 2px;
}

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

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.passcode-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  letter-spacing: .18em;
  font-variant-numeric: tabular-nums;
}

.passcode-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  letter-spacing: .04em;
}

.btn-primary:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.login-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--warn);
  font-size: 13px;
}

.login-foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

/* ---------------------------------------------------- ヘッダ */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-bar .brand {
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--accent);
  font-size: 15px;
}

.app-bar .account {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.app-bar .account b {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  flex: none;
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 17px;
  line-height: 1;
}

.icon-btn .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------- 検討パネル */

.lab {
  margin: 14px 16px 0;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.lab-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.lab-tag {
  flex: none;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.lab-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.lab-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.lab-row + .lab-row { border-top: 1px solid var(--line); }

.lab-row .q {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.seg {
  flex: none;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  padding: 5px 10px;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

/* ---------------------------------------------------- 本文 */

main {
  padding: 16px 16px calc(var(--bar-h) + 28px);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 2px 10px;
}

.section-title:first-child { margin-top: 4px; }

.section-title h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
}

.section-title .hint {
  font-size: 11px;
  color: var(--muted);
}

/* 前回と同じ内容 */

.repeat-card {
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  background: var(--accent-soft);
}

.repeat-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.repeat-card .meta {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
}

.repeat-card ul {
  margin: 0 0 14px;
  padding-left: 1.1em;
  font-size: 12px;
  color: var(--ink-soft);
}

/* 商品行（A案のリスト） */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

.row + .row { margin-top: 8px; }

.row .info { flex: 1; min-width: 0; }

.row .name {
  font-size: 14px;
  line-height: 1.45;
}

.row .sub {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row .price {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row .price .tax {
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}

/* 数量ステッパー */

.stepper {
  flex: none;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-2);
}

.stepper button {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  color: var(--accent);
}

.stepper button:disabled { color: var(--line); cursor: default; }

.stepper .qty {
  min-width: 30px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* カテゴリタブ（B案） */

.tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 16px 12px;
  margin: 0 -16px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: none;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.tabs button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

/* 商品カード（B案） */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.thumb {
  aspect-ratio: 4 / 3;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    -45deg, var(--surface-2), var(--surface-2) 9px, var(--paper) 9px, var(--paper) 18px);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
  text-align: center;
}

.card .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 11px 11px;
}

.card .name {
  font-size: 13px;
  line-height: 1.45;
}

.card .sub {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card .price {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card .price .tax {
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}

.card .stepper {
  align-self: flex-start;
  margin-top: 8px;
}

/* カート */

.cart-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.totals {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.totals dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.totals dt { font-size: 13px; color: var(--ink-soft); }
.totals dd { margin: 0; text-align: right; font-size: 13px; }

.totals .grand dt,
.totals .grand dd {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
}

.notice {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.textarea {
  width: 100%;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  resize: vertical;
  min-height: 74px;
}

/* 完了 */

.done {
  padding: 40px 8px;
  text-align: center;
}

.done .mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--ok);
  font-size: 26px;
  line-height: 56px;
}

.done h2 { margin: 0 0 6px; font-size: 18px; }

.done .receipt {
  display: inline-block;
  margin: 12px 0 18px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  letter-spacing: .06em;
}

.done p { color: var(--ink-soft); font-size: 13px; margin: 0 auto; max-width: 30em; }

.status-pill {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.review { background: var(--accent-soft); color: var(--warn); }
.status-pill.direct { background: var(--accent-soft); color: var(--ok); }

/* ---------------------------------------------------- 下部バー */

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.bottom-bar .inner {
  max-width: var(--shell-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar-h);
  padding: 0 16px;
}

.bottom-bar .sum {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.bottom-bar .sum b {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bottom-bar .btn-primary {
  flex: none;
  width: auto;
  margin: 0;
  padding: 12px 20px;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
  .row, .card, .repeat-card { transition: border-color .15s ease; }
}


/* ------------------------------------------------------------------
   表示モード（PCから見るときの切り替え）

   phone   … 実機と同じ幅。広い画面では端末の枠に見えるよう囲う
   desktop … 横幅を使い、商品を多く並べる
   ------------------------------------------------------------------ */

:root[data-device="phone"]   { --shell-w: 430px; }
:root[data-device="desktop"] { --shell-w: 1040px; }

/* 切り替え自体はスマホでは意味がないので、広い画面でだけ出す */
.lab-row--device { display: none; }

@media (min-width: 900px) {
  .lab-row--device { display: flex; }

  /* スマホ表示: 中央に1台だけ置いたように見せる */
  :root[data-device="phone"] .shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  /* 下部バーも端末の幅に合わせる。画面いっぱいに伸びると枠が壊れて見える */
  :root[data-device="phone"] .bottom-bar {
    left: 50%;
    right: auto;
    width: var(--shell-w);
    max-width: 100%;
    transform: translateX(-50%);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  /* PC表示: 検討パネルは1行に、商品は4列に */
  :root[data-device="desktop"] .lab {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 22px;
  }

  :root[data-device="desktop"] .lab-head {
    flex-basis: 100%;
    margin-bottom: 2px;
  }

  :root[data-device="desktop"] .lab-row {
    padding: 4px 0;
    border-top: 0;
  }

  :root[data-device="desktop"] .lab-row .q { flex: none; }

  :root[data-device="desktop"] .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  :root[data-device="desktop"] main {
    padding: 20px 20px calc(var(--bar-h) + 32px);
  }

  :root[data-device="desktop"] .lab { margin: 16px 20px 0; }

  /* PCでは1行が間延びするので、価格と数量を右端にまとめる */
  :root[data-device="desktop"] .row { padding: 12px 18px; }
  :root[data-device="desktop"] .row .price { min-width: 9em; text-align: right; }
}
