:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2433;
  --muted: #6b7280;
  --line: #e6e8f0;
  --brand: #b14d7e;
  --brand-soft: #fbeef4;
  --accent: #5b6ee1;

  --optimal: #0f9d6b;   --optimal-bg: #e3f7ee;
  --normal: #5b6ee1;    --normal-bg: #eceeff;
  --warn: #b7791f;      --warn-bg: #fcf3e3;
  --bad: #c2410c;       --bad-bg: #fdece4;
  --crit: #b91c1c;      --crit-bg: #fdeaea;

  --radius: 14px;
  --shadow: 0 1px 3px rgba(20,24,40,.06), 0 8px 24px rgba(20,24,40,.05);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 18px; }
[v-cloak] { display: none; }

/* Header */
.site-header { background: linear-gradient(135deg, #b14d7e 0%, #8a5cc4 100%); color: #fff; padding: 30px 0 26px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; }
.brand .logo { font-size: 30px; }
.tagline { margin: 10px 0 0; max-width: 680px; opacity: .94; font-size: 15px; }

/* Disclaimer */
.disclaimer { background: #fffaf0; border: 1px solid #f0e2c0; border-left: 4px solid var(--warn);
  border-radius: 10px; padding: 12px 16px; margin: 18px auto; font-size: 13.5px; color: #5b4a25; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin: 18px auto 4px; flex-wrap: wrap; }
.tab { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px;
  font-size: 14px; cursor: pointer; color: var(--muted); font-weight: 600; transition: .15s; }
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.panel { margin: 18px 0 40px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }

/* Inputs */
.grid-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; color: #3a4151; gap: 6px; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
/* remove number spinner arrows — not needed for lab values */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Buttons */
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 18px; cursor: pointer; border: 1px solid transparent; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #9a3f6c; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- Goal bar ---------------- */
.goal-bar { background: var(--brand-soft); border-color: #f0d6e3; }
.goal-head h2 { margin: 0; }
.goal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.goal-chip { display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 14px; color: #3a4151; cursor: pointer; transition: .15s; }
.goal-chip .gc-icon { font-size: 18px; }
.goal-chip:hover { border-color: var(--brand); }
.goal-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow); }
.context-inline { margin-top: 4px; }

/* ---------------- Table toolbar ---------------- */
.table-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.table-toolbar #search { flex: 1 1 320px; }
.relevant-toggle { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.relevant-toggle input { width: auto; }
.relevant-toggle:has(input:disabled) { opacity: .45; }

/* ---------------- Table + pane layout ---------------- */
.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.table-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.marker-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.marker-table thead th { position: sticky; top: 0; background: #faf7fa; text-align: left; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); z-index: 1; }
.th-sub { text-transform: none; letter-spacing: 0; font-weight: 500; }
.th-value { width: 204px; } .th-status { width: 96px; } .th-range { width: 168px; }

.cat-row td { background: #f3eef2; color: var(--brand); font-weight: 700; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; padding: 8px 12px; }
.m-row { border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.m-row:hover { background: #f8f9ff; }
.m-row.selected { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.m-row.priority .m-name::after { content: " ⚑"; color: var(--brand); font-size: 11px; }
.m-row td { padding: 9px 12px; vertical-align: middle; }
.td-marker { max-width: 320px; }
.m-name { display: block; font-weight: 600; }
.m-influence { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.td-value input[type="number"] { flex: 0 1 84px; min-width: 56px; padding: 9px 10px; font-size: 14px; }
.td-value .m-unit, .td-value .computed-val { font-size: 11.5px; color: var(--muted); }
.td-value .computed-val { font-weight: 700; color: var(--accent); font-size: 14px; }
.m-unit { display: inline-block; vertical-align: middle; margin-left: 4px; }
.goal-flag { color: var(--brand); cursor: help; }
.exp-txt { font-size: 13px; }
.row-flag .exp-txt { font-weight: 600; }

/* status badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-empty { background: #f1f2f6; color: #aeb4c2; }
.b-info { background: #eef0f6; color: #7a8295; }
.b-low, .b-high { background: var(--bad-bg); color: var(--bad); }
.b-very-high { background: var(--crit-bg); color: var(--crit); }
.b-borderline, .b-borderline-low { background: var(--warn-bg); color: var(--warn); }
.b-normal { background: var(--normal-bg); color: var(--normal); }
.b-optimal { background: var(--optimal-bg); color: var(--optimal); }

/* ---------------- Detail pane ---------------- */
.detail-pane { position: sticky; top: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; font-size: 13.5px; max-height: calc(100vh - 28px); overflow-y: auto; }
.dock-handle { display: none; }
.dp-back { background: none; border: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0 0 8px; }
.dp-top h3 { margin: 0; font-size: 17px; }
.dp-influences { background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; color: #5a3247; margin: 8px 0; }
.dp-desc { color: #3a4151; }
.dp-warn { background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; color: #5b4a25; font-size: 13px; }
.dp-value-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f7f8ff;
  border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.dp-yourval { font-size: 16px; font-weight: 700; }
.dp-range { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.dp-lbl { font-weight: 700; color: var(--brand); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
.dp-range .dp-lbl { display: inline; text-transform: none; letter-spacing: 0; }
.dp-goal { background: var(--optimal-bg); border-left: 3px solid var(--optimal); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.dp-goal-h { font-weight: 700; color: #0a6e4b; font-size: 13px; }
.dp-goal p { margin: 6px 0 0; color: #1f5640; }
.dp-optimal { background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; margin: 8px 0; color: #5a3247; }
.dp-related a, .dp-target a, .dp-targets a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }
.dp-related a:hover { text-decoration: underline; }
.dp-src { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.dp-src a { color: var(--muted); }
.dp-goal-head { display: flex; align-items: center; gap: 10px; }
.dp-goal-head h3 { margin: 0; font-size: 17px; }
.dp-goal-icon { font-size: 24px; }
.dp-targets { margin: 12px 0; }
.dp-target { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.dp-target.pri a::before { content: "⚑ "; color: var(--brand); }
.dp-target span { color: var(--muted); }
.dp-hint { font-size: 12.5px; color: var(--muted); margin-top: 12px; }

/* ---------------- Patterns ---------------- */
.patterns-wrap { margin-top: 18px; }
.patterns { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.patterns h3 { margin: 0 0 4px; }
.pattern { border-left: 4px solid var(--accent); background: #f7f8ff; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.pattern .p-title { font-weight: 700; font-size: 14px; }
.pattern .p-body { font-size: 13px; color: #3a4151; margin-top: 4px; }
.empty-note { color: var(--muted); font-size: 14px; padding: 10px 0; }

/* ---------------- Cycle calculator ---------------- */
.cycle-result:empty { display: none; }
.phase-bar { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); margin: 14px 0; font-size: 11px; color: #fff; text-align: center; }
.phase-seg { padding: 8px 4px; font-weight: 700; }
.seg-menses { background: #c2410c; } .seg-follicular { background: #5b6ee1; } .seg-fertile { background: #0f9d6b; } .seg-luteal { background: #b14d7e; }
.cycle-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin-top: 12px; }
.fact { background: #f7f8ff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.fact .f-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.fact .f-value { font-size: 15px; font-weight: 700; margin-top: 4px; }
.today-tag { display:inline-block; background: var(--brand); color:#fff; border-radius:999px; padding:3px 10px; font-size:12px; font-weight:700; }
.test-tip { font-size: 13px; background: var(--brand-soft); border-radius: 8px; padding: 10px 12px; margin-top: 12px; color:#5a3247; }
.fine { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* ---------------- Footer ---------------- */
.site-footer { padding: 24px 18px 50px; }
.site-footer h3 { font-size: 15px; }
.site-footer ul { padding-left: 18px; font-size: 13px; color: var(--muted); }
.site-footer a { color: var(--accent); }

/* ---------------- Unit dropdown in table ---------------- */
.unit-sel { width: auto; max-width: 92px; display: inline-block; vertical-align: middle; padding: 5px 6px; font-size: 11.5px; border-radius: 8px; color: var(--muted); flex: 0 0 auto; }
.td-value { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }

/* ---------------- Context hint (irregular phase) ---------------- */
.ctx-hint { font-size: 13px; background: #fff; border: 1px solid #f0d6e3; border-left: 3px solid var(--brand); border-radius: 8px; padding: 9px 12px; margin: 10px 0 0; color: #5a3247; }

/* ---------------- Cross-effects line ---------------- */
.dp-affects { background: #eef0f6; border-radius: 8px; padding: 8px 10px; color: #3a4151; font-size: 13px; }

/* ---------------- "Data needed" highlight (sand yellow) ---------------- */
.m-row.needed { background: #fdf7e1; }
.m-row.needed:hover { background: #fbf1cf; }
.m-row.needed.selected { box-shadow: inset 3px 0 0 #d9b24a; }
.b-needed { background: #f4e9bf; color: #8a6d1f; cursor: help; }
.needed-hint { font-size: 12.5px; color: #7a611a; background: #fdf7e1; border: 1px solid #ecdca0; border-radius: 8px; padding: 7px 11px; margin: -4px 0 12px; }
.dp-needed { background: #fdf7e1; border-left: 3px solid #d9b24a; border-radius: 8px; padding: 9px 11px; color: #6b5418; font-size: 13px; margin: 8px 0; }

/* ---------------- Drag & drop zone ---------------- */
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; transition: .15s; margin-bottom: 10px; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-hint { font-size: 13px; color: var(--muted); }

/* ---------------- Scan card ---------------- */
.scan-card { padding: 0; }
.scan-card summary { cursor: pointer; font-weight: 700; padding: 16px 22px; font-size: 16px; color: var(--brand); }
.scan-card > *:not(summary) { margin-left: 22px; margin-right: 22px; }
.scan-card > *:last-child { margin-bottom: 18px; }
.scan-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.file-btn { flex-direction: row; align-items: center; display: inline-flex; gap: 6px; background: var(--brand); color: #fff;
  border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.file-btn:hover { background: #9a3f6c; }
.scan-card textarea { width: 100%; font: inherit; font-size: 13px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
.scan-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.scan-status { font-size: 13px; color: var(--muted); }
.scan-review { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.scan-review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.scan-row { display: grid; grid-template-columns: auto minmax(120px,1fr) 90px 96px minmax(0,1.4fr); gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.scan-mk { font-weight: 600; }
.scan-val { padding: 6px 8px; }
.scan-snip { color: var(--muted); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Saved sets ---------------- */
.saved-sets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.saved-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.saved-chip a { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
.saved-chip a:hover { text-decoration: underline; }
.saved-x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 50%; }
.saved-x:hover { background: var(--bad-bg); color: var(--bad); }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .table-layout { grid-template-columns: 1fr; }
  body { padding-bottom: 17vh; }            /* clear the fixed bottom dock */
  .detail-pane {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; top: auto;
    max-height: 16vh; overflow: hidden;
    border: 1px solid var(--line); border-bottom: none; border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(20, 24, 40, .18); z-index: 60;
    transition: max-height .25s ease; padding: 0 16px 14px;
  }
  .detail-pane.dock-expanded { max-height: 82vh; overflow-y: auto; }
  .detail-pane.dragging { transition: none; }
  .dock-handle { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: sticky; top: 0; background: #fff; padding: 14px 0 8px; margin-bottom: 4px;
    border-bottom: 1px solid var(--line); cursor: grab; touch-action: none; user-select: none; }
  .dock-grip { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: var(--line); }
  .dock-peek { font-weight: 700; font-size: 14px; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock-caret { font-size: 11px; color: var(--muted); white-space: nowrap; }
  .dp-back { padding-top: 2px; }
  .m-influence { display: none; }
  .th-value { width: 118px; } .th-range { width: 118px; }
  .scan-row { grid-template-columns: auto 1fr 80px 84px; }
  .scan-snip { display: none; }
}
@media (max-width: 560px) {
  .brand { font-size: 22px; }
  .grid-inputs { grid-template-columns: 1fr; }
}

/* Phone: turn the marker table into stacked cards */
@media (max-width: 620px) {
  .site-header { padding: 22px 0 20px; }
  .tagline { font-size: 14px; }
  .goal-chip { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .marker-table thead { display: none; }
  .marker-table tbody { display: block; }
  .cat-row, .cat-row td { display: block; }
  .m-row { display: block; padding: 12px 14px; }
  .m-row td { display: block; padding: 3px 0; border: none; }
  .td-marker { margin-bottom: 8px; }
  .m-influence { display: block; }
  .td-value { display: inline-block; vertical-align: middle; }
  .td-value input[type="number"] { width: 110px; }
  .td-status { display: inline-block; vertical-align: middle; margin-left: 12px; }
  .td-range { margin-top: 6px; }
  .td-range::before { content: "Expected: "; color: var(--muted); font-weight: 600; }
  .m-row.selected { box-shadow: inset 0 0 0 2px var(--brand); }
  .scan-row { grid-template-columns: auto 1fr auto; }
  .scan-row .scan-val { grid-column: 2 / 3; }
}
