/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #2563eb;
  --amber:   #f59e0b;
  --green:   #10b981;
  --purple:  #8b5cf6;
  --red:     #ef4444;
  --bg:      #f0f5ff;
  --card:    #ffffff;
  --text:    #1e293b;
  --sub:     #64748b;
  --border:  #e2e8f0;
  --shadow:  0 2px 12px rgba(0,0,0,0.08);
  --radius:  14px;
}

body { font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }

/* ===== パスワードゲート ===== */
.gate-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #7c3aed 100%);
  z-index: 1000;
}
.gate-card {
  background: white; border-radius: 24px; padding: 48px 40px; width: 360px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.gate-logo { font-size: 56px; margin-bottom: 12px; }
.gate-title { font-size: 28px; font-weight: 800; color: var(--blue); margin-bottom: 4px; }
.gate-sub { color: var(--sub); font-size: 14px; margin-bottom: 28px; }
.gate-input {
  width: 100%; padding: 14px 16px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 16px; margin-bottom: 12px; outline: none; transition: border-color .2s;
}
.gate-input:focus { border-color: var(--blue); }
.gate-btn {
  width: 100%; padding: 14px; background: var(--blue); color: white;
  border: none; border-radius: 10px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.gate-btn:hover { background: #1d4ed8; }
.gate-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 20px; }

/* ===== ヘッダー ===== */
.header {
  background: white; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06); position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; height: 64px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { font-size: 28px; }
.header-title { font-size: 20px; font-weight: 800; color: var(--blue); }
.header-sub { font-size: 12px; color: var(--sub); }
.header-right { display: flex; align-items: center; gap: 12px; }
.data-badge {
  background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
.btn-icon { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 8px; }
.btn-icon:hover { background: var(--bg); }

/* ===== メインコンテンツ ===== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }

/* ===== サマリーカード ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.stat-icon { font-size: 36px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--blue); line-height: 1; }
.stat-label { font-size: 13px; color: var(--sub); margin-top: 4px; }

/* ===== クラスフィルター ===== */
.filter-section { margin-bottom: 20px; }
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  padding: 8px 18px; border-radius: 20px; border: 2px solid var(--border);
  background: white; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; color: var(--sub);
}
.tab:hover { border-color: var(--blue); color: var(--blue); }
.tab.active { background: var(--blue); border-color: var(--blue); color: white; }
.tab-count {
  display: inline-block; background: rgba(255,255,255,0.3);
  font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 4px;
}
.tab:not(.active) .tab-count { background: var(--bg); color: var(--sub); }

/* ===== 生徒グリッド ===== */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ===== 生徒カード ===== */
.student-card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .2s, box-shadow .2s;
  border: 2px solid transparent;
}
.student-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); border-color: var(--blue); }

.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-avatar {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-size: 24px; flex-shrink: 0;
}
.card-name { font-size: 16px; font-weight: 700; }
.card-furigana { font-size: 11px; color: var(--sub); }
.card-meta { margin-top: 2px; }
.class-badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; color: white;
}
.grade-text { font-size: 11px; color: var(--sub); margin-left: 6px; }

.skill-bars { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.skill-row { display: flex; align-items: center; gap: 8px; }
.skill-label { font-size: 11px; color: var(--sub); width: 14px; font-weight: 600; }
.skill-bar-bg { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.skill-bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }
.skill-score { font-size: 11px; font-weight: 700; width: 24px; text-align: right; }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.card-total { font-size: 13px; color: var(--sub); }
.card-total strong { font-size: 18px; font-weight: 800; color: var(--blue); }
.card-growth { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 8px; }
.growth-up { background: #d1fae5; color: #065f46; }
.growth-same { background: #f1f5f9; color: var(--sub); }
.growth-down { background: #fee2e2; color: #991b1b; }
.card-btn { font-size: 12px; color: var(--blue); font-weight: 600; }

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: white; border-radius: 20px; width: 100%; max-width: 760px;
  max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-close {
  position: sticky; top: 12px; float: right; margin: 12px 12px 0 0;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--bg); font-size: 16px; cursor: pointer; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); }

/* モーダル内コンテンツ */
.modal-header {
  padding: 24px 28px 0 28px; display: flex; align-items: center; gap: 16px;
}
.modal-avatar {
  width: 64px; height: 64px; border-radius: 16px; font-size: 32px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.modal-name { font-size: 24px; font-weight: 800; }
.modal-furigana { font-size: 13px; color: var(--sub); }
.modal-badges { margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.enroll-info { font-size: 12px; color: var(--sub); }

.modal-tabs { display: flex; gap: 0; padding: 0 28px; margin-top: 20px; border-bottom: 2px solid var(--border); }
.modal-tab {
  padding: 10px 20px; border: none; background: none; font-size: 14px; font-weight: 600;
  color: var(--sub); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.modal-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.modal-panel { padding: 24px 28px 28px; }
.modal-panel.hidden { display: none; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.chart-box { background: var(--bg); border-radius: 12px; padding: 16px; }
.chart-title { font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 12px; text-align: center; }
.chart-wrap { position: relative; height: 200px; }

.comments-section { margin-top: 8px; }
.comments-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.comment-item {
  background: var(--bg); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
  border-left: 3px solid var(--blue);
}
.comment-date { font-size: 11px; color: var(--sub); margin-bottom: 4px; }
.comment-text { font-size: 14px; line-height: 1.6; }
.comment-scores {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;
}
.score-chip {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: white;
}

.attendance-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
}
.att-month { background: var(--bg); border-radius: 10px; padding: 12px; }
.att-month-name { font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 8px; }
.att-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.att-dot {
  width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 700;
}
.att-present { background: #d1fae5; color: #065f46; }
.att-absent  { background: #fee2e2; color: #991b1b; }
.att-summary { font-size: 12px; color: var(--sub); margin-top: 8px; }

/* ===== 設定モーダル ===== */
.settings-box { max-width: 560px; }
.modal-title { font-size: 20px; font-weight: 800; padding: 24px 28px 0; }
.settings-body { padding: 16px 28px 28px; }
.settings-note {
  font-size: 13px; line-height: 1.7; color: var(--sub); background: var(--bg);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px;
}
.settings-note code { background: #e0e7ff; color: var(--blue); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.settings-field { margin-bottom: 16px; }
.settings-field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.settings-field input {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; transition: border-color .2s;
}
.settings-field input:focus { border-color: var(--blue); }
.btn-save {
  width: 100%; padding: 12px; background: var(--blue); color: white;
  border: none; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer;
  margin-bottom: 10px;
}
.btn-save:hover { background: #1d4ed8; }
.btn-sample {
  width: 100%; padding: 10px; background: none; color: var(--sub);
  border: 2px solid var(--border); border-radius: 10px; font-size: 14px; cursor: pointer;
}
.btn-sample:hover { border-color: var(--blue); color: var(--blue); }

/* ===== レスポンシブ ===== */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 22px; }
  .main-content { padding: 16px; }
  .modal-box { border-radius: 16px; }
  .modal-header, .modal-panel { padding-left: 16px; padding-right: 16px; }
}
