/* 顧客対応台：スマホ（860px 以下）の最終レイヤー。いちばん最後に読み込み、ほかの css の指定を上書きします。
   ・左のメニュー → 上の細いバー＋「メニュー」で全面表示
   ・本文は画面いっぱい、横にはみ出さない
   ・表は横スクロール、フォームは1列、ダイアログは下から出るシート */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  body { font-size: 14px; -webkit-text-size-adjust: 100%; }
  img, video, canvas, svg { max-width: 100%; }
  input, select, textarea { font-size: 16px; max-width: 100%; }   /* iPhone で入力時に拡大されないように */
  input[type=checkbox], input[type=radio] { font-size: 14px; }

  /* ---- 外枠 ---- */
  .app { display: block; grid-template-columns: 1fr; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .app .topbar, .topbar { display: none; }
  .app .side { position: sticky; top: 0; z-index: 40; width: auto; height: auto; min-height: 0; display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 8px 14px; background: #fff; border: 0; border-bottom: 1px solid var(--line); box-shadow: none; overflow: visible; }
  .app .side .brand { padding: 0; }
  .app .side .brand b, .app .side .brand .brand-g { color: var(--blue) !important; font-size: 22px !important; }
  .app .side .brand span { color: var(--soft); font-size: 11px; }
  .app .side .sbtoggle, #sbtoggle { display: none !important; }
  .app .side nav, .app .side .me { display: none; }
  .app .side .burger { display: none; }

  /* メニューを開いたとき（下の「メニュー」ボタン）：全面表示 */
  .app .side.open { position: fixed; inset: 0; z-index: 80; height: 100dvh; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0; padding: calc(10px + env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .app .side.open .brand { flex: none; padding: 2px 4px 10px; }
  .app .side.open nav { display: flex; flex-direction: column; overflow: visible; flex: none; gap: 1px; }
  .app .side.open nav a { height: 46px; font-size: 15px; padding: 0 12px; }
  .app .side.open nav .nhead { height: 34px; font-size: 12px; margin-top: 4px; }
  .app .side.open nav .ngrp.closed .nitems { display: none; }
  .app .side.open .newwrap { display: none; }
  .app .side.open .me { display: block; flex: none; margin-top: 16px; padding: 12px 6px 0; font-size: 12.5px; }

  /* 下のタブ */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(20, 40, 80, .06); }
  .tabbar > a, .tabbar > button { height: 52px; min-width: 0; }

  /* ---- 本文 ---- */
  .view, main.view { padding: 14px 14px 24px; min-width: 0; max-width: 100%; margin: 0; }
  .view > *, .card, .pagehead, .bar, .fsec { min-width: 0; max-width: 100%; }
  .view h1, .pagehead h1 { font-size: 21px; line-height: 1.35; }
  .view h2 { font-size: 16px; }
  .pagehead { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 12px; }
  .pagehead .bar { width: 100%; flex-wrap: wrap; }
  .card { padding: 14px; border-radius: 12px; }
  .bar { flex-wrap: wrap; gap: 8px; }
  .bar > input[type=search], .bar > input[type=text], .bar > select, .bar .searchbox, .bar > .sb { flex: 1 1 100%; min-width: 0; max-width: 100%; width: 100%; }
  .split, .cv-grid, .lg-grid, .dv-split, .rcv, .two, .cols2, .cols3, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr) !important; }
  .row2, .fgrid, .gd { grid-template-columns: minmax(0, 1fr) !important; }
  .fgrid .span2, .fgrid .full, .field.span2, .span2, .full { grid-column: auto; }
  .btn { min-height: 40px; }
  .btn.sm, .btn.ghost.sm { min-height: 34px; }
  .utabs, .hubtabs, .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .utabs::-webkit-scrollbar, .hubtabs::-webkit-scrollbar { display: none; }
  .utab, .utabs .utab { padding: 10px 14px !important; white-space: nowrap; flex: none; }
  .pillrow, .seg, .chips { flex-wrap: wrap; }

  /* 表：横にスクロール */
  .tw, .tbl-wrap, .bk-panel, .card.flush { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .tbl-wrap .tbl, .tw .tbl, .tw table { min-width: 560px; }
  .bk-list td:nth-child(2) { min-width: 170px; width: auto; max-width: 240px; }
  .bk-list td:nth-child(3) { min-width: 120px; }

  /* ダイアログ：下から出るシート */
  dialog.nm, dialog.nm.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  dialog.nm .nm-b { padding: 14px; max-height: calc(92dvh - 130px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  dialog.nm .nm-h { padding: 14px; }
  dialog.nm .nm-f { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 8px; }
  dialog.nm .nm-f .btn { flex: 1 1 40%; }
  dialog.nm .nm-f > span { display: none; }

  /* 個別の直し */
  .app .side.open nav { height: auto !important; max-height: none !important; overflow: visible !important; }
  .app .side.open .me { margin-top: 18px; position: static; }
  .banner { flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; }
  .banner > b { flex: none; white-space: nowrap; }
  .bar label, .pagehead .bar label { flex: 1 1 100%; max-width: 100%; }
  .bar label > input, .bar label > select { width: 100%; }
  .bk-tabrow { flex-direction: column; align-items: stretch; gap: 6px; border-bottom: 0; }
  .bk-tabs2 { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; border-bottom: 1px solid var(--line); }
  .bk-tabs2 button { white-space: nowrap; padding: 10px 16px; flex: none; }
  .bk-tabrow > *:not(.bk-tabs2) { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
  .bk-tabrow .btn, .bk-tabrow button:not(.on) { white-space: nowrap; }
  .bk-cardgrid { grid-template-columns: minmax(0, 1fr) !important; }
  .bk-card { min-height: 0 !important; }

  /* 注文書一覧（行を2段のカードに） */
  .op-card { overflow: hidden; }
  .op-r { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 6px 10px; align-items: start; padding: 12px; }
  .op-r > * { min-width: 0; }
  .op-r > .cb { grid-row: 1 / span 3; grid-column: 1; }
  .op-r > .op-main { grid-column: 2 / 4; }
  .op-r > .op-now { display: flex !important; grid-column: 2; }
  .op-r > .op-bar, .op-r > .op-amt { display: none !important; }
  .op-r > .op-due { display: flex !important; grid-column: 3; text-align: right; align-items: flex-end; }
  .op-r > .op-act { display: flex !important; grid-column: 2 / 4; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
  .op-r > .op-act .btn { flex: 0 1 auto; }
  .op-main b { display: block; overflow-wrap: anywhere; }
  .op-t2 { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .op-pill { white-space: nowrap; }
  .op-head { display: none !important; }

  /* トースト：下のタブに隠れない */
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
}

/* ごく小さい画面 */
@media (max-width: 380px) {
  .view, main.view { padding-left: 10px; padding-right: 10px; }
  .tabbar > a, .tabbar > button { font-size: 10px; }
}

/* ロゴ表記：8DESK（たたんだ左メニューでは「8」だけ） */
.app .side .brand .brand-g i { font-style: normal; }
.app .side .brand .brand-g { letter-spacing: .01em; white-space: nowrap; }
body.sb-mini .app .side .brand .brand-g i { display: none; }
.app .side .brand { gap: 8px; }
.app .side .brand .brand-g { font-size: 22px !important; }
.app .side .brand span { white-space: nowrap; font-size: 11px; letter-spacing: .06em; }

/* FAX返信：品目ごとの状況・納期 */
.rf-ln { display: grid; grid-template-columns: minmax(0, 1fr) 150px 170px; gap: 6px 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line2, #ECF1F7); }
.rf-ln .rf-nm { font-size: 13px; overflow-wrap: anywhere; }
@media (max-width: 860px) { .rf-ln { grid-template-columns: 1fr; } }
