/* 納品書の登録 — スマホ・タブレット優先
   UTC Design System v1.0（ClaudeCodeMD/DESIGN.md）準拠：社内ツールはUTC主導で統一（クライアントの色にしない）。
   白ベース・青の主色・濃紺のヘッダー。クライアント色はロゴだけ */
:root {
  --primary: #2563EB;     /* --utc-primary：主ボタン・選択中 */
  --primary-hover: #1D4ED8;
  --topbar: #0F172A;      /* --utc-bg-sidebar：ヘッダー */
  --bg: #F8FAFC;          /* --utc-bg-main */
  --card: #FFFFFF;
  --muted-bg: #F1F5F9;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-2: #475569;
  --muted: #64748B;
  --ok: #15803D; --ok-bg: #DCFCE7;
  --ng: #DC2626; --ng-bg: #FEE2E2;
  --warn: #9A3412; --warn-bg: #FEF3C7; --warn-line: #F59E0B;
  --radius: 12px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
}
h1 { font-size: 1.35rem; margin: .2rem 0 .6rem; color: var(--text); }
h2.sub { font-size: 1.05rem; margin: 1.2rem 0 .5rem; color: var(--text); }
h2.sub small { color: var(--muted); font-weight: normal; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.hint { color: var(--muted); font-size: .85rem; }

/* ヘッダー */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem;
  background: var(--topbar); color: #fff; padding: .55rem 16px; padding-top: calc(.55rem + env(safe-area-inset-top, 0px));
}
.topbar-home { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .6rem; background: none; border: 0; color: inherit; font: inherit; padding: 0; cursor: pointer; min-height: 40px; }
.topbar-home:focus-visible, .help-btn:focus-visible { outline: 3px solid rgba(147,197,253,.6); outline-offset: 2px; border-radius: 8px; }
.help-btn { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 50%; width: 34px; height: 34px; font: 700 1rem var(--font, inherit); cursor: pointer; flex: none; }
.who + .help-btn, .help-btn { margin-left: .4rem; }
.who[hidden] + .help-btn { margin-left: auto; }
.topbar-logo { height: 36px; width: 36px; }
.topbar-title { font-weight: 600; letter-spacing: .1em; }
.who { margin-left: auto; background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .85rem; }

main { padding: 16px 16px calc(120px + var(--safe-b)); max-width: 960px; margin: 0 auto; }
.view.narrow { max-width: 480px; margin: 0 auto; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .6rem 1rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn:focus-visible, .chip:focus-visible { outline: 3px solid rgba(37,99,235,.35); outline-offset: 1px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--ng); border-color: #f1c4bf; background: var(--card); }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.huge { min-height: 96px; font-size: 1.3rem; flex-direction: column; margin-bottom: .8rem; }
.btn.huge svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn.small { min-height: 38px; width: auto; padding: .3rem .8rem; font-size: .9rem; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.row-between .btn { width: auto; }
#v-home .btn { margin-bottom: .7rem; }

/* 入力 */
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.field.inline > span { white-space: nowrap; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .7rem; min-height: 44px; width: 100%;
}
input:focus, select:focus { outline: 3px solid rgba(37,99,235,.25); outline-offset: 0; border-color: var(--primary); }
.big-input { font-size: 1.8rem; text-align: center; letter-spacing: .3em; min-height: 64px; }
.msg { color: var(--ng); min-height: 1.4em; margin: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.chip { border: 1px solid var(--border); background: #fff; color: var(--text-2); border-radius: 999px; padding: .35rem .8rem; font: inherit; font-weight: 600; min-height: 40px; }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* カード */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.newvendor { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; background: var(--warn-bg); border-radius: 10px; padding: 10px; }
.totals { margin-top: 1rem; }
.sumout { font-size: 1.2rem; font-weight: 700; color: var(--text); padding: .45rem 0; }

/* 撮った写真 */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.page { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.page img { width: 100%; height: 100%; object-fit: cover; }
.page .no { position: absolute; left: 6px; top: 6px; background: var(--primary); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .5rem; }
.page .del { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 1rem; }
.thumbs { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .6rem; }
.thumbs img { height: 110px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; flex: none; }
.thumbs .loading { height: 110px; width: 80px; border-radius: 8px; background: var(--border); flex: none; }

/* お知らせ枠 */
.notes { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px; padding: .6rem .9rem; margin-bottom: .8rem; font-size: .9rem; }
.notes ul { margin: .2rem 0 0; padding-left: 1.2rem; }
.banner { border-radius: 12px; padding: .8rem 1rem; margin-bottom: .8rem; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }

/* 明細 */
.lines { display: flex; flex-direction: column; gap: .6rem; }
.line { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: repeat(6, 1fr); gap: .45rem; }
.line .name { grid-column: 1 / -1; }
.line .spec { grid-column: span 4; }
.line .unit, .line .qty, .line .price, .line .amount, .line .tax { grid-column: span 2; }
.line .tools { grid-column: span 4; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; justify-content: flex-end; }
.line .tools .btn { width: auto; }
.line .tag { font-size: .78rem; border-radius: 999px; padding: .1rem .6rem; font-weight: 700; }
.line .tag.hw { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.line .tag.prev { background: var(--warn-bg); color: var(--warn); }
.line .field span { font-size: .75rem; }
.line input, .line select { min-height: 40px; padding: .35rem .5rem; }
.line.excluded { opacity: .5; background: var(--muted-bg); }
.line.excluded input { text-decoration: line-through; }
.flag { background: var(--warn-bg) !important; border-color: var(--warn-line) !important; }
.toggle { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); min-height: 36px; }
.toggle input { width: 20px; min-height: 20px; height: 20px; }

/* 保存バー（画面下に固定） */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: rgba(248,250,252,.97);
  border-top: 1px solid var(--border); padding: .6rem 16px calc(.6rem + var(--safe-b));
  display: grid; grid-template-columns: 1fr minmax(140px, 220px); gap: .6rem; align-items: center;
}
.check { border-radius: 10px; padding: .45rem .7rem; font-size: .88rem; font-weight: 700; line-height: 1.35; }
.check.ok { background: var(--ok-bg); color: var(--ok); }
.check.ng { background: var(--ng-bg); color: var(--ng); }
.check.warn { background: var(--warn-bg); color: var(--warn); }

/* 一覧 */
.filters { display: flex; gap: .8rem; flex-wrap: wrap; }
.filters .field { flex: 1 1 180px; }
.listsum { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.listsum span { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: .25rem .8rem; font-size: .85rem; }
.slip-list { display: flex; flex-direction: column; gap: .5rem; }
.slip { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem; font: inherit; color: inherit; width: 100%; cursor: pointer; }
.slip .v { font-weight: 700; color: var(--text); }
.slip .amt { font-weight: 700; text-align: right; }
.slip .meta { color: var(--muted); font-size: .8rem; grid-column: 1 / -1; }
.slip.cancel { opacity: .5; }
.slip.cancel .amt { text-decoration: line-through; }
.kubun { font-size: .72rem; border-radius: 6px; padding: 0 .4rem; margin-left: .3rem; background: var(--bg); border: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }

/* ホームの登録状況 */
.queue { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .9rem; margin-bottom: .8rem; font-size: .9rem; }
.queue .q { display: flex; justify-content: space-between; gap: .5rem; align-items: center; padding: .25rem 0; }
.queue .q.ng { color: var(--ng); font-weight: 700; }
.queue .q .btn { width: auto; }
.badge { background: #d03b3b; color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .5rem; margin-left: .4rem; }

/* 仕入先の確認 */
.vendor-card .form-grid { margin-top: .5rem; }

/* 読み込み中・拡大・トースト */
.busy { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: grid; place-items: center; }
.busy-box { background: #fff; border-radius: 16px; padding: 1.4rem 1.8rem; text-align: center; min-width: 220px; }
.spinner { width: 40px; height: 40px; margin: 0 auto .6rem; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.zoom { position: fixed; inset: 0; z-index: 60; background: #111; display: flex; flex-direction: column; }
.zoom > .btn { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2; }
.zoom-scroll { flex: 1; overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.zoom-scroll img { display: block; width: 200%; max-width: none; }
@media (min-width: 900px) { .zoom-scroll img { width: 140%; } }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 70; background: var(--text); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; white-space: pre-line; line-height: 1.5; border-radius: 18px; }

@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .newvendor { grid-template-columns: 1fr; }
  .savebar { grid-template-columns: 1fr 120px; }
}
@media (min-width: 760px) {
  .line { grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr 1fr; align-items: end; }
  .line .name { grid-column: 1 / -1; }
  .line .spec { grid-column: 1 / 2; }
  .line .unit, .line .qty, .line .price, .line .tax { grid-column: auto; }
  .line .amount { grid-column: span 2; }
  .line .tools { grid-column: 1 / -1; }
}

/* 使い方（折りたたみ） */
.help { display: flex; flex-direction: column; gap: .6rem; }
.help details { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 1rem; }
.help summary { cursor: pointer; font-weight: 700; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: .5rem; list-style: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: '＋'; color: var(--primary); font-weight: 700; }
.help details[open] summary::after { content: '－'; }
.help details[open] { padding-bottom: .8rem; }
.help ol, .help ul { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .35rem; }
.help p { margin: .6rem 0 0; color: var(--text-2); }
.chip-ok, .chip-ng, .chip-warn { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 6px; padding: 0 .45rem; margin-right: .2rem; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-ng { background: var(--ng-bg); color: var(--ng); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }

/* ヘッダーは1行に収める（担当者名が長い時は…で省略） */
.who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 60%; }
@media (max-width: 400px) { .topbar-logo { width: 32px; height: 32px; } .topbar { gap: .45rem; } }

/* 原価レポート */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2); padding: .5rem 0; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs.small button { min-height: 38px; font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0 6px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.kpi .label { font-size: .78rem; color: var(--text-2); }
.kpi .value { font-size: 1.3rem; font-weight: 700; }
.kpi.main .value { color: var(--primary); font-size: 1.6rem; }
.num { font-variant-numeric: tabular-nums; }
.pill { align-self: flex-start; font-size: .75rem; font-weight: 700; border-radius: 999px; padding: .05rem .55rem; background: var(--muted-bg); color: var(--text-2); }
.pill.up { background: var(--ng-bg); color: var(--ng); }
.pill.down { background: var(--ok-bg); color: var(--ok); }
#v-report .card { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart { overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart text { fill: var(--muted); font: 11px 'Noto Sans JP', sans-serif; }
.tablewrap { overflow-x: auto; }
.tablewrap table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 520px; }
.tablewrap th { text-align: left; font-weight: 500; font-size: .76rem; color: var(--muted); padding: .45rem .5rem; border-bottom: 1px solid #CBD5E1; white-space: nowrap; }
.tablewrap td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tablewrap tr.click { cursor: pointer; }
.tablewrap tr.click:hover td { background: var(--bg); }
.tablewrap .r { text-align: right; }
.tablewrap .sub2 { display: block; font-size: .74rem; color: var(--muted); }
.vlist { display: flex; flex-direction: column; gap: 8px; }
.vrow { display: grid; grid-template-columns: minmax(0, 8em) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .9rem; }
.vrow .bar { height: 8px; border-radius: 4px; background: var(--primary); }
.vrow .bar.pack { background: #93C5FD; }
.vrow .bar.exp { background: #CBD5E1; }
.logrow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .1rem .7rem; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; font: inherit; color: inherit; width: 100%; }
button.logrow { cursor: pointer; }
.logrow .op { font-weight: 700; white-space: nowrap; }
.logrow .what { min-width: 0; overflow-wrap: anywhere; }
.logrow .meta { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); }
.logrow .op.reg { color: var(--primary); }
.logrow .op.mod { color: var(--warn); }
.logrow .op.del { color: var(--ng); }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
