/* ===== 基本リセット ===== */
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  margin: 0;
  touch-action: manipulation;
}
input, select, textarea {
  font-size: 16px !important;
  touch-action: manipulation;
}

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid #e5e7eb;
  display: flex; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px 6px; cursor: pointer; transition: all 0.2s;
  color: #9ca3af; font-size: 10px; gap: 2px;
  border: none; background: none;
}
.nav-item.active { color: #1e293b; }
.nav-item i { font-size: 18px; }

/* ===== ヘッダー ===== */
.app-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white; padding: 14px 16px; position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.header-logo img {
  height: 28px; width: 28px;
  object-fit: contain;
}
.header-logo h1 { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.header-date { font-size: 11px; opacity: 0.7; }

/* ===== セクションカード ===== */
.section-card {
  background: #fff; border-radius: 16px; margin: 10px 12px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05); overflow: hidden;
}
.section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 10px; font-weight: 700; font-size: 13px;
  color: #1e293b; border-bottom: 1px solid #f1f5f9;
}
.section-header i { font-size: 14px; }
.section-body { padding: 12px 16px 14px; }

/* ===== フォーム ===== */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block; font-size: 11px; font-weight: 600;
  color: #64748b; margin-bottom: 5px; letter-spacing: 0.3px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid #e2e8f0;
  border-radius: 10px; font-size: 15px; background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none; -webkit-appearance: none;
}
.form-textarea { resize: vertical; min-height: 60px; font-size: 14px; line-height: 1.5; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #1e293b; background: #fff;
  box-shadow: 0 0 0 3px rgba(30,41,59,0.1);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ===== 数値入力グリッド ===== */
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.num-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.num-item { text-align: center; }
.num-label {
  font-size: 10px; font-weight: 700; color: #64748b;
  margin-bottom: 4px; letter-spacing: 0.3px;
}
.num-label .pts { font-size: 9px; color: #94a3b8; font-weight: 600; }
.num-input {
  width: 100%; padding: 10px 0; text-align: center;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 20px !important; font-weight: 700; background: #f8fafc;
  outline: none; -webkit-appearance: none;
  touch-action: manipulation;
}
.num-input:focus {
  border-color: #1e293b; background: #fff;
  box-shadow: 0 0 0 3px rgba(30,41,59,0.1);
}

/* ===== ボタン ===== */
.submit-btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  box-shadow: 0 4px 12px rgba(30,41,59,0.3);
  transition: transform 0.15s, box-shadow 0.15s; letter-spacing: 0.5px;
}
.submit-btn:active { transform: scale(0.97); box-shadow: 0 2px 6px rgba(30,41,59,0.2); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  width: 100%; padding: 12px; border: 1.5px solid #e2e8f0; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: #64748b; cursor: pointer;
  background: #fff; transition: all 0.15s;
}
.btn-secondary:active { background: #f1f5f9; }
.btn-danger {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: #ef4444; cursor: pointer;
  background: #fef2f2; transition: all 0.15s;
}

/* ===== ランキング ===== */
.rank-tabs { display: flex; gap: 6px; padding: 0 12px; margin-top: 10px; }
.rank-tab {
  flex: 1; padding: 9px 0; border: none; border-radius: 10px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  background: #f1f5f9; color: #64748b; transition: all 0.2s;
}
.rank-tab.active {
  background: #1e293b; color: #fff;
  box-shadow: 0 2px 8px rgba(30,41,59,0.3);
}
.rank-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid #f1f5f9;
}
.rank-card:last-child { border-bottom: none; }
.rank-badge {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #d1d5db, #9ca3af); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; }
.rank-other { background: #f1f5f9; color: #64748b; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 14px; font-weight: 700; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-company { font-size: 10px; color: #94a3b8; font-weight: 600; margin-top: 1px; }

/* ===== 日付ピッカー ===== */
.date-picker {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; margin-top: 10px;
}
.date-btn {
  width: 34px; height: 34px; border: none; border-radius: 10px;
  background: #f1f5f9; cursor: pointer; font-size: 13px; color: #64748b;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.date-btn:active { background: #e2e8f0; transform: scale(0.95); }
.date-display {
  flex: 1; text-align: center; font-size: 14px; font-weight: 700; color: #1e293b;
}
.cal-wrap {
  position: relative; width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: #f1f5f9;
}
.cal-icon { font-size: 14px; color: #64748b; pointer-events: none; }
.date-calendar-input {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 16px;
  -webkit-appearance: none; border: none; background: transparent;
}

/* ===== 会社カード ===== */
.company-card {
  border-radius: 12px; padding: 12px; margin-bottom: 10px;
}
.company-card:last-child { margin-bottom: 0; }
.cc-breath { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; }
.cc-labore { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border: 1px solid #a7f3d0; }
.cc-wolfgate { background: linear-gradient(135deg, #f5f3ff, #ede9fe); border: 1px solid #c4b5fd; }
.cc-name { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.cc-breath .cc-name { color: #1e40af; }
.cc-labore .cc-name { color: #047857; }
.cc-wolfgate .cc-name { color: #6d28d9; }
.cc-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.cc-stat { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,0.7); color: #475569; }

/* ===== マイページ ===== */
.profile-card {
  text-align: center; padding: 20px 16px;
}
.profile-avatar {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #1e293b, #475569);
}
.profile-name { font-size: 18px; font-weight: 800; color: #1e293b; }
.profile-company { font-size: 12px; color: #64748b; margin-top: 2px; }
.admin-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: #fef3c7; color: #92400e; padding: 2px 10px;
  border-radius: 20px; margin-top: 6px;
}

/* ===== ボーダー ===== */
.border-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f8fafc; border-radius: 10px; margin-top: 8px;
}
.border-fill {
  flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
}
.border-fill-inner {
  height: 100%; border-radius: 4px; transition: width 0.5s;
}
.border-fill-inner.green { background: linear-gradient(90deg, #10b981, #059669); }
.border-fill-inner.red { background: linear-gradient(90deg, #f87171, #ef4444); }
.border-text { font-size: 11px; font-weight: 700; flex-shrink: 0; min-width: 60px; text-align: right; }

/* ===== ポイント表示(管理者のみ) ===== */
.points-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 8px; background: #fef3c7; color: #92400e;
}

/* ===== トースト ===== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: 12px; font-size: 13px; font-weight: 600;
  color: #fff; z-index: 100; opacity: 0; transition: opacity 0.3s;
  pointer-events: none; max-width: 90%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.show { opacity: 1; }
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

/* ===== 空の状態 ===== */
.empty-state { text-align: center; padding: 30px 20px; color: #94a3b8; }
.empty-state i { font-size: 40px; margin-bottom: 10px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* ===== 共通 ===== */
.page-content { padding-bottom: 72px; }
.page { display: none; }
.page.active { display: block; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeInUp 0.3s ease-out; }
.spinner { width: 24px; height: 24px; border: 3px solid #e2e8f0; border-top-color: #1e293b; border-radius: 50%; animation: spin 0.6s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== スコア公開トグル ===== */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle-switch {
  width: 50px; height: 28px; border-radius: 14px; border: none;
  background: #d1d5db; position: relative; cursor: pointer; transition: background 0.3s;
  flex-shrink: 0;
}
.toggle-switch.on { background: #059669; }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: transform 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.toggle-switch.on .toggle-knob { transform: translateX(22px); }
.toggle-label { font-size: 12px; font-weight: 600; color: #475569; }

/* ===== 登録画面 ===== */
.register-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}
.register-card {
  background: #fff; border-radius: 20px; padding: 30px 24px;
  width: 100%; max-width: 380px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.register-logo {
  text-align: center; margin-bottom: 20px;
}
.register-logo img {
  height: 48px; width: auto;
  display: inline-block;
  object-fit: contain;
}
.register-title {
  text-align: center; font-size: 20px; font-weight: 800;
  color: #1e293b; margin-bottom: 4px;
}
.register-sub {
  text-align: center; font-size: 12px; color: #94a3b8; margin-bottom: 20px;
}
.login-link {
  text-align: center; margin-top: 16px; font-size: 13px; color: #64748b;
}
.login-link a {
  color: #1e293b; font-weight: 700; text-decoration: none;
}

/* ===== 日報 ===== */
.nippou-item {
  padding: 12px 0; border-bottom: 1px solid #f1f5f9; cursor: pointer;
}
.nippou-item:last-child { border-bottom: none; }
.nippou-header {
  display: flex; align-items: center; gap: 10px;
}
.nippou-arrow {
  font-size: 12px; color: #94a3b8; transition: transform 0.2s;
}
.nippou-detail {
  max-height: 0; overflow: hidden; transition: max-height 0.3s, padding 0.3s;
  padding: 0 0 0 42px;
}
.nippou-detail.open {
  max-height: 300px; padding: 8px 0 4px 42px;
}
.nd-item {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 12px; margin-bottom: 6px; line-height: 1.5;
}
.nd-item i { margin-top: 3px; font-size: 11px; flex-shrink: 0; }

/* ===== 編集モーダル ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-card {
  background: #fff; border-radius: 20px 20px 0 0; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 12px; border-bottom: 1px solid #f1f5f9;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 12px 20px 24px; }

/* ===== マイページ報告アイテム ===== */
.my-record-item {
  padding: 10px 0; border-bottom: 1px solid #f1f5f9; cursor: pointer;
  transition: background 0.15s;
}
.my-record-item:active { background: #f8fafc; }
.my-record-item:last-child { border-bottom: none; }

/* ===== 会社アバター ===== */
.company-breath { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.company-labore { background: linear-gradient(135deg, #10b981, #059669); }
.company-wolfgate { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.record-avatar {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex-shrink: 0;
}
