/* 輸入業務アプリ (デモ)。UI は Square / Shopify の管理画面にならう:
   - 落ち着いた灰色の地に白いカード。色は「意味」にだけ使う (ステータスのバッジ・危険・主ボタン)
   - 画面の大半はリスト。1 行 = 1 件、左に名前と補足、右に数値とバッジ。数値は右寄せ・等幅数字
   - 主な操作はページ右上に 1 つ (黒いボタン)。詳細は「メイン + サイド」の 2 カラム (スマホでは縦に積む)
   iPhone (WebKit) で崩れない書き方: 割合の高さを flex:1 の中で使わない */
:root {
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-hover: #f7f7f7;
  --surface-sunken: #f7f7f7;
  --border: #e3e3e3;
  --border-strong: #cfcfcf;
  --text: #303030;
  --text-sub: #616161;
  --text-faint: #8a8a8a;
  --primary: #303030;
  --primary-hover: #1a1a1a;
  --brand: #e8533f;                 /* GlobalB の赤。ロゴとアクセントにだけ使う */
  --link: #005bd3;
  --success-bg: #cdfee1; --success-fg: #0c5132;
  --attention-bg: #ffef9d; --attention-fg: #4f4700;
  --info-bg: #e0f0ff; --info-fg: #00527c;
  --critical-bg: #fedad9; --critical-fg: #8e0b21;
  --neutral-bg: #e3e3e3; --neutral-fg: #4a4a4a;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(26,26,26,.07), 0 0 0 1px rgba(26,26,26,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 14px; line-height: 1.5;
  font-feature-settings: "tnum";
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* 上のバー: 白・細い。赤はロゴだけ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: #1a1a1a; color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
.brand-mark { background: var(--brand); color: #fff; font-weight: 800; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.demo-tag { font-size: 11px; color: #bdbdbd; border: 1px solid #4a4a4a; border-radius: 999px; padding: 0 7px; font-weight: 500; }
.user { font-size: 12px; color: #d4d4d4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

.app { max-width: 1000px; margin: 0 auto; padding: 16px 12px 32px; }
.loading, .empty { color: var(--text-faint); text-align: center; padding: 20px 16px; margin: 0; }

/* ページ見出し */
.page-head { margin: 0 4px 14px; }
.back { display: inline-block; color: var(--text-sub); font-size: 13px; margin-bottom: 2px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-head-main { min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.page-sub { margin: 2px 0 0; color: var(--text-sub); font-size: 13px; }

/* カード */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card.flush .card-head { padding: 14px 16px 6px; margin: 0; }
.card-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.card-link { color: var(--link); font-size: 13px; }

/* 指標 (Shopify の分析カード) */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.metric { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; min-width: 0; }
a.metric:hover { background: var(--surface-hover); }
.metric-label { font-size: 12px; color: var(--text-sub); border-bottom: 1px dashed var(--border-strong); align-self: flex-start; }
.metric-value { font-size: 20px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-sub { font-size: 12px; color: var(--text-faint); }

.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.pipe { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; border-radius: 8px; background: var(--surface-sunken); }
.pipe b { font-size: 18px; line-height: 1.2; }
.pipe small { font-size: 11px; color: var(--text-sub); white-space: nowrap; }
.pipe.zero b { color: var(--text-faint); }

/* タブ + 検索 (リストの上) */
.tabs { display: flex; gap: 4px; padding: 8px 8px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; color: var(--text-sub); padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 550; white-space: nowrap; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { background: var(--surface-hover); }
.tab.on { background: #ebebeb; color: var(--text); }
.tab-n { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.list-tools { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.search { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 7px 10px 7px 30px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
  background-image: linear-gradient(transparent, transparent); }
.search:focus, .field input:focus, .field select:focus, .inline-form input:focus { outline: 2px solid var(--link); outline-offset: -1px; border-color: transparent; }
.list-tools { position: relative; }
.list-tools::before { content: "⌕"; position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 15px; pointer-events: none; }
.list-count { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* リストの行 */
.list { display: block; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--border); min-width: 0; }
.card-head + .list .row:first-child, .list-tools + .list .row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-hover); }
a.row:active { background: #efefef; }
.row-main { flex: 1; min-width: 0; }
.row-primary { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-secondary { font-size: 12px; color: var(--text-sub); margin-top: 1px; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.num.strong { font-weight: 650; }
.num.sub { font-size: 12px; color: var(--text-faint); }
.when { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.when.soon { color: var(--critical-fg); font-weight: 600; }
.jf { font-weight: 700; }
.chev { color: var(--text-faint); font-size: 18px; }
.bar { height: 4px; background: #ebebeb; border-radius: 2px; overflow: hidden; margin-top: 6px; max-width: 220px; }
.bar span { display: block; height: 100%; background: #616161; border-radius: 2px; }

/* バッジ (ステータスは色で意味を持たせる) */
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 550; border-radius: 8px; padding: 1px 8px; white-space: nowrap; line-height: 1.6; }
.tone-success { background: var(--success-bg); color: var(--success-fg); }
.tone-attention { background: var(--attention-bg); color: var(--attention-fg); }
.tone-info { background: var(--info-bg); color: var(--info-fg); }
.tone-critical { background: var(--critical-bg); color: var(--critical-fg); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.page-title .badge { font-size: 12px; }

/* 2 カラム (詳細・作成画面)。スマホでは縦に積む */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
@media (min-width: 760px) {
  .layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
  .layout-side { position: sticky; top: 60px; }
}

/* タイムライン (Shopify の注文履歴風) */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl { display: flex; gap: 10px; position: relative; padding-bottom: 12px; }
.tl:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; background: #fff; border: 2px solid var(--border-strong); z-index: 1; }
.tl.done .tl-dot { background: var(--text); border-color: var(--text); }
.tl.plan .tl-dot { border-color: #b98900; border-style: dashed; }
.tl-body { display: flex; flex-direction: column; }
.tl-label { font-weight: 600; font-size: 13px; }
.tl-date { font-size: 12px; color: var(--text-sub); }
.tl.plan .tl-date { color: #7a6400; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-sub); }
.kv dd { margin: 0; text-align: right; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: #fff; color: var(--text); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 rgba(0,0,0,.05); white-space: nowrap; }
.btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.3), 0 1px 0 rgba(0,0,0,.1); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.block { width: 100%; padding: 10px 12px; font-size: 14px; margin-top: 12px; }
.btn.plain { background: none; box-shadow: none; color: var(--text-sub); font-weight: 500; text-decoration: underline; }
.btn:disabled { opacity: .5; }
.foot-actions { text-align: center; margin-top: 8px; }

/* フォーム */
.fields { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field-label { font-size: 13px; color: var(--text); }
.field-help { font-size: 12px; color: var(--text-faint); margin: 6px 0 0; }
.field input, .field select { min-width: 0; width: 100%; font: inherit; font-size: 16px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); }
.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.choices { display: inline-flex; background: var(--surface-sunken); border-radius: 8px; padding: 2px; gap: 2px; justify-self: start; box-shadow: inset 0 0 0 1px var(--border); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: block; padding: 5px 16px; border-radius: 6px; font-size: 13px; font-weight: 550; color: var(--text-sub); }
.choice input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.choice input:focus-visible + span { outline: 2px solid var(--link); }

.summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 13px; }
.summary dt { color: var(--text-sub); }
.summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.summary .total { font-weight: 700; color: var(--text); font-size: 15px; border-top: 1px solid var(--border); padding-top: 6px; }

.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.banner.attention { background: #fff8db; box-shadow: inset 0 0 0 1px #f0d97a; }
.banner p { margin: 2px 0 0; font-size: 13px; color: var(--text-sub); }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form input { width: 120px; font: inherit; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 8px; }

/* 下のタブ (スマホ) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a { display: flex; flex-direction: column; align-items: center; padding: 6px 0 7px; font-size: 11px; color: var(--text-faint); }
.nav a span { font-size: 18px; line-height: 1.25; }
.nav a.on { color: var(--text); font-weight: 650; }

/* 帳票 (スマホでは横にスクロール。紙の比率を崩さない) */
.paper-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.doc-bar { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 10px; }
.paper { min-width: 620px; background: #fff; border-radius: 8px; padding: 26px 22px; font-size: 12.5px; box-shadow: var(--shadow); position: relative; }
.doc-title { text-align: center; font-size: 20px; letter-spacing: .1em; margin: 0 0 14px; }
.doc-head { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; align-items: end; }
.doc-head p { margin: 0; }
.to { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; border-bottom: 1px solid var(--text); padding-bottom: 4px; }
.to-name { font-size: 15px; font-weight: 700; }
.onchu { margin-left: auto; }
.issuer { display: flex; flex-direction: column; text-align: right; font-size: 11.5px; margin-top: 6px; }
.issuer b { font-size: 13px; }
.small { font-size: 12px; }
.total-box { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; border: 2px solid var(--text); padding: 8px 12px; margin-bottom: 12px; }
.total-box b { font-size: 20px; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.doc-table th, .doc-table td { border: 1px solid #9ca3af; padding: 4px 6px; vertical-align: top; }
.doc-table thead th { background: #f3f4f6; font-weight: 600; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-table tfoot td { font-weight: 600; }
.doc-table tr.grand td { font-size: 14px; font-weight: 800; }
.doc-table.kv th { background: #f3f4f6; width: 18%; text-align: left; font-weight: 600; }
.demo-mark { position: absolute; top: 8px; right: 10px; margin: 0; font-size: 10px; color: var(--brand); border: 1px solid var(--brand); border-radius: 4px; padding: 0 6px; }

/* 通知イメージ (LINE WORKS のトーク風。ここだけは LINE WORKS の見た目に合わせる) */
.page-title + .muted, .muted { color: var(--text-sub); font-size: 13px; margin: 0 4px 10px; }
.talk { background: #e9eef3; border-radius: var(--radius); padding: 12px; display: grid; gap: 12px; }
.talk-head { display: flex; align-items: center; gap: 8px; }
.bot-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.bubble-row { display: flex; align-items: flex-end; gap: 6px; }
.bubble { background: #fff; border-radius: 4px 16px 16px 16px; padding: 10px 12px; max-width: 86%; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.bubble p { margin: 0; }
.bubble-type { font-weight: 800; color: var(--text); }
.bubble-btn { display: block; margin-top: 8px; text-align: center; border-top: 1px solid var(--border); padding-top: 8px; color: #00a23f; font-weight: 700; }
.bubble-time { font-size: 11px; color: var(--text-faint); }

/* トースト・エラー */
.toast { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1a1a1a; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 20; max-width: 92%; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.err { background: var(--critical-fg); }
.error-card h1 { font-size: 18px; margin: 0 0 6px; }
.diag { font-size: 12px; color: var(--text-faint); }
.diag dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }

@media (max-width: 420px) {
  .metrics { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .metrics .metric:first-child { grid-column: 1 / -1; }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  .topbar, .nav, .doc-bar, .toast { display: none !important; }
  body { background: #fff; padding: 0; }
  .app { max-width: none; padding: 0; }
  .paper-wrap { overflow: visible; }
  .paper { min-width: 0; box-shadow: none; padding: 0; }
}

/* PC では下のタブを左のサイドナビにする (Shopify / Square の管理画面と同じ配置) */
.grid2 { align-items: start; }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { top: 41px; bottom: 0; right: auto; width: 208px; display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border-top: 0; border-right: 1px solid var(--border); background: #ebebeb; }
  .nav a { flex-direction: row; gap: 10px; padding: 7px 10px; font-size: 13px; color: var(--text-sub); border-radius: 8px; font-weight: 550; }
  .nav a span { font-size: 15px; width: 18px; text-align: center; }
  .nav a:hover { background: #e0e0e0; }
  .nav a.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
  .app { margin-left: 208px; margin-right: auto; padding: 20px 24px 40px; }
  @media (min-width: 1240px) { .app { margin-left: calc(208px + (100vw - 208px - 1000px) / 2); } }
  .toast { bottom: 24px; }
}
@media print { .nav { display: none !important; } .app { margin: 0 !important; } }
