﻿/* NaQuay portal styles. Carried over from the naquay-portal.html prototype. */
:root {
  color-scheme: light;
  --paper: #FFFFFF;
  --wash: #F6F3FD;
  --wash-2: #EEE8FB;
  --line: #E4DDF4;
  --ink: #1E1A2E;
  --ink-2: #5E5776;
  --purple: #4B2E83;
  --purple-2: #6B4BD6;
  --mint: #0FA896;
  --mint-wash: #E3F7F3;
  --lemon: #FFD23F;
  --lemon-wash: #FFF6D6;
  --red: #D93F45;
  --red-wash: #FDECEC;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
/* The brief asks for a bright interface, so the light palette is kept in dark mode too */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: light; } }
:root[data-theme="dark"] { color-scheme: light; }
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%;
  overflow-x: clip;   /* nothing may ever make the page wider than the screen (phones then zoom out) */
  font-family: "Lexend", "IBM Plex Sans Thai", -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--wash);
  -webkit-tap-highlight-color: transparent;
}
:root[lang="th"] body { font-family: "IBM Plex Sans Thai", "Lexend", -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video, canvas, select, input, textarea { max-width: 100%; }
select { min-width: 0; text-overflow: ellipsis; }
[hidden] { display: none !important; }
button { cursor: pointer; border: none; background: none; }
:focus-visible { outline: 3px solid var(--purple-2); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: #3c2469; }
.btn-soft { background: var(--wash-2); color: var(--purple); }
.btn-soft:hover { background: #e3daf8; }
.btn-line { box-shadow: inset 0 0 0 1.5px var(--line); background: var(--paper); }
.btn-line:hover { box-shadow: inset 0 0 0 1.5px var(--purple-2); }
.btn-mint { background: var(--mint); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
.btn-danger { color: var(--red); }
.btn svg { width: 18px; height: 18px; }

/* form */
label.field { display: grid; gap: 6px; font-weight: 500; font-size: 0.92rem; }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--paper); font-size: 1rem; }
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { outline: none; border-color: var(--purple-2); box-shadow: 0 0 0 3px rgba(107, 75, 214, 0.15); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 13px; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 0.88rem; }
.chip[aria-pressed="true"] { background: var(--purple); color: #fff; box-shadow: none; }
.seg { display: inline-flex; padding: 4px; background: var(--wash-2); border-radius: 999px; gap: 2px; }
.seg button { padding: 8px 16px; border-radius: 999px; font-weight: 500; font-size: 0.92rem; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--purple); box-shadow: 0 1px 3px rgba(75, 46, 131, 0.18); }

/* shell */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: rgba(255, 255, 255, 0.92); }
.logo { height: 34px; width: auto; display: block; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .who { font-size: 0.85rem; color: var(--ink-2); border-left: 1px solid var(--line); padding-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-menu { display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; width: 44px; padding: 0; }
.menu-btn svg { width: 20px; height: 20px; }
/* phones and upright tablets: the top bar's buttons fold into a ☰ menu */
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .top-menu { display: none; }
  .topbar.menu-open .top-menu { display: grid; gap: 8px; position: absolute; right: 12px; top: calc(100% + 6px); min-width: 220px; padding: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(30, 26, 46, 0.18); z-index: 30; }
  .topbar.menu-open .top-menu .btn { width: 100%; justify-content: flex-start; min-height: 44px; }
}
.lang { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--wash-2); }
.lang button { padding: 5px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.lang button[aria-pressed="true"] { background: var(--purple); color: #fff; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 22px 20px 60px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.demo-banner { background: var(--lemon-wash); color: #6b5300; font-size: 0.84rem; padding: 8px 20px; text-align: center; }

/* auth */
.auth { min-height: calc(100vh - 40px); display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: var(--purple); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-weight: 600; max-width: 14ch; }
.auth-art p { color: #d9ccf7; max-width: 38ch; margin-top: 12px; }
.auth-art .mascot { position: absolute; right: 6%; bottom: 0; height: 74%; max-height: 520px; width: auto; pointer-events: none; }
.auth-art .beat-lines { position: absolute; left: 48px; bottom: 48px; display: flex; gap: 10px; align-items: flex-end; }
.auth-art .beat-lines i { width: 10px; border-radius: 6px; background: var(--lemon); display: block; }
.auth-form { padding: 40px clamp(20px, 5vw, 64px); display: flex; flex-direction: column; justify-content: center; gap: 22px; background: var(--paper); }
.auth-form form { display: grid; gap: 16px; max-width: 420px; }
.auth-form .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hint { background: var(--wash); border-radius: var(--radius); padding: 12px 14px; font-size: 0.85rem; color: var(--ink-2); max-width: 420px; }
.hint b { color: var(--ink); font-weight: 600; }
.err { color: var(--red); font-size: 0.9rem; min-height: 1.2em; }
.linkish { color: var(--purple-2); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.plan-card { border: 2px solid var(--purple-2); border-radius: var(--radius-lg); padding: 18px; display: grid; gap: 6px; max-width: 420px; background: var(--wash); }
.plan-card .price { font-size: 1.8rem; font-weight: 600; color: var(--purple); }

/* practitioner */
.detail, .panel, .tabbody { min-width: 0; }
/* single-column grids: the column may shrink below its content's natural width, so long text and wide
   dropdowns wrap instead of pushing the page sideways */
.detail, .tabbody, .modal, .plist, .pt-wrap, .hcard, .cat-block { grid-template-columns: minmax(0, 1fr); }
.prac { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.plist { position: sticky; top: 76px; padding: 16px; display: grid; gap: 12px; max-height: calc(100vh - 100px); overflow: auto; }
.plist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pitem { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; text-align: left; width: 100%; padding: 10px; border-radius: var(--radius); }
.pitem:hover { background: var(--wash); }
.pitem[aria-current="true"] { background: var(--wash-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: var(--purple); background: var(--wash-2); }
.pitem .meta { font-size: 0.8rem; color: var(--ink-2); }
.ring-mini { width: 34px; height: 34px; }
.detail { display: grid; gap: 18px; }
.phead { padding: 22px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.phead .avatar { width: 58px; height: 58px; font-size: 1.3rem; }
.phead .grow { flex: 1; min-width: 200px; display: grid; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; background: var(--wash-2); color: var(--purple); font-weight: 500; }
.tag.mint { background: var(--mint-wash); color: #0b6f63; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 22px; overflow-x: auto; }
.tabs button { padding: 14px 6px; margin-right: 18px; font-weight: 500; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--purple); border-bottom-color: var(--purple); }
.tabbody { padding: 22px; display: grid; gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--wash); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 600; color: var(--purple); line-height: 1.2; }
.stat span { font-size: 0.85rem; color: var(--ink-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }
th { text-align: left; font-weight: 500; color: var(--ink-2); background: var(--wash); padding: 10px 14px; font-size: 0.82rem; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
td .act { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.acc { font-weight: 600; }
.acc.good { color: var(--mint); } .acc.mid { color: #b07d00; } .acc.low { color: var(--red); }
.badge-assigned { font-size: 0.72rem; color: #0b6f63; background: var(--mint-wash); padding: 2px 8px; border-radius: 999px; font-weight: 500; }
.empty { text-align: center; padding: 36px 20px; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.cat-block { display: grid; gap: 8px; }
.cat-title { font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }
.arow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.arow.on { border-color: var(--purple-2); background: #fbfaff; }
.arow .opts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.arow .opts label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); flex-wrap: wrap; max-width: 100%; min-width: 0; }
.arow .opts select { max-width: 100%; }
.arow .opts input[type=number] { width: 72px; min-height: 38px; padding: 6px 8px; }
.arow .opts input[type=text] { min-width: 220px; flex: 1; min-height: 38px; padding: 6px 10px; }
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; background: #d8d1e9; flex: none; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--purple); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.arow .aname { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 500; }
/* activity search: stays in view under the top bar while scrolling through the list */
.act-search { position: sticky; top: 58px; z-index: 6; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; margin: -10px 0; background: var(--paper); }
.act-search .input { flex: 1 1 260px; min-height: 46px; padding-left: 42px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b5e8a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center; }
/* in office */
.orow { grid-template-columns: 1fr auto; align-items: center; }
.orow-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.orow-btns .btn svg { width: 14px; height: 14px; }
.badge-office { font-size: 0.72rem; color: #3b2a8f; background: var(--wash-2); padding: 2px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.hw-cfg summary { cursor: pointer; font-weight: 500; padding: 8px 0; }
@media (max-width: 520px) { .orow { grid-template-columns: 1fr; } .orow-btns { justify-content: flex-start; } }
.kind { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--lemon-wash); color: #7a5d00; font-weight: 500; }
.savebar { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 999px; box-shadow: 0 8px 24px rgba(30, 26, 46, 0.25); }
.savebar .btn-primary { background: var(--lemon); color: var(--ink); }
.cred { display: grid; gap: 10px; padding: 18px; border-radius: var(--radius-lg); background: var(--wash); border: 1.5px dashed var(--purple-2); }
.cred-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--paper); border-radius: var(--radius-sm); padding: 10px 14px; }
.cred-row code { font-family: "Lexend", sans-serif; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; color: var(--purple); }
.back-mobile { display: none; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 18px; align-items: start; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--wash); }
.status { font-size: 0.8rem; font-weight: 500; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.st-red { background: var(--red-wash); color: var(--red); }
.st-amber { background: var(--lemon-wash); color: #7a5d00; }
.st-mint { background: var(--mint-wash); color: #0b6f63; }
.st-grey { background: var(--wash); color: var(--ink-2); }
.pitem, .btn-sm { min-height: 44px; }

/* patient */
.hello { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 26px 26px 0; overflow: hidden; background: var(--purple); color: #fff; border-radius: var(--radius-lg); position: relative; }
.hello h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.hello p { color: #ddd1fa; }
.hello .txt { padding-bottom: 24px; display: grid; gap: 10px; }
.hello img { height: 190px; width: auto; display: block; margin-right: 6px; }
.week-progress { display: flex; align-items: center; gap: 14px; }
.week-progress .bar { flex: 1; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); overflow: hidden; max-width: 260px; }
.week-progress .bar i { display: block; height: 100%; background: var(--lemon); border-radius: 999px; }
.note { display: flex; gap: 12px; padding: 16px 18px; background: var(--lemon-wash); border-radius: var(--radius); color: #5c4700; }
.note b { color: var(--ink); }
.hw { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.hcard { padding: 18px; display: grid; gap: 12px; }
.hcard-top { display: flex; gap: 14px; align-items: flex-start; }
.hicon { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: var(--wash-2); color: var(--purple); flex: none; }
.hicon.ex { background: var(--lemon-wash); color: #8a6a00; }
.hicon svg { width: 26px; height: 26px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--wash-2); display: block; }
.dots i.on { background: var(--mint); }
.hcard .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hcard.done { background: #fbfffe; border-color: #bfe9e1; }
.done-flag { font-size: 0.8rem; color: #0b6f63; font-weight: 600; }

/* modal */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(30, 26, 46, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: var(--radius-lg); padding: 24px; display: grid; gap: 18px; box-shadow: 0 20px 60px rgba(30, 26, 46, 0.3); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.x { width: 38px; height: 38px; border-radius: 50%; background: var(--wash); display: grid; place-items: center; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 0.92rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: calc(100% - 32px); }

/* metronome */
.metro { display: grid; gap: 18px; justify-items: center; text-align: center; }
.pulse { width: 180px; height: 180px; border-radius: 50%; background: var(--wash-2); display: grid; place-items: center; transition: transform 0.08s ease-out, background 0.08s; position: relative; }
.pulse b { font-size: 3.4rem; font-weight: 600; color: var(--purple); line-height: 1; }
.pulse span { position: absolute; bottom: 38px; font-size: 0.85rem; color: var(--ink-2); }
.pulse.beat { background: var(--lemon); transform: scale(1.06); }
.pulse.beat.accent { background: var(--purple-2); }
.pulse.beat.accent b, .pulse.beat.accent span { color: #fff; }
.beats { display: flex; gap: 8px; }
.beats i { width: 14px; height: 14px; border-radius: 50%; background: var(--wash-2); display: block; }
.beats i.on { background: var(--purple-2); }
.metro-row { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 380px; }
.metro-row input[type=range] { flex: 1; accent-color: var(--purple); }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--wash-2); color: var(--purple); font-size: 1.4rem; font-weight: 600; flex: none; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 300px; padding: 28px; }
  .auth-art .mascot { height: 92%; right: 2%; }
  .auth-art .beat-lines { display: none; }
}
/* practitioners mostly use laptops and tablets: keep the two-panel layout down to tablet portrait */
@media (max-width: 720px) {
  .prac { grid-template-columns: minmax(0, 1fr); }
  /* tables become stacked cards so nothing scrolls sideways */
  .table-wrap { border: none; overflow: visible; }
  .table-wrap table { min-width: 0; display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: grid; gap: 10px; }
  .table-wrap tr { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 0; background: var(--paper); }
  .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: none; padding: 6px 14px; text-align: right; }
  .table-wrap td::before { content: attr(data-label); color: var(--ink-2); font-size: 0.8rem; text-align: left; flex: none; max-width: 50%; }
  .table-wrap td:first-child { display: block; text-align: left; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .table-wrap td:first-child::before { display: none; }
  table.ov th:nth-child(n), table.ov td:nth-child(n) { display: flex; }
  table.ov td:first-child { display: block; }
  .savebar { flex-wrap: wrap; border-radius: 22px; }
  /* tabs become pills that wrap, so every tab is visible and none runs past the edge */
  .tabs { flex-wrap: wrap; gap: 8px; padding: 12px 16px; overflow: visible; }
  .tabs button { margin: 0; padding: 8px 14px; border: none; border-radius: 999px; background: var(--wash); font-size: 0.9rem; }
  .tabs button[aria-selected="true"] { background: var(--purple); color: #fff; }
  .savebtns { width: 100%; }
  .savebtns .btn { flex: 1; }
  .phead { gap: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .arow .opts input[type=text] { min-width: 0; width: 100%; }
  .pchart { gap: 12px; }
  .plist { position: static; max-height: none; }
  .prac.show-detail .plist { display: none; }
  .prac:not(.show-detail) .detail { display: none; }
  .back-mobile { display: inline-flex; }
}
@media (min-width: 721px) and (max-width: 1100px) {
  .prac { gap: 14px; grid-template-columns: 220px minmax(0, 1fr); }
  .plist { padding: 12px; }
  .pitem { grid-template-columns: 34px 1fr auto; gap: 8px; padding: 8px; }
  .pitem .avatar { width: 34px; height: 34px; font-size: 0.8rem; }
  table.ov { min-width: 0; }
  table.ov th:nth-child(4), table.ov td:nth-child(4), table.ov th:nth-child(6), table.ov td:nth-child(6) { display: none; }
  .wrap { padding: 18px 16px 50px; }
  .tabbody, .phead { padding: 18px; }
}
@media (max-width: 560px) {
  .wrap { padding: 16px 14px 60px; }
  .topbar { padding: 8px 14px; }
  .brand .who { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .hello { grid-template-columns: 1fr 110px; padding: 20px 18px 0; }
  .hello img { height: 150px; }
  .hw { grid-template-columns: 1fr; }
  .tabbody, .phead { padding: 16px; }
  .tabs { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) { .pulse, .switch::after { transition: none; } }

/* patient side: phones and tablets first */
.pt-wrap { display: grid; gap: 22px; max-width: 1100px; }
.pt-wrap .btn-sm { min-height: 50px; padding: 0 20px; font-size: 1rem; }
.pt-wrap h2 { font-size: 1.25rem; }
.pt-wrap .hcard h3 { font-size: 1.1rem; }
.pt-wrap .dots i { width: 16px; height: 16px; }
.next-wrap { display: grid; gap: 10px; }
.hcard { grid-template-rows: 1fr auto; }
.hcard .actions { align-items: flex-end; }
.hcard.next { border: 2px solid var(--mint); box-shadow: 0 6px 20px rgba(15, 168, 150, 0.12); padding: 22px; }
.hcard.next h3 { font-size: 1.35rem; }
.hcard.next .hicon { width: 60px; height: 60px; }
.hcard.next .actions .btn { min-height: 56px; font-size: 1.05rem; flex: 1 1 auto; }
.sideways { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-2); }
.hw { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (min-width: 700px) and (max-width: 1366px) {
  .pt-wrap { padding: 24px 28px 60px; }
  .hello { padding: 30px 32px 0; }
  .hello img { height: 230px; }
  .hello h1 { font-size: 2.1rem; }
}
@media (max-width: 560px) {
  .hw { grid-template-columns: 1fr; }
  .hcard.next .actions { flex-direction: column; }
  .hcard.next .actions .btn { width: 100%; }
}
.plan-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.pchart { display: flex; gap: 18px; align-items: flex-end; padding: 18px; background: var(--wash); border-radius: var(--radius); overflow-x: auto; }
.pcol { display: grid; justify-items: center; gap: 4px; min-width: 70px; font-size: 0.8rem; }
.pcol span { color: var(--ink-2); }
.pbars { height: 120px; display: flex; align-items: flex-end; gap: 6px; }
.pbars i { width: 18px; border-radius: 6px 6px 2px 2px; display: block; min-height: 3px; }
.b-score { background: var(--purple-2); }
.b-adh { background: var(--mint); }
.legend { display: flex; gap: 18px; font-size: 0.82rem; color: var(--ink-2); margin-top: -8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.period { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.period.current { border: 2px solid var(--mint); }
.period-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.period-head h3 { display: flex; align-items: center; gap: 8px; }
.period-kpis { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-2); }
.period-kpis b { color: var(--purple); font-size: 1.1rem; }
td .act + .muted { display: block; margin-top: 2px; }
.up { color: var(--mint); font-weight: 600; } .down { color: var(--red); font-weight: 600; }
.savebtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-ghost-light { color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5); }
.btn-ghost-light:hover { box-shadow: inset 0 0 0 1.5px #fff; }
.period-actions { display: flex; gap: 10px; flex-wrap: wrap; }
main > .stats .stat { background: var(--paper); border: 1px solid var(--line); }
.owner-tabs { padding: 0; border-bottom: 1px solid var(--line); }
.owner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 18px; align-items: start; }
.rev-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rev-row.total { border-bottom: none; font-size: 1.05rem; }
.rev-row.total b { color: var(--purple); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; color: var(--ink-2); }
label.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--purple); flex: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.subpanel { display: grid; gap: 14px; padding: 18px; border: 2px solid var(--purple-2); border-radius: var(--radius-lg); background: #fbfaff; }
.sub-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.sub-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.sub-box { display: grid; gap: 10px; align-content: start; padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.sub-box h3 { font-size: 0.95rem; }
.sub-box .btn { justify-self: start; }
.sub-log { font-size: 0.88rem; }
.sub-log summary { cursor: pointer; color: var(--purple-2); font-weight: 500; }
.sub-log div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.kpi-label { font-size: 0.85rem; color: var(--ink-2); font-weight: 500; }
.kpi-value { font-size: 1.9rem; font-weight: 600; color: var(--purple); line-height: 1.15; }
.kpi-sub { font-size: 0.8rem; color: var(--ink-2); }
.kpi-trend { font-size: 0.82rem; font-weight: 600; }
.kpi-trend.up { color: var(--mint); } .kpi-trend.down { color: var(--red); } .kpi-trend.flat { color: var(--ink-2); font-weight: 500; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card { padding: 18px; display: grid; gap: 12px; align-content: start; }
.chart-card.wide { grid-column: span 1; }
.mixbar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: var(--wash); }
.mixbar i { display: block; height: 100%; }
.mixlist { display: grid; gap: 8px; }
.mixlist div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mixlist span { display: flex; align-items: center; gap: 8px; }
.mixlist i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
/* added in v1: sign-in extras */
.loading { min-height: 60vh; display: grid; place-items: center; color: var(--ink-2); }
.qr { width: 200px; height: 200px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.secret { font-family: "Lexend", monospace; font-size: 0.9rem; word-break: break-all; background: var(--wash); padding: 8px 12px; border-radius: var(--radius-sm); }
.code-input { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; max-width: 220px; }
.ok-msg { background: var(--mint-wash); color: #0b6f63; border-radius: var(--radius); padding: 12px 14px; font-size: 0.9rem; max-width: 420px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
label.check a { color: var(--purple-2); }
.placeholder { padding: 40px 22px; display: grid; gap: 10px; justify-items: center; text-align: center; color: var(--ink-2); }
/* plan editor: activity settings */
.cfg-chip { flex-basis: 100%; }
#cfgForm .grid2 { align-items: start; }

/* patient: my progress */
.prog-stats .stat { background: var(--paper); border: 1px solid var(--line); text-align: center; }
.prog-stats .stat b { font-size: 1.7rem; }
.prog-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 420px; }
.prog-cal .wd { text-align: center; font-size: 0.75rem; color: var(--ink-2); font-weight: 600; }
.prog-cal i { font-style: normal; aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: 0.8rem; color: var(--ink-2); background: var(--wash); }
.prog-cal i.on { background: var(--mint); color: #fff; font-weight: 600; }
.prog-cal i.future { opacity: 0.35; }
.prog-card { padding: 18px; display: grid; gap: 10px; align-content: start; }
.lvl-badge { display: grid; justify-items: center; line-height: 1; padding: 6px 12px; border-radius: 14px; background: var(--wash-2); color: var(--purple); flex: none; }
.lvl-badge span { font-size: 0.7rem; font-weight: 600; }
.lvl-badge b { font-size: 1.6rem; }
.lvl-line { font-size: 0.9rem; color: var(--ink); }
.prog-bars { height: 64px; display: flex; align-items: flex-end; gap: 5px; }
.prog-bars i { flex: 1; border-radius: 5px 5px 2px 2px; background: var(--purple-2); min-height: 3px; }
.prog-bars i.blank { background: var(--wash-2); height: 6%; }
.prog-legend { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--ink-2); margin-top: -4px; }

/* the game covers the whole screen with a solid backing (nothing of the page shows through); the frame inside is
   padded clear of a notched phone's notch and home bar */
.game-wrap { position: fixed; inset: 0; z-index: 100; background: #F6F3FF; display: flex;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.game-frame { flex: 1; display: block; width: 100%; height: 100%; border: 0; background: #F6F3FF; }
body.gaming { overflow: hidden; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
}
