/* ========================================================
   TAKUYA HEALTH LOG — Modern Health Analytics Stylesheet
   Typography: Zen Kaku Gothic New + Plus Jakarta Sans
   ======================================================== */

:root {
  /* Color Palette: Warm Natural & Crisp Healthcare */
  --bg-main: #f7f9fc;
  --bg-card: #ffffff;
  --bg-subtle: #edf2f7;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --text-inverse: #ffffff;

  /* Accent Colors */
  --brand-navy: #1e3a5f;
  --brand-blue: #2563eb;
  --accent-teal: #0d9488;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-emerald: #059669;
  --accent-indigo: #4f46e5;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  /* Fonts */
  --font-sans: 'Zen Kaku Gothic New', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-num: 'Plus Jakarta Sans', var(--font-sans);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 60px;
}

/* Header */
.app-header {
  background: var(--brand-navy);
  color: var(--text-inverse);
  padding: 36px 24px;
  box-shadow: var(--shadow-md);
  border-bottom: 3px solid rgba(255, 255, 255, 0.1);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.badge-status {
  display: inline-block;
  font-family: var(--font-num);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 8px;
}

.brand-title {
  font-family: var(--font-num);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

.header-meta {
  display: flex;
  gap: 14px;
}

.meta-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  text-align: right;
}

.meta-label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.meta-val {
  font-family: var(--font-num);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

/* Dashboard Container */
.dashboard-container {
  max-width: 1240px;
  margin: -24px auto 0;
  padding: 0 20px;
}

/* KPI Summary Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.kpi-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.kpi-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

.kpi-badge.normal {
  background: #e0f2fe;
  color: #0369a1;
}

.kpi-badge.inbody {
  background: #e0e7ff;
  color: #4338ca;
}

.kpi-badge.latest {
  background: #fef3c7;
  color: #b45309;
}

.kpi-body {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-num {
  font-family: var(--font-num);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.kpi-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
}

/* Chart Section */
.chart-section {
  margin-bottom: 36px;
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

/* Category Tabs */
.tabs-nav {
  display: flex;
  background: #e2e8f0;
  padding: 4px;
  border-radius: var(--radius-pill);
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 9px 18px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--brand-blue);
  box-shadow: var(--shadow-sm);
}

/* Filter Group */
.filter-group {
  display: flex;
  background: #e2e8f0;
  padding: 4px;
  border-radius: var(--radius-pill);
  gap: 4px;
}

.filter-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn.active {
  background: var(--brand-navy);
  color: #ffffff;
}

/* Chart Card */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 16px;
}

#chart-main-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand-navy);
}

#chart-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.chart-guide-note {
  font-size: 0.78rem;
  color: var(--accent-teal);
  background: #f0fdf4;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-weight: 500;
}

.canvas-container {
  position: relative;
  height: 440px;
  width: 100%;
}

/* Table Section */
.table-section {
  margin-top: 32px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
}

.table-title-area h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.table-title-area p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.record-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: #e2e8f0;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  max-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--brand-navy);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-color);
  z-index: 2;
  line-height: 1.3;
}

.th-unit {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-family: var(--font-num);
}

tbody tr:nth-child(even) {
  background-color: #fafbfc;
}

tbody tr:hover {
  background-color: #f1f5f9;
}

td.td-date {
  text-align: center;
  font-weight: 700;
  color: var(--brand-navy);
}

td.td-age {
  text-align: center;
  color: var(--text-muted);
}

td.td-source {
  text-align: left;
  font-family: var(--font-sans);
}

/* Source Badges */
.badge-source {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.badge-source.kenkou {
  background: #eff6ff;
  color: #1e40af;
}

.badge-source.oike {
  background: #fdf2f8;
  color: #9d174d;
}

.badge-source.inbody {
  background: #ecfdf5;
  color: #065f46;
}

.badge-source.latest {
  background: #fffbeb;
  color: #92400e;
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 50px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-meta {
    width: 100%;
    justify-content: space-between;
  }
  .chart-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .canvas-container {
    height: 320px;
  }
}

/* ========================================================
   InBody 専用 & 体型・動物マトリクス (Body Type Matrix) スタイル
   ======================================================== */

/* タブのInBody強調 */
.tab-btn.tab-inbody {
  background: #f0fdf4;
  color: #166534;
  border-color: #86efac;
}
.tab-btn.tab-inbody.active {
  background: #16a34a;
  color: #ffffff;
  border-color: #16a34a;
}

.tab-btn.tab-matrix {
  background: #fdf4ff;
  color: #86198f;
  border-color: #f0abfc;
}
.tab-btn.tab-matrix.active {
  background: #a21caf;
  color: #ffffff;
  border-color: #a21caf;
}

/* マトリクス用レイアウト */
.matrix-section {
  display: none;
  margin-top: 24px;
}
.matrix-section.active {
  display: block;
}

.matrix-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.matrix-zone-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.matrix-zone-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.matrix-zone-info {
  display: flex;
  flex-direction: column;
}

.matrix-zone-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.matrix-zone-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* 体型変遷タイムライン (12年間の軌跡カード) */
.timeline-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.timeline-card:hover, .timeline-card.selected {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-subtle);
}

.timeline-date {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.timeline-age {
  font-size: 0.75rem;
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

.timeline-animal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline-animal-icon {
  font-size: 2rem;
  background: #f8fafc;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.timeline-animal-text {
  display: flex;
  flex-direction: column;
}

.timeline-animal-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--brand-navy);
}

.timeline-type-badge {
  font-size: 0.72rem;
  color: var(--accent-teal);
  font-weight: 600;
}

.timeline-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.timeline-metric-item span:first-child {
  color: var(--text-muted);
  display: block;
  font-size: 0.7rem;
}

.timeline-metric-item span:last-child {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--text-primary);
}

/* ========================================================
   PINコード ロック画面 (Passcode Lock Screen)
   ======================================================== */
.lock-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
}

.lock-box {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 36px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  color: #ffffff;
}

.lock-shield {
  font-size: 2.4rem;
  display: inline-block;
  margin-bottom: 8px;
}

.lock-title {
  font-family: var(--font-num);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  margin-bottom: 4px;
}

.lock-desc {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 24px;
}

.pin-dots-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #64748b;
  background: transparent;
  transition: all 0.2s ease;
}

.pin-dot.filled {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  transform: scale(1.15);
}

.lock-error-msg {
  height: 20px;
  font-size: 0.78rem;
  color: #f87171;
  margin-bottom: 12px;
  font-weight: 600;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 270px;
  margin: 0 auto 20px;
}

.key-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-family: var(--font-num);
  font-size: 1.4rem;
  font-weight: 600;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.92);
}

.key-btn.key-action {
  font-size: 0.85rem;
  border-radius: 14px;
  color: #94a3b8;
}

.lock-remember-row {
  font-size: 0.78rem;
  color: #94a3b8;
}

.remember-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-relock {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-relock:hover {
  background: rgba(255, 255, 255, 0.25);
}

.shake-animation {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

