/* ==========================================================================
   ระบบแจ้งและสรุปสถิติการมาเรียนของนักเรียน - Main Stylesheet
   โรงเรียนบ้านห้วยปอ ภาคเรียนที่ 2 ปีการศึกษา 2569
   ธีมน่ารัก น่าใช้ สะอาดตา สี่เหลี่ยมลบมุม แยกสี 3 ช่วงชั้น
   ========================================================================== */

:root {
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Color Palette */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  
  --color-k: #f43f5e;       /* ชมพู - อนุบาล */
  --color-k-bg: #fff1f2;
  --color-k-border: #fda4af;
  
  --color-p: #0284c7;       /* ฟ้า - ประถม */
  --color-p-bg: #f0f9ff;
  --color-p-border: #7dd3fc;
  
  --color-m: #7c3aed;       /* ม่วง - มัธยม */
  --color-m-bg: #f5f3ff;
  --color-m-border: #c4b5fd;
  
  --bg-page: #fafbfc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --shadow-cute: 0 4px 14px 0 rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 20px 0 rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

/* ================= Top Navigation Bar ================= */
.top-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-text h1 {
  font-size: 18px;
  margin: 0;
  line-height: 1.2;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: var(--radius-md);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background-color: #fff;
  border-color: #cbd5e1;
  color: var(--text-main);
  border-radius: var(--radius-md);
}
.btn-outline:hover {
  background-color: #f8fafc;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.main-wrapper {
  max-width: 1200px;
  margin: 22px auto;
  padding: 0 20px;
}

/* ==========================================================================
   หน้าบันทึกข้อมูลรายห้อง (สไตล์น่ารัก สะอาดตา สี่เหลี่ยมลบมุม แยกสี 3 ช่วงชั้น)
   ========================================================================== */
.cute-entry-card {
  max-width: 680px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  padding: 32px 36px;
  box-shadow: var(--shadow-cute);
}

.cute-page-header {
  text-align: center;
  margin-bottom: 24px;
}

.cute-page-title {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cute-page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* Control Bar แถบเลือกวันที่ */
.cute-control-bar {
  background: #f8fafd;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.cute-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 6px 12px;
}

.cute-date-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.cute-date-group input[type="date"] {
  border: none;
  background: transparent;
  font-family: var(--font-heading);
  font-size: 14px;
  color: #1e293b;
  outline: none;
  cursor: pointer;
}

.cute-date-badge {
  font-size: 13.5px;
  color: #0284c7;
  background: #e0f2fe;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.cute-btn-today {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cute-btn-today:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* หัวข้อเลือกห้องเรียน */
.cute-section-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cute-current-badge {
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.cute-capacity-badge {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

/* กลุ่มปุ่มเลือกชั้นเรียน แยกสี 3 ช่วงชั้น */
.cute-room-categories {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.cute-cat-group {
  background: #fafbfc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
}

.cute-cat-group.group-k {
  border-color: #fecdd3;
  background: #fffbfa;
}

.cute-cat-group.group-p {
  border-color: #bae6fd;
  background: #f8fcff;
}

.cute-cat-group.group-m {
  border-color: #ddd6fe;
  background: #faf8ff;
}

.cute-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.badge-k { background: #ffe4e6; color: #e11d48; }
.badge-p { background: #e0f2fe; color: #0284c7; }
.badge-m { background: #ede9fe; color: #7c3aed; }

.cute-room-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ปุ่มเลือกห้องเรียน (สี่เหลี่ยมลบมุมโค้งมน) */
.cute-room-btn {
  width: 78px;
  height: 48px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  border: 1.5px solid transparent;
}

/* 1. ปุ่มอนุบาล (ชมพูพาสเทล) */
.cute-room-btn.btn-k {
  border-color: #fb7185;
  background: #ffffff;
  color: #e11d48;
}
.cute-room-btn.btn-k:hover {
  background: #ffe4e6;
  transform: translateY(-2px);
}
.cute-room-btn.btn-k.active {
  background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  color: #ffffff;
  border-color: #be123c;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.35);
  transform: translateY(-2px);
}

/* 2. ปุ่มประถม (ฟ้าพาสเทล) */
.cute-room-btn.btn-p {
  border-color: #38bdf8;
  background: #ffffff;
  color: #0284c7;
}
.cute-room-btn.btn-p:hover {
  background: #e0f2fe;
  transform: translateY(-2px);
}
.cute-room-btn.btn-p.active {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transform: translateY(-2px);
}

/* 3. ปุ่มมัธยม (ม่วงพาสเทล) */
.cute-room-btn.btn-m {
  border-color: #a855f7;
  background: #ffffff;
  color: #7c3aed;
}
.cute-room-btn.btn-m:hover {
  background: #ede9fe;
  transform: translateY(-2px);
}
.cute-room-btn.btn-m.active {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  color: #ffffff;
  border-color: #6d28d9;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
  transform: translateY(-2px);
}

.cute-room-btn.has-data::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 11px;
  font-weight: 900;
}
.cute-room-btn.btn-k.has-data::after { color: #e11d48; }
.cute-room-btn.btn-p.has-data::after { color: #0284c7; }
.cute-room-btn.btn-m.has-data::after { color: #7c3aed; }
.cute-room-btn.active.has-data::after { color: #ffffff !important; }

/* ==========================================================================
   4 ช่องลงสถิติ สี่เหลี่ยมลบมุม แยกสี 4 สถานะน่ารัก สดใส
   ========================================================================== */
.cute-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.cute-stat-card {
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
}

.cute-stat-card label {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
}

.cute-stat-input {
  width: 100%;
  max-width: 90px;
  height: 52px;
  border-radius: var(--radius-md);
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: #1e293b;
  outline: none;
  transition: all 0.15s ease;
}

/* 1. มา (เขียวมิ้นต์สดใส) */
.cute-stat-card.card-present {
  background: #f0fdf4;
  border-color: #86efac;
}
.cute-stat-card.card-present label { color: #047857; }
.cute-stat-card.card-present .cute-stat-input {
  border-color: #4ade80;
  color: #047857;
}
.cute-stat-card.card-present .cute-stat-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* 2. ป่วย (ส้มพีชพาสเทล) */
.cute-stat-card.card-sick {
  background: #fffbeb;
  border-color: #fde68a;
}
.cute-stat-card.card-sick label { color: #b45309; }
.cute-stat-card.card-sick .cute-stat-input {
  border-color: #fcd34d;
  color: #b45309;
}
.cute-stat-card.card-sick .cute-stat-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* 3. ลา (ฟ้าพาสเทล) */
.cute-stat-card.card-personal {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.cute-stat-card.card-personal label { color: #1d4ed8; }
.cute-stat-card.card-personal .cute-stat-input {
  border-color: #93c5fd;
  color: #1d4ed8;
}
.cute-stat-card.card-personal .cute-stat-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* 4. ขาด (แดงคอรัลพาสเทล) */
.cute-stat-card.card-absent {
  background: #fff1f2;
  border-color: #fecdd3;
}
.cute-stat-card.card-absent label { color: #be123c; }
.cute-stat-card.card-absent .cute-stat-input {
  border-color: #fda4af;
  color: #be123c;
}
.cute-stat-card.card-absent .cute-stat-input:focus {
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

/* ช่องหมายเหตุ สี่เหลี่ยมลบมุม */
.cute-note-section {
  margin-bottom: 24px;
}

.cute-note-section label {
  display: block;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.cute-note-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  padding: 0 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: #1e293b;
  outline: none;
  transition: all 0.15s ease;
}

.cute-note-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ปุ่มบันทึกห้องนี้ สี่เหลี่ยมลบมุม มนสวยงาม */
.cute-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cute-save-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 28px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3);
  transition: all 0.15s ease;
}

.cute-save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.4);
}

.cute-save-btn:active {
  transform: translateY(0);
}

/* ข้อความแจ้งเตือน "บันทึกเรียบร้อยแล้ว" แบบน่ารัก */
.cute-save-alert,
.save-alert-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: #dcfce7;
  border: 1.5px solid #86efac;
  color: #15803d;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
  width: fit-content;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.12);
  animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ================= Dashboard & Reports General Styles ================= */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 22px;
}

.chart-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-cute);
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

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

.chart-header h3 {
  font-size: 16px;
  font-weight: 600;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--bg-card);
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-cute);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.metric-card.primary::before { background: var(--primary); }
.metric-card.success::before { background: #10b981; }
.metric-card.danger::before { background: #ef4444; }
.metric-card.warning::before { background: #f59e0b; }
.metric-card.info::before { background: #6366f1; }

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

.metric-label {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.badge-present { background: #d1fae5; color: #059669; }
.badge-absent { background: #fee2e2; color: #dc2626; }
.badge-sick { background: #fef3c7; color: #d97706; }
.badge-personal { background: #e0e7ff; color: #4338ca; }

.metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.metric-value {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

.metric-unit {
  font-size: 13px;
  color: var(--text-muted);
}

.metric-percentage {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
}

.progress-bar-bg {
  height: 6px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.fill-success { background: #10b981; }
.fill-danger { background: #ef4444; }
.fill-warning { background: #f59e0b; }
.fill-info { background: #6366f1; }

.ranking-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 22px;
}

.ranking-card {
  background: var(--bg-card);
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-cute);
}

.ranking-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.ranking-list {
  list-style: none;
}

.ranking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  background: #f8fafc;
}

.rank-badge {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.rank-top { background: #fef08a; color: #854d0e; }
.rank-warn { background: #fee2e2; color: #991b1b; }

.insight-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  border-left: 5px solid var(--primary);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.insight-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.insight-icon {
  font-size: 26px;
}

.insight-text h3 {
  font-size: 15px;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.insight-text p {
  font-size: 14px;
  color: #3b82f6;
  font-weight: 500;
}

/* ================= Report & PDF Preview Tab ================= */
.report-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 22px;
  box-shadow: var(--shadow-cute);
  flex-wrap: wrap;
  gap: 14px;
}

.report-preview-sheet {
  background: #ffffff;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 50px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-cute);
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.15);
  font-family: var(--font-heading);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease;
  min-width: 260px;
}

.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.error { background: #991b1b; border-left: 4px solid #ef4444; }
.toast.info { background: #1e3a8a; border-left: 4px solid var(--primary); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .cute-entry-card {
    padding: 20px;
  }
  .nav-container {
    height: auto;
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
  }
  .nav-tabs {
    width: 100%;
    justify-content: space-around;
  }
  .cute-control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .cute-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid, .ranking-grid {
    grid-template-columns: 1fr;
  }
  .report-preview-sheet {
    padding: 20px;
  }
}

/* ==========================================================================
   ROLE PORTAL & AUTHENTICATION STYLES (หน้าแรกเลือกบทบาทและระบบรหัสผ่าน)
   ========================================================================== */
.role-portal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.role-portal-card {
  background: #ffffff;
  width: 100%;
  max-width: 820px;
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  text-align: center;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.role-portal-header {
  margin-bottom: 28px;
}

.role-portal-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: inline-block;
  background: #eff6ff;
  width: 80px;
  height: 80px;
  line-height: 80px;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.15);
}

.role-portal-title {
  font-size: 24px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}

.role-portal-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 16px;
}

.role-card-item {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 32px 20px 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.role-card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
}

.role-card-item.role-teacher:hover {
  border-color: #3b82f6;
  background: #f8fbff;
}

.role-card-item.role-duty:hover {
  border-color: #10b981;
  background: #f0fdf4;
}

.role-card-item.role-executive:hover {
  border-color: #f59e0b;
  background: #fffbeb;
}

.role-card-item.role-admin:hover {
  border-color: #8b5cf6;
  background: #faf5ff;
}

.role-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.role-icon-box {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}

.role-teacher .role-icon-box { background: #dbeafe; color: #1d4ed8; }
.role-duty .role-icon-box { background: #dcfce7; color: #15803d; }
.role-executive .role-icon-box { background: #fef3c7; color: #b45309; }
.role-admin .role-icon-box { background: #ede9fe; color: #6d28d9; }

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

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

.badge-lock {
  background: #fef3c7;
  color: #92400e;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.role-name {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  font-family: var(--font-heading);
}

.role-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.role-arrow {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Password Modal */
.pwd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pwd-modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-xl);
  padding: 28px 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwd-input-wrap {
  position: relative;
  margin-bottom: 14px;
}

.pwd-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1.5px solid #cbd5e1;
  padding: 0 46px 0 16px;
  font-size: 16px;
  font-family: var(--font-heading);
  outline: none;
  transition: all 0.15s ease;
}

.pwd-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.pwd-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
}

.pwd-error-alert {
  display: none;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Role Badge & Switch Button in Navbar */
.current-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.current-role-badge.role-teacher { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.current-role-badge.role-duty { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.current-role-badge.role-executive { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.current-role-badge.role-admin { background: #faf5ff; color: #6d28d9; border-color: #ddd6fe; }

/* Duty Teacher Topic Card in Tab 3 */
.duty-topic-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #a7f3d0;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.08);
}

.duty-topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.duty-topic-title {
  font-size: 17px;
  font-weight: 700;
  color: #065f46;
  display: flex;
  align-items: center;
  gap: 8px;
}

.duty-day-badge {
  font-size: 12.5px;
  font-weight: 700;
  background: #ffffff;
  color: #047857;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid #6ee7b7;
}

.duty-topic-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1.5px solid #6ee7b7;
  padding: 0 16px;
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  background: #ffffff;
  color: #064e3b;
  font-weight: 600;
  transition: all 0.15s ease;
}

.duty-topic-input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.duty-routine-preview {
  margin-top: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid #d1fae5;
  font-size: 13px;
  color: #065f46;
  line-height: 1.6;
}

/* Admin Settings Tabbed Modal */
.admin-settings-card {
  background: #ffffff;
  width: 95%;
  max-width: 980px;
  border-radius: var(--radius-xl);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
}

.admin-settings-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.admin-nav-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 28px 0 28px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.admin-nav-tab {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.admin-nav-tab:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

.admin-nav-tab.active {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--border-color);
  border-bottom-color: #ffffff;
  margin-bottom: -1px;
}

.admin-tab-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

/* Weekly Schedule Grid (5 Columns: Mon - Fri) */
.weekly-schedule-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.day-schedule-col {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 14px 12px;
}

.day-schedule-col.col-mon { border-top: 4px solid #facc15; }
.day-schedule-col.col-tue { border-top: 4px solid #f472b6; }
.day-schedule-col.col-wed { border-top: 4px solid #4ade80; }
.day-schedule-col.col-thu { border-top: 4px solid #fb923c; }
.day-schedule-col.col-fri { border-top: 4px solid #60a5fa; }

.day-col-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 10px;
  text-align: center;
}

.day-teacher-input {
  width: 100%;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12.5px;
  margin-bottom: 6px;
  background: #ffffff;
  outline: none;
}

.day-teacher-input:focus {
  border-color: var(--primary);
}

@media (max-width: 900px) {
  .weekly-schedule-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .weekly-schedule-grid {
    grid-template-columns: 1fr;
  }
  .role-grid {
    grid-template-columns: 1fr;
  }
}
