/* ===== 変数定義 (tadaima-platform風 パレット) ===== */
:root {
  --font-inter: 'Inter', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
  --bg-gradient: linear-gradient(135deg, #FFF5F7 0%, #F0F8FF 50%, #F9F7FF 100%);
  --pastel-blue-100: #E0F0FF;
  --pastel-blue-500: #66B4FF;
  --pastel-blue-600: #5CA3E6;
  --pastel-blue-800: #4880B3;
  --pastel-pink-100: #FFE4E9;
  --pastel-pink-500: #FF759D;
  --pastel-lavender-100: #F3EFFF;
  --pastel-lavender-600: #B09EE6;
  --white-glass: rgba(255, 255, 255, 0.85);
  
  --shadow-soft: 0 2px 15px -3px rgba(0, 0, 0, 0.05), 0 8px 16px -2px rgba(0, 0, 0, 0.03);
  --shadow-soft-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --text-main: #334155;
  --text-muted: #64748B;
}

/* ===== リセット・ベース ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: var(--font-inter);
  background: var(--bg-gradient);
  color: var(--text-main);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ===== 画面管理 ===== */
.screen {
  display: none;
  min-height: 100vh;
  padding: 0;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ===== ヘッダー ===== */
.app-header {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-main);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 0 rgba(255,255,255,0.5);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.6);
}
.app-header h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.badge {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.badge.offline {
  background: rgba(76, 175, 80, 0.1);
  color: #2E7D32;
  border: 1px solid rgba(76, 175, 80, 0.2);
}
.badge.online {
  background: rgba(255, 152, 0, 0.1);
  color: #E65100;
  border: 1px solid rgba(255, 152, 0, 0.2);
}
.badge.unknown {
  background: #f1f5f9;
  color: var(--text-muted);
}

/* ===== コンテンツエリア ===== */
.content {
  flex: 1;
  padding: 24px 16px;
  overflow-y: auto;
}

/* ===== カード ===== */
.card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft-lg);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.card h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text-main);
  font-weight: 700;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding-bottom: 12px;
}

/* ===== フォーム要素 ===== */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font-inter);
  color: var(--text-main);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--pastel-blue-500);
  background: white;
  box-shadow: 0 0 0 4px var(--pastel-blue-100);
}

/* ===== ボタン ===== */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-family: var(--font-inter);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: linear-gradient(135deg, var(--pastel-blue-500), var(--pastel-lavender-600));
  color: white;
  box-shadow: 0 4px 12px rgba(102, 180, 255, 0.3);
}
.btn-primary:active {
  box-shadow: 0 2px 6px rgba(102, 180, 255, 0.2);
}
.btn-success {
  background: linear-gradient(135deg, #10B981, #059669);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-danger {
  background: linear-gradient(135deg, #F43F5E, #E11D48);
  color: white;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}
.btn-warning {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: white;
}
.btn-info {
  background: linear-gradient(135deg, var(--pastel-blue-500), var(--pastel-blue-600));
  color: white;
}
.btn-secondary {
  background: #94A3B8;
  color: white;
}
.btn-outline {
  background: rgba(255, 255, 255, 0.5);
  color: var(--pastel-blue-800);
  border: 1px solid var(--pastel-blue-100);
}
.btn-outline:active {
  background: var(--pastel-blue-50);
}
.btn + .btn {
  margin-top: 12px;
}
.btn-sm {
  padding: 12px 16px;
  font-size: 15px;
}

/* ===== ステータス表示 ===== */
.status-box {
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 12px 0;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
}
.status-box.success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}
.status-box.error {
  background: #FFF1F2;
  color: #9F1239;
  border: 1px solid #FECDD3;
}
.status-box.warning {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}
.status-box.info {
  background: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

/* ===== QRスキャン画面 ===== */
#screen-scan .content {
  padding: 0;
  display: flex;
  flex-direction: column;
}
#camera-container {
  position: relative;
  width: 100%;
  background: #0f172a;
  flex-shrink: 0;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-soft-lg);
}
#camera-video {
  width: 100%;
  display: block;
  max-height: 65vh;
  object-fit: cover;
}
#camera-canvas {
  display: none;
}
.scan-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.scan-frame {
  width: 240px;
  height: 240px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  box-shadow: 0 0 0 2000px rgba(15, 23, 42, 0.6);
  position: relative;
}
.scan-frame::before,
.scan-frame::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 36px;
  border-color: var(--pastel-blue-500);
  border-style: solid;
}
.scan-frame::before {
  top: -2px; left: -2px;
  border-width: 4px 0 0 4px;
  border-radius: 8px 0 0 0;
}
.scan-frame::after {
  bottom: -2px; right: -2px;
  border-width: 0 4px 4px 0;
  border-radius: 0 0 8px 0;
}
.scan-tip {
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
  text-align: center;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
#scan-buttons {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== チェックイン結果画面 ===== */
.result-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  text-align: center;
  margin: 12px 0 4px 0;
}
.result-count {
  font-size: 18px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.result-block {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: var(--pastel-blue-800);
  background: var(--pastel-blue-100);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 12px 0;
}
.result-payment {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--radius-md);
}
.result-error-title {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin: 8px 0;
}
.result-time {
  font-size: 16px;
  text-align: center;
  color: var(--text-muted);
  margin: 8px 0;
}
.result-terminal {
  font-size: 14px;
  text-align: center;
  color: #94a3b8;
}

/* ===== 同期画面 ===== */
.sync-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 15px;
}
.sync-stat:last-child {
  border-bottom: none;
}
.sync-stat .label {
  color: var(--text-muted);
}
.sync-stat .value {
  font-weight: 700;
  color: var(--text-main);
  font-size: 18px;
}
.duplicate-item {
  background: #FFFBEB;
  border-left: 4px solid #F59E0B;
  padding: 12px;
  margin: 8px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 13px;
  color: #92400E;
}

/* ===== モーダル ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-glass);
}
.modal h3 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-main);
  text-align: center;
}
.modal .btn + .btn {
  margin-top: 12px;
}

/* ===== トースト通知 ===== */
#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  color: white;
  padding: 14px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== ローディング ===== */
.loading {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 15px;
}
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--pastel-blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 12px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== ナビゲーション ===== */
.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  position: sticky;
  bottom: 0;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
}
.nav-tab {
  flex: 1;
  padding: 14px 4px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.2s;
  font-weight: 600;
  position: relative;
}
.nav-tab.active {
  color: var(--pastel-blue-600);
}
.nav-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 3px;
  background: var(--pastel-blue-500);
  border-radius: 0 0 4px 4px;
}
.nav-tab .icon {
  display: block;
  margin: 0 auto 4px auto;
  font-size: 20px;
  filter: grayscale(100%) opacity(0.6);
  transition: all 0.2s;
}
.nav-tab.active .icon {
  filter: grayscale(0%) opacity(1);
  transform: translateY(-2px);
}

/* ===== 設定画面 ===== */
.cache-status {
  text-align: center;
  padding: 14px;
  font-size: 14px;
  border-radius: var(--radius-md);
  margin-top: 16px;
}
.cache-status.cached {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #DCFCE7;
  font-weight: 600;
}
.cache-status.not-cached {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FEF3C7;
}

/* ===== 現金払い画面 ===== */
.cash-result {
  background: white;
  border: 1px solid var(--pastel-blue-100);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 16px 0;
  box-shadow: var(--shadow-soft);
}
.cash-result .name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}
.cash-result .detail {
  font-size: 15px;
  color: var(--text-muted);
  margin: 6px 0;
}
.cash-result .fee {
  font-size: 20px;
  font-weight: 700;
  color: var(--pastel-blue-600);
  margin-top: 16px;
  background: var(--pastel-blue-50);
  padding: 12px;
  border-radius: var(--radius-md);
}
