:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #18212a;
  --muted: #62707d;
  --line: #dbe3ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff4f1;
  --warning: #a86405;
  --warning-soft: #fff3d7;
  --shadow: 0 18px 45px rgba(20, 35, 48, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 5vw, 72px);
  background: rgba(246, 248, 251, 0.9);
  border-bottom: 1px solid rgba(219, 227, 234, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
}

.nav,
.side-nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.nav a:hover,
.side-nav a:hover,
.side-nav .active {
  color: var(--accent-strong);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(32px, 6vw, 76px);
  align-items: center;
  min-height: calc(100vh - 77px);
  padding: clamp(56px, 9vw, 110px) clamp(20px, 5vw, 72px);
}

.hero-copy {
  max-width: 760px;
}

.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 1.05;
  font-weight: 700;
}

.hero p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 22px);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 34px;
}

.btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.system-card,
.panel,
.feature,
.metric,
.auth-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.system-card {
  padding: clamp(22px, 4vw, 34px);
}

.card-head,
.panel-head,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.card-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.card-head strong {
  color: var(--accent-strong);
}

.status-list {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.status-list dt {
  color: var(--muted);
}

.status-list dd {
  margin: 0;
  font-weight: 700;
}

.section {
  padding: clamp(58px, 8vw, 96px) clamp(20px, 5vw, 72px);
}

.section-title {
  max-width: 720px;
  margin-bottom: 28px;
}

.section h2,
.app-header h1,
.auth-copy h1 {
  margin: 0 0 10px;
  line-height: 1.2;
}

.section h2 {
  font-size: clamp(30px, 4vw, 46px);
}

.section p,
.app-header p,
.auth-copy p {
  margin: 0;
  color: var(--muted);
}

.grid-3,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.feature {
  min-height: 190px;
  padding: 24px;
}

.feature h3 {
  margin: 0 0 12px;
  font-size: 21px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: clamp(28px, 6vw, 70px);
  align-items: start;
  background: var(--surface);
}

.check-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-weight: 600;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px clamp(20px, 5vw, 72px);
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.auth-page {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
  margin: clamp(16px, 3vw, 34px);
  padding: clamp(24px, 5vw, 44px);
  box-shadow: none;
}

.auth-copy h1 {
  font-size: clamp(34px, 5vw, 52px);
}

.auth-form,
.form-panel {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: #b42318;
  font-weight: 700;
}

.demo-box {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.demo-box strong {
  color: var(--text);
}

.auth-aside {
  display: grid;
  align-content: end;
  padding: clamp(36px, 7vw, 90px);
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.9), rgba(24, 33, 42, 0.92)),
    var(--accent);
  color: #ffffff;
}

.auth-aside h2 {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.1;
}

.auth-aside p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 20px;
}

.app-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.side-nav {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  margin-top: 34px;
}

.side-nav a {
  padding: 11px 12px;
  border-radius: var(--radius);
}

.side-nav .active {
  background: var(--accent-soft);
}

.app-main {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: clamp(22px, 4vw, 44px);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.quick-action {
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}

.quick-action strong {
  font-size: 20px;
}

.quick-action span {
  color: var(--muted);
}

.app-header h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.metric {
  padding: 22px;
  box-shadow: none;
}

.metric span {
  color: var(--muted);
  font-weight: 600;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1.1;
}

.panel {
  padding: 22px;
  box-shadow: none;
}

.panel h2 {
  margin: 0;
  font-size: 24px;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 14px;
}

.tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
}

.tag.success {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.empty-state {
  margin-top: 18px;
  padding: 38px 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.form-panel {
  max-width: 620px;
}

.wide-panel {
  max-width: none;
}

.student-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.full-span {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-search {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.small-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 9px;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.simple-details {
  padding: 0;
  overflow: hidden;
}

.simple-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  font-size: 20px;
  font-weight: 800;
}

.simple-details > summary::after {
  content: "+";
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.simple-details[open] > summary {
  border-bottom: 1px solid var(--line);
}

.simple-details[open] > summary::after {
  content: "-";
}

.simple-details > summary::-webkit-details-marker {
  display: none;
}

.simple-details > .student-form,
.simple-details > .group-grid {
  padding: 22px;
  margin-top: 0;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-2);
}

.group-card h3 {
  margin: 0 0 8px;
}

.group-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.group-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 900px) {
  .hero,
  .split,
  .auth-shell,
  .app-page {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .grid-3,
  .metric-grid,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .student-form,
  .group-grid {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    min-height: 320px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .topbar,
  .app-header,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
  }

  .actions,
  .btn {
    width: 100%;
  }

  .status-list div {
    flex-direction: column;
    gap: 2px;
  }
}
