/* ============================================================
   CML Voice Survey — Frontend Styles
   Dark theme. Brand colors: black #000, orange #F58220.
   ============================================================ */

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

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.cmlv-body { min-height: 100vh; }

a { color: #F58220; text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* ---------------- Boot screen ---------------- */
.cmlv-boot {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #000; z-index: 9999;
}
.cmlv-boot-spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(245, 130, 32, 0.18);
  border-top-color: #F58220;
  border-radius: 50%;
  animation: cmlv-spin 0.7s linear infinite;
}
.cmlv-boot-text { margin-top: 16px; color: #888; font-size: 13px; letter-spacing: 0.5px; }
@keyframes cmlv-spin { to { transform: rotate(360deg); } }

/* ---------------- Layout shell ---------------- */
.cmlv-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: #000;
}
.cmlv-page-header {
  width: 100%; padding: 0;
  background: #000;
}
.cmlv-page-header img {
  width: 100%; height: auto; display: block;
  max-height: 280px; object-fit: cover; object-position: center;
}
.cmlv-page-body { flex: 1; padding: 32px 20px; max-width: 1100px; margin: 0 auto; width: 100%; }

.cmlv-page-footer {
  background: #000;
  padding: 0;
  line-height: 0; /* prevent inline-image gap */
}
.cmlv-page-footer img {
  width: 100%; height: auto; display: block;
  max-width: 100%;
}

.cmlv-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #0a0a0a; border-bottom: 1px solid #1a1a1a;
  gap: 12px;
}
.cmlv-topbar .brand {
  display: inline-flex; align-items: center;
  text-decoration: none; flex-shrink: 0;
  padding: 4px 0;
}
.cmlv-topbar .brand img {
  height: 28px; width: auto; max-width: 180px;
  display: block;
}
.cmlv-topbar .brand:hover { opacity: 0.85; }
.cmlv-topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.cmlv-topbar nav a { color: #aaa; font-size: 13px; }
.cmlv-topbar nav a.active { color: #F58220; }
.cmlv-topbar .who { color: #666; font-size: 12px; }

/* ---------------- Login screen ---------------- */
/* When wrapped inside .cmlv-page (which has the Header banner + Footer image),
   .cmlv-login is the flex body — it fills available height and centers the card. */
.cmlv-login {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 600px at 20% 80%, rgba(245, 130, 32, 0.18), transparent 60%),
    radial-gradient(700px 500px at 80% 20%, rgba(245, 130, 32, 0.08), transparent 60%),
    #000;
  padding: 40px 20px;
}
.cmlv-login-card {
  width: 100%; max-width: 440px;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid #1f1f1f;
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* Logo inside the login card (replaces the old text H1) */
.cmlv-login-logo {
  text-align: center;
  margin: 0 0 18px 0;
}
.cmlv-login-logo img {
  max-width: 280px; width: 80%;
  height: auto;
  display: inline-block;
}

.cmlv-login-step-title {
  margin: 0 0 8px 0;
  font-size: 20px; font-weight: 700; color: #fff;
  text-align: center;
  letter-spacing: 0.3px;
}

.cmlv-login-card .sub {
  margin: 0 0 24px 0; color: #888; font-size: 14px; line-height: 1.5;
  text-align: center;
}

.cmlv-field { margin-bottom: 16px; }
.cmlv-field label {
  display: block; color: #ccc; font-size: 13px; margin-bottom: 6px;
  font-weight: 500;
}
.cmlv-field input[type="email"],
.cmlv-field input[type="text"],
.cmlv-field input[type="number"],
.cmlv-field textarea,
.cmlv-field select {
  width: 100%; padding: 12px 14px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 8px;
  color: #fff; font-size: 14px;
  transition: border-color 0.15s;
}
.cmlv-field input:focus,
.cmlv-field textarea:focus,
.cmlv-field select:focus {
  outline: none; border-color: #F58220; box-shadow: 0 0 0 3px rgba(245,130,32,0.18);
}
.cmlv-checkbox {
  display: flex; align-items: center; gap: 8px;
  color: #ccc; font-size: 13px; cursor: pointer;
  margin-bottom: 20px;
}
.cmlv-checkbox input[type="checkbox"] { accent-color: #F58220; width: 16px; height: 16px; }

.cmlv-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 24px; border: 0; border-radius: 8px;
  background: #F58220; color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: filter 0.15s, transform 0.05s;
  letter-spacing: 0.5px;
}
.cmlv-btn:hover { filter: brightness(1.1); }
.cmlv-btn:active { transform: translateY(1px); }
.cmlv-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.cmlv-btn-block { width: 100%; }
.cmlv-btn-ghost {
  background: transparent; color: #ccc; border: 1px solid #2a2a2a;
}
.cmlv-btn-ghost:hover { background: #1a1a1a; }
.cmlv-btn-danger { background: #c0392b; }

.cmlv-alert {
  padding: 12px 14px; border-radius: 8px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5;
}
.cmlv-alert-error   { background: rgba(192, 57, 43, 0.15); border: 1px solid rgba(192, 57, 43, 0.4); color: #ffb3a8; }
.cmlv-alert-success { background: rgba(39, 174, 96, 0.12); border: 1px solid rgba(39, 174, 96, 0.4); color: #a8e6b9; }
.cmlv-alert-info    { background: rgba(245, 130, 32, 0.12); border: 1px solid rgba(245, 130, 32, 0.4); color: #ffd0a0; }

/* ---------------- Dashboard ---------------- */
.cmlv-dashboard-title {
  text-align: center; margin: 0 0 32px 0;
}
.cmlv-dashboard-title img { max-width: 460px; width: 80%; height: auto; }

.cmlv-survey-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px; max-width: 720px; margin: 0 auto;
}
.cmlv-tile {
  position: relative; aspect-ratio: 16/9;
  border-radius: 12px; overflow: hidden;
  background: #0a0a0a; cursor: pointer;
  border: 1px solid #1f1f1f;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cmlv-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(245,130,32,0.25); }
.cmlv-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cmlv-dashboard-cta {
  display: flex; flex-direction: row; align-items: stretch; justify-content: center;
  flex-wrap: wrap; gap: 12px;
  margin-top: 40px;
}
.cmlv-dashboard-cta .cmlv-btn {
  flex: 1 1 200px; max-width: 320px;
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; padding-left: 16px; padding-right: 16px;
}
.cmlv-recent {
  margin-top: 48px;
  background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 12px; padding: 20px;
}
.cmlv-recent h2 { margin-top: 0; font-size: 16px; color: #fff; }
.cmlv-recent table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmlv-recent th, .cmlv-recent td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid #1a1a1a; color: #ccc;
}
.cmlv-recent th { color: #888; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.cmlv-recent tr:last-child td { border-bottom: 0; }

/* ---------------- Survey form ---------------- */
.cmlv-survey-form { max-width: 760px; margin: 0 auto; }
.cmlv-survey-form h1 { font-size: 22px; color: #fff; margin-bottom: 4px; }
.cmlv-survey-form .meta { color: #888; font-size: 13px; margin-bottom: 24px; }

.cmlv-section {
  background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 12px;
  padding: 24px 24px 8px 24px; margin-bottom: 20px;
}
.cmlv-section h2 {
  margin: 0 0 18px 0; font-size: 14px; color: #F58220;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.cmlv-question { padding: 16px 0; border-bottom: 1px solid #1a1a1a; }
.cmlv-question:last-child { border-bottom: 0; }
.cmlv-q-label {
  display: block; margin-bottom: 12px;
  font-size: 15px; color: #fff; line-height: 1.5;
}
.cmlv-q-label .req { color: #F58220; margin-left: 4px; }
.cmlv-q-helper { color: #888; font-size: 12px; margin-top: -4px; margin-bottom: 12px; }

/* Likert */
.cmlv-likert {
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap;
}
.cmlv-likert-scale { display: flex; gap: 8px; }
.cmlv-likert-btn {
  width: 44px; height: 44px; border-radius: 8px;
  background: #1a1a1a; border: 1px solid #2a2a2a; color: #ccc;
  cursor: pointer; font-size: 16px; font-weight: 700;
  transition: all 0.12s;
}
.cmlv-likert-btn:hover { border-color: #F58220; color: #fff; }
.cmlv-likert-btn.selected { background: #F58220; border-color: #F58220; color: #fff; }
.cmlv-likert-label { font-size: 12px; color: #888; max-width: 140px; }

/* Radio / single choice */
.cmlv-options { display: flex; flex-direction: column; gap: 8px; }
.cmlv-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
  color: #ccc; cursor: pointer; font-size: 14px;
  transition: all 0.12s;
}
.cmlv-option:hover { border-color: #444; }
.cmlv-option.selected { border-color: #F58220; background: rgba(245, 130, 32, 0.08); color: #fff; }
.cmlv-option input { accent-color: #F58220; margin-top: 2px; }
.cmlv-option-text { flex: 1; line-height: 1.5; }
.cmlv-other-input {
  margin-top: 8px;
  display: flex; gap: 8px; align-items: center;
}
.cmlv-other-input input {
  flex: 1; padding: 10px 12px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 6px; color: #fff; font-size: 13px;
}

/* Ranked top-N */
.cmlv-rank-pool, .cmlv-rank-chosen {
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
  padding: 12px; min-height: 40px;
}
.cmlv-rank-section-title {
  font-size: 11px; color: #888; text-transform: uppercase;
  letter-spacing: 0.6px; margin: 12px 0 6px; font-weight: 600;
}
.cmlv-rank-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 6px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 6px;
  color: #ccc; font-size: 13px;
}
.cmlv-rank-item:last-child { margin-bottom: 0; }
.cmlv-rank-item .text { flex: 1; }
.cmlv-rank-item .rank-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: #F58220; color: #fff; font-weight: 700; font-size: 12px;
}
.cmlv-rank-btn {
  background: transparent; border: 1px solid #2a2a2a; color: #888;
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.cmlv-rank-btn:hover { border-color: #F58220; color: #F58220; }
.cmlv-rank-btn-add { background: #F58220; color: #fff; border-color: #F58220; }

/* Numeric / duration / text */
.cmlv-inline-input {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.cmlv-inline-input input[type="number"],
.cmlv-inline-input input[type="text"] {
  width: 120px; padding: 10px 12px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 6px; color: #fff; font-size: 14px;
}
.cmlv-inline-input .unit { color: #888; font-size: 13px; }
.cmlv-inline-input textarea {
  width: 100%;
  padding: 10px 12px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 6px; color: #fff; font-size: 14px;
}

/* Matrix table */
.cmlv-matrix {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.cmlv-matrix th, .cmlv-matrix td {
  padding: 10px 8px; border-bottom: 1px solid #1a1a1a;
  text-align: center; color: #ccc;
}
.cmlv-matrix th:first-child, .cmlv-matrix td:first-child {
  text-align: left; color: #fff;
}
.cmlv-matrix thead th {
  color: #888; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.cmlv-matrix-cell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid #2a2a2a; border-radius: 6px; cursor: pointer;
  font-weight: 600; color: #ccc; background: #1a1a1a;
  transition: all 0.1s;
}
.cmlv-matrix-cell:hover { border-color: #F58220; }
.cmlv-matrix-cell.selected { background: #F58220; border-color: #F58220; color: #fff; }
.cmlv-matrix-frequency .cmlv-matrix-cell { width: auto; padding: 6px 12px; font-size: 12px; }

/* Form footer */
.cmlv-form-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid #1a1a1a;
}
.cmlv-autosave {
  color: #666; font-size: 12px;
  display: flex; align-items: center; gap: 6px;
}
.cmlv-autosave .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #444;
}
.cmlv-autosave.saving .dot { background: #F58220; animation: cmlv-pulse 1s infinite; }
.cmlv-autosave.saved .dot { background: #27ae60; }
.cmlv-autosave.error .dot { background: #c0392b; }
@keyframes cmlv-pulse { 50% { opacity: 0.4; } }

.cmlv-missing-list {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid rgba(192, 57, 43, 0.4);
  color: #ffb3a8;
  padding: 14px; border-radius: 8px; margin-top: 16px;
}
.cmlv-missing-list ul { margin: 8px 0 0 18px; padding: 0; }
.cmlv-missing-list li { margin: 4px 0; font-size: 13px; }

/* Patient picker */
.cmlv-patient-picker {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 12px; padding: 28px; max-width: 560px; margin: 0 auto;
}
.cmlv-patient-picker h2 { margin: 0 0 8px; font-size: 20px; color: #fff; }
.cmlv-patient-picker .sub { color: #888; margin-bottom: 20px; font-size: 13px; }

.cmlv-suggestions {
  margin-top: 4px;
  background: #000; border: 1px solid #2a2a2a; border-radius: 8px;
  max-height: 220px; overflow-y: auto;
}
.cmlv-suggestions div {
  padding: 10px 14px; cursor: pointer; color: #ccc;
  border-bottom: 1px solid #1a1a1a; font-size: 13px;
}
.cmlv-suggestions div:last-child { border-bottom: 0; }
.cmlv-suggestions div:hover { background: rgba(245, 130, 32, 0.12); color: #fff; }
.cmlv-suggestions .meta { color: #666; font-size: 11px; }
.cmlv-suggestions .no-results { color: #666; font-style: italic; cursor: default; }

/* Submission detail / read view */
.cmlv-sub-detail h1 { color: #fff; }
.cmlv-sub-detail .meta-row {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 16px; background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 8px;
  margin-bottom: 24px; font-size: 13px; color: #aaa;
}
.cmlv-sub-detail .meta-row span strong { color: #fff; }

.cmlv-sub-q {
  padding: 18px 0; border-bottom: 1px solid #1a1a1a;
}
.cmlv-sub-q .qtext { color: #fff; font-size: 14px; margin-bottom: 8px; }
.cmlv-sub-q .qanswer { color: #ccc; font-size: 14px; padding-left: 12px; border-left: 2px solid #F58220; }

.cmlv-pill {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.cmlv-pill-draft    { background: rgba(245, 130, 32, 0.2); color: #F58220; }
.cmlv-pill-complete { background: rgba(39, 174, 96, 0.2);  color: #27ae60; }

/* Submissions list (frontend) */
.cmlv-table {
  width: 100%; border-collapse: collapse; background: #0a0a0a;
  border: 1px solid #1a1a1a; border-radius: 12px; overflow: hidden;
}
.cmlv-table th, .cmlv-table td {
  padding: 12px 16px; text-align: left; border-bottom: 1px solid #1a1a1a;
  color: #ccc; font-size: 13px;
}
.cmlv-table th { color: #888; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; background: #000; }
.cmlv-table tr:last-child td { border-bottom: 0; }
.cmlv-table tr:hover td { background: rgba(245, 130, 32, 0.04); }

/* Code input on login verify step */
.cmlv-code-input {
  font-family: 'Courier New', Consolas, monospace !important;
  font-size: 28px !important;
  letter-spacing: 12px !important;
  text-align: center !important;
  font-weight: 700 !important;
  padding: 14px 12px !important;
}

.cmlv-login-meta {
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #1a1a1a;
}
.cmlv-login-meta a {
  color: #888 !important;
  font-size: 13px;
}
.cmlv-login-meta a:hover { color: #F58220 !important; }

/* Matrix hint shown above the table (mostly used on mobile when table reshapes) */
.cmlv-matrix-wrap { width: 100%; }
.cmlv-matrix-hint {
  font-size: 12px; color: #888;
  padding: 6px 10px; background: rgba(245, 130, 32, 0.06);
  border-radius: 6px; margin-bottom: 8px;
  display: none; /* shown only on mobile */
}

/* ============================================================
   RESPONSIVE — iPad, tablet, mobile
   Mobile-first cascade: phone @ 600, large phone/portrait tablet @ 768,
   landscape tablet @ 1024.
   ============================================================ */

/* ---------- iPad / large tablet (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  .cmlv-page-body { padding: 28px 18px; }
  .cmlv-page-header img { max-height: 220px; }
  .cmlv-dashboard-title img { max-width: 360px; }
  .cmlv-survey-form { max-width: 100%; }
}

/* ---------- iPad portrait & small tablet (≤ 820px) ---------- */
@media (max-width: 820px) {
  .cmlv-page-header img { max-height: 180px; }
  .cmlv-dashboard-title img { max-width: 320px; }
  .cmlv-section { padding: 20px 18px 4px 18px; }
  .cmlv-topbar .brand img { height: 26px; max-width: 160px; }
  .cmlv-login-logo img { max-width: 260px; }
}

/* ---------- Tablet portrait / large phone (≤ 768px) ---------- */
@media (max-width: 768px) {
  .cmlv-page-body { padding: 20px 14px; }
  .cmlv-page-header img { max-height: 150px; }
  .cmlv-topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .cmlv-topbar nav { gap: 10px; flex-wrap: wrap; }
  .cmlv-topbar .who { display: none; } /* save space */
  .cmlv-topbar .brand img { height: 24px; max-width: 140px; }

  .cmlv-login { padding: 28px 16px; }
  .cmlv-login-card { padding: 30px 24px; }
  .cmlv-login-logo img { max-width: 240px; }

  /* Likert: stretch full width, labels go above the buttons row */
  .cmlv-likert { flex-direction: column; align-items: stretch; gap: 6px; }
  .cmlv-likert-label { max-width: none; text-align: center; }
  .cmlv-likert-label:first-child { order: -1; }
  .cmlv-likert-scale {
    justify-content: space-between;
    gap: 6px;
  }
  .cmlv-likert-btn { flex: 1; min-width: 0; }

  /* Form footer stacks */
  .cmlv-form-footer { flex-direction: column-reverse; gap: 12px; align-items: stretch; }
  .cmlv-form-footer .cmlv-btn { width: 100%; }
  .cmlv-autosave { justify-content: center; }
}

/* ---------- Phone (≤ 600px) ---------- */
@media (max-width: 600px) {
  body { font-size: 14px; }

  .cmlv-page-header img { max-height: 120px; }
  .cmlv-page-body { padding: 18px 12px; }

  .cmlv-topbar { padding: 8px 12px; gap: 6px; }
  .cmlv-topbar .brand img { height: 22px; max-width: 120px; }
  .cmlv-topbar nav { gap: 10px; }
  .cmlv-topbar nav a { font-size: 12px; }

  .cmlv-login { padding: 20px 12px; }
  .cmlv-login-card { padding: 24px 18px; border-radius: 12px; }
  .cmlv-login-logo { margin-bottom: 14px; }
  .cmlv-login-logo img { max-width: 220px; width: 75%; }
  .cmlv-login-step-title { font-size: 18px; }
  .cmlv-login-card .sub { font-size: 13px; margin-bottom: 20px; }
  .cmlv-code-input { font-size: 22px !important; letter-spacing: 8px !important; padding: 12px 8px !important; }

  .cmlv-dashboard-title img { max-width: 260px; width: 90%; }
  /* Survey tiles: force 2 columns side-by-side on phone so they don't stack and dominate the screen */
  .cmlv-survey-tiles {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 100%;
  }
  .cmlv-tile { aspect-ratio: 4/3; }

  .cmlv-recent { padding: 14px; margin-top: 28px; }
  .cmlv-recent h2 { font-size: 15px; }

  .cmlv-survey-form h1 { font-size: 19px; }
  .cmlv-section { padding: 16px 14px 4px 14px; border-radius: 10px; }
  .cmlv-section h2 { font-size: 12px; margin-bottom: 14px; }
  .cmlv-question { padding: 14px 0; }
  .cmlv-q-label { font-size: 14px; }

  /* Likert: smaller buttons, but always fit the row */
  .cmlv-likert-btn { height: 42px; font-size: 15px; border-radius: 6px; }

  /* Single/multi options — slightly more compact */
  .cmlv-option { padding: 11px 12px; font-size: 13px; }

  /* Ranked items: allow controls to wrap */
  .cmlv-rank-item { flex-wrap: wrap; padding: 10px; gap: 6px; }
  .cmlv-rank-item .text { flex: 1 1 100%; order: -1; }
  .cmlv-rank-btn { padding: 4px 8px; font-size: 11px; }

  /* Inline number/duration inputs: full-width on phone */
  .cmlv-inline-input { gap: 6px; }
  .cmlv-inline-input input[type="number"],
  .cmlv-inline-input input[type="text"] { flex: 1; min-width: 80px; }

  /* Show the matrix hint above the table */
  .cmlv-matrix-hint { display: block; }

  /* Matrix: stack each row as a card */
  .cmlv-matrix,
  .cmlv-matrix thead,
  .cmlv-matrix tbody,
  .cmlv-matrix tr,
  .cmlv-matrix th,
  .cmlv-matrix td { display: block; box-sizing: border-box; }
  .cmlv-matrix thead { display: none; }
  .cmlv-matrix tbody tr {
    background: #050505;
    border: 1px solid #1f1f1f;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
  }
  .cmlv-matrix tbody td {
    text-align: left;
    border: 0;
    padding: 0;
  }
  .cmlv-matrix tbody td.cmlv-matrix-item {
    color: #fff;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.4;
  }
  .cmlv-matrix tbody td:not(.cmlv-matrix-item) {
    display: inline-block;
    margin: 0 4px 4px 0;
  }
  .cmlv-matrix tbody td:not(.cmlv-matrix-item) .cmlv-matrix-cell {
    width: auto !important; height: auto !important;
    padding: 8px 12px !important; font-size: 13px;
  }
  .cmlv-matrix-frequency tbody td:not(.cmlv-matrix-item) .cmlv-matrix-cell { padding: 8px 10px !important; }

  /* Tables in the frontend — stack as cards */
  .cmlv-table,
  .cmlv-table thead,
  .cmlv-table tbody,
  .cmlv-table tr,
  .cmlv-table th,
  .cmlv-table td { display: block; box-sizing: border-box; }
  .cmlv-table thead { display: none; }
  .cmlv-table tbody tr {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  .cmlv-table tbody tr:hover td { background: transparent; }
  .cmlv-table tbody td {
    text-align: left;
    border: 0;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .cmlv-table tbody td::before {
    content: attr(data-label);
    color: #777; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 600;
    flex-shrink: 0;
  }
  .cmlv-table tbody td:last-child { justify-content: flex-end; padding-top: 8px; }
  .cmlv-table tbody td:last-child::before { display: none; }

  /* Recent submissions (dashboard) — same card treatment */
  .cmlv-recent table,
  .cmlv-recent thead,
  .cmlv-recent tbody,
  .cmlv-recent tr,
  .cmlv-recent th,
  .cmlv-recent td { display: block; box-sizing: border-box; }
  .cmlv-recent thead { display: none; }
  .cmlv-recent tbody tr {
    background: #050505;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .cmlv-recent tbody td {
    border: 0;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .cmlv-recent tbody td::before {
    content: attr(data-label);
    color: #777; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 600;
  }

  /* Submission detail meta-row — stack */
  .cmlv-sub-detail .meta-row {
    flex-direction: column; gap: 6px;
  }
  .cmlv-sub-detail .meta-row span {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 6px 0; border-bottom: 1px solid #1a1a1a;
  }
  .cmlv-sub-detail .meta-row span:last-child { border-bottom: 0; }

  .cmlv-sub-q .qtext { font-size: 13px; }
  .cmlv-sub-q .qanswer { font-size: 13px; padding-left: 10px; }

  .cmlv-patient-picker { padding: 22px 16px; }
  .cmlv-patient-picker h2 { font-size: 18px; }
}

/* ---------- Very narrow (≤ 360px) ---------- */
@media (max-width: 360px) {
  .cmlv-likert-btn { height: 38px; font-size: 13px; }
  .cmlv-survey-tiles { gap: 8px; }
  .cmlv-code-input { font-size: 18px !important; letter-spacing: 6px !important; }
  .cmlv-login-logo img { max-width: 200px; }
  .cmlv-topbar .brand img { height: 20px; max-width: 105px; }
}

/* ---------- Landscape phones: keep header smaller ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .cmlv-page-header img { max-height: 90px; }
  .cmlv-login { padding: 16px 12px; }
  .cmlv-login-card { padding: 18px 22px; }
  .cmlv-login-logo { margin-bottom: 10px; }
  .cmlv-login-logo img { max-width: 200px; }
}

/* ============================================================
   ADMIN SECTION (frontend, for whitelist admins)
   ============================================================ */
.cmlv-nav-admin {
  background: #F58220; color: #fff !important;
  padding: 4px 12px; border-radius: 6px;
  font-weight: 600;
}
.cmlv-nav-admin.active { background: #ffa44a; }

.cmlv-admin-page { color: #fff; }
.cmlv-admin-h1 {
  color: #fff; margin: 16px 0 8px 0;
  font-size: 22px; font-weight: 700;
}
.cmlv-admin-h2 {
  color: #fff; margin: 28px 0 14px 0;
  font-size: 16px; font-weight: 600;
}
.cmlv-admin-actions { margin: 16px 0; }

.cmlv-admin-subnav {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 4px 0 20px 0; padding: 6px;
  background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 10px;
}
.cmlv-admin-subnav a {
  color: #aaa; font-size: 13px; padding: 8px 14px;
  border-radius: 6px; text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.cmlv-admin-subnav a:hover { background: rgba(245, 130, 32, 0.1); color: #fff; }
.cmlv-admin-subnav a.active { background: #F58220; color: #fff; }

.cmlv-admin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin: 16px 0;
}
.cmlv-admin-stat {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 10px; padding: 16px;
}
.cmlv-admin-stat .num {
  font-size: 28px; font-weight: 700; color: #F58220; line-height: 1.1;
}
.cmlv-admin-stat .label {
  margin-top: 4px; font-size: 11px; color: #888;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.cmlv-admin-card {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 12px; padding: 20px 22px; margin-bottom: 14px;
}
.cmlv-admin-card h3 {
  margin: 0 0 14px 0; font-size: 14px; color: #F58220;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
}
.cmlv-admin-card .sub {
  color: #888; font-size: 12px; margin: -8px 0 14px 0;
}

.cmlv-admin-filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px;
  padding: 14px; background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 10px;
}
.cmlv-admin-filters input {
  flex: 1; min-width: 180px;
  padding: 10px 12px; background: #000; border: 1px solid #2a2a2a;
  border-radius: 6px; color: #fff; font-size: 13px;
}

.cmlv-btn-danger { background: #c0392b; }
.cmlv-btn-danger:hover { background: #d4503e; }

/* Pills on the admin section */
.cmlv-pill-admin     { background: rgba(192, 57, 43, 0.2); color: #ffb3a8; }
.cmlv-pill-doctor    { background: rgba(13, 110, 253, 0.2); color: #9fc3ff; }
.cmlv-pill-filler    { background: rgba(13, 110, 253, 0.2); color: #9fc3ff; }
.cmlv-pill-action {
  background: rgba(108, 117, 125, 0.2); color: #ccc;
  font-family: monospace; font-weight: 500;
}

/* ============================================================
   ANALYTICS — dark-native, polished
   ============================================================ */
.cmlv-an-host { color: #f0f0f0; }
.cmlv-an { display: block; }

/* ---- Filter bar ---- */
.cmlv-an-filters {
  background: #0a0a0a; border: 1px solid #1a1a1a; border-radius: 12px;
  padding: 16px 18px; margin-bottom: 22px;
}
.cmlv-an-presets {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px dashed #1a1a1a;
}
.cmlv-an-preset {
  background: #111; color: #ccc; border: 1px solid #222;
  padding: 7px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all 0.12s;
}
.cmlv-an-preset:hover { background: #1a1a1a; color: #fff; border-color: #2a2a2a; }
.cmlv-an-preset.active {
  background: #F58220; color: #fff; border-color: #F58220;
}

.cmlv-an-filters-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.cmlv-an-filters-row select,
.cmlv-an-filters-row input[type=text],
.cmlv-an-filters-row input[type=date] {
  background: #111; border: 1px solid #222; color: #fff;
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
  min-width: 180px;
}
.cmlv-an-filters-row select:focus,
.cmlv-an-filters-row input:focus { border-color: #F58220; outline: 0; }
.cmlv-an-arrow { color: #555; font-size: 13px; }
.cmlv-an-exports { margin-left: auto; display: flex; gap: 6px; }

.cmlv-an-btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: all 0.12s;
}
.cmlv-an-btn-primary { background: #F58220; color: #fff; }
.cmlv-an-btn-primary:hover { background: #ff9543; }
.cmlv-an-btn-ghost { background: transparent; color: #aaa; border-color: #2a2a2a; }
.cmlv-an-btn-ghost:hover { background: #1a1a1a; color: #fff; }

/* ---- KPI hero ---- */
.cmlv-an-hero {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 28px;
}
.cmlv-an-kpi {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 12px; padding: 18px 18px 16px;
  position: relative; transition: border-color 0.15s;
}
.cmlv-an-kpi:hover { border-color: #2a2a2a; }
.cmlv-an-kpi-accent { background: linear-gradient(180deg, rgba(245,130,32,0.10) 0%, #0a0a0a 100%); border-color: rgba(245,130,32,0.4); }
.cmlv-an-kpi-num {
  font-size: 32px; font-weight: 800; color: #fff;
  line-height: 1; letter-spacing: -0.5px;
}
.cmlv-an-kpi-accent .cmlv-an-kpi-num { color: #F58220; }
.cmlv-an-kpi-label {
  margin-top: 8px; font-size: 11px; color: #888;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.cmlv-trend {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.cmlv-trend-up   { background: rgba(76, 175, 80, 0.15);  color: #81c784; }
.cmlv-trend-down { background: rgba(239, 83, 80, 0.15);  color: #ef9a9a; }
.cmlv-trend-flat { background: rgba(255, 255, 255, 0.08); color: #888; }

/* ---- Sections ---- */
.cmlv-an-section { margin-bottom: 28px; }
.cmlv-an-h2 {
  color: #fff; font-size: 15px; font-weight: 700;
  margin: 0 0 12px 0; display: flex; align-items: baseline; gap: 12px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.cmlv-an-h2-meta { font-size: 12px; color: #888; font-weight: 400; text-transform: none; letter-spacing: 0; }
.cmlv-an-h2-meta strong { color: #F58220; }

.cmlv-an-card {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 12px; padding: 18px;
  overflow: hidden;
}
.cmlv-an-card .cmlv-chart-svg { width: 100%; height: auto; display: block; }

.cmlv-an-split {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 28px;
}
.cmlv-an-split > div > .cmlv-an-h2 { margin-top: 0; }

.cmlv-an-prompt {
  background: linear-gradient(180deg, rgba(245,130,32,0.10) 0%, rgba(245,130,32,0.04) 100%);
  border: 1px solid rgba(245,130,32,0.3);
  color: #ffd9b3; padding: 18px 22px; border-radius: 12px;
  font-size: 14px; margin-bottom: 28px;
}
.cmlv-an-prompt strong { color: #F58220; }

/* ---- Section dividers in per-question list ---- */
.cmlv-an-section-divider {
  color: #F58220; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  margin: 28px 0 12px;
  padding: 10px 0; border-top: 1px dashed #222;
  display: flex; align-items: center; gap: 12px;
}
.cmlv-an-section-divider::before {
  content: ''; flex: 0 0 24px; height: 2px; background: #F58220; border-radius: 2px;
}

/* ---- Per-question card ---- */
.cmlv-an-q {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 12px; padding: 20px 22px; margin-bottom: 14px;
  page-break-inside: avoid; break-inside: avoid;
}
.cmlv-an-q-empty { opacity: 0.55; }
.cmlv-an-q-head {
  display: grid; grid-template-columns: 48px 1fr;
  gap: 14px; align-items: start; margin-bottom: 14px;
  padding-bottom: 14px; border-bottom: 1px solid #1a1a1a;
}
.cmlv-an-q-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(180deg, #FFA855 0%, #F58220 100%);
  color: #fff; font-weight: 700; font-size: 13px;
}
.cmlv-an-q-title { font-size: 15px; font-weight: 600; color: #fff; line-height: 1.4; }
.cmlv-an-q-helper { color: #888; font-size: 12px; margin-top: 4px; }
.cmlv-an-q-meta {
  margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: #aaa;
}
.cmlv-an-q-meta strong { color: #fff; }
.cmlv-an-tag {
  background: #1a1a1a; color: #aaa; font-family: monospace;
  padding: 2px 8px; border-radius: 4px; font-size: 11px;
}
.cmlv-an-q-skip { color: #666; font-style: italic; }
.cmlv-an-q-noresp {
  padding: 24px; text-align: center; color: #555;
  background: #050505; border-radius: 8px; font-style: italic;
}

.cmlv-an-q-body {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 22px; align-items: start;
}
.cmlv-an-q-body-textonly { display: block; }
.cmlv-an-q-chart { min-width: 0; }
.cmlv-an-q-stats { min-width: 0; }

/* ---- Stats group (right column) ---- */
.cmlv-an-statgroup {
  background: #050505; border: 1px solid #1a1a1a;
  border-radius: 10px; padding: 4px 0; overflow: hidden;
}
.cmlv-an-statgroup-scroll {
  max-height: 320px; overflow-y: auto;
}
.cmlv-an-statrow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid #111;
  font-size: 13px; gap: 12px;
}
.cmlv-an-statrow:last-child { border-bottom: 0; }
.cmlv-an-statrow span { color: #888; flex: 1; min-width: 0; }
.cmlv-an-statrow strong { color: #fff; font-weight: 700; white-space: nowrap; }

.cmlv-an-other {
  margin-top: 10px; background: #050505; border: 1px solid #1a1a1a;
  border-radius: 8px; padding: 8px 12px;
}
.cmlv-an-other summary { cursor: pointer; color: #aaa; font-weight: 600; padding: 4px 0; font-size: 12px; }
.cmlv-an-other ul { margin: 8px 0 4px 18px; max-height: 220px; overflow-y: auto; }
.cmlv-an-other li { color: #ccc; padding: 3px 0; font-size: 13px; }

/* ---- Text responses (full width) ---- */
.cmlv-an-text-block {
  background: #050505; border: 1px solid #1a1a1a;
  border-radius: 10px; padding: 14px;
}
.cmlv-an-text-bar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 12px;
}
.cmlv-an-text-search {
  flex: 1; background: #111; border: 1px solid #2a2a2a; color: #fff;
  padding: 9px 12px; border-radius: 6px; font-size: 13px;
}
.cmlv-an-text-search:focus { border-color: #F58220; outline: 0; }
.cmlv-an-text-count { color: #888; font-size: 12px; }
.cmlv-an-text-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 420px; overflow-y: auto;
}
.cmlv-an-text-list li {
  padding: 10px 14px; border-bottom: 1px solid #1a1a1a;
  color: #ccc; font-size: 13px; line-height: 1.5;
}
.cmlv-an-text-list li:last-child { border-bottom: 0; }
.cmlv-an-text-list li:hover { background: rgba(245, 130, 32, 0.04); color: #fff; }

/* ---- Print mode ---- */
@media print {
  .cmlv-topbar, .cmlv-page-footer, .cmlv-admin-subnav,
  .cmlv-an-filters, .cmlv-an-exports { display: none !important; }
  body, .cmlv-frame { background: #fff !important; color: #000 !important; }
  .cmlv-an-host, .cmlv-an-q, .cmlv-an-card, .cmlv-an-kpi,
  .cmlv-an-statgroup, .cmlv-an-text-block, .cmlv-an-prompt {
    background: #fff !important; color: #000 !important; border-color: #ddd !important;
  }
  .cmlv-an-kpi-num, .cmlv-an-q-title, .cmlv-an-statrow strong { color: #000 !important; }
  .cmlv-an-kpi-label, .cmlv-an-statrow span, .cmlv-an-q-helper, .cmlv-an-q-meta { color: #555 !important; }
  .cmlv-an-kpi-accent .cmlv-an-kpi-num, .cmlv-an-h2-meta strong, .cmlv-an-section-divider { color: #c4651b !important; }
  .cmlv-an-q { page-break-inside: avoid; break-inside: avoid; }
}

/* ============================================================
   PATIENT LONGITUDINAL VIEW — /patient/:id
   ============================================================ */
.cmlv-patient-page { color: #f0f0f0; }
.cmlv-patient-link { color: #F58220; text-decoration: none; font-weight: 600; }
.cmlv-patient-link:hover { text-decoration: underline; }

.cmlv-pt-header {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(245,130,32,0.10) 0%, #0a0a0a 100%);
  border: 1px solid #1a1a1a; border-radius: 12px;
  padding: 22px 24px; margin: 8px 0 18px;
  gap: 16px; flex-wrap: wrap;
}
.cmlv-pt-headline { display: flex; align-items: center; gap: 18px; }
.cmlv-pt-num {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(180deg, #FFA855 0%, #F58220 100%);
  color: #fff; font-weight: 800; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cmlv-pt-name {
  margin: 0; font-size: 22px; color: #fff; font-weight: 700;
}
.cmlv-pt-sub { color: #888; font-size: 13px; margin-top: 4px; }
.cmlv-pt-sub code { color: #aaa; }

.cmlv-pt-notes {
  background: #050505; border: 1px solid #1a1a1a;
  border-left: 3px solid #F58220;
  border-radius: 8px; padding: 12px 16px; margin-bottom: 18px;
  color: #ccc; font-size: 13px; line-height: 1.5;
}
.cmlv-pt-notes-label {
  color: #F58220; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px;
}

.cmlv-pt-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin-bottom: 24px;
}
.cmlv-pt-kpi {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 10px; padding: 14px 16px;
}
.cmlv-pt-kpi-num { font-size: 26px; font-weight: 800; color: #fff; line-height: 1; }
.cmlv-pt-kpi-num-sm { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; padding-top: 6px; }
.cmlv-pt-kpi-label {
  margin-top: 6px; font-size: 11px; color: #888;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}

.cmlv-pt-h2 {
  color: #fff; font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  margin: 28px 0 12px;
}

/* Likert trend cards */
.cmlv-pt-trends {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}
.cmlv-pt-trend {
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-radius: 10px; padding: 14px 16px;
}
.cmlv-pt-trend-head {
  display: flex; align-items: start; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.cmlv-pt-trend-text {
  color: #fff; font-size: 13px; font-weight: 600; line-height: 1.4;
  flex: 1; min-width: 0;
}
.cmlv-pt-trend-delta {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
}
.cmlv-pt-up   { background: rgba(76,175,80,0.15); color: #81c784; }
.cmlv-pt-down { background: rgba(239,83,80,0.15); color: #ef9a9a; }
.cmlv-pt-flat { background: rgba(255,255,255,0.06); color: #888; }
.cmlv-pt-trend-chart { margin: 4px -4px; }
.cmlv-pt-trend-svg { width: 100%; height: auto; display: block; }
.cmlv-pt-trend-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: #888; margin-top: 4px;
}
.cmlv-pt-trend-meta strong { color: #fff; }

/* Visit timeline */
.cmlv-pt-timeline { display: flex; flex-direction: column; gap: 10px; }
.cmlv-pt-visit {
  display: grid; grid-template-columns: 100px 1fr auto;
  gap: 14px; align-items: center;
  background: #0a0a0a; border: 1px solid #1a1a1a;
  border-left: 3px solid #1a1a1a;
  border-radius: 10px; padding: 14px 18px;
  transition: border-color 0.15s;
}
.cmlv-pt-visit-complete { border-left-color: #4caf50; }
.cmlv-pt-visit-draft    { border-left-color: #FFC107; }
.cmlv-pt-visit:hover { border-color: #2a2a2a; }
.cmlv-pt-visit-date {
  color: #fff; font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.cmlv-pt-visit-title {
  color: #fff; font-size: 14px; font-weight: 600;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.cmlv-pt-visit-edits { color: #888; font-size: 12px; font-weight: 400; }
.cmlv-pt-visit-meta { color: #888; font-size: 12px; margin-top: 4px; }
.cmlv-pt-visit-meta code { color: #aaa; }

@media (max-width: 700px) {
  .cmlv-pt-visit { grid-template-columns: 1fr; gap: 6px; }
  .cmlv-pt-headline { flex-direction: column; align-items: start; }
  .cmlv-pt-actions { width: 100%; }
}

/* ============================================================
   PRE-FILL BANNER (on new draft survey forms)
   ============================================================ */
.cmlv-prefill-banner {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(180deg, rgba(245,130,32,0.12) 0%, rgba(245,130,32,0.04) 100%);
  border: 1px solid rgba(245,130,32,0.4); border-radius: 12px;
  padding: 16px 20px; margin: 16px 0 24px;
  flex-wrap: wrap;
}
.cmlv-prefill-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: #F58220; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.cmlv-prefill-body { flex: 1; min-width: 200px; }
.cmlv-prefill-title { color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.cmlv-prefill-sub { color: #ddd; font-size: 13px; line-height: 1.5; }
.cmlv-prefill-sub strong { color: #F58220; }
.cmlv-prefill-btn {
  background: #F58220; color: #fff; border: 0;
  padding: 12px 22px; border-radius: 8px;
  font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.12s;
}
.cmlv-prefill-btn:hover { background: #ff9543; }
.cmlv-prefill-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   SUBMISSION DETAIL TITLEBAR (with Download PDF)
   ============================================================ */
.cmlv-sub-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 8px 0 16px;
}
.cmlv-sub-actions { display: flex; gap: 8px; }

/* ============================================================
   PRINT MODE (browser "Save as PDF")
   ============================================================ */
.cmlv-print-only { display: none; }
@media print {
  /* Reset to white print canvas */
  body, .cmlv-frame, .cmlv-page-body, .cmlv-content {
    background: #ffffff !important; color: #000000 !important;
  }
  .cmlv-topbar, .cmlv-page-footer, .cmlv-no-print, .cmlv-admin-subnav { display: none !important; }
  .cmlv-print-only { display: block !important; }

  /* Headings/text become dark */
  h1, h2, h3, h4, p, span, td, th, li, .meta-row, .meta-row span, .meta-row strong {
    color: #000 !important;
  }
  a, code, .cmlv-patient-link { color: #c4651b !important; text-decoration: none; }
  .cmlv-pill {
    background: #f0f0f0 !important; color: #333 !important;
    border: 1px solid #ddd; padding: 1px 8px; border-radius: 12px;
  }

  /* Submission detail print header */
  .cmlv-print-header {
    display: flex !important; align-items: center; gap: 18px;
    padding-bottom: 14px; margin-bottom: 18px;
    border-bottom: 2px solid #F58220;
  }
  .cmlv-print-logo { max-height: 50px; width: auto; }
  .cmlv-print-meta {
    flex: 1; font-size: 11px; line-height: 1.6; color: #333 !important;
  }
  .cmlv-print-meta div { color: #333 !important; }
  .cmlv-print-meta strong { color: #000 !important; }
  .cmlv-print-printed { color: #888 !important; font-size: 10px; margin-top: 4px; }

  /* Each Q/A block (submission detail) */
  .cmlv-sub-q {
    background: #fff !important; color: #000 !important;
    border: 1px solid #ddd !important; border-radius: 6px !important;
    padding: 12px 14px !important; margin-bottom: 8px !important;
    page-break-inside: avoid; break-inside: avoid;
  }
  .cmlv-sub-q .qtext { color: #000 !important; font-weight: 600; }
  .cmlv-sub-q .qanswer { color: #333 !important; }

  /* Patient page print */
  .cmlv-patient-page { color: #000 !important; }
  .cmlv-pt-header {
    background: #fff !important; color: #000 !important;
    border: 2px solid #F58220 !important;
  }
  .cmlv-pt-num { background: #F58220 !important; color: #fff !important; }
  .cmlv-pt-kpi, .cmlv-pt-trend, .cmlv-pt-visit, .cmlv-pt-notes {
    background: #fff !important; color: #000 !important;
    border: 1px solid #ddd !important;
    page-break-inside: avoid; break-inside: avoid;
  }
  .cmlv-pt-trend-text, .cmlv-pt-name, .cmlv-pt-kpi-num,
  .cmlv-pt-kpi-num-sm, .cmlv-pt-visit-date, .cmlv-pt-visit-title {
    color: #000 !important;
  }
  .cmlv-pt-kpi-label, .cmlv-pt-sub, .cmlv-pt-visit-meta { color: #555 !important; }
  .cmlv-pt-h2 { color: #F58220 !important; border-bottom: 1px solid #ddd; padding-bottom: 6px; }
  .cmlv-pt-trend-svg circle[fill="#0a0a0a"] { fill: #fff !important; }
}


@media (max-width: 900px) {
  .cmlv-an-q-body { grid-template-columns: 1fr; }
  .cmlv-an-split  { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .cmlv-admin-subnav { gap: 2px; padding: 4px; }
  .cmlv-admin-subnav a { padding: 6px 10px; font-size: 12px; }
  .cmlv-an-filters-row select,
  .cmlv-an-filters-row input { min-width: 100%; }
  .cmlv-an-exports { margin-left: 0; width: 100%; }
  .cmlv-an-kpi-num { font-size: 26px; }
}


/* ==========================================================
   v1.7.0 — UX upgrades: recent patients, sticky toolbar,
   bigger autosave, danger button, tablet polish.
   ========================================================== */

/* Recent patients strip on dashboard */
.cmlv-recent-patients { margin: 24px 0 28px; }
.cmlv-recent-patients-head {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 12px; padding: 0 4px;
}
.cmlv-recent-patients-head h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: 1px;
  color: #F58220; margin: 0;
}
.cmlv-rp-sub { color: #888; font-size: 12px; }
.cmlv-recent-patients-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.cmlv-recent-patient-card {
  display: block; padding: 14px 14px 12px; min-height: 84px;
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
  text-decoration: none; color: #eee;
  transition: border-color .15s, transform .1s;
}
.cmlv-recent-patient-card:hover {
  border-color: #F58220; transform: translateY(-1px);
}
.cmlv-rp-num { color: #F58220; font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.cmlv-rp-name {
  color: #fff; font-size: 14px; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmlv-rp-meta { color: #888; font-size: 11px; margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* Patient page — "+ New visit" panel */
.cmlv-pt-new-visit {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 24px; padding: 16px 20px;
  background: linear-gradient(135deg, #1a1a1a, #222); border: 1px solid #333;
  border-radius: 10px;
}
.cmlv-pt-new-visit-label {
  color: #ccc; font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
}
.cmlv-pt-new-visit-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* Submission detail — "Start next visit" panel */
.cmlv-sub-next-visit {
  margin: 20px 0; padding: 18px 20px;
  background: linear-gradient(135deg, rgba(245,130,32,0.12), rgba(245,130,32,0.05));
  border: 1px solid rgba(245,130,32,0.4); border-radius: 10px;
}
.cmlv-sub-next-label {
  color: #F58220; font-weight: 600; font-size: 14px; margin-bottom: 12px;
}
.cmlv-sub-next-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* Danger button (delete) */
.cmlv-btn-danger {
  background: #2a1414; border: 1px solid #5a2222; color: #ff8a8a;
}
.cmlv-btn-danger:hover {
  background: #4a1c1c; border-color: #8a3535; color: #ffbbbb;
}

/* Survey form sticky toolbar */
.cmlv-form-toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(0,0,0,0.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 12px 16px; margin: 0 -16px 20px;
  border-bottom: 1px solid #2a2a2a;
}
.cmlv-toolbar-row1 {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.cmlv-toolbar-jump-label {
  color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
}
.cmlv-section-jump {
  flex: 1 1 200px; min-width: 200px; padding: 10px 12px;
  background: #1a1a1a; color: #eee; border: 1px solid #333; border-radius: 6px;
  font-size: 13px; min-height: 44px;
}
.cmlv-toolbar-row2 {
  display: flex; align-items: center; gap: 12px;
}
.cmlv-progress-bar {
  flex: 1; height: 8px; background: #1a1a1a; border-radius: 4px;
  overflow: hidden;
}
.cmlv-progress-fill {
  height: 100%; background: linear-gradient(90deg, #F58220, #ffaa44);
  transition: width .3s ease;
}
.cmlv-progress-label {
  color: #ccc; font-size: 12px; font-variant-numeric: tabular-nums;
  white-space: nowrap; min-width: 130px; text-align: right;
}

/* Bigger autosave indicator */
.cmlv-autosave {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px;
  background: #1a1a1a; border: 1px solid #2a2a2a;
  font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.cmlv-autosave-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; font-size: 13px;
}
.cmlv-autosave-txt { color: #ccc; }
.cmlv-autosave.saved { background: rgba(40,160,80,0.12); border-color: rgba(40,160,80,0.4); }
.cmlv-autosave.saved .cmlv-autosave-icon { color: #4ade80; }
.cmlv-autosave.saved .cmlv-autosave-txt   { color: #86efac; }
.cmlv-autosave.saving { background: rgba(245,130,32,0.12); border-color: rgba(245,130,32,0.4); }
.cmlv-autosave.saving .cmlv-autosave-icon { color: #F58220; animation: cmlv-spin 1s linear infinite; }
.cmlv-autosave.saving .cmlv-autosave-txt  { color: #ffaa44; }
.cmlv-autosave.dirty  { background: rgba(120,120,120,0.12); border-color: #444; }
.cmlv-autosave.dirty  .cmlv-autosave-icon { color: #aaa; }
.cmlv-autosave.error  { background: rgba(200,40,40,0.15); border-color: rgba(200,40,40,0.5); }
.cmlv-autosave.error  .cmlv-autosave-icon { color: #ff6b6b; }
.cmlv-autosave.error  .cmlv-autosave-txt  { color: #ffbbbb; }
@keyframes cmlv-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* Enriched autocomplete rows */
.cmlv-sugg-row {
  padding: 10px 14px; cursor: pointer; min-height: 44px;
  border-bottom: 1px solid #222;
}
.cmlv-sugg-row:hover { background: #222; }
.cmlv-sugg-row:last-child { border-bottom: 0; }
.cmlv-sugg-main { color: #eee; font-size: 14px; }
.cmlv-sugg-main strong { color: #F58220; }
.cmlv-sugg-name { color: #ccc; }
.cmlv-sugg-meta { color: #888; font-size: 12px; margin-top: 3px; }

/* Tablet polish — bigger tap targets, no zoom on input focus */
@media (max-width: 900px) {
  .cmlv-btn { min-height: 44px; padding: 12px 18px; font-size: 15px; }
  .cmlv-btn-block { min-height: 48px; }
  input, select, textarea {
    min-height: 44px; font-size: 16px; /* 16px prevents iOS zoom-on-focus */
  }
  .cmlv-section-jump { font-size: 14px; }
  .cmlv-recent-patient-card { min-height: 96px; padding: 16px; }
  .cmlv-toolbar-row1 { flex-wrap: wrap; }
  .cmlv-form-toolbar { padding: 10px 12px; margin: 0 -12px 16px; }
  .cmlv-progress-label { min-width: 100px; font-size: 11px; }
  /* Faster touch scrolling */
  body { -webkit-overflow-scrolling: touch; }
}

/* Print: hide the toolbar and the no-print panels */
@media print {
  .cmlv-form-toolbar, .cmlv-no-print { display: none !important; }
}

/* =====================================================
   v1.7.1 — My Patients page + dashboard CTA tweaks
   ===================================================== */

/* My Patients page */
.cmlv-my-patients { max-width: 800px; margin: 0 auto; padding: 24px 16px 40px; }
.cmlv-page-title { color: #fff; font-size: 26px; margin: 0 0 6px; letter-spacing: .3px; }
.cmlv-page-sub   { color: #888; font-size: 14px; margin: 0 0 20px; line-height: 1.5; }

.cmlv-mp-search {
  width: 100%; padding: 14px 16px; min-height: 48px;
  background: #1a1a1a; color: #fff; border: 1px solid #333; border-radius: 8px;
  font-size: 16px; box-sizing: border-box;
}
.cmlv-mp-search:focus { outline: none; border-color: #F58220; }

.cmlv-mp-count {
  color: #888; font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  margin: 16px 0 10px;
}

.cmlv-mp-list { display: flex; flex-direction: column; gap: 8px; }
.cmlv-mp-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; min-height: 64px;
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
  text-decoration: none; color: inherit;
  transition: border-color .15s, transform .1s, background .15s;
}
.cmlv-mp-row:hover {
  border-color: #F58220; background: #1f1f1f; transform: translateY(-1px);
}
.cmlv-mp-row-num {
  color: #F58220; font-weight: 700; font-size: 15px;
  min-width: 90px; letter-spacing: .3px;
}
.cmlv-mp-row-body { flex: 1; min-width: 0; }
.cmlv-mp-row-name {
  color: #fff; font-size: 15px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmlv-mp-row-meta {
  color: #888; font-size: 12px; margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmlv-mp-row-chev {
  color: #555; font-size: 24px; line-height: 1; font-weight: 300;
}
.cmlv-mp-row:hover .cmlv-mp-row-chev { color: #F58220; }

.cmlv-mp-empty {
  padding: 32px 20px; background: #141414; border: 1px dashed #333; border-radius: 8px;
  color: #888; text-align: center; font-size: 14px; line-height: 1.6;
}

/* Tablet/mobile tweaks */
@media (max-width: 700px) {
  .cmlv-mp-row-num { min-width: 70px; font-size: 14px; }
  .cmlv-mp-row-name { font-size: 14px; }
  .cmlv-dashboard-cta .cmlv-btn { flex: 1 1 140px; min-width: 175px; }
}

/* =====================================================
   v1.7.2 — Patient header tweaks, My Patients headrow,
   add-patient modal, inline row delete buttons.
   ===================================================== */

/* Replace the big orange "#" pill with a small inline label above the name */
.cmlv-pt-headline-text { display: flex; flex-direction: column; gap: 4px; }
.cmlv-pt-num-label {
  color: #F58220; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}

/* My Patients head row — title block + Add button on same line, wraps on narrow */
.cmlv-mp-headrow {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.cmlv-mp-headrow > div { flex: 1 1 280px; min-width: 0; }
.cmlv-mp-add {
  flex: 0 0 auto; min-height: 48px; padding: 12px 22px;
  white-space: nowrap; font-weight: 600;
}
@media (max-width: 600px) {
  .cmlv-mp-add { width: 100%; flex: 1 1 100%; }
  .cmlv-mp-headrow { gap: 12px; }
}

/* Primary button — orange, brand-styled */
.cmlv-btn-primary {
  background: linear-gradient(180deg, #FFA855, #F58220);
  color: #fff; border: 1px solid #F58220;
  font-weight: 600;
}
.cmlv-btn-primary:hover { filter: brightness(1.08); }
.cmlv-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Add Patient modal */
body.cmlv-modal-open { overflow: hidden; }
.cmlv-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.cmlv-modal {
  background: #111; border: 1px solid #2a2a2a; border-radius: 12px;
  max-width: 480px; width: 100%; max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.cmlv-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #1f1f1f;
}
.cmlv-modal-head h2 { margin: 0; color: #fff; font-size: 18px; }
.cmlv-modal-close {
  background: transparent; border: 0; color: #777; font-size: 20px; cursor: pointer;
  padding: 4px 8px; line-height: 1;
}
.cmlv-modal-close:hover { color: #fff; }
.cmlv-modal form { padding: 18px 22px 22px; }
.cmlv-modal-field { margin-bottom: 14px; }
.cmlv-modal-field label {
  display: block; color: #aaa; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 6px;
}
.cmlv-modal-field input,
.cmlv-modal-field textarea {
  width: 100%; padding: 12px 14px; min-height: 44px;
  background: #1a1a1a; color: #fff; border: 1px solid #333; border-radius: 6px;
  font-size: 15px; box-sizing: border-box; font-family: inherit;
}
.cmlv-modal-field input:focus,
.cmlv-modal-field textarea:focus { outline: none; border-color: #F58220; }
.cmlv-modal-field textarea { min-height: 76px; resize: vertical; }
.cmlv-modal-err {
  background: rgba(200,40,40,0.15); border: 1px solid rgba(200,40,40,0.5);
  color: #ffbbbb; padding: 10px 14px; border-radius: 6px; font-size: 13px;
  margin-bottom: 12px;
}
.cmlv-modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px;
  flex-wrap: wrap;
}
.cmlv-modal-actions .cmlv-btn { min-height: 44px; padding: 10px 20px; }
@media (max-width: 500px) {
  .cmlv-modal-actions { justify-content: stretch; }
  .cmlv-modal-actions .cmlv-btn { flex: 1 1 100%; }
}

/* Inline row action buttons (table) */
.cmlv-row-actions {
  display: flex; gap: 6px; align-items: center; justify-content: flex-end;
  white-space: nowrap;
}
.cmlv-row-action {
  padding: 6px 12px !important; font-size: 12px !important;
  min-height: 36px; min-width: 36px;
  display: inline-flex; align-items: center; justify-content: center;
}
.cmlv-row-action.cmlv-btn-danger { padding: 6px 10px !important; }
@media (max-width: 700px) {
  .cmlv-row-action { padding: 8px 12px !important; font-size: 13px !important; min-height: 40px; }
}

/* =====================================================
   v1.7.3 — Orphan submission marker (patient deleted)
   ===================================================== */
.cmlv-row-orphan { opacity: 0.7; }
.cmlv-row-orphan:hover { opacity: 1; }
.cmlv-orphan-tag {
  display: inline-block; padding: 3px 8px;
  background: rgba(200,40,40,0.15); border: 1px solid rgba(200,40,40,0.4);
  border-radius: 4px;
  color: #ff9b9b; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}

/* =====================================================
   v1.8.1 — Danger modal (type DELETE to confirm)
   ===================================================== */
.cmlv-modal-danger { border-color: rgba(200,40,40,0.45); }
.cmlv-modal-danger .cmlv-modal-head {
  background: rgba(200,40,40,0.08);
  border-bottom-color: rgba(200,40,40,0.3);
}
.cmlv-modal-danger .cmlv-modal-head h2 { color: #ff9b9b; }

.cmlv-delete-warn {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px; margin-bottom: 18px;
  background: rgba(200,40,40,0.10);
  border: 1px solid rgba(200,40,40,0.35); border-radius: 8px;
}
.cmlv-delete-warn-icon {
  font-size: 28px; line-height: 1; color: #ff8a8a; flex-shrink: 0;
}
.cmlv-delete-warn-title {
  color: #ff9b9b; font-weight: 600; font-size: 14px; margin-bottom: 8px;
}
.cmlv-delete-warn-list {
  margin: 0; padding-left: 18px; color: #ddd; font-size: 13px; line-height: 1.6;
}
.cmlv-delete-warn-list li { margin-bottom: 4px; }
.cmlv-delete-warn-list strong { color: #fff; }

.cmlv-delete-confirm-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  letter-spacing: 2px !important;
  text-transform: uppercase;
  font-weight: 700;
}
.cmlv-delete-confirm-input--ok {
  border-color: #4ade80 !important; color: #86efac !important;
  background: rgba(40,160,80,0.08) !important;
}

/* Disabled danger button: muted red so the user clearly sees they can't click yet */
.cmlv-btn-danger:disabled {
  opacity: 0.4; cursor: not-allowed; filter: grayscale(0.4);
}
