html:has(body.desk) {
  background: var(--brand);
}
:root[data-theme="dark"]:has(body.desk),
html:has(body.desk)[data-theme="dark"] {
  background: #000;
}
body.desk {
  min-height: 100dvh;
  background: var(--bg, #e8eee9);
  color: var(--ink, #12241c);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}
/* Desk top bar = Plans `.nav.nav-green` (app.css). */
.desk-bar-links { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.desk-check {
  display: flex; align-items: flex-start; gap: 12px;
  max-width: 440px; margin: 18px 0 8px; cursor: pointer;
}
.desk-check input { width: 18px; height: 18px; margin: 3px 0 0; flex-shrink: 0; accent-color: var(--brand); }
.desk-check .lab { display: block; font-weight: 600; color: #12241c; }
.desk-check .fine { display: block; margin: 4px 0 0; color: #6b7a74; font-size: 13px; line-height: 1.4; }
.desk-logout { font-weight: 600; color: #6b7a74; font-size: 13px; }
.act.desk-profile-act {
  max-width: 440px;
  align-items: center;
  gap: 28px;
}
.desk-wrap {
  display: grid;
  grid-template-columns: 148px 1fr;
  grid-template-rows: 1fr;
  min-height: calc(100dvh - 56px);
}
.desk-nav { background: var(--card, #fff); border-right: 1px solid rgba(60,60,67,.12); padding: 16px 12px; }
.desk-nav a {
  display: block; padding: 10px 12px; border-radius: 10px;
  color: #3a4a44; font-weight: 500; margin-bottom: 4px;
  text-decoration: none;
}
.desk-nav a.on { background: var(--brand-mist); color: var(--brand); font-weight: 650; }
.desk-nav a.desk-nav-go {
  margin-top: 10px;
  color: var(--brand);
  font-weight: 650;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(29, 74, 58, .35);
}
.desk-nav a.desk-nav-go:hover { background: #f3f7f5; }
:root[data-theme="dark"] .desk-nav {
  background: #1c1c1e;
  border-right-color: rgba(255, 255, 255, .1);
}
:root[data-theme="dark"] .desk-nav a { color: rgba(255, 255, 255, .72); }
:root[data-theme="dark"] .desk-nav a.on {
  background: color-mix(in srgb, var(--brand-glow) 16%, transparent);
  color: var(--brand-glow);
}
:root[data-theme="dark"] .desk-nav a.desk-nav-go {
  color: var(--brand-glow);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brand-glow) 35%, transparent);
}
:root[data-theme="dark"] .desk-nav a.desk-nav-go:hover {
  background: color-mix(in srgb, var(--brand-glow) 10%, transparent);
}
.desk-nav a.desk-nav-go::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 8px;
  vertical-align: 1px;
  border-right: 1.7px solid currentColor;
  border-top: 1.7px solid currentColor;
  transform: rotate(45deg);
  opacity: .7;
}
.desk-main { padding: 24px 28px 56px; max-width: 1120px; }
.desk-h { font-size: 26px; margin: 0 0 6px; letter-spacing: -.03em; color: var(--ink, inherit); }
.desk-sub { margin: 0 0 18px; color: var(--muted, #6b7a74); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px; margin: 0 0 12px; }
.kpi { background: var(--card, #fff); border-radius: 10px; padding: 8px 8px; min-width: 0; }
.kpi b { display: block; font-size: 18px; letter-spacing: -.03em; line-height: 1.1; color: var(--ink, inherit); }
.kpi span { display: block; margin-top: 2px; color: var(--muted, #6b7a74); font-size: 11px; line-height: 1.2; }
:root[data-theme="dark"] .kpi {
  background: #1c1c1e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
/* Clinic plans — KPI strip lives in stable #bot-bar: digit + short hint. */
#bot-bar.tabbar-empty,
#bot-bar.tabbar-kpis,
#bot-bar.tabbar-actions {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  gap: 0;
  padding: 4px 8px var(--safe-b, 0px);
  /* Fixed footprint = Cabinet tabs — no mid resize blink on mode switch. */
  height: calc(var(--tab-h, 52px) + var(--safe-b, 0px));
  min-height: calc(var(--tab-h, 52px) + var(--safe-b, 0px));
  max-height: calc(var(--tab-h, 52px) + var(--safe-b, 0px));
  box-sizing: border-box;
}
#bot-bar.tabbar-empty,
#bot-bar.tabbar-kpis {
  pointer-events: none;
}
/* Same icon+title tabs as Cabinet — only pointer-events differ from KPIs. */
#bot-bar.tabbar-actions {
  pointer-events: auto;
}
#bot-bar.tabbar-actions .tab {
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--tint, var(--brand));
}
#bot-bar.tabbar-actions .tab.on {
  color: var(--tint, var(--brand));
  font-weight: 650;
}
#bot-bar.tabbar-actions .tab:active {
  opacity: .72;
}
#bot-bar.tabbar-actions .tab.hide {
  display: none !important;
}
/* Creating-a-plan: force grid over the shared actions flex/space-around. */
#bot-bar.tabbar-actions.wiz-bot {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr;
  justify-content: stretch;
  align-items: stretch;
  gap: 0;
  padding-left: 8px;
  padding-right: 8px;
}
#bot-bar.tabbar-actions.wiz-bot #wiz-back {
  grid-column: 1;
  justify-self: center;
  margin: 0 !important;
}
#bot-bar.tabbar-actions.wiz-bot #wiz-dots {
  grid-column: 2;
  justify-self: center;
  align-self: center;
}
#bot-bar.tabbar-actions.wiz-bot #wiz-next,
#bot-bar.tabbar-actions.wiz-bot #wiz-go:not(.fill) {
  grid-column: 3;
  justify-self: center;
  margin: 0 !important;
}
#bot-bar.tabbar-actions.wiz-bot #wiz-back,
#bot-bar.tabbar-actions.wiz-bot #wiz-next,
#bot-bar.tabbar-actions.wiz-bot #wiz-go:not(.fill) {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 72px;
  max-width: none;
}
#bot-bar.tabbar-actions.wiz-bot:has(#wiz-go.fill) {
  display: flex !important;
  grid-template-columns: none;
}
#bot-bar.tabbar-actions.wiz-bot:has(#lib-go.fill) {
  display: flex !important;
  grid-template-columns: none;
  justify-content: center;
}
#bot-bar.tabbar-actions.wiz-bot #lib-go.fill {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 96px;
  margin: 0 auto;
}
#bot-bar.tabbar-kpis .kpi {
  flex: 1;
  margin: 0;
  padding: 0;
  min-width: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
#bot-bar.tabbar-kpis .kpi b {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink, #12241c);
  line-height: 1;
}
#bot-bar.tabbar-kpis .kpi span {
  display: block;
  margin-top: 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--muted, #6b7a74);
  white-space: nowrap;
}
.inbox { width: 100%; border-collapse: collapse; background: var(--card, #fff); border-radius: 12px; overflow: hidden; }
.inbox th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted, #6b7a74);
  padding: 12px 14px; background: #f7f9f8; border-bottom: 1px solid rgba(60,60,67,.12);
}
.inbox td { padding: 13px 14px; border-bottom: 1px solid rgba(60,60,67,.08); vertical-align: middle; }
:root[data-theme="dark"] .inbox {
  background: #1c1c1e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
:root[data-theme="dark"] .inbox th {
  background: #161618;
  border-bottom-color: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .55);
}
:root[data-theme="dark"] .inbox td {
  border-bottom-color: rgba(255, 255, 255, .06);
  color: var(--ink, #f2f2f7);
}
:root[data-theme="dark"] .desk .inbox tr:hover td { background: color-mix(in srgb, var(--brand-glow) 8%, transparent); }
:root[data-theme="dark"] .inbox tr.on td { background: color-mix(in srgb, var(--brand-glow) 12%, transparent); }
:root[data-theme="dark"] .doc-pick select {
  background: #1c1c1e;
  color: var(--brand-glow);
  border-color: rgba(255, 255, 255, .16);
}
:root[data-theme="dark"] .b.ghost {
  background: #2c2c2e;
  color: var(--brand-glow);
}
:root[data-theme="dark"] .desk-check .lab { color: var(--ink, #f2f2f7); }
:root[data-theme="dark"] .desk-check .fine,
:root[data-theme="dark"] .desk-logout { color: var(--muted, #8e8e93); }
.inbox tr:last-child td { border-bottom: 0; }
.inbox strong { font-size: 15px; }
.act { display: flex; flex-wrap: wrap; gap: 6px; }
.act form { margin: 0; }
.doc-pick { margin: 0; }
.doc-pick select {
  max-width: 180px; min-height: 34px; padding: 0 10px;
  border: 1px solid rgba(60,60,67,.18); border-radius: 8px;
  background: #fff; color: var(--brand);
  font: 500 13px/1.2 inherit; cursor: pointer;
}
.b {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 12px; border-radius: 8px; border: 0;
  font: 600 13px/1 -apple-system, sans-serif; cursor: pointer;
}
.b.go { background: var(--brand); color: #fff; }
.b.ghost { background: #eef2f0; color: var(--brand); }
.desk-card { display: none; }
.desk .group { max-width: 440px; }
.desk .cell { max-width: 560px; padding-right: 16px; }
.desk .desk-swipe { max-width: 560px; margin: 0 0 10px; }
.desk .desk-swipe .cell { max-width: none; }
.desk-head + .fine { margin-top: 0; }
.desk .cell.editing { box-shadow: inset 0 0 0 2px var(--brand); }
.desk .cell-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.desk .cell-actions a { font-size: 13px; font-weight: 600; }
.desk .swipe-front { cursor: grab; }
.desk .swipe-front a { color: inherit; text-decoration: none; }
/* .desk-plan* shared styles live in app.css (Clinic + Cabinet). */
/* Not scoped to body.desk — mode toggle used to drop .desk before HTMX
   replaced clinic HTML, which unhid these as plain grey buttons. */
.swipe-copy,
.desk .swipe-copy {
  position: absolute; inset: 0 0 0 auto; width: 118px; margin: 0;
  display: flex;
  background: var(--brand);
  opacity: 0;
  pointer-events: none;
}
.swipe.pull .swipe-copy,
.desk .swipe.pull .swipe-copy {
  opacity: 1;
  pointer-events: auto;
}
.swipe-copy button,
.desk .swipe-copy button {
  flex: 1; border: 0; background: transparent; color: #fff;
  font-weight: 600; font-size: 14px; padding: 0 8px;
  cursor: pointer;
}

/* Mid band only — fixed to viewport chrome vars so top/sub/bot stay clear. */
.desk-sheet {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--chrome-top, 48px) + var(--chrome-rail, 44px));
  bottom: var(--chrome-bot, 56px);
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.desk-sheet.hide,
.desk-sheet[hidden] { display: none !important; }
.desk-sheet-back {
  position: absolute; inset: 0;
  background: rgba(18, 36, 28, .34);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  opacity: 0;
  transition: opacity .28s ease;
}
.desk-sheet.on .desk-sheet-back { opacity: 1; }
body.desk.chrome-lock #del-ask.ask {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--chrome-top, 48px) + var(--chrome-rail, 44px));
  bottom: var(--chrome-bot, 56px);
  inset: auto;
  z-index: 35;
  padding: 16px;
  background: rgba(18, 36, 28, .34);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
}
.desk-sheet-card {
  position: relative; width: 100%; max-width: 430px;
  background: #fff; border-radius: 16px;
  padding: 14px 16px 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.16);
  opacity: 0;
  transform: translateY(16px) scale(.88);
  transition: transform .4s cubic-bezier(.2,.8,.2,1), opacity .28s ease;
  transform-origin: center center;
  will-change: transform, opacity;
}
.desk-sheet.on .desk-sheet-card { opacity: 1; transform: none; }
.desk .desk-sheet-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  letter-spacing: -.02em;
}
.desk-sheet-card .group { max-width: none; margin: 0 0 14px; }
.desk-sheet-card .act { margin: 0; max-width: none; }
.desk-sheet-card .act .b,
.desk-sheet-card .act .btn { flex: 1; }
.desk-sheet-card .group,
.desk-sheet-card .act .b,
.desk-sheet-card .act .btn {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s ease .1s, transform .3s cubic-bezier(.2,.8,.2,1) .1s;
}
.desk-sheet.on .desk-sheet-card .group,
.desk-sheet.on .desk-sheet-card .act .b,
.desk-sheet.on .desk-sheet-card .act .btn {
  opacity: 1;
  transform: none;
}
.desk-sheet.on .desk-sheet-card .act .b.go,
.desk-sheet.on .desk-sheet-card .act .btn {
  transition-delay: .16s;
}
.desk-sheet.on .desk-sheet-card .act .b.ghost {
  transition-delay: .2s;
}
@media (prefers-reduced-motion: reduce) {
  .desk-sheet-back,
  .desk-sheet-card,
  .desk-sheet-card .group,
  .desk-sheet-card .act .b,
  .desk-sheet-card .act .btn { transition: none; }
}
.desk form .act { margin: 12px 0 0; }
.desk h2 { font-size: 16px; margin: 22px 0 10px; }
.desk-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 0 0 24px;
}
.desk-head h2 { margin: 0; }
.desk-add {
  flex-shrink: 0;
  font-size: 15px; font-weight: 600; color: var(--brand);
}
.desk-main > .desk-head:first-child,
.desk-main > .banner:first-child + .desk-head,
.desk-main > h2:first-child,
.desk-main > .banner:first-child + h2 { margin-top: 0; }
.desk .inbox tr:hover td { background: #f7fbf8; }
.inbox tr.on td { background: #f3faf6; }
.desk-card.editing { box-shadow: inset 0 0 0 2px var(--brand); }
.desk-login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.desk-login .app { max-width: 400px; min-height: auto; box-shadow: none; background: transparent; }
.desk-login .login-page { min-height: auto; background: #fff; border-radius: 16px; padding: 36px 28px; }

@media (max-width: 800px) {
  .desk-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  /* Chip size/padding: app.css body.desk @media — keep layout only here. */
  .desk-nav {
    display: flex;
    gap: 6px;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid rgba(60,60,67,.12);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .desk-nav::-webkit-scrollbar { display: none; }
  .desk-nav a {
    flex: 0 0 auto;
    text-align: center;
    margin: 0;
    white-space: nowrap;
  }
  .desk-nav a.desk-nav-go {
    margin-top: 0;
    margin-left: 2px;
    padding-right: 14px;
  }
  /* Match Cabinet `.page` top padding so Clinic↔Cabinet list doesn’t jump. */
  .desk-main { padding: 8px 14px 32px; }
  .desk-head { margin-bottom: 16px; }
  .desk-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .desk-profile .desk-h,
  .desk-profile .desk-sub,
  .desk-profile .banner { width: 100%; max-width: 440px; }
  .desk-profile form {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .desk-profile .group,
  .desk-profile .desk-check,
  .desk-profile .desk-profile-act {
    width: 100%;
    max-width: 440px;
  }
  .desk-profile .group label { text-align: left; }
  .desk-profile .desk-check {
    text-align: left;
    justify-content: center;
  }
  .act.desk-profile-act { justify-content: center; }
  .kpis { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 4px; margin: 0 0 10px; }
  .kpi { padding: 6px 5px; border-radius: 8px; text-align: center; }
  .kpi b { font-size: 16px; }
  .kpi span { font-size: 10px; }
}
