* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f0f2f5; color: #333; }

.header { background: #1a73e8; color: #fff; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header h1 { font-size: 18px; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header .auth-btn { border: none; color: #fff; padding: 6px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; white-space: nowrap; text-decoration: none; display: inline-block; }
.header .auth-btn { background: rgba(255,255,255,0.2); }
.header .guide-btn { border: 1px solid rgba(255,255,255,0.45); }
.header .auth-btn:disabled { opacity: 0.5; cursor: default; }
.header { flex-wrap: wrap; }
.header-actions { flex-wrap: wrap; max-width: 100%; }

.inspection-settings { margin: auto; border: 1px solid #ddd; border-radius: 8px; padding: 24px; width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; color: #333; }
.inspection-settings::backdrop { background: rgba(0,0,0,0.5); }
.inspection-settings h2 { font-size: 18px; margin-bottom: 8px; }
.settings-scope { font-size: 13px; color: #666; margin-bottom: 16px; }
.inspection-settings fieldset { border: 0; display: grid; gap: 12px; }
.inspection-settings label { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.6; cursor: pointer; overflow-wrap: anywhere; }
.inspection-settings input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: #1a73e8; }
.settings-warning { color: #9c3d10; font-size: 13px; line-height: 1.6; }
#inspectionSettingsStatus { min-height: 24px; margin-top: 16px; font-size: 14px; color: #b3261e; overflow-wrap: anywhere; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.settings-actions button { min-height: 44px; padding: 10px 20px; border: 1px solid #ccc; border-radius: 6px; background: #fff; color: #333; cursor: pointer; font-size: 14px; }
.settings-actions #saveInspectionSettingsBtn { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.settings-actions button:disabled { opacity: 0.5; cursor: default; }

.container { max-width: 800px; margin: 0 auto; padding: 16px; }

/* 検索セクション */
.search-section { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.search-section h2 { font-size: 16px; margin-bottom: 12px; color: #555; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; padding: 12px; font-size: 18px; border: 2px solid #ddd; border-radius: 6px; outline: none; }
.search-row input:focus { border-color: #1a73e8; }
.search-row button { padding: 12px 24px; background: #1a73e8; color: #fff; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; white-space: nowrap; }
.search-row button:hover { background: #1557b0; }

/* 伝票情報 */
.order-info { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: none; }
.order-info h2 { font-size: 16px; margin-bottom: 12px; }
.order-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 14px; }
.order-meta dt { color: #888; }
.order-meta dd { font-weight: 600; margin-bottom: 4px; }

.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-20, .status-40 { background: #e8f5e9; color: #2e7d32; }
.status-other { background: #fff3e0; color: #e65100; }

/* 検品セクション */
.inspection-section { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: none; }
.inspection-section h2 { font-size: 16px; margin-bottom: 12px; }
.scan-input-row { display: flex; gap: 8px; margin-bottom: 16px; }
.scan-input-row input { flex: 1; min-width: 0; padding: 12px; font-size: 18px; border: 2px solid #4caf50; border-radius: 6px; outline: none; background: #f9fff9; }
.scan-input-row input:focus { border-color: #2e7d32; }

/* 明細テーブル — デスクトップ */
.items-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.items-table th { background: #f5f5f5; padding: 10px 8px; text-align: left; border-bottom: 2px solid #ddd; }
.items-table td { padding: 10px 8px; border-bottom: 1px solid #eee; vertical-align: middle; }
.items-table tr.inspected { background: #fffde7; }
.items-table tr.partial { background: #e8f5e9; }
.items-table tr.complete { background: #e3f2fd; }

.qty-badge { display: inline-block; min-width: 60px; text-align: center; padding: 4px 8px; border-radius: 4px; font-weight: 600; font-size: 13px; }
.qty-pending { background: #eee; color: #666; }
.qty-partial { background: #c8e6c9; color: #2e7d32; }
.qty-done { background: #bbdefb; color: #1565c0; }

/* 進捗バー */
.progress-bar { height: 8px; background: #eee; border-radius: 4px; margin-bottom: 16px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: #4caf50; transition: width 0.3s; border-radius: 4px; }

/* 出荷確定ポップアップ */
.ship-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; justify-content: center; align-items: center; padding: 16px; }
.ship-overlay.show { display: flex; }
.ship-card { background: #fff; border-radius: 16px; padding: 48px 32px; text-align: center; max-width: 400px; width: 100%; }
.ship-card .ship-icon { font-size: 56px; }
.ship-card h2 { margin: 12px 0 8px; color: #333; }
.ship-card p { color: #666; font-size: 14px; margin-bottom: 24px; }
.ship-btn { padding: 16px 48px; background: #4caf50; color: #fff; border: none; border-radius: 8px; font-size: 20px; font-weight: 600; cursor: pointer; animation: pulse 1.5s infinite; width: 100%; }
.ship-btn:hover { background: #388e3c; }
.ship-cancel { margin-top: 12px; padding: 10px 24px; background: none; border: 2px solid #ddd; border-radius: 6px; font-size: 14px; cursor: pointer; color: #666; }
.ship-cancel:hover { border-color: #999; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.4); } 50% { box-shadow: 0 0 0 12px rgba(76,175,80,0); } }

/* 完了画面 */
.complete-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; justify-content: center; align-items: center; padding: 16px; }
.complete-overlay.show { display: flex; }
#mismatchOverlay, #cancelledOverlay { z-index: 300; }
.complete-card { background: #fff; border-radius: 16px; padding: 48px; text-align: center; max-width: 400px; width: 100%; }
.complete-card .check { font-size: 64px; color: #4caf50; }
.complete-card h2 { margin: 16px 0 8px; }
.complete-card button { margin-top: 24px; padding: 12px 32px; background: #1a73e8; color: #fff; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; }
.picking-card { border: 4px solid #ff9800; text-align: left; max-width: 520px; padding: 32px; }
.picking-card h2 { color: #e65100; text-align: center; }
.picking-card .notice-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: #fff3e0; color: #e65100; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; }
.picking-card .notice-text { margin-top: 16px; padding: 16px; background: #fff8e1; border: 1px solid #ffe0b2; border-radius: 8px; color: #333; font-size: 18px; font-weight: 700; line-height: 1.7; white-space: pre-wrap; word-break: break-word; max-height: 42vh; overflow: auto; }
.picking-card button { display: block; width: 100%; background: #e65100; font-size: 18px; font-weight: 700; }
.picking-card button:hover { background: #bf360c; }

/* 通知 */
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8); padding: 16px 28px; border-radius: 12px; color: #fff; font-weight: 600; z-index: 200; opacity: 0; transition: transform 0.3s, opacity 0.3s; text-align: center; max-width: 90%; pointer-events: none; }
.toast.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.toast.success { background: #4caf50; }
.toast.error { background: #f44336; }
.toast.warning { background: #ff9800; }
.toast.info { background: #2196f3; }

/* 操作ガイド */
.guide-highlight { position: relative; z-index: 230; box-shadow: 0 0 0 4px rgba(26,115,232,0.45), 0 12px 30px rgba(0,0,0,0.22); }
.guide-overlay { display: none; position: fixed; inset: 0; background: transparent; z-index: 220; pointer-events: none; }
.guide-overlay.show { display: block; }
.guide-card { position: fixed; right: 14px; bottom: 14px; width: min(380px, calc(100vw - 20px)); max-height: min(54vh, 430px); overflow: auto; background: #fff; border: 1px solid #dbeafe; border-radius: 8px; padding: 16px; box-shadow: 0 14px 34px rgba(15,23,42,0.22); z-index: 240; pointer-events: auto; }
.guide-card-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.guide-card h2 { font-size: 20px; margin: 2px 0 0; color: #1a73e8; }
.guide-step-count { color: #64748b; font-size: 13px; font-weight: 700; }
.guide-body { color: #334155; font-size: 15px; line-height: 1.7; min-height: 76px; white-space: pre-line; }
.guide-wait { margin-top: 12px; padding: 10px 12px; background: #e8f0fe; border-left: 4px solid #1a73e8; border-radius: 6px; color: #1e3a8a; font-size: 14px; font-weight: 700; }
.guide-close { border: none; background: #eef2f7; color: #334155; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 36px; cursor: pointer; flex-shrink: 0; }
.guide-progress { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 16px 0; }
.guide-progress span { display: block; height: 100%; width: 0%; background: #1a73e8; transition: width 0.2s; }
.guide-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.guide-actions button, .guide-actions a { min-height: 40px; padding: 9px 14px; border-radius: 6px; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; }
.guide-actions button { border: none; background: #1a73e8; color: #fff; }
.guide-actions button:disabled { background: #cbd5e1; cursor: default; }
.guide-actions .guide-secondary { border: 1px solid #cbd5e1; background: #fff; color: #334155; }

/* ローディング */
.loading { display: none; text-align: center; padding: 20px; color: #888; }
.loading.show { display: block; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #ddd; border-top-color: #1a73e8; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* カメラスキャナー */
.scanner-container { display: none; border-radius: 8px; overflow: hidden; position: relative; max-height: 220px; }
.scanner-container.active {
  display: block;
  position: fixed;
  top: 56px;
  left: 50%;
  width: min(760px, calc(100vw - 24px));
  height: 220px;
  transform: translateX(-50%);
  z-index: 160;
  background: #111;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.scanner-container video, .scanner-container canvas { width: 100% !important; height: 220px !important; object-fit: cover; display: block; }
.scanner-container canvas.drawingBuffer { position: absolute; top: 0; left: 0; }
.scanner-close-btn { background: #f44336; color: #fff; border: none; border-radius: 6px; padding: 8px 16px; font-size: 14px; cursor: pointer; }
.scanner-close-wrap.fixed {
  position: fixed;
  top: 284px;
  left: 50%;
  width: min(760px, calc(100vw - 24px));
  transform: translateX(-50%);
  z-index: 161;
  text-align: right;
  pointer-events: none;
}
.scanner-close-wrap.fixed .scanner-close-btn { pointer-events: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.scan-guide { position: absolute; top: 25%; left: 10%; right: 10%; bottom: 25%; border: 2px solid rgba(76,175,80,0.7); border-radius: 4px; z-index: 2; pointer-events: none; }
.scan-guide::after { content: ""; position: absolute; top: 50%; left: 5%; right: 5%; height: 2px; background: rgba(76,175,80,0.5); }
.scan-paused .scan-guide { border-color: rgba(255,255,255,0.7); }
.scan-status { position: absolute; top: 8px; left: 12px; color: #fff; background: rgba(0,0,0,0.72); padding: 4px 8px; border-radius: 4px; z-index: 3; font-size: 14px; }
.camera-controls { position: absolute; left: 8px; right: 8px; bottom: 6px; display: flex; align-items: center; gap: 8px; z-index: 3; background: rgba(0,0,0,0.72); padding: 4px 6px; border-radius: 4px; }
.camera-controls:empty { display: none; }
.camera-controls select { min-width: 0; max-width: 60%; height: 32px; font-size: 16px; border-radius: 4px; }
.camera-controls label { display: flex; align-items: center; gap: 6px; min-width: 0; color: #fff; font-size: 12px; }
.camera-controls input[type="range"] { width: 100px; max-width: 100%; min-width: 48px; }
.scan-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; background: #fff; color: #333; border: 2px solid #4caf50; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
.scan-btn:hover { background: #f9fff9; }
.scan-btn svg { flex-shrink: 0; }
.scan-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 600px) {
  .header { padding: 10px 12px; gap: 8px; }
  .header h1 { font-size: 15px; }
  .header-actions { gap: 6px; }
  .header .auth-btn { padding: 8px 10px; font-size: 13px; }

  .container { padding: 10px; }

  .search-section, .order-info, .inspection-section { padding: 14px; border-radius: 6px; }
  .search-section h2, .inspection-section h2 { font-size: 14px; }

  .search-row { flex-direction: column; }
  .search-row input { font-size: 16px; padding: 14px 12px; }
  .search-row button { padding: 14px; font-size: 16px; border-radius: 6px; }
  .order-meta { grid-template-columns: 1fr; gap: 4px; font-size: 13px; }
  .order-meta dt { margin-top: 6px; }

  .scan-input-row input { font-size: 16px; padding: 14px 12px; }

  /* テーブル → カード型レイアウト */
  .items-table thead { display: none; }
  .items-table, .items-table tbody, .items-table tr, .items-table td {
    display: block; width: 100%;
  }
  .items-table tr {
    padding: 12px; margin-bottom: 8px;
    border: 1px solid #eee; border-radius: 6px;
    background: #fff;
  }
  .items-table td {
    padding: 3px 0; border: none; font-size: 13px;
  }
  .items-table td:first-child { font-weight: 600; color: #1a73e8; }
  .items-table td:nth-child(2) { font-size: 15px; font-weight: 600; }
  .items-table td:last-child { margin-top: 6px; }

  .ship-btn { font-size: 18px; padding: 16px; width: 100%; max-width: none; }

  .complete-card { padding: 32px 20px; }
  .complete-card .check { font-size: 48px; }
  .scanner-container.active { top: 50px; width: calc(100vw - 16px); height: 210px; }
  .scanner-container video, .scanner-container canvas { height: 210px !important; }
  .scanner-close-wrap.fixed { top: 268px; width: calc(100vw - 16px); }
  .guide-card { width: calc(100vw - 16px); max-height: 46vh; padding: 14px; }
  .guide-card h2 { font-size: 17px; }
  .guide-body { font-size: 14px; min-height: 0; }
}
