/* ====================================================
   WELLNESS CIRCLE — DESIGN SYSTEM
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,600&family=Albert+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f5f0e8;
  --bg-soft: #faf6ee;
  --card: #fffdf8;
  --ink: #2c2a26;
  --ink-soft: #5a564f;
  --ink-light: #8a857c;
  --sage: #5b6f4e;
  --sage-deep: #3d4d34;
  --sage-light: #a3b89a;
  --sage-wash: #e6ede1;
  --terra: #c97b5e;
  --terra-light: #e8b8a3;
  --terra-wash: #f6e5dc;
  --border: #dcd4c2;
  --gold: #b89968;
  --error: #a13434;
  --error-bg: #fdecec;
  --success: #3d4d34;
  --success-bg: #e6ede1;
}

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

html, body {
  font-family: 'Albert Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3CfeColorMatrix values='0 0 0 0 0.7 0 0 0 0 0.65 0 0 0 0 0.55 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.font-display { font-family: 'Fraunces', serif; font-optical-sizing: auto; }

a { color: var(--sage-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }

button {
  font-family: inherit; cursor: pointer; border: none; background: none;
  transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  font-family: inherit; font-size: 0.95rem; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 0.85rem 1rem; border-radius: 0.75rem; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-wash);
}
textarea { resize: vertical; min-height: 80px; }

/* ====== Layout ====== */
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.app-main { flex: 1; padding: 2rem 0 4rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 1.5rem; }

/* ====== Header ====== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  background: rgba(245, 240, 232, 0.85);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1100px; margin: 0 auto; padding: 0.9rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.brand-link { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.brand-link:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%; height: 100%; object-fit: contain;
  display: block;
}
.brand-name { font-size: 1.15rem; font-weight: 500; }
.header-nav { display: flex; align-items: center; gap: 1.2rem; font-size: 0.92rem; }
.header-nav a { color: var(--ink-soft); }
.header-nav a:hover { color: var(--sage-deep); text-decoration: none; }
.header-nav .muted { color: var(--ink-light); }
.btn-pill {
  background: var(--sage-deep); color: var(--bg-soft) !important;
  padding: 0.5rem 1rem; border-radius: 9999px; font-weight: 500;
}
.btn-pill:hover { background: var(--sage); }

@media (max-width: 600px) {
  .header-nav { gap: 0.7rem; font-size: 0.85rem; }
  .brand-name { font-size: 1rem; }
}

/* ====== Footer ====== */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0; text-align: center;
  color: var(--ink-light); font-size: 0.9rem;
  background: var(--bg-soft);
}
.app-footer p { margin-bottom: 0.3rem; }

/* ====== Buttons ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 500; font-size: 0.95rem;
  border-radius: 9999px; transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-primary {
  background: var(--sage-deep); color: var(--bg-soft);
  width: 100%; padding: 0.95rem; letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--sage); }
.btn-primary.inline { width: auto; padding: 0.75rem 1.6rem; }
.btn-ghost {
  background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--border); padding: 0.85rem 1.4rem;
}
.btn-ghost:hover { background: var(--sage-wash); }
.btn-sm { padding: 0.55rem 1rem; font-size: 0.85rem; }
.btn-link {
  background: none; color: var(--sage-deep); padding: 0;
  text-decoration: underline; text-underline-offset: 4px;
  font-weight: 500; font-size: 0.92rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.btn-link:hover { color: var(--sage); }
.btn-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.btn-danger { color: var(--error); }
.btn-danger:hover { background: var(--error-bg); border-color: #f5c8c8; }

/* ====== Cards ====== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1.5rem;
  margin-bottom: 1rem;
}
.card-h {
  font-size: 1.2rem; font-weight: 500; margin-bottom: 1rem;
  font-family: 'Fraunces', serif;
}

.eyebrow {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--ink-light); margin-bottom: 0.6rem; font-weight: 500;
}

.muted { color: var(--ink-light); }
.tiny { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-light); }

.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.4rem; }
.mb-2 { margin-bottom: 0.8rem; }
.mb-3 { margin-bottom: 1.2rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.4rem; }
.mt-2 { margin-top: 0.8rem; }
.mt-3 { margin-top: 1.2rem; }
.mt-4 { margin-top: 2rem; }

/* ====== Page heads ====== */
.page-head { margin-bottom: 2rem; }
.page-h {
  font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 500;
  letter-spacing: -0.01em; margin-bottom: 0.5rem;
}
.page-sub { color: var(--ink-soft); margin-bottom: 1.5rem; max-width: 60ch; }
.section-h {
  font-size: 1.7rem; font-weight: 500; margin-bottom: 1.5rem;
}
.step-h { font-size: 1.7rem; font-weight: 500; margin-bottom: 0.4rem; }

/* ====== Hero (landing) ====== */
.hero { padding: 4rem 0 3rem; }
.hero-h {
  font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 400;
  letter-spacing: -0.02em; line-height: 1.05;
  margin-bottom: 1rem;
}
.hero-h em { color: var(--sage); font-style: italic; font-weight: 300; }
.hero-sub {
  font-size: 1.05rem; max-width: 56ch; margin: 0 auto 1.8rem;
  color: var(--ink-soft);
}
.hero-cta {
  display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap;
}
.hero-cta .btn { width: auto; }

/* ====== Pillars ====== */
.pillars { padding: 3rem 0; }
.pillar-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.pillar-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1.5rem; text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}
.pillar-card:hover { transform: translateY(-3px); border-color: var(--sage-light); }
.pillar-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--sage-wash);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.pillar-card h3 { font-size: 1.15rem; font-weight: 500; margin-bottom: 0.5rem; }
.pillar-card p { font-size: 0.92rem; }

@media (max-width: 800px) {
  .pillar-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .pillar-grid { grid-template-columns: 1fr; }
}

/* ====== How it works ====== */
.how-it-works { padding: 3rem 0; }
.steps-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.step-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1.8rem;
}
.step-num {
  font-family: 'Fraunces', serif; font-size: 2rem;
  color: var(--sage); font-weight: 300; display: block; margin-bottom: 0.5rem;
}
.step-card h3 { font-size: 1.2rem; font-weight: 500; margin-bottom: 0.6rem; }
@media (max-width: 800px) {
  .steps-grid { grid-template-columns: 1fr; }
}

/* ====== Forms ====== */
.field { display: block; margin-bottom: 1rem; }
.field-label {
  display: block; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-light);
  margin-bottom: 0.4rem; font-weight: 500;
}
.alert {
  background: var(--error-bg); color: var(--error);
  padding: 0.85rem 1rem; border-radius: 0.75rem;
  margin-bottom: 1rem; font-size: 0.92rem;
  border: 1px solid #f5c8c8;
}
.alert.success {
  background: var(--success-bg); color: var(--success);
  border-color: var(--sage-light);
}

.auth-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 1.25rem; padding: 2.5rem 2rem;
  max-width: 500px; margin: 3rem auto;
}
.auth-h {
  font-size: 1.8rem; font-weight: 500;
  letter-spacing: -0.01em; margin-bottom: 0.6rem;
}
.success-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--sage-wash); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.2rem;
}
.info-box {
  background: var(--sage-wash); border: 1px solid var(--sage-light);
  border-radius: 0.85rem; padding: 1rem 1.2rem;
  text-align: left; margin: 1rem 0;
}
.empty-box {
  background: var(--bg-soft); border: 1px dashed var(--border);
  border-radius: 0.85rem; padding: 1.5rem;
  text-align: center;
}
.empty-box p { margin-bottom: 0.5rem; }
.empty-box p:last-child { margin-bottom: 0; }

/* ====== Chips ====== */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--border);
  padding: 0.5rem 0.95rem; border-radius: 9999px;
  font-size: 0.88rem;
}
.chip.active {
  background: var(--sage-deep); color: var(--bg-soft);
  border-color: var(--sage-deep);
}

/* ====== Progress bars (assessment) ====== */
.progress-bars {
  display: flex; gap: 0.4rem; margin-bottom: 1.5rem;
}
.progress-bars span {
  flex: 1; height: 4px; border-radius: 9999px;
  background: var(--border);
}
.progress-bars span.active { background: var(--sage); }

/* ====== Step nav ====== */
.row-spread {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
}
.step-nav {
  padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.step-nav .btn-link[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ====== Grids ====== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ====== Meal protein table ====== */
.meal-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 0.9rem; padding: 1rem 1rem 0.5rem;
  margin-bottom: 1rem;
}
.meal-card-h {
  font-size: 1rem; font-weight: 500; color: var(--sage-deep);
  margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em;
}
.meal-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.meal-table th {
  text-align: left; padding: 0.4rem 0.5rem; font-weight: 500;
  color: var(--ink-light); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}
.meal-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid rgba(220, 212, 194, 0.4);
}
.meal-table tr:last-child td { border-bottom: none; }
.meal-table input[type="number"] {
  background: var(--card); padding: 0.4rem 0.5rem;
  font-size: 0.9rem; text-align: center;
}
.meal-table .td-mid {
  text-align: center; color: var(--ink-light); font-size: 0.85rem;
}
@media (max-width: 600px) {
  .meal-table { font-size: 0.85rem; }
  .meal-table th, .meal-table td { padding: 0.35rem 0.25rem; }
}

.summary-box {
  background: var(--sage-wash); border: 1px solid var(--sage-light);
  border-radius: 0.85rem; padding: 1rem; margin-top: 1rem;
}
.summary-value {
  font-family: 'Fraunces', serif; font-size: 1.35rem;
  color: var(--sage-deep); margin-bottom: 0.25rem;
}

.ladies-card {
  background: var(--terra-wash); border: 1px solid var(--terra-light);
  border-radius: 0.85rem; padding: 1rem; margin-top: 1rem;
}

/* ====== Loading ====== */
.loading {
  text-align: center; padding: 3rem; color: var(--ink-light);
  display: flex; justify-content: center; align-items: center; gap: 0.6rem;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--sage);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-up { animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ====== Badges ====== */
.badge {
  display: inline-block; padding: 0.25rem 0.7rem;
  border-radius: 9999px; font-size: 0.78rem;
  font-weight: 500; letter-spacing: 0.02em;
}
.badge-sage { background: var(--sage-wash); color: var(--sage-deep); }
.badge-terra { background: var(--terra-wash); color: var(--terra); }

/* ====== Dose / supplement list ====== */
.dose-list { list-style: none; }
.dose-item {
  border-left: 3px solid var(--sage-light);
  padding: 0.7rem 0 0.7rem 1rem;
  margin-bottom: 0.6rem;
}
.dose-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.6rem; margin-bottom: 0.2rem;
}
.dose-line { color: var(--ink-soft); font-size: 0.92rem; }

.notes-list { list-style: none; }
.notes-list li {
  border-left: 3px solid var(--terra-light);
  padding: 0.6rem 0 0.6rem 1rem; margin-bottom: 0.8rem;
}

.assessment-list { list-style: none; }
.assessment-item {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 0.85rem; padding: 1rem; margin-bottom: 0.7rem;
}
.assessment-item details summary { cursor: pointer; padding: 0.3rem 0; }

/* ====== Assessment summary (client + admin) ====== */
.assessment-summary { font-size: 0.93rem; }
.summary-section {
  font-family: 'Fraunces', serif; font-size: 1.05rem;
  color: var(--sage-deep); font-weight: 500;
  margin: 1.2rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.summary-dl {
  display: grid; grid-template-columns: 180px 1fr;
  row-gap: 0.4rem; column-gap: 1.5rem;
}
.summary-dl dt {
  color: var(--ink-light); font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.summary-dl dd { color: var(--ink); }
@media (max-width: 600px) {
  .summary-dl { grid-template-columns: 1fr; row-gap: 0.2rem; }
  .summary-dl dt { margin-top: 0.4rem; }
}

/* ====== Dashboard grid ====== */
.dashboard-grid { gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ====== Admin shell ====== */
.admin-shell {
  display: grid; grid-template-columns: 220px 1fr;
  gap: 2rem; align-items: start;
}
.admin-side {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1.2rem;
  position: sticky; top: 80px;
}
.admin-nav { display: flex; flex-direction: column; gap: 0.2rem; }
.admin-nav a {
  display: block; padding: 0.6rem 0.8rem;
  border-radius: 0.6rem; color: var(--ink-soft);
  font-size: 0.93rem;
}
.admin-nav a:hover { background: var(--sage-wash); text-decoration: none; }
.admin-nav a.active {
  background: var(--sage-deep); color: var(--bg-soft);
}
.admin-main { min-width: 0; }

@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-nav a { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem; margin: 1.5rem 0 2rem;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 0.85rem; padding: 1rem 1.2rem;
}
.stat-num {
  font-family: 'Fraunces', serif; font-size: 1.8rem;
  font-weight: 500; color: var(--sage-deep); margin-top: 0.3rem;
}
@media (max-width: 800px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

/* ====== Tables ====== */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 0.85rem; overflow: hidden;
  margin-bottom: 1.5rem;
}
.data-table th, .data-table td {
  padding: 0.85rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.data-table th {
  background: var(--bg-soft);
  font-weight: 500; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-light);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-soft); }

.search-form {
  display: flex; gap: 0.6rem; max-width: 500px;
}
.search-form input { flex: 1; }

.protocol-table { width: 100%; border-collapse: collapse; }
.protocol-table th {
  text-align: left; padding: 0.5rem 0.4rem;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-light); font-weight: 500;
}
.protocol-table td {
  padding: 0.4rem 0.4rem;
}
.protocol-table input {
  padding: 0.55rem 0.7rem; font-size: 0.9rem;
}
@media (max-width: 800px) {
  .protocol-table, .protocol-table thead, .protocol-table tbody, .protocol-table tr, .protocol-table td, .protocol-table th { display: block; }
  .protocol-table thead { display: none; }
  .protocol-table tr {
    border: 1px solid var(--border); border-radius: 0.6rem;
    padding: 0.6rem; margin-bottom: 0.6rem; background: var(--bg-soft);
  }
  .protocol-table td::before {
    content: attr(data-label); display: block;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-light); margin-bottom: 0.2rem;
  }
}

/* ============================================================
   v3 BILINGUAL ASSESSMENT — additional component styles
   ============================================================ */

/* --- Step navigation row --- */
.step-nav { gap: 1rem; }
.step-nav .btn-link[disabled] { opacity: 0.35; cursor: not-allowed; }

/* --- Section sub-heading inside a step --- */
.section-sub {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  margin: 1.6rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* --- Symptom system accordion --- */
.system-acc {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  margin-bottom: 0.7rem;
  overflow: hidden;
}
.system-acc[open] { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.system-acc-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  list-style: none;
  background: var(--bg-soft);
  font-size: 0.95rem;
}
.system-acc-h::-webkit-details-marker { display: none; }
.system-acc-h::before {
  content: "›";
  display: inline-block;
  font-size: 1.4rem;
  color: var(--sage);
  transition: transform 0.2s;
  margin-right: 0.3rem;
  line-height: 1;
}
.system-acc[open] > .system-acc-h::before { transform: rotate(90deg); }

.system-acc-title { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.system-acc-title strong { font-size: 0.98rem; }
.system-acc-titleHi { font-size: 0.85rem; }

.system-acc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* --- Yes/No question rows --- */
.qlist { padding: 0.6rem 1.1rem 1.1rem; }
.qrow {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.qrow:last-child { border-bottom: none; }
.qrow-text { flex: 1; min-width: 220px; }
.qrow-en { margin: 0 0 0.15rem; font-size: 0.92rem; line-height: 1.4; }
.qrow-hi { margin: 0; font-size: 0.85rem; color: var(--ink-light); line-height: 1.4; }
.qrow-buttons { display: flex; gap: 0.4rem; flex-shrink: 0; }

.yn-btn {
  appearance: none;
  border: 1.5px solid var(--border);
  background: var(--bg-soft);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.83rem;
  cursor: pointer;
  min-width: 76px;
  transition: all 0.15s;
}
.yn-btn:hover { border-color: var(--sage); }
.yn-yes.active {
  background: var(--sage);
  border-color: var(--sage);
  color: white;
}
.yn-no.active {
  background: var(--terra, #b76b4f);
  border-color: var(--terra, #b76b4f);
  color: white;
}

.badge-neutral {
  background: rgba(0,0,0,0.06);
  color: var(--ink-light);
}

/* --- Conditions checklist grid --- */
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.cond-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-soft);
  transition: all 0.15s;
}
.cond-item:hover { border-color: var(--sage); }
.cond-item.active { border-color: var(--sage); background: rgba(135, 169, 107, 0.08); }
.cond-item input { margin-top: 0.2rem; flex-shrink: 0; }
.cond-en { display: block; font-size: 0.9rem; line-height: 1.3; }
.cond-hi { display: block; font-size: 0.78rem; }

/* --- Family history table --- */
.family-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
}
.family-table th, .family-table td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.family-table th { font-size: 0.82rem; color: var(--ink-light); font-weight: 500; }
.family-table input {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  font: inherit;
  font-size: 0.88rem;
}
.family-table td:last-child { width: 36px; }

/* --- 3-column grid for height inputs etc --- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 600px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   ADMIN / CLIENT SCORECARD
   ============================================================ */
.scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.7rem;
}
.score-card {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1.5px solid;
  background: var(--bg-soft);
}
.score-green { border-color: rgba(135, 169, 107, 0.5); background: rgba(135, 169, 107, 0.08); }
.score-amber { border-color: rgba(218, 165, 32, 0.55); background: rgba(218, 165, 32, 0.08); }
.score-red   { border-color: rgba(183, 107, 79, 0.55); background: rgba(183, 107, 79, 0.08); }
.score-title { margin: 0 0 0.1rem; font-size: 0.88rem; font-weight: 500; line-height: 1.3; }
.score-title-hi { margin: 0 0 0.4rem; font-size: 0.75rem; color: var(--ink-light); line-height: 1.3; }
.score-num { margin: 0; font-family: 'Fraunces', serif; font-size: 1.8rem; font-weight: 500; line-height: 1; }
.score-of { font-size: 1rem; color: var(--ink-light); }
.score-pct { margin: 0.2rem 0 0; font-size: 0.78rem; color: var(--ink-light); }

/* ============================================================
   ADMIN ASSESSMENT DETAIL VIEW
   ============================================================ */
.assessment-detail .adetail {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  margin-bottom: 0.7rem;
  overflow: hidden;
}
.assessment-detail .adetail-h {
  padding: 0.75rem 1rem;
  background: var(--bg-soft);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  list-style: none;
}
.assessment-detail .adetail-h::-webkit-details-marker { display: none; }
.assessment-detail .adetail-h::before {
  content: "›";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--sage);
  transition: transform 0.2s;
}
.assessment-detail .adetail[open] > .adetail-h::before { transform: rotate(90deg); }
.assessment-detail .adetail > *:not(.adetail-h) { padding: 0.8rem 1rem 1rem; }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.2rem;
  margin: 0;
}
.kv dt { color: var(--ink-light); font-size: 0.85rem; }
.kv dd { margin: 0; font-size: 0.92rem; }

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.kv-table th, .kv-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.kv-table th { font-weight: 500; color: var(--ink-light); font-size: 0.82rem; }

.sys-h {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 500;
  margin: 1rem 0 0.4rem;
}
.sys-list { list-style: none; padding: 0; margin: 0; }
.sys-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.88rem;
}
.sym-flag .sym-dot { color: var(--terra, #b76b4f); }
.sym-ok .sym-dot { color: var(--sage); }
.sym-text { flex: 1; }
.sym-ans {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: rgba(0,0,0,0.05);
}
.sym-flag .sym-ans { background: rgba(183, 107, 79, 0.15); color: var(--terra, #b76b4f); }
.sym-ok .sym-ans { background: rgba(135, 169, 107, 0.15); color: var(--sage); }

.cond-list { list-style: none; padding: 0; margin: 0; }
.cond-list li { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }
.cond-list li:last-child { border-bottom: none; }

.meal-summary {
  list-style: disc;
  padding-left: 1.4rem;
  margin: 0.2rem 0 1rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* ============================================================
   DIET CARDS (Do's / Don'ts) — admin form picker + client display
   ============================================================ */
.diet-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.diet-pick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  background: var(--bg-soft);
  transition: all 0.15s;
}
.diet-pick:hover { border-color: var(--sage); }
.diet-pick.active { border-color: var(--sage); background: rgba(135, 169, 107, 0.1); }

.diet-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}
.diet-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  background: var(--bg-soft);
}
.diet-card-h {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0 0 0.7rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.diet-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.diet-col-h {
  font-weight: 600;
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  text-align: center;
  padding: 0.3rem;
  border-radius: 4px;
}
.diet-dont .diet-col-h { background: rgba(183, 107, 79, 0.12); color: var(--terra, #b76b4f); }
.diet-do .diet-col-h { background: rgba(135, 169, 107, 0.15); color: var(--sage); }
.diet-col ul { list-style: none; padding: 0; margin: 0; }
.diet-col li {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
  line-height: 1.35;
}
.diet-col li:last-child { border-bottom: none; }
@media (max-width: 480px) {
  .diet-card-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   v4 CTAs, save badge, resume banner
   ============================================================ */
.cta-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.8rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--sage-wash) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--sage-light);
}
.cta-resume {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.1) 0%, var(--bg-soft) 100%);
  border-color: rgba(218, 165, 32, 0.4);
}
.cta-box > div:first-child { flex: 1; min-width: 240px; }
.cta-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}
.btn-link-danger {
  background: none;
  border: none;
  color: var(--terra);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.3rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: inherit;
}
.btn-link-danger:hover { color: var(--error); }

.save-badge {
  font-size: 0.82rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  min-width: 110px;
  text-align: center;
  transition: all 0.2s;
}
.save-saving { background: rgba(0,0,0,0.05); color: var(--ink-light); }
.save-saved  { background: rgba(135, 169, 107, 0.15); color: var(--sage-deep); }
.save-error  { background: rgba(183, 107, 79, 0.15); color: var(--terra); }
.save-idle   { /* invisible */ }

.resume-banner {
  background: rgba(218, 165, 32, 0.1);
  border-left: 4px solid rgba(218, 165, 32, 0.7);
  padding: 0.9rem 1.2rem;
  border-radius: 6px;
  margin: 0.5rem 0 1.5rem;
}
.resume-banner p { margin: 0; }

@media (max-width: 600px) {
  .cta-box { flex-direction: column; align-items: stretch; }
  .cta-actions { align-items: stretch; }
}

/* ============================================================
   v4 ADMIN THEME PICKER
   ============================================================ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.theme-form { margin: 0; }
.theme-card {
  display: block;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--bg);
  cursor: pointer;
  font: inherit;
  text-align: left;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.theme-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border-color: var(--sage);
}
.theme-card.active {
  border-color: var(--sage-deep);
  box-shadow: 0 0 0 3px var(--sage-wash), 0 8px 18px rgba(0,0,0,0.06);
}

/* Mini-preview using each theme's own scoped variables */
.theme-mock { display: block; padding: 0; }
.theme-mock-bar {
  display: block;
  height: 22px;
  background: var(--sage);
}
.theme-mock-body {
  display: block;
  background: var(--bg-soft);
  padding: 0.7rem 0.8rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.theme-mock-h {
  display: block;
  height: 8px;
  width: 60%;
  border-radius: 3px;
  background: var(--sage-deep);
  margin-bottom: 0.5rem;
}
.theme-mock-line {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: var(--sage-light);
  margin-bottom: 0.4rem;
  opacity: 0.7;
}
.theme-mock-line-short { width: 75%; }
.theme-mock-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.6rem;
}
.theme-mock-btn {
  display: inline-block;
  height: 18px;
  width: 60px;
  border-radius: 4px;
  background: var(--sage);
}
.theme-mock-chip {
  display: inline-block;
  height: 14px;
  width: 38px;
  border-radius: 10px;
  background: var(--terra-wash);
  border: 1px solid var(--terra-light);
}

.theme-meta {
  display: block;
  padding: 0.65rem 0.85rem 0.85rem;
  background: #fff;
  position: relative;
}
.theme-meta strong {
  display: block;
  font-size: 0.95rem;
  color: #2c2a26;
  margin-bottom: 0.15rem;
}
.theme-meta .muted { color: #8a857c; }
.theme-active-tag {
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(135, 169, 107, 0.18);
  color: #3d4d34;
  font-weight: 600;
}

/* ============================================================
   ADMIN PREVIEW MODE
   ============================================================ */
.preview-banner {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.18), rgba(218, 165, 32, 0.05));
  border: 1px solid rgba(218, 165, 32, 0.4);
  border-left: 4px solid rgba(218, 165, 32, 0.7);
  padding: 0.9rem 1.2rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  flex-wrap: wrap;
}
.preview-banner p { margin: 0; }
.preview-banner .tiny { font-size: 0.82rem; line-height: 1.4; }
.preview-banner .btn-sm { flex-shrink: 0; }

/* Buttons that exist visually in preview but don't do anything */
.preview-disabled {
  opacity: 0.55;
  cursor: not-allowed !important;
  pointer-events: none;
  user-select: none;
}

/* ============================================================
   KHATA / LEDGER
   ============================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.8rem;
}
.kpi-card {
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.kpi-card.kpi-green {
  background: rgba(135, 169, 107, 0.1);
  border-color: rgba(135, 169, 107, 0.3);
}
.kpi-card.kpi-amber {
  background: rgba(218, 165, 32, 0.1);
  border-color: rgba(218, 165, 32, 0.35);
}
.kpi-label {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-num {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.1;
  color: var(--ink);
}

.bal-due    { color: #b06a18; }
.bal-credit { color: var(--sage-deep); }
.bal-zero   { color: var(--ink-light); }

.khata-form .field { margin-bottom: 0.6rem; }
.khata-form .grid-2 { gap: 0.6rem; }
.khata-form select, .khata-form input[type="number"], .khata-form input[type="text"] {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  font: inherit;
}

@media (max-width: 720px) {
  .grid-2.khata-form, .grid-2 > .khata-form { grid-column: 1 / -1; }
}

/* ============================================================
   PRICE-TIER pills (MRP / PC / WS selector inside khata form)
   ============================================================ */
.price-tier-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.price-tier-pill {
  flex: 1 1 auto;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.55rem 0.6rem;
  background: var(--bg-soft, #f4f6f3);
  border: 1.5px solid var(--border-soft, #d8dcd6);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.05s;
  user-select: none;
}
.price-tier-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.price-tier-pill:has(input[type="radio"]:checked) {
  border-color: var(--sage-deep, #355441);
  background: var(--sage-wash, #e7eee9);
  box-shadow: 0 0 0 1px var(--sage-deep, #355441) inset;
}
.price-tier-pill:hover:not(.price-tier-pill-disabled) {
  border-color: var(--sage-light, #8aa893);
}
.price-tier-pill-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent;
}
.price-tier-label {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-muted, #6b7569);
  text-transform: uppercase;
}
.price-tier-pill:has(input[type="radio"]:checked) .price-tier-label {
  color: var(--sage-deep, #355441);
}
.price-tier-amount {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink, #2d2d2d);
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   FRANCHISEE CTA on client dashboard
   ============================================================ */
.cta-franchisee {
  background: linear-gradient(135deg, var(--sage-wash), var(--bg-soft));
  border-color: var(--sage-light);
}

/* ============================================================
   FRANCHISEE: NOTES card + textareas
   ============================================================ */
.notes-card {
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.7), var(--bg-soft));
  border-left: 3px solid var(--gold, #d4a847);
}
.notes-card textarea,
.khata-form textarea,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  font: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 70px;
}
.notes-preview {
  max-width: 320px;
  white-space: normal;
  line-height: 1.35;
}

/* ============================================================
   AI BADGE — Option 5: double ring counter-rotating
   ============================================================ */
.ai-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: 0.55rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.ai-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
}
.ai-ring-outer {
  inset: 0;
  border-top-color: var(--sage-deep);
  border-right-color: var(--sage-deep);
  animation: ai-spin 2.5s linear infinite;
}
.ai-ring-inner {
  inset: 4px;
  border-bottom-color: var(--gold, #d4a847);
  border-left-color: var(--gold, #d4a847);
  animation: ai-spin-reverse 3s linear infinite;
}
.ai-text {
  position: relative;
  z-index: 1;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--sage-deep);
  line-height: 1;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
@keyframes ai-spin-reverse {
  to { transform: rotate(-360deg); }
}
/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ai-ring { animation: none; }
}
/* On small screens (mobile), keep it visible but slightly smaller */
@media (max-width: 600px) {
  .ai-badge { width: 28px; height: 28px; margin-left: 0.4rem; }
  .ai-ring-inner { inset: 3px; }
  .ai-text  { font-size: 0.62rem; }
}

/* ============================================================
   PRODUCT EDIT — inline edit row
   ============================================================ */
.row-editing > td {
  background: var(--sage-wash);
  border-left: 3px solid var(--sage-deep);
  padding: 1rem 1.1rem !important;
}
.product-edit-form .field { margin-bottom: 0.6rem; }
.product-edit-form .field-label { display: block; font-size: 0.78rem; color: var(--ink-light); margin-bottom: 0.2rem; }
.product-edit-form input[type="text"],
.product-edit-form input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  font: inherit;
}
