/* Zineph v3.5 — shell layer (see includes/views/head.php). Loaded after app.css.
   Owner: signed-in shell (sidebar, topbar, phone tab bar, generic phone tables /
   filters / modals) + client & staff portals. Class prefix: sh-

   Conventions for other pages
   ---------------------------
   --sh-tabbar-h   Height of the phone tab bar (incl. safe-area), set on <body>.
                   0px when there is no tab bar (desktop, public pages, opt-out).
                   Fixed / sticky bottom bars:  bottom: var(--sh-tabbar-h, 0px);
   body.sh-no-tabbar          hide the tab bar on a page (e.g. own sticky action bar)
   table[data-no-cards]       keep a .table as a real table on phones (or on any ancestor)
   th[data-label="…"]          label used for that column's cells in card mode
   form[data-filters]          always collapse this form behind "Filters" on phones
   form[data-no-collapse]      never collapse this GET form
   ========================================================================== */

body { --sh-tabbar-h: 0px; }

/* ---------------------------------------------------------------------------
   Drawer: the sidebar slides in below 1024px (app.css did it below 900px; the
   tab bar's "More" needs the drawer wherever the tab bar shows).
   --------------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: min(var(--sidebar-w), 86vw);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.28s;
    overscroll-behavior: contain;
    z-index: 60;
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
  }
  .sidebar-backdrop { z-index: 55; }
  .sidebar-backdrop.show { animation: fadeIn 0.2s; }
  .main { margin-left: 0; }
  .burger { display: flex; }
  .topbar { padding: 0 1rem; }
  .sidebar .nav-link { min-height: 44px; }
  .sidebar__footer { padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px)); }
  html.sh-drawer-open, html.sh-drawer-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar.open { transition: none; }
}

/* ---------------------------------------------------------------------------
   Topbar on phones
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { height: 56px; gap: 0.5rem; padding: 0 0.5rem 0 0.25rem; }
  .topbar .burger { width: 44px; height: 44px; flex: 0 0 auto; }
  .topbar__title h1 { font-size: 1.12rem; line-height: 1.2; }
  .topbar__actions { gap: 0.15rem; flex: 0 0 auto; }
  .topbar__actions .icon-btn { width: 44px; height: 44px; }
  .content { padding: 1rem; }
}

/* ---------------------------------------------------------------------------
   Phone tab bar
   --------------------------------------------------------------------------- */
.sh-tabbar { display: none; }

@media (max-width: 1023.98px) {
  body.sh-has-tabbar:not(.sh-no-tabbar) { --sh-tabbar-h: calc(62px + env(safe-area-inset-bottom, 0px)); }
  body.sh-has-tabbar:not(.sh-no-tabbar) .main { padding-bottom: var(--sh-tabbar-h); }

  body:not(.sh-no-tabbar) .sh-tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    height: var(--sh-tabbar-h);
    padding: 0 max(0.25rem, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(0.25rem, env(safe-area-inset-left, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(60, 25, 40, 0.06);
  }
  [data-theme="dark"] .sh-tabbar { box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.35); }
}

.sh-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-width: 0; min-height: 48px;
  padding: 6px 2px 4px;
  border: 0; background: none; font: inherit;
  color: var(--ink-muted);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.sh-tab:hover { color: var(--ink); }
.sh-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -4px; border-radius: 12px; }
.sh-tab__icon {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 30px;
  border-radius: 999px;
  transition: background 0.18s, color 0.18s;
}
.sh-tab__icon svg { width: 22px; height: 22px; }
.sh-tab__label {
  font-size: 0.7rem; font-weight: 500; line-height: 1.1; letter-spacing: 0.01em;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sh-tab.is-active { color: var(--brand-dark); }
.sh-tab.is-active .sh-tab__icon { background: var(--brand-soft); }
.sh-tab.is-active .sh-tab__label { font-weight: 600; }
[data-theme="dark"] .sh-tab.is-active { color: var(--brand-light); }

/* The one primary action per role (Book / New booking): a filled pill */
.sh-tab--primary { color: var(--brand-dark); }
.sh-tab--primary .sh-tab__icon {
  background: var(--brand-dark); color: #fff;
  width: 54px; height: 34px;
  box-shadow: var(--shadow-brand);
}
.sh-tab--primary .sh-tab__label { font-weight: 600; }
.sh-tab--primary:hover, .sh-tab--primary.is-active { color: var(--brand-dark); }
.sh-tab--primary.is-active .sh-tab__icon { background: var(--brand-dark); }
[data-theme="dark"] .sh-tab--primary { color: var(--brand-light); }
[data-theme="dark"] .sh-tab--primary .sh-tab__icon { background: var(--brand); color: #231f20; }

.sh-tab__badge {
  position: absolute; top: -3px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--brand-dark); color: #fff;
  font-size: 0.66rem; font-weight: 600; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.sh-tab__dot {
  position: absolute; top: 3px; right: 13px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 2px var(--surface);
}

/* Keep other fixed bottom things above the tab bar */
@media (max-width: 1023.98px) {
  body.sh-has-tabbar .booking-alerts { bottom: calc(var(--sh-tabbar-h) + 0.6rem); }
  body.sh-has-tabbar #toast-container { top: auto !important; bottom: calc(var(--sh-tabbar-h) + 0.75rem); right: 0.75rem !important; left: 0.75rem !important; align-items: center; }
  body.sh-has-tabbar #toast-container .alert { min-width: 0 !important; width: 100%; }
}

/* ---------------------------------------------------------------------------
   Tables → stacked cards under 640px (labels from app.js, see header)
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .table-wrap.sh-cards-wrap { overflow: visible; }
  .table.sh-cards, .table.sh-cards tbody, .table.sh-cards tfoot { display: block; width: 100%; }
  .table.sh-cards thead { display: none; }
  .table.sh-cards tr {
    display: block;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
  }
  .table.sh-cards tbody tr:last-child, .table.sh-cards tfoot tr:last-child { border-bottom: 0; }
  .table.sh-cards td {
    display: block;
    position: relative;
    border: 0;
    padding: 0.3rem 1rem 0.3rem calc(38% + 1rem);
    min-height: 1.9rem;
    text-align: left !important;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: none !important;
  }
  .table.sh-cards td::before {
    content: attr(data-label);
    position: absolute; left: 1rem; top: 0.42rem;
    width: 38%;
    padding-right: 0.5rem;
    font-size: 0.7rem; font-weight: 500;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--ink-muted);
    line-height: 1.35;
  }
  .table.sh-cards td[data-label=""]::before { content: none; }
  .table.sh-cards td[data-label=""] { padding-left: 1rem; }
  /* first column reads as the card's heading */
  .table.sh-cards td:first-child { padding-left: 1rem; font-weight: 500; font-size: 0.98rem; }
  .table.sh-cards td:first-child::before { position: static; display: block; width: auto; margin-bottom: 0.1rem; }
  .table.sh-cards td.sh-td-empty { display: none; }
  .table.sh-cards td.sh-td-span { padding: 0.75rem 1rem; text-align: center !important; }
  .table.sh-cards td.sh-td-actions {
    display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.5rem;
    padding-top: 0.5rem;
  }
  .table.sh-cards td.sh-td-actions:first-child { justify-content: flex-start; }
  .table.sh-cards td .nowrap, .table.sh-cards td.nowrap { white-space: normal; }
  .table.sh-cards td [style*="nowrap"] { white-space: normal !important; overflow: visible !important; }
  .table.sh-cards tbody tr:hover { background: transparent; }
  .table.sh-cards tr[onclick] { cursor: pointer; }
  .table.sh-cards tr[onclick]:active { background: var(--surface-2); }
}

/* ---------------------------------------------------------------------------
   Filter bars → "Filters" toggle on phones
   --------------------------------------------------------------------------- */
.sh-filter-toggle { display: none; }
@media (max-width: 640px) {
  .sh-filter-toggle { display: inline-flex; gap: 0.45rem; margin-bottom: 0.75rem; border: 1px solid var(--border); background: var(--surface); }
  .sh-filter-toggle svg { width: 16px; height: 16px; }
  .sh-filter-toggle[aria-expanded="true"] { background: var(--brand-tint); border-color: var(--brand-soft); color: var(--brand-dark); }
  form.sh-filters:not(.is-open) { display: none !important; }
  form.sh-filters.is-open { display: flex !important; flex-direction: column; align-items: stretch !important; gap: 0.6rem; width: 100%; margin-bottom: 1rem; }
  form.sh-filters.is-open.card { display: block !important; }
  form.sh-filters.is-open > .input, form.sh-filters.is-open > .select,
  form.sh-filters.is-open > input, form.sh-filters.is-open > select { max-width: none !important; width: 100%; }
  form.sh-filters.is-open > .btn { width: 100%; }
  form.sh-filters.is-open > div[style*="margin-left:auto"] { margin-left: 0 !important; }
}

/* ---------------------------------------------------------------------------
   Forms & modals on phones
   --------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .app .input, .app .select, .app .textarea,
  .app input[type="text"], .app input[type="search"], .app input[type="email"], .app input[type="tel"],
  .app input[type="number"], .app input[type="date"], .app input[type="datetime-local"], .app input[type="time"],
  .app input[type="password"], .app select, .app textarea,
  .modal .input, .modal .select, .modal .textarea { font-size: 16px; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-backdrop .modal {
    max-width: none !important;
    width: 100%;
    max-height: calc(100vh - 0.75rem);
    max-height: calc(100dvh - 0.75rem);
    border-radius: 18px 18px 0 0;
    animation: shSheetUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .modal-backdrop .modal .modal__head {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface);
    padding: 0.9rem 1rem;
  }
  .modal-backdrop .modal .modal__head .icon-btn { width: 44px; height: 44px; font-size: 1.4rem; }
  .modal-backdrop .modal .modal__body { padding: 1rem; }
  .modal-backdrop .modal .modal__body .grid-2,
  .modal-backdrop .modal .modal__body .grid-3 { grid-template-columns: 1fr; }
  .modal-backdrop .modal .modal__foot {
    position: sticky; bottom: 0; z-index: 2;
    padding: 0.75rem 1rem max(0.75rem, env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .modal-backdrop .modal .modal__foot .btn { flex: 1 1 auto; min-height: 46px; }
  html.sh-modal-open, html.sh-modal-open body { overflow: hidden; }
}
@keyframes shSheetUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ===========================================================================
   Client & staff portals
   =========================================================================== */
.sh-hello { font-size: 1.7rem; margin: 0.15rem 0 1.25rem; }
.sh-hello em { font-family: var(--font-display); font-style: italic; color: var(--brand); }
@media (max-width: 640px) { .sh-hello { font-size: 1.45rem; margin-bottom: 1rem; } }

/* Big call to action */
.sh-cta {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--brand-dark);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-brand);
  margin-bottom: 1.25rem;
  min-height: 64px;
}
.sh-cta:hover { color: #fff; filter: brightness(1.05); }
.sh-cta__icon { flex: 0 0 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; }
.sh-cta__icon svg { width: 22px; height: 22px; }
.sh-cta__text { flex: 1; min-width: 0; }
.sh-cta__title { display: block; font-weight: 600; font-size: 1.05rem; line-height: 1.25; }
.sh-cta__sub { display: block; font-size: 0.85rem; opacity: 0.85; }
.sh-cta__arrow { flex: 0 0 auto; font-size: 1.3rem; opacity: 0.9; }
[data-theme="dark"] .sh-cta { background: var(--brand); color: #231f20; }
[data-theme="dark"] .sh-cta:hover { color: #231f20; }
[data-theme="dark"] .sh-cta__icon { background: rgba(35,31,32,0.12); }

/* Next-visit card */
.sh-next { background: linear-gradient(135deg, var(--brand-tint), var(--surface)); border-color: var(--brand-soft); }
.sh-next__when { font-family: var(--font-display); font-size: 1.65rem; font-weight: 300; line-height: 1.15; margin-top: 0.35rem; }
.sh-next__time { font-size: 1.15rem; color: var(--brand-dark); margin: 0.15rem 0 0.85rem; font-weight: 500; }
[data-theme="dark"] .sh-next__time { color: var(--brand-light); }
.sh-next__meta { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-top: 0.25rem; }
.sh-next__meta > div { min-width: 0; }
.sh-next__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.sh-next__actions .btn { min-height: 44px; }
@media (max-width: 640px) {
  .sh-next__actions .btn { flex: 1 1 calc(50% - 0.25rem); }
  .sh-next__actions .btn.sh-wide { flex-basis: 100%; }
}

/* Who-gets-what list (single and group bookings) */
.sh-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.sh-person { display: flex; gap: 0.7rem; align-items: flex-start; }
.sh-person__av {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem;
}
[data-theme="dark"] .sh-person__av { color: var(--brand-light); }
.sh-person__main { flex: 1; min-width: 0; }
.sh-person__name { font-weight: 600; }
.sh-person__svc { line-height: 1.35; }
.sh-person__svc + .sh-person__svc { margin-top: 0.2rem; }
.sh-person__meta { font-size: 0.82rem; color: var(--ink-3); }
.sh-group-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--info-soft); color: var(--info);
}
.sh-group-tag svg { width: 13px; height: 13px; }

/* Booking cards (client + staff lists) */
.sh-list { display: grid; gap: 0.75rem; }
.sh-bk {
  display: flex; gap: 0.9rem; align-items: stretch;
  padding: 0.95rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: inherit; text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
a.sh-bk:hover { border-color: var(--brand-light); box-shadow: var(--shadow-sm); color: inherit; }
.sh-bk__date {
  flex: 0 0 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--brand-tint); color: var(--brand-dark);
  padding: 0.4rem 0.2rem; text-align: center; line-height: 1.1;
}
[data-theme="dark"] .sh-bk__date { color: var(--brand-light); }
.sh-bk__dow { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.sh-bk__day { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; }
.sh-bk__mon { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
.sh-bk__main { flex: 1; min-width: 0; }
.sh-bk__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.sh-bk__time { font-weight: 600; font-size: 1rem; }
.sh-bk__svc { margin-top: 0.15rem; line-height: 1.35; overflow-wrap: anywhere; }
.sh-bk__sub { font-size: 0.82rem; color: var(--ink-3); margin-top: 0.2rem; }
.sh-bk__foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: 0.45rem; font-size: 0.85rem; }
.sh-bk--past .sh-bk__date { background: var(--surface-3); color: var(--ink-3); }

.sh-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.sh-toolbar .chips { flex-wrap: nowrap; }
.sh-toolbar .chip { min-height: 40px; display: inline-flex; align-items: center; }
@media (max-width: 640px) {
  .sh-toolbar .sh-toolbar__cta { display: none; } /* the tab bar's "Book" covers it */
}

/* Detail page actions */
.sh-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.sh-actions .btn { min-height: 44px; }
.sh-actions form { margin: 0; }
@media (max-width: 640px) {
  .sh-actions > .btn, .sh-actions > form { flex: 1 1 100%; }
  .sh-actions > form .btn { width: 100%; }
}
.sh-svc-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--divider); }
.sh-svc-row:last-child { border-bottom: 0; }
.sh-svc-row__price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sh-person-block + .sh-person-block { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px dashed var(--border); }
.sh-person-block__head { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.25rem; }

/* ---- Staff "Today" ---- */
.sh-now {
  border: 1px solid var(--brand-soft);
  background: linear-gradient(135deg, var(--brand-tint), var(--surface));
}
.sh-now__label { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.sh-now__time { font-family: var(--font-display); font-size: 2rem; font-weight: 300; line-height: 1.1; margin-top: 0.35rem; }
.sh-now__time small { font-family: var(--font-body); font-size: 0.95rem; color: var(--ink-3); }
.sh-now__client { font-size: 1.2rem; font-weight: 600; margin-top: 0.5rem; }
.sh-now__svc { margin-top: 0.15rem; font-size: 1rem; }
.sh-now__group { margin-top: 0.4rem; font-size: 0.85rem; color: var(--ink-3); }
.sh-note {
  margin-top: 0.75rem; padding: 0.65rem 0.8rem;
  background: var(--warning-soft); color: var(--ink-2);
  border-radius: var(--radius-sm); font-size: 0.9rem;
  border-left: 3px solid var(--warning);
}
.sh-bigbtns { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.sh-bigbtns form { margin: 0; flex: 1 1 160px; display: flex; }
.sh-bigbtns .btn { min-height: 52px; font-size: 1rem; flex: 1 1 160px; }
.sh-bigbtns form .btn { width: 100%; }

.sh-day { display: grid; gap: 0.6rem; }
.sh-appt {
  display: grid; grid-template-columns: 86px minmax(0, 1fr) auto; gap: 0.75rem; align-items: center;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: inherit; text-decoration: none;
}
a.sh-appt:hover { border-color: var(--brand-light); color: inherit; }
.sh-appt__time { font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.sh-appt__time span { display: block; font-weight: 400; font-size: 0.78rem; color: var(--ink-muted); }
.sh-appt__who { font-weight: 500; overflow-wrap: anywhere; }
.sh-appt__svc { font-size: 0.86rem; color: var(--ink-3); overflow-wrap: anywhere; }
.sh-appt--done { opacity: 0.6; }
.sh-appt--now { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
@media (max-width: 400px) {
  .sh-appt { grid-template-columns: 80px minmax(0, 1fr); }
  .sh-appt > .badge { grid-column: 2; justify-self: start; }
}
.sh-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
@media (max-width: 900px) { .sh-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .sh-stats .stat { padding: 0.85rem 0.9rem; }
  .sh-stats .stat__value { font-size: 1.25rem; }
}

/* Staff schedule week strip: horizontal swipe on phones */
.sh-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.6rem; }
.sh-weekday { padding: 0.75rem; }
.sh-weekday.is-today { border-color: var(--brand); }
.sh-weekday__appt {
  display: block; padding: 0.4rem 0.5rem; margin-bottom: 4px;
  background: var(--brand-tint); border-left: 2px solid var(--brand); border-radius: 4px;
  text-decoration: none; color: inherit;
}
.sh-weekday__appt b { display: block; font-size: 0.75rem; color: var(--brand-dark); }
[data-theme="dark"] .sh-weekday__appt b { color: var(--brand-light); }
.sh-weekday__appt span { font-size: 0.8rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) { .sh-week { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .sh-week { grid-template-columns: 1fr; gap: 0.5rem; }
  .sh-weekday { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
  .sh-weekday__appt span { white-space: normal; }
}

/* Messages / loyalty / claim readability */
@media (max-width: 640px) {
  .sh-portal .card__head { padding: 0.9rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
  .sh-portal .card__body { padding: 1rem; }
}

/* Page header rows (title + action buttons) wrap instead of overflowing */
@media (max-width: 640px) {
  .content .flex-between { flex-wrap: wrap; gap: 0.75rem; }
  .content .flex-between > .flex { flex-wrap: wrap; }
  .content .card__head { flex-wrap: wrap; gap: 0.5rem; }
}

/* KPI tiles: two per row on phones instead of one tall column */
@media (max-width: 640px) {
  .content .grid:is(.grid-2, .grid-3, .grid-4):has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .content .grid:has(> .stat) > .stat { padding: 0.85rem 0.9rem; min-width: 0; }
  .content .grid:has(> .stat) .stat__value { font-size: 1.3rem; overflow-wrap: anywhere; }
  .content .grid:has(> .stat) .stat__label { font-size: 0.66rem; letter-spacing: 0.08em; }
  .content .grid:has(> .stat) .stat__icon { display: none; }
  .content .grid:has(> .stat) .stat__delta { font-size: 0.75rem; }
}

/* Card links keep body text colour (links are pink, esp. in dark mode) */
a.sh-bk, a.sh-bk:hover, a.sh-appt, a.sh-appt:hover { color: var(--ink); }
.sh-bk__foot > * { white-space: nowrap; }
.sh-bk__foot { flex-wrap: wrap; }
/* Links are pink in dark mode — tabs keep their own colours */
.sh-tabbar a.sh-tab:not(.is-active):not(.sh-tab--primary),
[data-theme="dark"] .sh-tabbar a.sh-tab:not(.is-active):not(.sh-tab--primary) { color: var(--ink-muted); }
.sh-tabbar a.sh-tab:not(.is-active):not(.sh-tab--primary):hover { color: var(--ink); }

/* v3.5 QA: on phones the live "new booking" alerts drop in from the top, so
   they never cover a page's sticky action bar (e.g. the new-booking form). */
@media (max-width: 640px) {
  body.sh-has-tabbar .booking-alerts {
    top: calc(64px + env(safe-area-inset-top, 0px)); bottom: auto !important;
    left: 0.75rem; right: 0.75rem; max-width: none;
  }
}
