/* ============================================================
   Field Effect Theme — Survey Tool
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  /* Brand colours */
  --color-primary:    #1a6de8;
  --color-primary-dk: #1458cc;
  --color-primary-lt: #e8f0fd;

  /* Semantic colours */
  --color-success:    #16a34a;
  --color-warning:    #d97706;
  --color-danger:     #dc2626;

  /* Surface / background */
  --color-bg:         #edf2fb;   /* very light blue-tinted page bg */
  --color-surface:    #ffffff;
  --color-border:     #dde3f0;
  --color-border-lt:  #ecf0f9;

  /* Typography */
  --color-text:       #111827;
  --color-muted:      #5f7289;

  /* Navbar */
  --navbar-bg:        #0a1a38;   /* deep navy */

  /* Radius / shadow */
  --radius:           6px;
  --radius-lg:        10px;
  --shadow:           0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:        0 4px 14px rgba(10,50,140,.10), 0 1px 4px rgba(0,0,0,.05);
  --shadow-auth:      0 20px 60px rgba(0,0,0,.30), 0 4px 20px rgba(0,0,0,.18);

  --font:       "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: 150ms ease;

  /* Auth-page blue radial gradient (Field Effect login background) */
  --auth-bg:
    radial-gradient(ellipse at 78% 12%, rgba(144,202,249,.50) 0%, transparent 44%),
    radial-gradient(ellipse at 22% 58%, rgba(66,165,245,.40) 0%, transparent 52%),
    linear-gradient(155deg, #1565c0 0%, #0d3d96 50%, #071a5e 100%);
}

/* ============================================================
   Base
   ============================================================ */
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-size: 14px;
}

/* Auth pages: blue gradient fills the viewport */
body:has(.auth-container) {
  background: var(--auth-bg);
  min-height: 100vh;
}

/* Remove main-content padding/constraints on auth pages so gradient fills fully */
body:has(.auth-container) .main-content {
  padding: 0;
  max-width: none;
  margin: 0;
}

/* Flash messages float above the card on auth pages */
body:has(.auth-container) .flash-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: 90%;
  max-width: 420px;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navbar-bg);
  color: #fff;
  padding: .75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
}
.nav-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
}
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links a {
  color: rgba(255,255,255,.80);
  text-decoration: none;
  font-weight: 500;
  font-size: .875rem;
  transition: color var(--transition);
}
.nav-links a:hover { color: #fff; }
.nav-user {
  color: rgba(255,255,255,.55);
  font-size: .8rem;
  border-left: 1px solid rgba(255,255,255,.15);
  padding-left: 1rem;
}
.notif-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.80);
  cursor: pointer;
  font-size: 1rem;
  position: relative;
  padding: .25rem;
  transition: color var(--transition);
}
.notif-btn:hover { color: #fff; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--color-danger); color: #fff;
  border-radius: 999px; font-size: .65rem; padding: 0 4px; min-width: 16px;
  text-align: center; line-height: 16px;
}

/* Logout is a <button> styled as a link */
.btn-link {
  background: none;
  border: none;
  color: rgba(255,255,255,.80);
  cursor: pointer;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 500;
  padding: 0;
  transition: color var(--transition);
}
.btn-link:hover { color: #fff; }

/* ============================================================
   Notification Panel
   ============================================================ */
.notif-panel {
  position: fixed; top: 52px; right: 1rem;
  width: 320px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 200;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid var(--color-border);
}
.notif-header button { background: none; border: none; cursor: pointer; color: var(--color-muted); }
.notif-list { list-style: none; max-height: 400px; overflow-y: auto; }
.notif-list li {
  padding: .75rem 1rem; border-bottom: 1px solid var(--color-border-lt);
  cursor: pointer; transition: background var(--transition); font-size: .875rem;
}
.notif-list li:hover { background: var(--color-bg); }
.notif-list li.unread { border-left: 3px solid var(--color-primary); background: var(--color-primary-lt); }
.notif-text { font-size: .875rem; }
.notif-time { font-size: .72rem; color: var(--color-muted); margin-top: .15rem; }
.notif-list li.notif-navigable { display: flex; align-items: center; gap: .5rem; }
.notif-list li.notif-navigable > div { flex: 1; }
.notif-list li.notif-navigable::after { content: '→'; color: var(--color-primary); font-size: .85rem; flex-shrink: 0; }

/* Pulse highlight when a question is jumped to via a notification link */
@keyframes notif-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(99,102,241,.45); }
  60%  { box-shadow: 0 0 0 10px rgba(99,102,241,0); }
  100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}
.question-block.notif-highlight {
  animation: notif-pulse 1.2s ease 2;
  border-color: var(--color-primary) !important;
}
.section-description {
  margin: 0 0 1.25rem;
  padding: .75rem 1rem;
  background: var(--color-bg);
  border-left: 3px solid var(--color-primary);
  border-radius: 4px;
  color: var(--color-muted);
  font-size: .92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.section-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border, #e0e6ef);
}
.section-nav .btn { max-width: 48%; }

/* Rich-text editor (descriptions) */
.rich-editor { border: 1px solid var(--color-border, #dde3f0); border-radius: 6px; overflow: hidden; background: #fff; }
.rich-toolbar { display: flex; gap: .25rem; padding: .3rem .4rem; background: var(--color-bg, #f5f8ff); border-bottom: 1px solid var(--color-border, #dde3f0); }
.rich-btn { min-width: 2rem; }
.rich-editable { min-height: 3.2rem; border: none; border-radius: 0; outline: none; font-size: .9rem; line-height: 1.5; }
.rich-editable:focus { box-shadow: none; }
.rich-editable ul, .rich-editable ol { margin: .25rem 0 .25rem 1.4rem; }
/* Rich-text display (rendered descriptions) */
.rich-text ul { list-style: disc; margin: .25rem 0 .5rem 1.4rem; }
.rich-text ol { list-style: decimal; margin: .25rem 0 .5rem 1.4rem; }
.rich-text li { margin: .15rem 0; }
.rich-text p { margin: 0 0 .5rem; }
.rich-text a { color: var(--color-primary); }
/* Inline rich text (e.g. question labels): trim outer paragraph margins. */
.rich-inline > :first-child { margin-top: 0; }
.rich-inline > :last-child { margin-bottom: 0; }
.overdue-text { color: var(--color-danger, #dc2626); font-weight: 600; }
.completed-text { color: var(--color-success, #16a34a); font-weight: 600; }
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
  background: var(--color-danger, #dc2626); color: #fff;
  padding: .6rem 1rem; text-align: center; font-size: .9rem; font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.comment-item.comment-pending { opacity: .6; }

/* ============================================================
   Toast
   ============================================================ */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem; z-index: 300;
}
.toast {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: .75rem 1rem .75rem .75rem;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: .5rem;
  min-width: 240px; max-width: 360px;
  animation: slideIn .2s ease;
}
.toast.success { border-left: 4px solid var(--color-success); }
.toast.error   { border-left: 4px solid var(--color-danger); }
.toast.info    { border-left: 4px solid var(--color-primary); }
.toast-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .5; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash-container { padding: .5rem 1.5rem; }
.alert {
  padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: .5rem;
  font-size: .875rem; font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ============================================================
   Layout
   ============================================================ */
.main-content { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

/* ============================================================
   Error pages (404, 403)
   ============================================================ */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 1rem;
}
.error-code {
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--color-primary);
  opacity: .15;
  letter-spacing: -.05em;
}
.error-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.error-message {
  color: var(--color-muted);
  font-size: 1rem;
  max-width: 380px;
  margin: 0;
}
.error-actions {
  margin-top: .5rem;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.layout-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .layout-split { grid-template-columns: 1fr; } }
.dashboard-grid { display: grid; gap: 1rem; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to bottom, #fafcff, #ffffff);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-header h2 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 1rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .45rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font-size: .875rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all var(--transition);
  white-space: nowrap; font-family: var(--font);
}
.btn:hover { background: var(--color-bg); border-color: #c0cfe8; }
.btn-primary {
  background: var(--color-primary); color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(26,109,232,.30);
}
.btn-primary:hover {
  background: var(--color-primary-dk);
  border-color: var(--color-primary-dk);
  box-shadow: 0 2px 6px rgba(26,109,232,.35);
}
.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--color-danger);  color: #fff; border-color: var(--color-danger); }
.btn-danger:hover  { background: #b91c1c; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.auth-divider { display: flex; align-items: center; text-align: center; color: var(--color-muted); margin: 1rem 0; font-size: .85rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--color-border, #dde3f0); }
.auth-divider span { padding: 0 .75rem; }
.sso-btn { display: flex; align-items: center; justify-content: center; }
.btn-outline:hover { background: var(--color-primary-lt); }
.btn-sm  { padding: .25rem .6rem; font-size: .8rem; }
.btn-xs  { padding: .15rem .4rem; font-size: .75rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-weight: 500; margin-bottom: .35rem;
  font-size: .875rem; color: var(--color-text);
}
.form-control {
  width: 100%; padding: .55rem .8rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: .875rem; font-family: var(--font);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control::placeholder { color: #a0aec0; }
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,109,232,.14);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.field-error { color: var(--color-danger); font-size: .8rem; margin-top: .25rem; }

/* ============================================================
   Tables
   ============================================================ */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td {
  padding: .6rem .75rem; text-align: left;
  border-bottom: 1px solid var(--color-border-lt);
}
.table th { font-weight: 600; background: #f5f8ff; color: var(--color-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8faff; }
.row-danger td { background: #fff5f5; }
.table-sm th, .table-sm td { padding: .3rem .5rem; }
.action-cell { white-space: nowrap; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  background: var(--color-bg); color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.badge-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-primary { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ============================================================
   Auth pages  (login, MFA, change-code, reset)
   ============================================================ */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-auth);
}

/* Logo mark at the top of each auth card */
.auth-logo {
  display: block;
  height: 52px;
  width: auto;
  margin: 0 auto 1.25rem;
}

/* Brand header inside auth card */
.auth-card h1 {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .35rem;
  color: var(--color-text);
  letter-spacing: -.01em;
}
.auth-card h2 {
  text-align: center;
  color: var(--color-muted);
  font-size: .875rem;
  font-weight: 400;
  margin-bottom: 1.75rem;
}

/* Auth-page submit button — full width, blue */
.auth-card .btn-primary {
  margin-top: .25rem;
  padding: .65rem;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .01em;
}

/* Auth sub-links (forgot password, etc.) */
.auth-links {
  text-align: center;
  margin-top: .9rem;
  font-size: .8rem;
  color: var(--color-muted);
}
.auth-links a { color: var(--color-primary); text-decoration: none; font-weight: 500; }
.auth-links a:hover { text-decoration: underline; }

.back-link {
  text-align: center; margin-top: 1rem; font-size: .875rem;
  color: var(--color-muted);
}
.back-link a { color: var(--color-primary); text-decoration: none; }

/* QR code and manual key */
.qr-container { margin: 1.25rem 0; display: flex; justify-content: center; }
.qr-container img { display: block; border-radius: var(--radius); border: 1px solid var(--color-border); }
.manual-key { margin: 1rem 0; font-size: .875rem; }
.manual-key summary { cursor: pointer; color: var(--color-muted); user-select: none; }
.manual-key code {
  display: block; padding: .6rem .75rem; margin-top: .5rem;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); word-break: break-all; font-family: monospace;
  font-size: .8rem; color: var(--color-text);
}
.code-input { font-size: 1.5rem; text-align: center; letter-spacing: .5rem; }

/* ============================================================
   Survey list (participant)
   ============================================================ */
.survey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.survey-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.25rem; display: flex;
  flex-direction: column; gap: .75rem; box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.survey-card:hover { box-shadow: var(--shadow-lg); border-color: #c0cfe8; }
.survey-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.survey-card h2 { font-size: 1rem; font-weight: 600; }
.survey-desc { color: var(--color-muted); font-size: .875rem; }
.survey-meta { color: var(--color-muted); font-size: .8rem; }
.survey-progress { margin: .25rem 0 .5rem; }
.survey-category-breakdown { margin: .25rem 0 .5rem; font-size: .8rem; }
.survey-category-breakdown summary { cursor: pointer; color: var(--color-muted); user-select: none; margin-bottom: .4rem; }
.category-progress-row { margin-bottom: .4rem; }

/* ============================================================
   Session (survey participation)
   ============================================================ */
.session-header {
  margin-bottom: 1rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.session-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.session-meta {
  display: flex; gap: 1rem; align-items: center; color: var(--color-muted);
  font-size: .8rem; margin-top: .25rem; flex-wrap: wrap;
}

/* Required-but-incomplete question highlight */
.question-block.required-incomplete {
  border: 2px solid var(--color-danger);
  border-radius: var(--radius);
  background: #fff5f5;
  animation: shake .35s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-4px); }
  40%,80%  { transform: translateX(4px); }
}

/* Sidebar nav + content */
.tabs-container {
  display: flex; flex-direction: row; gap: 1.25rem; align-items: flex-start;
}
.tab-list {
  display: flex; flex-direction: column; list-style: none;
  width: 200px; flex-shrink: 0;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); overflow-y: auto;
  max-height: calc(100vh - 80px);
  position: sticky; top: 64px;
}
.tab-item {
  padding: .7rem 1rem; cursor: pointer;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--color-border-lt);
  transition: all var(--transition);
  display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
  font-size: .875rem; width: 100%;
}
.tab-item:last-child { border-bottom: none; }
.tab-item:hover { background: var(--color-primary-lt); }
.tab-item.active {
  background: var(--color-primary-lt);
  border-left-color: var(--color-primary);
  font-weight: 600; color: var(--color-primary);
}
.tab-name-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: .35rem; }
.tab-name { word-break: break-word; }
.tab-check {
  color: var(--color-success); font-weight: 700; font-size: .85rem;
  flex-shrink: 0; transition: opacity var(--transition);
}
.tab-item.tab-complete { border-left-color: var(--color-success); }
.tab-item.tab-complete .tab-name { color: var(--color-success); }
.progress-label { font-size: .7rem; color: var(--color-muted); }
.progress-bar-mini {
  width: 100%; height: 3px; background: var(--color-border);
  border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--color-primary); transition: width .3s ease; }
.tab-content { flex: 1; min-width: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
@media (max-width: 640px) {
  .tabs-container { flex-direction: column; }
  .tab-list { width: 100%; position: static; flex-direction: row; overflow-x: auto; flex-wrap: nowrap; border-radius: var(--radius); }
  .tab-item { border-left: none; border-bottom: 3px solid transparent; border-right: 1px solid var(--color-border-lt); white-space: nowrap; min-width: max-content; }
  .tab-item:last-child { border-right: none; }
  .tab-item.active { border-bottom-color: var(--color-primary); border-left: none; }
}

/* Questions */
.question-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: box-shadow var(--transition);
}
.question-block:hover { box-shadow: var(--shadow); }
.question-block.hidden { display: none; }
.question-block.assigned-to-me {
  border-left: 4px solid var(--color-primary);
}
.question-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .5rem; margin-bottom: .75rem;
}
.question-label { font-weight: 600; flex: 1; font-size: .95rem; }
.required-star { color: var(--color-danger); margin-right: .2rem; }
.assigned-badge { color: var(--color-warning); }
.tooltip-icon { color: var(--color-muted); cursor: help; font-size: .875rem; }
.question-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* Answer inputs */
.radio-group, .checkbox-group, .rating-group {
  display: flex; flex-wrap: wrap; gap: .5rem;
}
.radio-label, .checkbox-label {
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer; font-size: .875rem; padding: .35rem .65rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  transition: all var(--transition);
}
.radio-label:hover, .checkbox-label:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-lt);
}
.rating-label {
  display: flex; flex-direction: column; align-items: center;
  gap: .2rem; cursor: pointer; padding: .35rem .6rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  min-width: 40px; text-align: center; font-size: .875rem;
  transition: all var(--transition);
}
.rating-label:hover { border-color: var(--color-primary); background: var(--color-primary-lt); }
.answer-meta { margin-top: .5rem; color: var(--color-muted); font-size: .8rem; }

/* Matrix / grid question */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix-table {
  border-collapse: collapse; width: 100%; min-width: 480px;
  font-size: .875rem;
}
.matrix-table th, .matrix-table td {
  border: 1px solid var(--color-border-lt); padding: .5rem .65rem;
}
.matrix-table thead th {
  background: var(--color-primary-lt); text-align: center;
  font-weight: 600; white-space: nowrap;
}
.matrix-table thead th.matrix-corner { background: transparent; border: none; }
.matrix-row-label {
  text-align: left; font-weight: 500; background: var(--color-border-lt);
  min-width: 200px;
}
.matrix-cell { text-align: center; }
.matrix-cell-label {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin: 0; padding: .25rem;
}
.matrix-table tbody tr:hover { background: var(--color-primary-lt); }

/* History & Comments */
.history-panel {
  margin-top: .75rem; border-top: 1px solid var(--color-border-lt);
  padding-top: .5rem;
}
.history-panel summary {
  cursor: pointer; color: var(--color-muted); font-size: .8rem;
  user-select: none;
}
.history-entry {
  display: flex; gap: .75rem; align-items: center; padding: .35rem 0;
  font-size: .8rem; border-bottom: 1px solid var(--color-border-lt);
}
.history-entry:last-child { border-bottom: none; }
.history-user { font-weight: 600; min-width: 80px; }
.history-value { flex: 1; }
.history-time { color: var(--color-muted); white-space: nowrap; }

.comment-panel {
  margin-top: .75rem; border-top: 1px solid var(--color-border-lt);
  padding-top: .75rem;
}
.comment-item {
  display: flex; gap: .5rem; align-items: flex-start; padding: .4rem 0;
  font-size: .875rem; border-bottom: 1px solid var(--color-border-lt);
}
.comment-item:last-child { border-bottom: none; }
.comment-user { font-weight: 600; min-width: 70px; color: var(--color-primary); }
.comment-text { flex: 1; }
.comment-time { color: var(--color-muted); font-size: .75rem; white-space: nowrap; }
.comment-input-row {
  display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap;
}
.comment-input-row .form-control { flex: 1; min-width: 180px; }

/* Mention highlight overlay */
.comment-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 180px;
  display: flex;
}
.comment-input-wrapper .form-control {
  flex: 1;
  position: relative;
  background: transparent !important;
  z-index: 1;
}
.comment-highlight-mirror {
  position: absolute;
  inset: 0;
  pointer-events: none;
  white-space: pre;
  overflow: hidden;
  color: transparent;
  z-index: 0;
  border: 1px solid transparent; /* reserves same border-box space as input */
}
.comment-highlight-mirror .mention-tag {
  background: var(--color-primary-lt);
  border-radius: 3px;
  color: transparent;
}

/* @mention autocomplete dropdown */
.mention-dropdown {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  cursor: pointer;
  font-size: .875rem;
  transition: background var(--transition), color var(--transition);
}
.mention-item:hover,
.mention-item.focused {
  background: var(--color-primary-lt);
  color: var(--color-primary);
}
.mention-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.mention-item.focused .mention-avatar,
.mention-item:hover .mention-avatar {
  background: var(--color-primary-dk);
}

/* @mention tag inside posted comment text */
.mention-tag {
  display: inline;
  background: var(--color-primary-lt);
  color: var(--color-primary);
  border-radius: 4px;
  padding: 0 .3em;
  font-weight: 600;
  font-size: .9em;
}

/* Comment count badge on the 💬 button */
.comment-count {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 600;
  padding: 0 4px;
  min-width: 16px;
  text-align: center;
  line-height: 16px;
  vertical-align: middle;
  margin-left: 2px;
}

/* ============================================================
   Admin results
   ============================================================ */
.result-question { padding: .75rem 0; border-bottom: 1px solid var(--color-border-lt); }
.result-question:last-child { border-bottom: none; }
.current-answer { margin-top: .5rem; }
.answer-chip {
  display: inline-block; padding: .35rem .7rem;
  background: var(--color-primary-lt);
  color: var(--color-primary);
  border-radius: var(--radius); font-size: .875rem; font-weight: 500;
}
.answer-meta { font-size: .8rem; color: var(--color-muted); margin-top: .25rem; }

/* ============================================================
   Survey Builder
   ============================================================ */
.builder-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; }
@media (max-width: 640px) { .builder-layout { grid-template-columns: 1fr; } }
.builder-sidebar {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.sidebar-header h3 { font-size: .875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); }
.category-list { list-style: none; }
.category-item {
  padding: .5rem .75rem; border-radius: var(--radius); cursor: pointer;
  font-size: .875rem; transition: background var(--transition);
}
.category-item:hover { background: var(--color-bg); }
.category-item.active {
  background: var(--color-primary); color: #fff; font-weight: 500;
}
.builder-main {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.25rem;
}
.save-status { color: var(--color-muted); font-size: .8rem; }
.save-status-saving { color: var(--color-muted); }
.save-status-saved { color: var(--color-success, #1a7f48); }
.save-status-error { color: var(--color-danger, #c0392b); font-weight: 600; }

.question-edit-card {
  border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; background: var(--color-bg);
  position: relative;
}
.question-edit-inner { padding-left: 1.5rem; }
.option-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.option-row input { flex: 1; }
.condition-row {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: .6rem; margin-top: .5rem; font-size: .8rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal {
  position: fixed; inset: 0; background: rgba(5,15,40,.55);
  display: flex; align-items: center; justify-content: center; z-index: 500;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-auth); min-width: 320px; max-width: 480px; width: 90%;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid var(--color-border); font-weight: 600;
}
.modal-close { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--color-muted); }
.modal-body { padding: 1rem; }
.code-hint {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: .75rem; font-size: .75rem;
  overflow-x: auto; margin-bottom: 1rem; font-family: monospace;
}

/* ============================================================
   Misc helpers
   ============================================================ */
.empty-state { color: var(--color-muted); font-style: italic; }
.empty-page {
  text-align: center; padding: 4rem 2rem; color: var(--color-muted);
}
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }


/* ============================================================
   FES Tagged Questions (admin dashboard)
   ============================================================ */
.fes-question-block {
  padding: 1rem; background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  margin-bottom: 0;
}
.fes-question-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: .75rem; gap: 1rem;
}
