/* อักษร — shared layout & component styles */

/* ── Layout ─────────────────────────────────────────── */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

/* App shell (sidebar + content) */
.app-shell {
  display: flex; min-height: 100vh; background: var(--bg);
}
.app-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  /* ไม่ใช้ overflow:hidden — มันทำให้ browser ถือว่า app-content เป็น sticky
     scroll container แทน viewport ทำให้ topbar (position:sticky) หลุด overlay content */
}
.app-main { flex: 1; overflow-y: auto; min-height: 0; }

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: 240px; padding: 20px 16px;
  border-right: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo { padding: 4px 6px 16px; }
.sidebar-section-label {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: 0.12em; padding: 10px 10px 6px; text-transform: uppercase;
}
.sidebar-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--ink-3);
  transition: background .1s, color .1s; cursor: pointer;
}
.sidebar-item:hover { background: var(--line-3); color: var(--ink); }
.sidebar-item.active { background: var(--primary-50); color: var(--primary); }
.sidebar-item svg { flex: 0 0 auto; }
.sidebar-item .label { flex: 1; }
.sidebar-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  font-size: 10.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-item.active .sidebar-badge { background: var(--primary); color: #fff; }
.sidebar-item:not(.active) .sidebar-badge { background: var(--line-2); color: var(--muted); }

.sidebar-spacer { flex: 1; }

.sidebar-user {
  margin-top: 8px; padding: 12px; border-radius: 12px;
  background: var(--paper-2); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-id { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

/* ── Top Bar ────────────────────────────────────────── */
.topbar {
  height: 68px; padding: 0 32px;
  border-bottom: 1px solid var(--line); background: var(--paper);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 10; flex: 0 0 auto;
}
.topbar-title { font-family: var(--serif); font-size: 22px; line-height: 1.1; }
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 38px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line);
  min-width: 260px; color: var(--muted); cursor: text;
}
.search-bar input {
  border: 0; outline: none; background: transparent;
  font-size: 13px; flex: 1; color: var(--ink); width: 100%;
}
.search-shortcut { font-family: var(--mono); font-size: 10px; color: var(--muted-2); }

/* ── Public Navbar ──────────────────────────────────── */
.navbar {
  height: 68px; padding: 0 56px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.navbar-nav { display: flex; gap: 4px; }
.navbar-nav a {
  padding: 8px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: background .1s, color .1s;
}
.navbar-nav a:hover { background: var(--line-3); color: var(--ink); }
.navbar-nav a.active { background: var(--line-3); color: var(--ink); }
.navbar-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

/* ── Avatar Dropdown (shared across pages) ──────────── */
.av-wrap { position: relative; display: inline-block; }
.av-dd {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0,0,0,.14);
  min-width: 200px; z-index: 500; overflow: hidden; display: none;
}
.av-dd.open { display: block; }
.av-dd-info {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.av-dd-name {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 172px;
}
.av-dd-role { font-size: 11px; color: var(--muted); margin-top: 2px; }
.av-dd a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 13.5px; color: var(--ink-3);
  text-decoration: none; transition: background .1s; cursor: pointer;
}
.av-dd a:hover { background: var(--paper-2); }
.av-dd-div { height: 1px; background: var(--line); margin: 2px 0; }
.av-dd a.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.av-dd a.disabled:hover { background: transparent; }

.ak-logo {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 800; font-size: 17px;
  text-decoration: none;
}
.ak-logo-mark {
  border-radius: 8px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; flex: 0 0 auto;
  font-family: "Inter", "Noto Sans Thai", -apple-system, sans-serif;
  font-style: normal;
}
.ak-logo-text {
  letter-spacing: -0.01em;
  font-family: "Inter", "Noto Sans Thai", -apple-system, sans-serif;
  font-weight: 800;
}
.ak-logo.mono { color: #fff; }
.ak-logo.mono .ak-logo-mark { background: #fff; color: var(--primary); }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  padding: 64px 56px 56px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--paper) 0%, var(--bg) 100%);
  position: relative; overflow: hidden;
}
.hero-grid {
  display: grid; grid-template-columns: 1fr 1.5fr;
  gap: 48px; align-items: center; position: relative;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); margin-bottom: 20px;
}
.hero-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); }
.hero-headline {
  font-family: var(--serif); font-size: 60px; line-height: 1.05;
  letter-spacing: -0.02em; color: var(--ink); margin-bottom: 20px;
}
.hero-headline em { color: var(--primary); font-style: italic; }
.hero-lead {
  font-size: 16.5px; line-height: 1.6; color: var(--ink-3);
  max-width: 480px; margin-bottom: 28px;
}
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 28px; margin-top: 36px; }
.hero-stat-n { font-family: var(--serif); font-size: 28px; color: var(--primary); }
.hero-stat-l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Hero card stack */
.hero-cards {
  position: relative; align-content: center;
}
.hero-card-back {
  position: absolute; right: 32px; top: 0;
  width: 280px; transform: rotate(3deg);
  overflow: hidden;
}
.hero-card-front {
  position: absolute; left: 0; bottom: 20px;
  width: 260px; padding: 18px;
  transform: rotate(-4deg);
  box-shadow: var(--sh-3);
}

/* Dotted grid background */
.dot-grid {
  position: absolute; inset: 0; opacity: 0.5; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(15,23,42,.08) 1px, transparent 0);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

/* ── News Feed ──────────────────────────────────────── */
.news-section { padding: 64px 56px; }
.section-eyebrow {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 0.12em; margin-bottom: 6px;
}
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px;
}
.section-title { font-family: var(--serif); font-size: 36px; letter-spacing: -0.01em; }
.section-link {
  font-size: 13px; color: var(--primary);
  display: inline-flex; align-items: center; gap: 4px;
}

.news-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px;
}
.news-col-double { display: grid; grid-template-rows: 1fr 1fr; gap: 20px; }

.news-card {
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.news-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.news-card-thumb {
  position: relative; overflow: hidden;
}
.news-card-thumb-inner {
  width: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
}
.news-card-pinned {
  position: absolute; top: 12px; left: 12px; padding: 4px 8px;
  background: var(--ink); color: #fff; border-radius: 6px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.04em;
  display: inline-flex; align-items: center; gap: 4px;
}
.news-card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.news-card-meta {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12px;
}
.news-card-title {
  font-family: var(--serif); font-size: 18px; line-height: 1.25; color: var(--ink);
}
.news-card-title.large { font-size: 24px; }
.news-card-excerpt { font-size: 14px; line-height: 1.55; color: var(--ink-3); }

/* Newsletter card */
.newsletter-card {
  padding: 22px; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
}
.newsletter-eyebrow {
  font-family: var(--mono); font-size: 11px; opacity: 0.6; letter-spacing: 0.12em;
}
.newsletter-title { font-family: var(--serif); font-size: 22px; line-height: 1.2; margin-top: 10px; }
.newsletter-form { display: flex; gap: 6px; margin-top: 16px; }
.newsletter-input {
  flex: 1; height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06);
  color: #fff; font-size: 13px; outline: none; font-family: inherit;
}
.newsletter-input::placeholder { color: rgba(255,255,255,.4); }

/* ── Quick Links ────────────────────────────────────── */
.quicklinks-section {
  padding: 40px 56px 64px;
  border-top: 1px solid var(--line); background: var(--paper);
}
.quicklinks-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 14px; }
.quicklink-item {
  padding: 18px; border-radius: 14px;
  background: var(--paper-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  cursor: pointer; transition: border-color .12s, transform .15s;
}
.quicklink-item:hover { border-color: var(--primary-100); transform: translateY(-2px); }
.quicklink-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.quicklink-label { font-size: 13.5px; font-weight: 500; }
.quicklink-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.quicklink-arrow { margin-top: auto; color: var(--muted); }

/* ── Footer ─────────────────────────────────────────── */
.footer {
  background: var(--ink); color: #fff;
  padding: 64px 56px 32px;
}
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 48px; }
.footer-brand-text {
  margin-top: 20px; font-size: 14px; line-height: 1.6;
  color: rgba(255,255,255,.65); max-width: 360px;
}
.footer-socials { display: flex; gap: 8px; margin-top: 20px; }
.footer-social-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,.06);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--mono); color: rgba(255,255,255,.85);
  transition: background .12s;
}
.footer-social-btn:hover { background: rgba(255,255,255,.12); }
.footer-col-label {
  font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,.4);
  letter-spacing: 0.12em; margin-bottom: 14px;
}
.footer-links { display: flex; flex-direction: column; gap: 10px; }
.footer-links a { font-size: 13px; color: rgba(255,255,255,.85); transition: color .1s; }
.footer-links a:hover { color: #fff; }
.footer-contact { display: flex; flex-direction: column; gap: 10px; }
.footer-input {
  height: 38px; padding: 0 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04); color: #fff;
  font-size: 13px; outline: none; font-family: inherit;
}
.footer-input::placeholder { color: rgba(255,255,255,.35); }
.footer-input:focus { border-color: rgba(255,255,255,.3); }
.footer-textarea {
  padding: 10px 12px; border-radius: 8px; min-height: 80px; resize: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04); color: #fff;
  font-size: 13px; outline: none; font-family: inherit;
}
.footer-textarea::placeholder { color: rgba(255,255,255,.35); }
.footer-bottom {
  margin-top: 48px; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between;
  font-size: 11px; color: rgba(255,255,255,.4); flex-wrap: wrap; gap: 8px;
}

/* ── Dashboard ──────────────────────────────────────── */
.dashboard-main { padding: 32px; display: flex; flex-direction: column; gap: 24px; }

/* Up Next card */
.upnext-card {
  padding: 24px; display: grid; grid-template-columns: 1fr auto; gap: 24px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--primary-700) 100%);
  color: #fff; border: none; position: relative; overflow: hidden;
}
.upnext-dot-grid {
  position: absolute; inset: 0; opacity: 0.4; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.12) 1px, transparent 0);
  background-size: 20px 20px;
}
.upnext-eyebrow { font-family: var(--mono); font-size: 11px; opacity: 0.6; letter-spacing: 0.12em; }
.upnext-title { font-family: var(--serif); font-size: 28px; line-height: 1.15; margin-top: 8px; max-width: 540px; }
.upnext-meta { display: flex; gap: 14px; margin-top: 16px; font-size: 12.5px; opacity: 0.8; }

/* Stat cards */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.stat-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.stat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.stat-header { display: flex; align-items: center; justify-content: space-between; }
.stat-key { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.stat-value { font-family: var(--serif); font-size: 36px; line-height: 1; color: var(--ink); }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat-delta { font-size: 11.5px; font-weight: 500; }

/* Timeline */
.timeline-row {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 16px;
  padding: 14px 4px; border-top: 1px solid var(--line-2); align-items: center;
}
.timeline-t { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.timeline-when { font-size: 11px; color: var(--muted); margin-top: 2px; }
.timeline-title { font-size: 13.5px; font-weight: 500; }
.timeline-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Score table */
.score-table-header {
  display: grid; grid-template-columns: 1.6fr 0.8fr 0.8fr 0.6fr;
  padding: 8px 20px;
  font-size: 10px; color: var(--muted); letter-spacing: 0.08em;
  border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  font-family: var(--mono); text-transform: uppercase;
  background: var(--paper-2);
}
.score-row {
  display: grid; grid-template-columns: 1.6fr 0.8fr 0.8fr 0.6fr;
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  align-items: center; font-size: 13px;
}

/* ── Classroom ──────────────────────────────────────── */
.classroom-header {
  padding: 28px 32px 20px; background: var(--paper);
  border-bottom: 1px solid var(--line-2);
}
.breadcrumb { display: flex; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 10px; align-items: center; }
.classroom-icon {
  border-radius: 14px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-style: italic;
}
.classroom-chips { display: flex; gap: 8px; margin-top: 18px; overflow-x: auto; padding-bottom: 4px; }
.classroom-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 10px;
  font-size: 12.5px; white-space: nowrap; cursor: pointer;
  transition: background .12s;
}

.tab-bar {
  border-bottom: 1px solid var(--line); background: var(--paper);
  padding: 0 32px; display: flex; gap: 4px; overflow-x: auto;
  flex: 0 0 auto;
}
.tab-btn {
  padding: 14px 16px; border: 0; background: transparent;
  font-size: 13.5px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; position: relative; top: 1px;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  transition: color .12s; white-space: nowrap; font-family: inherit;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--primary); }
.tab-count {
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
  font-size: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab-btn.active .tab-count { background: var(--primary); color: #fff; }
.tab-btn:not(.active) .tab-count { background: var(--line-2); color: var(--muted); }

/* Featured assignment */
.assignment-header { padding: 24px; border-bottom: 1px solid var(--line-2); }

/* แถวหัว: flex-wrap เพื่อรองรับหน้าจอแคบ/สั้น */
.assignment-header > div {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;       /* wrap เมื่อพื้นที่ไม่พอ */
}

.assignment-due-badge {
  padding: 10px 14px; border-radius: 12px;
  background: var(--rose-50); color: var(--rose); text-align: center;
  min-width: 120px; max-width: 200px;   /* จำกัดไม่ให้กว้างเกิน */
  flex-shrink: 0;
}
.assignment-due-label { font-family: var(--mono); font-size: 10px; opacity: 0.7; letter-spacing: 0.12em; }
.assignment-due-val {
  font-family: var(--serif);
  font-size: 18px;          /* ลดจาก 28px — ป้องกัน text wrap + badge สูงเกิน */
  line-height: 1.35;
  margin-top: 4px;
  word-break: keep-all;     /* ไม่ตัดคำกลางระหว่างอักษรไทย */
}

/* Drop zone */
.dropzone {
  border: 1.5px dashed var(--primary-100); background: var(--paper);
  border-radius: 14px; padding: 20px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone.drag-over { border-color: var(--primary); background: var(--primary-50); }
.dropzone-icon {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--primary-50); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}

/* Assignment list */
.assignment-row {
  display: grid;
  /* week: auto ป้องกัน overflow, title: 1fr ยืดหด, pill+due+arrow: คงที่ */
  grid-template-columns: auto 1fr auto auto auto;
  gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--line-2);
  align-items: center; cursor: pointer; transition: background .1s;
  min-width: 0;       /* ป้องกัน grid overflow ออกนอก card */
}
.assignment-row:hover { background: var(--paper-2); }

/* Week label — ไม่ wrap */
.assignment-row > .mono { white-space: nowrap; }

/* Title cell — ซ่อนข้อความล้น */
.assignment-row-title {
  min-width: 0;
  overflow: hidden;
}
.assignment-row-title > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignment-row-title > div:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Admin ──────────────────────────────────────────── */
.admin-topbar {
  height: 64px; padding: 0 32px;
  border-bottom: 1px solid var(--line); background: var(--paper);
  display: flex; align-items: center; justify-content: space-between;
}
.admin-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.stat-box { padding: 18px; position: relative; overflow: hidden; }
.stat-box-label { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }
.stat-box-val { font-family: var(--serif); font-size: 30px; line-height: 1; margin-top: 8px; }
.stat-box-sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-tabs { display: inline-flex; padding: 4px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); }
.filter-tab {
  height: 30px; padding: 0 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink-3);
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
  transition: background .1s, color .1s;
}
.filter-tab.active { background: var(--ink); color: #fff; }
.filter-count {
  padding: 0 6px; border-radius: 8px; font-size: 10.5px; font-weight: 600;
}
.filter-tab.active .filter-count { background: rgba(255,255,255,.15); }
.filter-tab:not(.active) .filter-count { background: var(--line-3); }

.bulk-banner {
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between; font-size: 13px;
}

/* Member table */
.member-table { overflow: hidden; }
.member-thead {
  display: grid; grid-template-columns: 32px 2.2fr 1fr 1fr 1.2fr 1fr 240px;
  gap: 16px; padding: 12px 24px;
  font-size: 10px; color: var(--muted); letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line-2);
  font-family: var(--mono); text-transform: uppercase;
  background: var(--paper-2);
}
.member-row {
  display: grid; grid-template-columns: 32px 2.2fr 1fr 1fr 1.2fr 1fr 240px;
  gap: 16px; padding: 14px 24px; border-top: 1px solid var(--line-2);
  align-items: center; transition: background .1s;
}
.member-row:hover { background: var(--paper-2); }
.member-row.selected { background: var(--primary-50); }
.member-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-id { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.member-email { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Member detail drawer */
.member-drawer {
  width: 340px; border-left: 1px solid var(--line);
  background: var(--paper); display: flex; flex-direction: column;
  height: 100%; overflow-y: auto;
}
.drawer-header {
  padding: 20px 24px; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--paper); z-index: 1;
}
.drawer-section { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }
.drawer-body { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-field-label { font-family: var(--mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.drawer-field-val { font-size: 13px; margin-top: 4px; }
.drawer-footer {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--line-2);
}

/* Storage quota card */
.quota-card {
  padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--paper-2) 100%);
  border: 1px solid var(--primary-100);
}
.quota-label { font-family: var(--mono); font-size: 10px; color: var(--primary); letter-spacing: 0.12em; }
.quota-val { font-family: var(--serif); font-size: 20px; margin-top: 4px; }
.quota-bar { height: 4px; border-radius: 2px; background: var(--paper); margin-top: 8px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--primary); border-radius: 2px; }
.quota-link { display: block; font-size: 11px; color: var(--primary); margin-top: 8px; }

/* Pagination */
.pagination {
  padding: 14px 24px; border-top: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); background: var(--paper-2);
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 28px; height: 28px; padding: 0 6px; border-radius: 6px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.page-btn:hover { background: var(--line-3); }
.page-btn.active { background: var(--ink); color: #fff; }

/* ── Mini Calendar ──────────────────────────────────── */
.mini-cal { padding: 20px; }
.mini-cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.mini-cal-title { font-family: var(--serif); font-size: 18px; margin-top: 2px; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.mini-cal-day-label { font-size: 10px; color: var(--muted); text-align: center; padding: 4px 0; }
.mini-cal-day {
  aspect-ratio: 1; border-radius: 6px; position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--mono); cursor: default;
}
.mini-cal-legend { display: flex; gap: 14px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.mini-cal-legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-50) 100%);
  padding: 24px;
}
.login-card { width: 100%; max-width: 420px; padding: 40px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 32px; }
.login-title { font-family: var(--serif); font-size: 28px; text-align: center; margin-bottom: 8px; }
.login-sub { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 32px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; color: var(--muted); margin: 20px 0;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.google-btn {
  width: 100%; height: 44px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer; font-family: inherit; transition: background .12s, box-shadow .12s;
}
.google-btn:hover { background: var(--bg); box-shadow: var(--sh-2); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .navbar { padding: 0 24px; grid-template-columns: auto 1fr auto; }
  .navbar-nav { display: none; }
  .hero { padding: 40px 24px 32px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-cards { display: none; }
  .hero-headline { font-size: 40px; }
  .news-section { padding: 40px 24px; }
  .news-grid { grid-template-columns: 1fr; }
  .news-col-double { grid-template-rows: none; }
  .quicklinks-section { padding: 32px 24px; }
  .quicklinks-grid { grid-template-columns: repeat(2,1fr); }
  .footer { padding: 40px 24px 24px; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .dashboard-main { padding: 16px; gap: 16px; }
  .member-drawer { display: none; }
  .member-thead, .member-row {
    grid-template-columns: 32px 1fr auto;
  }
}

@media (max-width: 640px) {
  .topbar { height: auto; padding: 12px 16px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .upnext-card { grid-template-columns: 1fr; }
  .tab-bar { padding: 0 16px; }
  .classroom-header { padding: 16px; }
  .assignment-header { padding: 16px; }
}

/* ── Attendance (เช็คชื่อ) ──────────────────────── */

/* Student — status banner */
.attend-banner {
  border-radius: var(--r-md); padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.attend-banner.open   { background: var(--emerald-50); border: 1.5px solid var(--emerald-100); }
.attend-banner.closed { background: var(--line-3);     border: 1.5px solid var(--line); }

/* PIN display (ใหญ่) */
.pin-display {
  font-family: var(--mono); font-size: 42px; font-weight: 700;
  letter-spacing: 0.18em; color: var(--ink); line-height: 1;
  padding: 12px 0;
}

/* PIN input */
.pin-input-row { display: flex; gap: 8px; align-items: center; }
.pin-input {
  width: 140px; height: 46px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--paper);
  font-family: var(--mono); font-size: 24px; font-weight: 700;
  letter-spacing: 0.2em; text-align: center; color: var(--ink);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.pin-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }

/* Attendance percentage bar */
.attend-pct-bar {
  height: 8px; border-radius: 4px; background: var(--line-2);
  overflow: hidden; margin: 6px 0;
}
.attend-pct-fill {
  height: 100%; border-radius: 4px;
  transition: width .4s ease;
}
.attend-pct-fill.pass   { background: var(--emerald); }
.attend-pct-fill.warn   { background: var(--amber); }
.attend-pct-fill.danger { background: var(--rose); }

/* Attendance history table */
.attend-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.attend-table th {
  padding: 10px 16px; font-size: 11px; font-weight: 600;
  color: var(--muted); text-align: left; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line); font-family: var(--mono);
  text-transform: uppercase;
}
.attend-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.attend-table tr:last-child td { border-bottom: none; }
.attend-table tr:hover td { background: var(--paper-2); }

/* Admin — session card */
.session-card {
  padding: 16px 20px; display: flex; align-items: center;
  gap: 14px; border-bottom: 1px solid var(--line-2);
}
.session-card:last-child { border-bottom: none; }
.session-pin {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  letter-spacing: 0.14em; color: var(--ink);
  background: var(--line-3); padding: 6px 12px; border-radius: 8px;
  flex-shrink: 0;
}

/* Present Mode overlay (full-screen PIN สำหรับฉาย) */
#present-mode-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: #0F172A;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
}
#present-mode-overlay .pm-label {
  font-family: var(--mono); font-size: 16px;
  color: rgba(255,255,255,.4); letter-spacing: 0.18em; text-transform: uppercase;
}
#present-mode-overlay .pm-pin {
  font-family: var(--mono); font-size: 120px; font-weight: 900;
  letter-spacing: 0.22em; color: #fff; line-height: 1;
}
#present-mode-overlay .pm-session {
  font-size: 20px; color: rgba(255,255,255,.5);
}
#present-mode-overlay .pm-close {
  position: absolute; top: 24px; right: 24px;
  background: rgba(255,255,255,.1); color: #fff;
  border: none; border-radius: 8px; padding: 8px 14px;
  font-size: 14px; cursor: pointer; font-family: inherit;
}

/* ── Ticket System (ตั๋วออนไลน์) ───────────────────── */

/* Student — balance card */
.ticket-balance-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-700) 100%);
  border-radius: var(--r-lg); padding: 32px 28px;
  text-align: center; color: #fff; position: relative; overflow: hidden;
}
.ticket-balance-card::before {
  content: "🎟️";
  position: absolute; right: -8px; top: -8px;
  font-size: 96px; opacity: .12; line-height: 1;
  transform: rotate(15deg);
}
.ticket-balance-num {
  font-family: var(--mono); font-size: 80px; font-weight: 900;
  line-height: 1; letter-spacing: -.02em;
}
.ticket-balance-label {
  font-size: 14px; opacity: .75; margin-top: 4px; letter-spacing: .06em;
}

/* Transaction row */
.ticket-tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line-2);
  transition: background .1s;
}
.ticket-tx-row:last-child { border-bottom: none; }
.ticket-tx-row:hover { background: var(--paper-2); }
.ticket-tx-amount {
  font-family: var(--mono); font-size: 18px; font-weight: 700;
  min-width: 52px; text-align: right; flex-shrink: 0;
}
.ticket-tx-amount.plus  { color: var(--emerald); }
.ticket-tx-amount.minus { color: var(--rose); }

/* Admin — student balance row */
.ticket-student-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--line-2);
  transition: background .1s;
}
.ticket-student-row:last-child { border-bottom: none; }
.ticket-student-row:hover { background: var(--paper-2); }
.ticket-student-row.selected { background: var(--primary-50); }
.ticket-bal-chip {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  min-width: 52px; text-align: center; flex-shrink: 0;
  color: var(--primary);
}

/* Quick +/- buttons */
.ticket-quick-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--paper);
  font-size: 16px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .1s, border-color .1s;
  flex-shrink: 0; line-height: 1;
}
.ticket-quick-btn.plus:hover  { background: var(--emerald-50); border-color: var(--emerald); color: var(--emerald); }
.ticket-quick-btn.minus:hover { background: var(--rose-50);    border-color: var(--rose);    color: var(--rose); }

/* Mobile bottom nav */
.bottom-nav {
  position: sticky; bottom: 0; margin-top: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px; display: grid; grid-template-columns: repeat(5,1fr); gap: 2px;
  box-shadow: var(--sh-2); margin: 16px;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; border-radius: 10px; position: relative;
  color: var(--muted); font-size: 10.5px; font-weight: 500;
  transition: background .1s, color .1s; cursor: pointer;
}
.bottom-nav-item.active { color: var(--primary); background: var(--primary-50); }
.bottom-nav-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 14px; height: 14px; padding: 0 4px; border-radius: 7px;
  background: var(--rose); color: #fff; font-size: 9px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Progress bar */
.progress-bar {
  height: 4px; border-radius: 2px; background: var(--line-3); overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 2px; transition: width .3s; }
