/* ===================================================
   焼あご製造トレース調査票管理システム
   Design System & Styles
   スマートフォン最適化版
   =================================================== */

/* --- CSS Custom Properties --- */
:root {
  /* Light Theme (default) */
  --bg-primary: #eef2f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f5f8fb;
  --bg-hover: #e4eaf2;
  --border: #cdd6e2;
  --border-focus: #2e8bc0;
  --text-primary: #1a2744;
  --text-secondary: #5a6e8a;
  --text-muted: #8b9cb8;

  /* Accent Colors */
  --accent: #2e8bc0;
  --accent-hover: #2578a8;
  --accent-light: rgba(46, 139, 192, 0.12);
  --accent-glow: rgba(46, 139, 192, 0.35);
  --success: #22c55e;
  --success-hover: #1aac50;
  --success-light: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Typography */
  --font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-xs: 0.7rem;
  --fs-sm: 0.82rem;
  --fs-base: 0.95rem;
  --fs-lg: 1.08rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* Transition */
  --tr-fast: 150ms ease;
  --tr-base: 250ms ease;
  --tr-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Safe Area (PWAのノッチ対応) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0c1524;
  --bg-secondary: #132035;
  --bg-card: #182a45;
  --bg-input: #1e3355;
  --bg-hover: #243d60;
  --border: #2a4065;
  --border-focus: #4da8da;
  --text-primary: #e2e8f0;
  --text-secondary: #8899b2;
  --text-muted: #5a6e88;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.45);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* iOS Safari のバウンスを防止 */
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  min-height: 100dvh;
  transition: background var(--tr-base), color var(--tr-base);
  /* タッチハイライト無効化 */
  -webkit-tap-highlight-color: transparent;
  /* iOS の慣性スクロール */
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* --- Header --- */
.header {
  background: linear-gradient(135deg, #0f1b2d 0%, #1a3555 50%, #1e4d6e 100%);
  color: #ffffff;
  padding: var(--sp-md) var(--sp-lg);
  padding-top: calc(var(--sp-md) + var(--safe-top));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.header-logo {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.header-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.header-subtitle {
  font-size: var(--fs-xs);
  color: rgba(255,255,255,0.65);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* --- 接続状態表示 --- */
.connection-status {
  font-size: var(--fs-xs);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--tr-fast);
}

.connection-status.online {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.connection-status.offline {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  animation: pulse-offline 2s infinite;
}

@keyframes pulse-offline {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.header-clock {
  font-size: var(--fs-sm);
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
  display: none;
}

.theme-toggle,
.header-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tr-fast);
  color: #fff;
  /* タッチ操作で十分な大きさを確保 */
  min-width: 44px;
  min-height: 44px;
}

.theme-toggle:hover,
.header-menu-btn:hover {
  background: rgba(255,255,255,0.22);
}

.theme-toggle:active,
.header-menu-btn:active {
  background: rgba(255,255,255,0.3);
  transform: scale(0.95);
}

/* --- Header Menu (データ管理) --- */
.header-menu {
  position: absolute;
  top: 100%;
  right: var(--sp-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
  animation: fadeSlideIn 0.2s ease;
  min-width: 220px;
}

.header-menu-item {
  display: block;
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--tr-fast);
  min-height: 48px;
}

.header-menu-item:last-child {
  border-bottom: none;
}

.header-menu-item:hover,
.header-menu-item:active {
  background: var(--bg-hover);
}

/* --- Tab Navigation --- */
.tab-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 72px;
  z-index: 90;
  box-shadow: var(--shadow-xs);
  transition: background var(--tr-base), border-color var(--tr-base);
}

.tab-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-nav-inner::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 0;
  padding: var(--sp-md) var(--sp-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  transition: color var(--tr-fast), background var(--tr-fast);
  white-space: nowrap;
  /* タッチ対応: 最小タップ領域 */
  min-height: 56px;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: width var(--tr-base);
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.tab-btn:active {
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent);
  font-weight: 700;
}

.tab-btn.active::after {
  width: 60%;
}

.tab-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.tab-label {
  font-size: var(--fs-xs);
  line-height: 1.2;
}

/* --- Main Content --- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-lg);
  padding-bottom: calc(var(--sp-2xl) + var(--safe-bottom));
}

.tab-panel {
  display: none;
  animation: fadeSlideIn 0.35s var(--tr-slow);
}

.tab-panel.active {
  display: block;
}

/* --- Card --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-lg);
  transition: background var(--tr-base), border-color var(--tr-base), box-shadow var(--tr-base);
  overflow: hidden;
}

.card-header {
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
}

.card-header h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.card-header h2 .icon {
  font-size: 1.2rem;
}

.card-body {
  padding: var(--sp-lg);
}

/* --- Form Elements --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-md);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.form-group label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px; /* iOS Safariのズーム防止: 16px以上 */
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast);
  outline: none;
  /* タッチ操作に適したサイズ */
  min-height: 48px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-secondary);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6e8a' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.form-error {
  font-size: var(--fs-xs);
  color: var(--danger);
}

/* --- Stamp Button Component --- */
.stamp-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--tr-fast), background var(--tr-fast);
}

.stamp-group.stamped {
  border-color: var(--success);
  background: var(--success-light);
}

.stamp-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.stamp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  width: 100%;
  min-height: 60px; /* スマホ対応: より大きなタップ領域 */
  padding: 12px var(--sp-lg);
  background: linear-gradient(135deg, #2e8bc0, #1e6fa0);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--fs-lg);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), opacity var(--tr-fast);
  position: relative;
  overflow: hidden;
  /* タッチフィードバック */
  -webkit-tap-highlight-color: transparent;
}

.stamp-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.stamp-btn:active {
  transform: translateY(1px) scale(0.97);
}

.stamp-btn.stamped {
  background: linear-gradient(135deg, #22c55e, #1aac50);
  pointer-events: none;
}

.stamp-btn .stamp-icon {
  font-size: 1.3rem;
}

/* 打刻成功のパルスアニメーション */
.stamp-btn.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.4);
  border-radius: inherit;
  animation: stampPulse 0.6s ease-out forwards;
}

.stamp-display {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--success-light);
  border: 1.5px solid var(--success);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--success);
}

.stamp-display .stamp-check {
  font-size: 1.1rem;
}

.stamp-manual {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.stamp-manual .form-input {
  flex: 1;
  min-width: 200px;
}

.stamp-toggle {
  font-size: var(--fs-xs);
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 36px;
}

.stamp-toggle:hover {
  color: var(--accent-hover);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 12px 20px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr-fast);
  white-space: nowrap;
  text-decoration: none;
  /* スマホ対応: タッチフレンドリー */
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #2e8bc0, #1e6fa0);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2578a8, #1a5f8e);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #1aac50);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-success:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 8px 14px;
  font-size: var(--fs-xs);
  min-height: 38px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: var(--fs-base);
  min-height: 52px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  min-height: 40px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.form-actions {
  display: flex;
  gap: var(--sp-md);
  margin-top: var(--sp-lg);
  flex-wrap: wrap;
}

/* --- Lot List (登録済み一覧) --- */
.lot-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.lot-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background var(--tr-fast), border-color var(--tr-fast), box-shadow var(--tr-fast);
  cursor: pointer;
  /* スマホ対応: タッチフレンドリー */
  min-height: 64px;
}

.lot-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.lot-item:active {
  background: var(--bg-hover);
  transform: scale(0.99);
}

.lot-item.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.lot-date {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
  min-width: 90px;
}

.lot-info {
  flex: 1;
  min-width: 0;
}

.lot-detail {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-md);
}

.lot-badges {
  display: flex;
  gap: var(--sp-xs);
  flex-wrap: wrap;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
}

.badge-pending {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-complete {
  background: var(--success-light);
  color: var(--success);
}

.badge-info {
  background: var(--accent-light);
  color: var(--accent);
}

.lot-actions {
  display: flex;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

/* --- Packing: Dynamic Rows --- */
.packing-rows {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.packing-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.packing-row .form-select,
.packing-row .form-input {
  flex: 1;
}

.packing-row .btn-icon {
  flex-shrink: 0;
}

.packing-summary {
  margin-top: var(--sp-md);
  padding: var(--sp-md);
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
}

.packing-summary h4 {
  font-size: var(--fs-sm);
  color: var(--accent);
  margin-bottom: var(--sp-sm);
}

.packing-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-lg);
  font-size: var(--fs-sm);
}

/* --- Fraction (端数) Input --- */
.fraction-area {
  margin-top: var(--sp-md);
  padding: var(--sp-md);
  background: var(--warning-light);
  border: 1.5px dashed var(--warning);
  border-radius: var(--radius-md);
}

.fraction-area .fraction-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--warning);
  margin-bottom: var(--sp-sm);
}

.fraction-row {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}

.fraction-row .form-select,
.fraction-row .form-input {
  flex: 1;
}

/* --- Report Tab --- */
.report-controls {
  display: flex;
  gap: var(--sp-md);
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--sp-lg);
}

.report-controls .form-group {
  min-width: 140px;
  flex: 1;
}

.report-btn-group {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  flex: 1;
  min-width: 100%;
}

.report-btn-group .btn {
  flex: 1;
  min-width: 0;
}

.report-preview {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-2xl);
  overflow-x: auto;
  box-shadow: var(--shadow-md);
  /* スマホでの横スクロール改善 */
  -webkit-overflow-scrolling: touch;
}

/* レポートテーブル */
.report-preview h3 {
  font-size: var(--fs-xl);
  text-align: center;
  margin-bottom: var(--sp-sm);
}

.report-preview .report-dest {
  font-size: var(--fs-base);
  margin-bottom: var(--sp-lg);
  text-decoration: underline;
}

.report-preview .report-year {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--sp-sm);
}

.report-preview .report-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--sp-xs);
}

.report-preview .report-product {
  font-size: var(--fs-base);
  color: #2e8bc0;
  margin-bottom: var(--sp-lg);
  text-decoration: underline;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-lg);
}

.report-table th,
.report-table td {
  border: 1px solid #333;
  padding: 6px 10px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.report-table th {
  background: #f0f4f8;
  font-weight: 700;
  font-size: var(--fs-xs);
}

.report-table td {
  background: #fff;
}

.report-table .total-row td {
  font-weight: 700;
  background: #f8f9fa;
}

.report-section-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: var(--sp-lg) 0 var(--sp-md);
}

.report-packages {
  padding-left: var(--sp-2xl);
}

.report-packages p {
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: var(--sp-xs);
  line-height: 1.6;
}

.summary-table {
  width: auto;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin-top: var(--sp-md);
}

.summary-table th,
.summary-table td {
  border: 1px solid #333;
  padding: 6px 14px;
  text-align: center;
}

.summary-table th {
  background: #f0f4f8;
  font-weight: 700;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--sp-2xl) var(--sp-lg);
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-md);
  opacity: 0.5;
}

.empty-state p {
  font-size: var(--fs-sm);
}

/* --- Toast Notification --- */
.toast-container {
  position: fixed;
  bottom: calc(var(--sp-lg) + var(--safe-bottom));
  right: var(--sp-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.4s var(--tr-slow);
  max-width: 360px;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error   { border-left: 4px solid var(--danger); }
.toast.toast-warning { border-left: 4px solid var(--warning); }

.toast.toast-out {
  animation: toastOut 0.3s ease forwards;
}

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }

/* --- Modal (確認ダイアログ) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  overflow: hidden;
  animation: modalSlideIn 0.3s var(--tr-slow);
}

.modal-body {
  padding: var(--sp-lg);
  font-size: var(--fs-base);
  line-height: 1.8;
}

.modal-actions {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-lg);
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* --- Install Banner (PWA) --- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  padding: var(--sp-md) var(--sp-lg);
  padding-bottom: calc(var(--sp-md) + var(--safe-bottom));
  animation: slideUpIn 0.4s var(--tr-slow);
}

.install-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.install-banner-text {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); }
.mb-md { margin-bottom: var(--sp-md); }
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* --- Checkbox --- */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  min-height: 44px;
}

.checkbox-group input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-group label {
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

/* --- Animations --- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideUpIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes stampPulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(2.5);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Responsive --- */
@media (min-width: 600px) {
  .header-clock {
    display: block;
  }
}

@media (min-width: 768px) {
  .tab-btn {
    flex-direction: row;
    gap: var(--sp-sm);
    padding: var(--sp-md) var(--sp-lg);
  }

  .tab-label {
    font-size: var(--fs-sm);
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .report-btn-group {
    min-width: auto;
    flex: 0;
  }
}

@media (max-width: 599px) {
  .header-inner {
    padding: 0;
  }

  .header-title {
    font-size: var(--fs-lg);
  }

  .header-subtitle {
    font-size: 0.65rem;
  }

  .main-content {
    padding: var(--sp-md);
  }

  .card-body {
    padding: var(--sp-md);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .report-preview {
    padding: var(--sp-md);
  }

  .lot-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .lot-actions {
    align-self: flex-end;
  }

  .toast-container {
    left: var(--sp-md);
    right: var(--sp-md);
    bottom: calc(var(--sp-md) + var(--safe-bottom));
  }

  .toast {
    max-width: 100%;
  }

  /* スマホではメニューを全幅に */
  .header-menu {
    left: var(--sp-md);
    right: var(--sp-md);
  }

  .stamp-btn {
    min-height: 64px;
    font-size: var(--fs-xl);
  }

  .btn-lg {
    width: 100%;
    min-height: 56px;
    font-size: var(--fs-lg);
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* レポートボタンをスタックに */
  .report-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .report-controls .form-group {
    min-width: 0;
  }

  .report-btn-group {
    flex-direction: column;
  }

  .install-banner-inner {
    flex-wrap: wrap;
  }

  .install-banner-text {
    flex-basis: 100%;
    margin-bottom: var(--sp-xs);
  }
}

/* --- Print Styles --- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 10pt;
  }

  .header,
  .tab-nav,
  .no-print,
  .toast-container,
  .theme-toggle,
  .header-menu-btn,
  .header-menu,
  .install-banner,
  .modal-overlay {
    display: none !important;
  }

  .main-content {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .tab-panel {
    display: none !important;
  }

  .tab-panel.printing {
    display: block !important;
  }

  .card {
    border: none;
    box-shadow: none;
    border-radius: 0;
    margin: 0;
  }

  .card-header {
    display: none;
  }

  .report-preview {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 10mm;
  }

  .report-table th,
  .report-table td {
    border: 1px solid #000;
    padding: 4px 8px;
  }

  .report-table th {
    background: #e8e8e8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .summary-table th,
  .summary-table td {
    border: 1px solid #000;
  }

  .summary-table th {
    background: #e8e8e8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page {
    size: A4 landscape;
    margin: 10mm;
  }
}
