/* ============================================================
   貴金属査定システム - スタイル
   （ZIOBIT WEBシステムツールのデザイン言語を踏襲。テーマ色のみ金色系）
============================================================ */
/* 色
   ------------------------------------------------------------
   実務画面は黒系です。お客様にお見せする画面（display.html）とは
   わざと少し違う地の色にしています。あちらは見せるための面、
   こちらは長時間さわる道具なので、地をわずかに温かくし、
   状態の色（済み・注意・不可）は暗い地でも一目で分かる明るさにしています。

   ・面は3段（地 → カード → カードの中の一段上）
   ・注意書きや札は、色を塗るのではなく「暗い色味の下地＋明るい文字」
   ・金色のボタンの上の文字は、白ではなく黒に近い色（そのほうが読めます） */
:root {
  --theme: #D6A93A;          /* 金。暗い地の上で読める明るさ */
  --theme-dark: #B8891F;
  --on-theme: #17120A;       /* 金色の上に乗せる文字 */

  --bg: #0F1216;             /* 地 */
  --bg2: #141920;            /* うっすら浮かせる面（行のホバーなど） */
  --card: #171C22;           /* カード */
  --card2: #1E242B;          /* カードの中の一段上（入力欄・表の見出し） */

  --text: #E6EAEF;
  --muted: #8A939D;
  --line: #2A323B;

  --danger: #F87171;
  --warn: #FBBF24;
  --ok: #4ADE80;

  /* 注意書き・札の下地。暗い地に馴染むよう、色味を落として使います */
  --tint-warn: #241D0E;   --tint-warn-b: #4A3B12;
  --tint-danger: #2A1517; --tint-danger-b: #4E2126;
  --tint-ok: #10241A;     --tint-ok-b: #1E4A2E;
  --tint-info: #101E2B;   --tint-info-b: #1D3A54;

  --gold: #D6A93A;
  --pt: #A9B2BC;
  --silver: #8A939D;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* 画面はすべてiPadで使います。
   ・腕の長さで見るので、本文は16px以上（iOSは16px未満の入力欄で勝手に拡大します）
   ・指で押すので、押せるものは44px以上
   ・マウスが無いので、当てないと出ない説明（title）は使わない */
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;   /* 画面の端で下に引いても、うっかり再読み込みしない */
}
.hidden { display: none !important; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ============ ログイン ============ */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--theme) 0%, var(--theme-dark) 60%, #4a2c05 100%);
}
.login-box {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.25); overflow: hidden;
}
.login-head { text-align: center; padding: 28px 24px 8px; }
.login-head .sys-logo { width: 64px; height: 64px; border-radius: 14px; }
.login-head h1 { font-size: 19px; margin: 12px 0 2px; }
.login-head .sub { color: var(--muted); font-size: 13px; }
.login-body { padding: 20px 28px 30px; }
.login-error {
  display: none; background: var(--tint-danger); color: var(--danger);
  border: 1px solid var(--tint-danger-b); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.num-input { letter-spacing: .18em; text-align: center; font-size: 20px !important; }

/* 起動中のスプラッシュ */
.splash {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: linear-gradient(160deg, var(--theme) 0%, var(--theme-dark) 100%); color: var(--on-theme);
}
.splash .spin {
  width: 38px; height: 38px; border: 4px solid rgba(255,255,255,.35);
  border-top-color: var(--on-theme); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ヘッダー・ナビ ============ */
.header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--theme); color: var(--on-theme); padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; }
.brand img { width: 28px; height: 28px; border-radius: 6px; background: var(--card); }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.user-chip {
  background: rgba(255,255,255,.16); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-mark { color: var(--tint-warn-b); margin-right: 4px; }
.icon-btn {
  background: none; border: none; color: var(--on-theme); font-size: 17px;
  padding: 8px 10px; cursor: pointer; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }

.nav {
  display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 8px; position: sticky; top: 48px; z-index: 40;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); padding: 14px 16px 11px; font-size: 15px;
  cursor: pointer; white-space: nowrap;
}
.nav button.active { color: var(--theme); border-bottom-color: var(--theme); font-weight: 700; }
.nav button:hover { color: var(--theme); }
body:not(.admin-mode) .admin-only { display: none !important; }

.main { max-width: 1100px; margin: 0 auto; padding: 18px 20px 60px; }

/* ============ 共通部品 ============ */
h2.page-title { font-size: 20px; margin: 4px 0 14px; display: flex; align-items: center; gap: 9px; }
h2.page-title i { color: var(--theme); }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h3 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h3 i { color: var(--theme); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--theme); color: var(--on-theme); border: none;
  border-radius: 9px; padding: 11px 18px; font-size: 15px;
  cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--theme-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger); }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: var(--ok); }
.btn-sm { padding: 9px 14px; font-size: 14px; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }

.form-row { margin-bottom: 13px; }
.form-label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.form-control {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; background: var(--card2); color: var(--text);
}
.form-control:focus { outline: 2px solid var(--theme); outline-offset: 0; border-color: var(--theme); }
.form-hint { font-size: 13.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .form-control { width: auto; flex: 1; min-width: 140px; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th {
  text-align: left; background: var(--bg2); color: var(--muted);
  font-size: 13px; padding: 12px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.list td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: var(--bg2); }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 履歴一覧：列が狭いと「セカンドストリート北見店」が1文字ずつ縦に折り返し、
   1行が異様に高くなる。日本語を途中で切らせず、収まらないときは
   表ごと横にスクロールさせる（.table-wrap が面倒を見る）。 */
#hTable th, #hTable td { word-break: keep-all; white-space: nowrap; }
#hTable td.hist-stack { white-space: normal; }

/* タブレットでは横に収まらないので、店舗（店では常に同じ）を隠し、
   ボタンも少し詰める。担当は残す。 */
@media (max-width: 1400px) {
  #hTable .hide-md { display: none; }
  #hTable .btn-sm { padding: 7px 8px; font-size: 12.5px; }
  #hTable th, #hTable td { padding-left: 6px; padding-right: 6px; }
  #hTable td[style*="nowrap"] { font-size: 0; }
  #hTable td[style*="nowrap"] .btn-sm { font-size: 12.5px; }
}

/* 履歴一覧：1件に複数点あるとき、品位・重さを点ごとに縦へ積み、上端を揃える */
table.list td.hist-stack { vertical-align: top; line-height: 1.55; }
table.list td.hist-stack > div { white-space: nowrap; }
.hist-more { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block; border-radius: 999px; font-size: 11.5px;
  padding: 2px 10px; font-weight: 700; white-space: nowrap;
}
.badge-gold   { background: var(--tint-warn); color: var(--warn); }
.badge-pt     { background: var(--line); color: var(--text); }
.badge-silver { background: var(--bg2); color: var(--muted); }
.badge-ok     { background: var(--tint-ok); color: var(--ok); }
.badge-warn   { background: var(--tint-warn); color: var(--warn); }
.badge-off    { background: var(--bg2); color: var(--muted); }

.notice {
  border-radius: 10px; padding: 11px 14px; font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px;
}
.notice i { margin-top: 3px; }
.notice-warn   { background: var(--tint-warn); border: 1px solid var(--tint-warn-b); color: var(--warn); }
.notice-danger { background: var(--tint-danger); border: 1px solid var(--tint-danger-b); color: var(--danger); }
.notice-info   { background: var(--tint-info); border: 1px solid var(--tint-info-b); color: #7CC4F0; }

/* ============ 相場バー ============ */
.souba-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; margin-bottom: 6px;
}
.souba-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px;
  border-left: 5px solid var(--c, var(--theme));
}
.souba-cell .s-name { font-size: 12px; color: var(--muted); font-weight: 700; }
.souba-cell .s-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.souba-cell .s-val small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.souba-cell .s-diff { font-size: 12px; font-variant-numeric: tabular-nums; }
.s-up { color: var(--danger); }
.s-down { color: #7CC4F0; }
.souba-meta { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
@media (max-width: 560px) { .souba-bar { grid-template-columns: 1fr; } }
.souba-cell.empty .s-val { color: var(--muted); }
.s-manual { font-size: 11px; color: var(--muted); }

/* ============ 品位の選択 ============ */
.metal-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.metal-tabs button {
  border: 1px solid var(--line); background: var(--card2); color: var(--muted);
  border-radius: 999px; padding: 7px 16px; font-size: 13.5px; cursor: pointer; font-weight: 600;
}
.metal-tabs button.active { background: var(--theme); border-color: var(--theme); color: var(--on-theme); }

.purity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.purity-btn {
  border: 1px solid var(--line); background: var(--card2); border-radius: 10px;
  padding: 10px 6px; cursor: pointer; text-align: center; line-height: 1.3;
}
.purity-btn:hover { border-color: var(--theme); }
.purity-btn.active { background: var(--tint-warn); border-color: var(--theme); box-shadow: 0 0 0 2px var(--tint-warn-b) inset; }
.purity-btn .p-name { font-weight: 700; font-size: 14px; }
.purity-btn .p-unit { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============ 明細 ============ */
.item-row {
  display: grid;
  grid-template-columns: 1.3fr 0.85fr 0.75fr 0.95fr 0.8fr 1fr 36px;
  gap: 8px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
/* 買取不可の行はひと目で分かるように */
.item-row.ng { background: var(--tint-danger); border-radius: 10px; }
.item-row.ng .a-cell { color: var(--danger); }

/* 石の重さ：入力欄＋計算ボタン */
.stone-cell { display: flex; gap: 4px; align-items: center; }
.stone-cell .s-input { min-width: 0; }
.calc-btn {
  flex: 0 0 auto; background: var(--card2); border: 1px solid var(--line); color: var(--theme);
  border-radius: 8px; padding: 8px 9px; cursor: pointer; font-size: 14px; line-height: 1;
}
.calc-btn:hover { background: var(--tint-warn); border-color: var(--theme); }

/* 行ごとの注意書き */
.ir-judge { grid-column: 1 / -1; }
.ir-judge:empty { display: none; }
.ir-judge > div { font-size: 12.5px; line-height: 1.5; padding: 4px 2px; }
.j-ng   { color: var(--danger); }
.j-warn { color: var(--warn); }
.j-note { color: var(--muted); }
.item-row .ir-head { font-size: 12px; color: var(--muted); font-weight: 700; }
.item-row input, .item-row select { width: 100%; }
.item-row .ir-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-head { display: none; }
@media (min-width: 761px) {
  .item-head { display: grid; }
}
@media (max-width: 760px) {
  .item-row {
    grid-template-columns: 1fr 1fr; gap: 6px 8px;
    background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
    padding: 10px; margin-bottom: 9px;
  }
  .item-row .ir-purity { grid-column: 1 / -1; }
  .item-row .ir-del { grid-column: 2; justify-self: end; }
  .item-row .ir-amount { grid-column: 1 / -1; text-align: right; font-size: 17px; }
  .item-row .f-lab { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
}
.f-lab { display: none; }
.del-btn {
  background: none; border: none; color: var(--danger); font-size: 16px; cursor: pointer;
  padding: 6px 8px; border-radius: 7px;
}
.del-btn:hover { background: var(--tint-danger); }

/* ============ 合計 ============ */
.total-box {
  background: linear-gradient(160deg, var(--tint-warn), var(--tint-warn));
  border: 1px solid var(--tint-warn-b); border-radius: 12px; padding: 16px 18px;
}
.total-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 14px;
}
.total-line.grand {
  border-top: 2px solid #fbbf24; margin-top: 8px; padding-top: 12px;
  font-size: 17px; font-weight: 700;
}
.total-line.grand .t-val { font-size: 30px; color: var(--theme-dark); }
.t-val { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ============ モーダル ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center;
  padding: 4vh 14px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 9px;
  background: var(--theme); color: var(--on-theme); padding: 13px 18px; font-weight: 700;
}
.modal-body { padding: 18px; max-height: 68vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line); background: var(--bg2);
}
/* 横に広い表を出すモーダル（販売価格など）。
   520pxだと「12.90 g」「8,666 円/g」が折り返して読みにくいので広げます。
   画面が狭いときは width:100% が効くので、はみ出しません。 */
.modal.wide { max-width: 880px; }

/* 販売価格の表。金額を大きく、折り返さずに読めるようにします。
   狭い画面では .table-wrap が横スクロールします。 */
.sell-table th, .sell-table td { white-space: nowrap; }
.sell-table td { font-size: 16px; padding: 15px 14px; }
.sell-table td:first-child { font-size: 17px; }
.sell-table th { font-size: 13.5px; padding: 12px 14px; }

/* トグルスイッチ */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: none; }
.switch-label { font-size: 14.5px; font-weight: 700; }
.switch-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .2s; }
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============ トースト ============ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 20px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ============ 査定書（印刷用） ============ */
#printSheet { display: none; }
.sheet {
  width: 180mm; margin: 0 auto; padding: 6mm 0; color: #000;
  font-size: 11.5pt; line-height: 1.55;
}
.sheet h1 { font-size: 19pt; text-align: center; margin: 0 0 2mm; letter-spacing: .3em; }
.sheet .sh-sub { text-align: center; font-size: 9.5pt; color: #444; margin-bottom: 6mm; }
.sheet .sh-meta { display: flex; justify-content: space-between; font-size: 10pt; margin-bottom: 4mm; }
.sheet .sh-cust { border-bottom: 1px solid #000; padding: 2mm 1mm; margin-bottom: 5mm; font-size: 12pt; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 10.5pt; }
.sheet table th, .sheet table td { border: 1px solid #555; padding: 1.6mm 2mm; }
.sheet table th { background: #eee; font-size: 9.5pt; }
.sheet table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet .sh-total { margin-top: 4mm; text-align: right; font-size: 15pt; font-weight: 700; }
.sheet .sh-note { margin-top: 6mm; font-size: 8.5pt; color: #333; line-height: 1.5; }
.sheet .sh-foot { margin-top: 7mm; display: flex; justify-content: space-between; align-items: flex-end; }
.sheet .sh-store { font-size: 10pt; }
.sheet .sh-qr { text-align: center; font-size: 8pt; color: #444; }
.sheet .sh-qr canvas, .sheet .sh-qr img { width: 26mm !important; height: 26mm !important; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  /* 紙に出すものなので、画面が黒系でも査定書は白のままにします */
  body { background: #fff !important; color: #1e293b !important; }
  body.printing > *:not(#printSheet) { display: none !important; }
  body.printing #printSheet { display: block !important; }
  .sheet { width: auto; }
}

/* ============ お客様ページ（check / view） ============ */
.guest-wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 70px; }
.guest-head {
  background: var(--theme); color: var(--on-theme); padding: 18px 16px;
  padding-top: calc(18px + env(safe-area-inset-top)); text-align: center;
}
.guest-head h1 { font-size: 18px; margin: 0 0 3px; }
.guest-head .g-sub { font-size: 12.5px; opacity: .9; }
.guest-result {
  background: linear-gradient(160deg, var(--tint-warn), var(--tint-warn));
  border: 1px solid var(--tint-warn-b); border-radius: 14px; padding: 20px; text-align: center;
}
.guest-result .g-lab { font-size: 13px; color: var(--muted); font-weight: 700; }
.guest-result .g-amt { font-size: 34px; font-weight: 700; color: var(--theme-dark); font-variant-numeric: tabular-nums; }
.guest-result .g-amt small { font-size: 15px; }

/* ============ スマホ調整 ============ */
@media (max-width: 640px) {
  .main { padding: 14px 10px 70px; }
  .card { padding: 14px; }
  .nav { top: 47px; }
  .nav button span { font-size: 12.5px; }
  table.list { font-size: 12.5px; }
  table.list th, table.list td { padding: 7px 6px; }
  .hide-sp { display: none; }
}

/* ============ 真贋の記録（写真） ============ */
.ir-photos { grid-column: 1 / -1; }
.ir-photos:empty { display: none; }
.ph-row { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 2px 2px; }
.ph-cell { display: flex; align-items: center; gap: 6px; }
.ph-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 9px; padding: 6px 11px;
  font-size: 12.5px; color: var(--muted); background: var(--card2);
}
.ph-btn:hover { border-color: var(--theme); color: var(--theme); }
.ph-cell.has .ph-btn { border-style: solid; border-color: var(--ok); color: var(--ok); }
.ph-thumb {
  width: 42px; height: 42px; object-fit: cover; border-radius: 7px;
  border: 1px solid var(--line);
}
.ph-del {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 13px; padding: 3px 5px; border-radius: 6px;
}
.ph-del:hover { background: var(--tint-danger); }
.ph-elem { color: var(--muted); }

/* 読み取り結果の確認 */
.read-box { display: flex; gap: 14px; align-items: flex-start; }
.read-box img { width: 45%; max-width: 220px; border-radius: 9px; border: 1px solid var(--line); }
.read-val { font-size: 30px; font-weight: 700; color: var(--theme-dark); font-variant-numeric: tabular-nums; }
.read-val small { font-size: 15px; color: var(--muted); margin-left: 3px; }
@media (max-width: 560px) { .read-box { flex-direction: column; } .read-box img { width: 100%; max-width: none; } }

/* お客様向けの別画面（display.html）は、あちらに自前のCSSを持たせています */
/* ============ 査定：1点ずつの画面 ============ */
.step-card { border-left: 5px solid var(--theme); }
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; margin-right: 8px;
  background: var(--theme); color: var(--on-theme); font-size: 13px; font-weight: 700;
}
.big-input { font-size: 22px !important; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.kind-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.kind-tabs button {
  border: 1px solid var(--line); background: var(--card2); color: var(--muted);
  border-radius: 999px; padding: 8px 18px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.kind-tabs button.active { background: var(--theme); border-color: var(--theme); color: var(--on-theme); }

/* 確定した品物の帯 */
.done-strip {
  background: var(--tint-ok); border: 1px solid var(--tint-ok-b); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px;
}
.ds-head { font-size: 14px; color: var(--ok); font-weight: 700; margin-bottom: 8px; }
.ds-head i { margin-right: 6px; }
.ds-list { display: flex; flex-wrap: wrap; gap: 7px; }
.ds-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--tint-ok); border: 1px solid var(--tint-ok-b); border-radius: 999px;
  padding: 4px 6px 4px 13px; font-size: 12.5px; color: var(--ok);
}
.ds-del { background: none; border: none; color: var(--ok); cursor: pointer; padding: 2px 5px; border-radius: 50%; }
.ds-del:hover { background: var(--tint-ok); color: var(--danger); }

/* X線の読み取り結果 */
.tester-box {
  background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: 11px; padding: 14px 16px; margin-top: 12px;
}
.tester-box.ok { border-left-color: var(--ok); background: var(--tint-ok); }
.tb-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.tb-val { font-size: 28px; font-weight: 700; color: var(--theme-dark); font-variant-numeric: tabular-nums; }
.tb-stamp { font-size: 13.5px; color: var(--muted); }

/* 計算の内訳 */
.calc-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.calc-line:last-of-type { border-bottom: none; }

/* 写真のサムネイル */
.ph-thumb.big { width: 88px; height: 88px; }
.ph-thumb.mini { width: 34px; height: 34px; margin-right: 3px; }
#weightPhoto .ph-cell, #testerPhoto .ph-cell { gap: 10px; }
#weightPhoto .ph-btn, #testerPhoto .ph-btn { padding: 10px 16px; font-size: 14px; }

/* 確定処理の最中は、明細をいじれないようにする */
body.saving #confirmTable, body.saving #doneStrip { opacity: .55; pointer-events: none; }

/* 確認画面の未確定行 */
tr.cf-draft td { background: var(--tint-warn); }

/* 刻印・磁気で買取不可になる選択肢は、赤で分かるように */
.kind-tabs button.ng.active { background: var(--danger); border-color: var(--danger); }
.kind-tabs button.ng:not(.active) { color: var(--danger); border-color: var(--tint-danger-b); }

/* 保管・発送先とPOSの備考欄 */
.storage-box {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 16px; margin-top: 14px; font-size: 13.5px;
}
.sb-row { display: flex; gap: 12px; padding: 5px 0; align-items: flex-start; }
.sb-lab { flex: 0 0 96px; color: var(--muted); font-weight: 700; font-size: 12.5px; padding-top: 2px; }
.pos-memo {
  display: inline-block; background: var(--card2); border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px;
  margin-right: 6px;
}

/* お試しモードの帯 */
.demo-bar {
  position: sticky; top: 0; z-index: 60;
  background: #7c2d12; color: #fed7aa; font-size: 13px;
  padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.demo-bar b { color: var(--card); }
.demo-bar span { opacity: .8; }
.demo-bar code { background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 4px; }
body.demo .header { top: 34px; }
body.demo .nav { top: 82px; }

/* ============ 指で押す前提の大きさ（iPad） ============
   1点ごとに必ず押すボタンは、指の目安 44px を下回らないようにする。 */
.kind-tabs button { padding: 11px 18px; font-size: 14.5px; min-height: 44px; }
.metal-tabs button { padding: 10px 20px; min-height: 44px; }
.calc-btn { padding: 11px 13px; min-height: 44px; min-width: 44px; }
.ph-btn { padding: 11px 16px; min-height: 44px; }
.del-btn, .ph-del, .ds-del, .rec-del { min-height: 44px; min-width: 44px; }
.nav button { padding: 14px 18px 11px; min-height: 50px; }
.btn { min-height: 44px; }
.btn-sm { padding: 9px 14px; min-height: 40px; }
.icon-btn { min-height: 44px; min-width: 44px; }
.form-control { padding: 11px 12px; min-height: 44px; }
.purity-btn { min-height: 62px; }

/* 画面が狭いときは、選択肢を詰めすぎない */
@media (max-width: 820px) {
  .kind-tabs { gap: 8px; }
  .kind-tabs button { flex: 1 1 auto; min-width: 104px; justify-content: center; }
}


/* ============ 記録写真 ============
   1点につき何枚でも。指で押す前提なので、追加ボタンは大きめにとる。 */
.rec-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
.rec-cell { position: relative; margin: 0; }
.rec-cell img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); background: #0f172a;
}
.rec-cell figcaption {
  font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px;
}
.rec-del { position: absolute; top: 4px; right: 4px; }
.rec-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; aspect-ratio: 1; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 13px; text-align: center;
}
.rec-add:hover { border-color: var(--accent); color: var(--accent); }
.rec-add i { font-size: 20px; }


/* 履歴から見る写真 */
.rec-cell a { display: block; }
.rec-cell a img { cursor: zoom-in; }
.rec-miss .rec-missbox {
  width: 100%; aspect-ratio: 1; border-radius: 8px;
  border: 1px dashed var(--danger); color: var(--danger);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; font-size: 12px; text-align: center;
}
.rec-miss .rec-missbox i { font-size: 20px; }


/* ============ ①グラムを測る の横一列 ============
   撮る・総重量・石・区分を一列に並べます。
   iPadの縦など幅が足りないときは、崩れずに折り返します。 */
/* 上ぞろえにすること。下ぞろえ（flex-end）にすると、いちばん背の高い枠
   （コンビ商品の説明）に他の列が引きずられて下がり、説明文のすぐ下に
   150px以上の空きができる。 */
.inline-row {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  gap: 14px 20px; margin-top: 8px;
}
.inline-item { display: flex; flex-direction: column; gap: 6px; }
.inline-item .form-label { margin: 0; }
/* 数値欄は、桁が見えるだけの幅にとどめる（伸ばすと目が横に泳ぐため） */
.inline-item .w-num { width: 150px; }
/* 写真の枠は、撮る前と撮った後で高さが変わらないようにそろえる */
.inline-item #weightPhoto { min-height: 44px; display: flex; align-items: center; }
/* 読み取れなかった理由は、一列から外して下に出す */
.inline-item .ph-cell { flex-wrap: wrap; max-width: 460px; }


/* 店舗は担当者のものを出すだけなので、入力欄ではなく文字で見せる */
.store-fixed {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; padding: 10px 0 4px;
}


/* コンビ商品の行は、同じ品物だと分かるように左端に印を付ける */
#confirmTable tr.cf-combi td:first-child { box-shadow: inset 3px 0 0 var(--theme); }


/* ============ 工程の切り替え（タブレット向け） ============
   縦に長い画面を延々とスクロールさせず、1画面に1工程だけ出します。
   見出しは押せます。足りないものがある工程には印を付けます。 */
.stepper {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.st-step {
  flex: 1 1 0; min-width: 96px; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--muted); font-size: 13px; cursor: pointer; padding: 8px 6px;
}
.st-step .st-no {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--muted); font-weight: 700; font-size: 13px;
}
.st-step.done { border-color: var(--tint-ok-b); }
.st-step.done .st-no { background: var(--ok); color: #06240F; }
.st-step.done .st-lab i { color: var(--ok); font-size: 11px; }
.st-step.miss .st-no { background: var(--tint-warn); color: var(--warn); }
.st-step.on {
  border-color: var(--theme); color: var(--theme); font-weight: 700;
  box-shadow: 0 0 0 2px rgba(161,98,7,.12);
}
.st-step.on .st-no { background: var(--theme); color: var(--on-theme); }

/* 送りの帯。画面の下に貼り付けて、どこにいても押せるようにする */
.step-foot {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  margin-top: 4px;
}
.step-foot-sp { flex: 1 1 auto; }
#stepNext, #commitBtn { min-width: 190px; justify-content: center; }


/* ============ 暗い地に合わせた細かい調整 ============ */
/* 入力欄まわり。iOSは16px未満の入力欄で勝手に拡大するので、16pxを下回らせない */
input, select, textarea { color: var(--text); }
.form-control::placeholder { color: var(--muted); opacity: 1; }
select.form-control option { background: var(--card2); color: var(--text); }
/* 数字の入力欄は、桁を読み違えないよう等幅にする */
.big-input { font-variant-numeric: tabular-nums; }
/* 写真の下地。抜けた背景が黒く沈まないように、わずかに明るくする */
.ph-thumb, .rec-cell img { background: #0B0E12; }
/* 表の見出しと行 */
table.list th { background: var(--card2); color: var(--muted); }
table.list tr:hover td { background: var(--bg2); }
/* 押した瞬間の手応え（iPadは指なので、押した色が要る） */
.btn:active, .kind-tabs button:active, .purity-btn:active,
.st-step:active, .ph-btn:active { filter: brightness(1.25); }


/* ============ 相場の画面 ============ */
.souba-src {
  padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.souba-src i { color: var(--theme); margin-right: 6px; }
.souba-src a { color: var(--theme); }
.souba-day { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.souba-nums { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.souba-num { display: inline-flex; align-items: baseline; gap: 8px; }
.sn-lab { font-size: 14px; color: var(--muted); }
.souba-num b {
  font-size: clamp(24px, 2.4vw, 32px); font-variant-numeric: tabular-nums; color: var(--theme);
}
.sn-unit { font-size: 13px; color: var(--muted); }
