* { box-sizing: border-box; }

:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #dde5ef;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --blue: #2563eb;
  --green-soft: #e9f7f4;
  --blue-soft: #edf4ff;
  --warning-soft: #fff7ed;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; }
a { color: inherit; text-decoration: none; }

.app { min-height: 100vh; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, rgba(15,118,110,.12), rgba(37,99,235,.1)), var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .primary-btn {
  margin-top: 6px;
}

.chat-page {
  height: 100vh;
  overflow: hidden;
  background: #edf2f7;
}

.chat-app {
  max-width: 760px;
  height: 100vh;
  margin: 0 auto;
  background: #edf2f7;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.student-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.student-tools button {
  border: 0;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  font-weight: 800;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.advisor-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.chat-header h1 {
  margin: 0;
  font-size: 17px;
}

.chat-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-header span {
  margin-left: auto;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.chat-messages {
  overflow: auto;
  padding: 16px 14px;
}

.chat-row {
  display: flex;
  margin-bottom: 14px;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.7;
  font-size: 15px;
  white-space: pre-wrap;
}

.chat-row.ai .chat-bubble {
  background: #fff;
  border-top-left-radius: 4px;
}

.chat-row.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
}

.chat-images {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.chat-images figure {
  margin: 0;
}

.chat-images img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.chat-images figcaption {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  white-space: normal;
}

.quick-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  background: rgba(255,255,255,.72);
  border-top: 1px solid var(--line);
}

.quick-bar button {
  border: 1px solid rgba(15,118,110,.18);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--primary);
  background: var(--green-soft);
  font-weight: 800;
  white-space: nowrap;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 9px;
  padding: 11px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.chat-compose input {
  border-radius: 999px;
}

.chat-compose button {
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.entry-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(10px);
}

.entry-mask.show {
  display: grid;
}

.entry-card {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.entry-card h2 {
  margin: 0 0 8px;
}

.entry-card p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 16px;
}

.entry-card form {
  display: grid;
  gap: 12px;
}

.mini-login {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.mini-login button {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 10px;
  min-height: 40px;
  font-weight: 800;
}

.mini-login .text-btn {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  min-height: 34px;
  padding: 0;
  text-align: left;
  font-weight: 800;
}

.student-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: var(--shadow);
}

.student-dialog::backdrop {
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(8px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-head button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  min-height: 36px;
  padding: 0 12px;
}

#dialogBody {
  padding: 16px;
  max-height: min(70vh, 680px);
  overflow: auto;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: #fbfcfe;
  margin-bottom: 12px;
}

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

.mini-card p {
  margin: 5px 0;
  color: var(--muted);
  line-height: 1.6;
}

.dialog-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.student-profile-self {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.empty-text {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}
.brand p, .eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 12px; font-weight: 800; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}
.status-pill.ok { color: var(--primary); background: var(--green-soft); border-color: rgba(15, 118, 110, 0.2); }

.nav-btn, .admin-tab, .ghost-btn, .primary-btn, .secondary-btn, .nav-link {
  border: 0;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}
.nav-btn, .admin-tab, .ghost-btn, .nav-link { background: #f6f8fb; color: var(--muted); border: 1px solid var(--line); }
.nav-link { display: inline-flex; align-items: center; }
.nav-btn.active, .admin-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary-btn { background: var(--primary); color: #fff; }
.primary-btn:hover { background: var(--primary-dark); }
.secondary-btn { background: var(--blue-soft); color: var(--blue); }

.view { display: none; padding: 22px; }
.view.active { display: block; }

.student-layout {
  max-width: 1260px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  gap: 20px;
}

.student-info, .phone-shell, .content-card, .admin-main {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.student-info { padding: 26px; align-self: start; }
.student-info h2 { margin: 0 0 12px; font-size: 30px; line-height: 1.25; }
.lead { color: var(--muted); line-height: 1.75; margin: 0 0 18px; }

.quick-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 14px;
  background: #fbfcfe;
}
.quick-card h3, .content-card h3 { margin: 0 0 12px; font-size: 16px; }
.quick-questions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-questions button {
  border: 1px solid rgba(15,118,110,.18);
  color: var(--primary);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 8px 11px;
  font-weight: 700;
}
.image-strip { display: grid; gap: 10px; color: var(--muted); font-size: 13px; }
.image-strip img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.phone-shell {
  overflow: hidden;
  min-height: calc(100vh - 130px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #edf2f7;
}
.phone-head {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.phone-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.phone-head b { color: var(--primary); font-size: 12px; }
.messages { padding: 18px; overflow: auto; }
.msg { display: flex; margin-bottom: 14px; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(76%, 680px);
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.7;
  font-size: 15px;
  white-space: pre-wrap;
}
.msg.ai .bubble { background: #fff; border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.reply-images { display: grid; gap: 10px; margin-top: 12px; }
.reply-images img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.reply-images small { color: var(--muted); display: block; margin-top: 4px; white-space: normal; }

.chat-input {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(15,118,110,.5); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.chat-input input { border-radius: 999px; }
.chat-input button { border: 0; border-radius: 999px; background: var(--primary); color: #fff; font-weight: 900; }

.admin-layout {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
}
.admin-nav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  align-self: start;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
}
.admin-tab { width: 100%; text-align: left; }
.admin-main { padding: 20px; min-height: calc(100vh - 130px); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 24px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: linear-gradient(180deg, #fff, #f8fbfd);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.metric span { display: block; font-size: 30px; font-weight: 900; color: var(--primary); }
.metric p { margin: 4px 0 0; color: var(--muted); }

.content-card { padding: 16px; margin-bottom: 16px; }
.content-card p { color: var(--muted); line-height: 1.75; }
.material-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.form-stack { display: grid; gap: 12px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.materials-list { display: grid; gap: 10px; }
.material-card, .table-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}
.material-card strong, .table-row strong { display: block; margin-bottom: 5px; }
.material-card p, .table-row p { margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.material-card img { width: 120px; height: 80px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.delete-btn { background: #fff1f2; color: #be123c; border: 0; border-radius: 8px; padding: 7px 10px; font-weight: 800; align-self: start; }
.table-list, .chat-record-box { display: grid; gap: 10px; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: start; justify-content: flex-end; }

.student-admin-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.35fr);
  gap: 16px;
  align-items: start;
}

.student-list-card,
.student-detail-card {
  margin-bottom: 0;
}

.student-list-head,
.detail-head,
.student-pagination,
.student-row,
.student-row-side,
.detail-actions,
.detail-tabs {
  display: flex;
  align-items: center;
}

.student-list-head,
.detail-head,
.student-pagination {
  justify-content: space-between;
  gap: 12px;
}

.student-list-head h3,
.detail-head h3 {
  margin: 0;
}

.student-list-head span,
#detailMeta,
.muted-line {
  color: var(--muted);
  font-size: 12px;
}

.student-filter-bar {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  margin: 12px 0;
}

.student-table {
  display: grid;
  gap: 8px;
}

.student-row {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfefd;
  transition: .16s ease;
}

.student-row:hover,
.student-row.active {
  border-color: rgba(5, 199, 104, .38);
  background: #f4fffa;
}

.student-row-main {
  min-width: 0;
}

.student-row-main strong {
  display: block;
  margin-bottom: 5px;
}

.student-row-main p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.student-row-side {
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.intent-badge {
  min-width: 46px;
  text-align: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  color: #64748b;
  background: #f1f5f9;
}

.intent-badge.high { color: #be123c; background: #fff1f2; }
.intent-badge.medium { color: #b45309; background: #fff7ed; }
.intent-badge.low { color: #2563eb; background: #eff6ff; }
.intent-badge.unknown { color: #64748b; background: #f1f5f9; }

.student-pagination {
  margin-top: 12px;
}

.student-pagination button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.detail-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfefd;
  text-align: center;
  padding: 22px;
}

.hidden {
  display: none !important;
}

.detail-head {
  align-items: flex-start;
  margin-bottom: 14px;
}

.detail-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-tabs {
  gap: 8px;
  padding: 5px;
  border-radius: 12px;
  background: #f3f8f8;
  margin-bottom: 14px;
  overflow-x: auto;
}

.detail-tab {
  border: 0;
  border-radius: 9px;
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  white-space: nowrap;
}

.detail-tab.active {
  color: var(--primary-dark);
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 36, 54, .06);
}

.student-detail-view {
  display: none;
}

.student-detail-view.active {
  display: block;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.analysis-box {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfefd;
  color: var(--muted);
  line-height: 1.65;
}

.analysis-box h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.analysis-box p {
  margin: 5px 0;
}

.follow-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.chat-record-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfefd;
}

.chat-record-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-record-card b {
  color: var(--text);
}

.chat-record-card span {
  color: var(--muted);
  font-size: 12px;
}

.record-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-images img {
  width: 92px;
  height: 68px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.editor-grid,
.knowledge-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.structured-editor {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfefd;
  padding: 14px;
}

.structured-head,
.structured-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.structured-head {
  margin-bottom: 12px;
}

.structured-head h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.structured-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.structured-list {
  display: grid;
  gap: 12px;
}

.structured-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.structured-item-head strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--primary-dark);
  background: var(--green-soft);
}

.suggestion-item .structured-item-head strong {
  display: block;
  width: auto;
  height: auto;
  border-radius: 0;
  color: var(--text);
  background: transparent;
}

.suggestion-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.suggestion-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.conflict-text {
  margin: 0;
  color: #be123c;
  font-size: 12px;
  line-height: 1.55;
}

.detail-empty.compact {
  min-height: 120px;
  font-size: 13px;
}

.settings-form { display: grid; gap: 14px; max-width: 860px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: rgba(23, 32, 51, 0.94);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  transition: .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .student-layout, .admin-layout, .material-grid, .editor-grid, .knowledge-form-grid, .metrics, .student-admin-layout { grid-template-columns: 1fr; }
  .admin-nav { display: flex; overflow-x: auto; }
  .admin-tab { white-space: nowrap; }
  .phone-shell { min-height: 680px; }
}

@media (max-width: 560px) {
  .view { padding: 12px; }
  .topbar { padding: 14px; }
  .brand h1 { font-size: 17px; }
  .student-info { padding: 18px; }
  .student-info h2 { font-size: 24px; }
  .bubble { max-width: 90%; font-size: 14px; }
  .student-filter-bar,
  .student-profile-form,
  .student-profile-self {
    grid-template-columns: 1fr;
  }
  .student-row {
    align-items: flex-start;
  }
  .detail-head {
    display: grid;
  }
  .detail-actions {
    justify-content: flex-start;
  }
}

/* Visual refresh inspired by the reference screens: light grid, clean cards, green-cyan accents. */
:root {
  --bg: #f7fbfb;
  --text: #142236;
  --muted: #607086;
  --line: #e6edf1;
  --primary: #05c768;
  --primary-dark: #07965b;
  --blue: #08b7d9;
  --green-soft: #eafaf2;
  --blue-soft: #ebf8fb;
  --gradient: linear-gradient(100deg, #05c768 0%, #08c5aa 52%, #08b7d9 100%);
  --shadow: 0 18px 45px rgba(15, 36, 54, 0.08);
}

body,
.chat-page,
.login-page {
  background:
    radial-gradient(circle at 12% 18%, rgba(5, 199, 104, .12), transparent 30%),
    radial-gradient(circle at 88% 10%, rgba(8, 183, 217, .14), transparent 30%),
    linear-gradient(rgba(20, 34, 54, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 34, 54, .035) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

.chat-app {
  background: rgba(247, 251, 251, .78);
  border-color: rgba(230, 237, 241, .9);
}

.chat-header,
.topbar,
.chat-compose,
.quick-bar {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
}

.advisor-avatar,
.brand-mark,
.primary-btn,
.chat-compose button,
.chat-row.user .chat-bubble,
.nav-btn.active,
.admin-tab.active {
  background: var(--gradient);
  color: #fff;
}

.primary-btn,
.chat-compose button {
  box-shadow: 0 10px 24px rgba(5, 199, 104, .18);
}

.primary-btn:hover {
  filter: brightness(.98);
}

.secondary-btn {
  color: #079bb5;
  background: var(--blue-soft);
  border: 1px solid rgba(8, 183, 217, .18);
}

.student-tools {
  grid-template-columns: repeat(2, 1fr);
  background: rgba(230, 237, 241, .9);
}

.student-tools button {
  color: var(--primary-dark);
  background: rgba(255, 255, 255, .94);
}

.chat-row.ai .chat-bubble,
.entry-card,
.student-dialog,
.login-card,
.content-card,
.admin-main,
.admin-nav,
.metric {
  border: 1px solid rgba(230, 237, 241, .95);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.chat-row.ai .chat-bubble {
  box-shadow: 0 8px 22px rgba(15, 36, 54, .06);
}

.quick-bar button,
.quick-questions button {
  color: #07965b;
  background: rgba(234, 250, 242, .95);
  border-color: rgba(5, 199, 104, .18);
}

input,
textarea,
.mini-card,
.material-card,
.table-row,
.quick-card {
  background: #fbfefd;
}

input:focus,
textarea:focus {
  border-color: rgba(5, 199, 104, .55);
  box-shadow: 0 0 0 3px rgba(5, 199, 104, .10);
}

.metric {
  background: linear-gradient(180deg, #fff, #f7fcfb);
}

.metric span,
.brand p,
.eyebrow,
.chat-header span {
  color: var(--primary-dark);
}

/* Interface polish pass: refined controls, denser admin pages, mobile-friendly forms. */
:root {
  --surface: rgba(255, 255, 255, .92);
  --surface-strong: #ffffff;
  --line-strong: #dbe8ed;
  --field: #fbfefd;
  --danger: #be123c;
  --danger-soft: #fff1f2;
  --text-soft: #314158;
  --shadow-soft: 0 12px 32px rgba(15, 36, 54, .07);
  --shadow-card: 0 8px 22px rgba(15, 36, 54, .055);
}

button,
input,
textarea,
select {
  letter-spacing: 0;
}

input,
textarea,
select {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background-color: var(--field);
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

select {
  appearance: none;
  padding: 0 42px 0 13px;
  background-image:
    linear-gradient(45deg, transparent 50%, #7a8aa0 50%),
    linear-gradient(135deg, #7a8aa0 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

textarea {
  line-height: 1.65;
}

button,
.nav-link {
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease, background-color .16s ease, border-color .16s ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.delete-btn,
.admin-tab,
.nav-link {
  border-radius: 14px;
}

.ghost-btn,
.nav-link,
.admin-tab {
  background: rgba(255, 255, 255, .74);
  border-color: var(--line-strong);
}

.delete-btn {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(190, 18, 60, .08);
}

.primary-btn,
.secondary-btn {
  border: 1px solid transparent;
}

.secondary-btn {
  color: #078eaa;
  background: linear-gradient(180deg, #f0fbfd, #e8f8fb);
}

.topbar {
  padding: 14px 24px;
  box-shadow: 0 10px 28px rgba(15, 36, 54, .04);
}

.brand-mark {
  border-radius: 14px;
}

.brand h1 {
  font-size: 18px;
}

.view {
  padding: 22px clamp(14px, 2.4vw, 30px);
}

.admin-layout {
  max-width: 1480px;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 20px;
}

.admin-nav,
.admin-main,
.content-card,
.student-dialog,
.entry-card,
.login-card,
.metric {
  background: var(--surface);
  border-color: rgba(219, 232, 237, .9);
  box-shadow: var(--shadow-soft);
}

.admin-main {
  padding: clamp(18px, 2vw, 28px);
}

.admin-tab {
  min-height: 44px;
  padding: 0 13px;
  color: var(--text-soft);
}

.admin-tab.active {
  box-shadow: 0 10px 22px rgba(5, 199, 104, .18);
}

.panel-head {
  align-items: center;
}

.panel-head h2 {
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.18;
}

.eyebrow {
  letter-spacing: .01em;
}

.content-card {
  border-radius: 18px;
  padding: clamp(14px, 1.7vw, 22px);
}

.content-card h3,
.quick-card h3 {
  color: var(--text);
  font-size: 18px;
}

.student-admin-layout {
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 20px;
}

.student-list-card {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 118px);
  overflow: auto;
}

.student-list-head h3 {
  font-size: 20px;
}

.student-list-head span,
#detailMeta,
.muted-line {
  color: #718198;
  font-size: 13px;
}

.student-filter-bar {
  grid-template-columns: minmax(0, 1fr) 156px;
  gap: 10px;
  margin: 16px 0;
}

.student-row {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 5px 16px rgba(15, 36, 54, .035);
}

.student-row:hover {
  transform: translateY(-1px);
}

.student-row.active {
  border-color: rgba(5, 199, 104, .46);
  background: linear-gradient(180deg, #f4fffa, #fafffd);
  box-shadow: 0 10px 22px rgba(5, 199, 104, .1);
}

.student-row-main strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.3;
}

.student-row-main p {
  font-size: 13px;
  line-height: 1.6;
}

.student-row-side {
  gap: 10px;
}

.intent-badge {
  min-width: 50px;
  padding: 6px 10px;
  font-size: 13px;
}

.student-pagination {
  padding-top: 4px;
}

.student-pagination button {
  min-width: 82px;
}

.student-detail-card {
  min-height: calc(100vh - 154px);
}

.detail-head {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(219, 232, 237, .72);
}

.detail-head h3 {
  font-size: 24px;
  line-height: 1.25;
}

.detail-actions {
  align-items: center;
}

.detail-actions button {
  min-height: 46px;
  padding: 0 18px;
}

.detail-tabs {
  gap: 6px;
  padding: 7px;
  border-radius: 18px;
  background: #f1f8f8;
}

.detail-tab {
  min-height: 44px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 15px;
}

.detail-tab.active {
  color: var(--primary-dark);
  background: var(--surface-strong);
}

.student-profile-form,
.student-profile-self {
  gap: 16px;
}

.student-profile-form label,
.student-profile-self label,
.settings-form label,
.form-stack label,
.editor-grid label,
.knowledge-form-grid label {
  color: #64748b;
  font-size: 14px;
}

.student-profile-form input,
.student-profile-form select,
.student-profile-form textarea,
.student-profile-self input,
.student-profile-self select,
.student-profile-self textarea {
  font-size: 15px;
}

.analysis-box,
.chat-record-card,
.mini-card,
.material-card,
.table-row,
.structured-item,
.structured-editor {
  border-color: rgba(219, 232, 237, .92);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-card);
}

.analysis-box {
  padding: 16px;
}

.chat-record-card {
  padding: 16px;
}

.material-grid {
  gap: 18px;
}

.materials-list {
  gap: 12px;
}

.material-card,
.table-row {
  padding: 16px;
}

.material-card img {
  width: 132px;
  height: 88px;
}

.knowledge-form-grid {
  gap: 18px;
}

.structured-editor {
  padding: 18px;
}

.structured-item {
  padding: 16px;
}

.structured-item-head strong {
  width: 34px;
  height: 34px;
}

.metrics {
  gap: 14px;
}

.metric {
  border-radius: 18px;
  padding: 20px;
}

.metric span {
  font-size: 34px;
}

.settings-form {
  max-width: 920px;
}

.chat-app {
  max-width: 820px;
  background: rgba(247, 251, 251, .86);
}

.chat-header {
  padding: 16px;
}

.chat-messages {
  padding: 18px 14px 20px;
}

.chat-bubble {
  border-radius: 18px;
  padding: 12px 14px;
}

.quick-bar {
  padding: 10px 12px;
}

.chat-compose {
  padding: 12px;
  grid-template-columns: minmax(0, 1fr) 76px;
}

.entry-card {
  border-radius: 24px;
  padding: 26px;
}

.student-dialog {
  border-radius: 22px;
}

@media (max-width: 1180px) {
  .student-admin-layout {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .admin-layout {
    gap: 14px;
  }

  .admin-main {
    min-height: auto;
  }

  .student-list-card {
    position: static;
    max-height: none;
  }

  .student-detail-card {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 12px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions > * {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .view {
    padding: 10px;
  }

  .admin-main,
  .content-card {
    border-radius: 18px;
    padding: 14px;
  }

  .panel-head {
    display: grid;
  }

  .panel-head h2 {
    font-size: 25px;
  }

  .student-filter-bar {
    grid-template-columns: 1fr;
  }

  .student-row {
    padding: 14px;
    align-items: stretch;
  }

  .student-row-side {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .student-row {
    display: grid;
  }

  .detail-head {
    gap: 14px;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .detail-actions button {
    width: 100%;
    padding: 0 10px;
  }

  .detail-tabs {
    width: 100%;
  }

  .detail-tab {
    flex: 1;
    text-align: center;
  }

  .student-profile-form,
  .student-profile-self {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .material-grid,
  .knowledge-form-grid {
    gap: 12px;
  }

  .material-card,
  .table-row {
    grid-template-columns: 1fr;
  }

  .material-card img {
    width: 100%;
    height: auto;
    max-height: 220px;
  }

  .chat-app {
    max-width: none;
    border: 0;
  }

  .chat-compose {
    grid-template-columns: minmax(0, 1fr) 68px;
  }

  .student-dialog {
    width: min(100vw - 18px, 760px);
  }
}
