/* Shared interaction and responsive refinements. Keep the Energy House identity. */
:root {
  color-scheme: dark;
  --dim: #a0a9b6;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --header-offset: 80px;
}
html { scroll-padding-top: var(--header-offset); }
body { line-height: 1.5; }
[hidden] { display: none !important; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--lime); outline-offset: 4px;
}
#main-content:focus { outline: none; }
:where(input, select, textarea) { min-width: 0; }
:where(h1, h2, h3) { text-wrap: balance; }
:where(p, .rname, .mname, .cls-name, .pb-title, .task-main, .why) { overflow-wrap: anywhere; }
:where(.grid-2, .two-col, .reception-grid, .row2, .row3, .facts, .kpi-row) > * { min-width: 0; }
:where(button, .btn, .nav a, .tabbar a, .settings-nav a, .tabs a, .day-tabs a, .lang-seg a, summary) {
  -webkit-tap-highlight-color: transparent;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms var(--ease), box-shadow 180ms ease;
  touch-action: manipulation;
}
:where(button, .btn):active:not(:disabled) { transform: translateY(1px); }
:where(input, textarea, select) { transition: border-color 160ms ease, box-shadow 160ms ease; }
:where(input, textarea, select):focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--lime) 12%, transparent); }
.seg label:has(input:focus-visible), .plan-grid label:has(input:focus-visible) { outline: 2px solid var(--lime); outline-offset: 4px; }
.amount:focus-within, .search-box:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--lime) 12%, transparent); }
.skip-link { position: fixed; inset-block-start: 8px; inset-inline-start: 16px; z-index: 100; padding: 12px 18px; background: var(--lime); color: var(--ink); border-radius: 10px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); color: var(--ink); }
.main { padding-block-start: 28px; }
.page-head { gap: 16px; margin-bottom: 24px; }
.card { border-color: #272d35; }
label, .radios legend { color: var(--text-2); letter-spacing: .025em; }
input::placeholder, textarea::placeholder { opacity: 1; }
.small-btn { min-height: 40px; }
.lang-seg a { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.top { gap: 12px; }
.top .brand, .top .tools { flex-shrink: 0; }
.nav a { padding-inline: 11px; }
.nav-toggle { display: none; }
.menu-lines { width: 16px; height: 10px; border-block: 2px solid currentColor; }
.nav-open .menu-lines { height: 2px; border-bottom: 0; }
.nav a.on { box-shadow: 0 2px 10px #0002; }

/* Reception keeps search usable alongside the new-member and scanner actions. */
.search { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.search .search-box { grid-column: 1 / -1; width: 100%; min-width: 0; }
.search .search-box input { min-width: 0; width: 100%; }
.search > .btn { min-width: 0; padding-inline: 12px; min-height: 44px; font-size: .875rem; }
.search-col { min-width: 0; }
.results { gap: 10px; }
.results li a { grid-template-columns: 40px minmax(0, 1fr); }
.results .badge { grid-column: 2; grid-row: auto; justify-self: start; margin-top: 6px; }
.results .badge.due { grid-row: auto; }
.results .rphone { overflow-wrap: anywhere; }
.results [aria-current] { border-color: var(--lime); }
.results[aria-busy="true"] { opacity: .65; transition: opacity 150ms; }
.results-head { min-height: 26px; }
.member-head { gap: 14px; }
.member-head > div:not(.status) { min-width: 0; }
.member-head .mname { font-size: clamp(1.35rem, 2vw, 1.85rem); line-height: 1.25; }
.member-head .status { flex-shrink: 0; }
.member-head .badge.big { font-size: .85rem; min-height: 36px; padding: 8px 12px; }
.member .facts { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); margin-top: 20px; }
.facts .tile { padding: 12px; }
.facts .tile dd { font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; }
.card > .panel > summary { justify-content: flex-start; padding: 14px 16px; }
.card > .panel > summary::before { content: none; }
.card > .panel > summary::after { margin-inline-start: auto; }
.panel summary .badge { margin-inline-start: auto; max-width: 60%; white-space: normal; text-align: start; }
.primary-actions { margin-block: 16px; }
.checkin-form input { min-width: min(220px, 100%); }
.panel[open] > :not(summary) { animation: ui-enter 200ms var(--ease); }

/* Tables scroll within their own region, with an explicit hint and keyboard access. */
.tbl { max-width: 100%; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tbl th { line-height: 1.5; }
.tbl td.num { white-space: nowrap; }
.tbl th, .tbl td { padding: 12px 10px; }
.tbl tbody tr { transition: background-color 150ms; }
.table-hint { margin: 4px 0 8px; color: var(--muted); font-size: .78rem; }
.kpi .v { overflow-wrap: anywhere; }
.view-expenses .kpi .v { font-size: clamp(1.25rem, 2.2vw, 2rem); }
.view-owner .hero { padding: 26px; }
.hero .total .v { font-size: clamp(2.4rem, 4vw, 3.5rem); }
.hero .top-row { flex-wrap: wrap; gap: 8px; }
.list.audit .who-when { grid-row: auto; }
.settings-nav { gap: 8px; }
.settings-nav a { min-height: 40px; display: inline-flex; align-items: center; }
.settings-nav a.on { box-shadow: inset 0 0 0 1px var(--lime); }
.view-settings section.card { scroll-margin-top: var(--header-offset); }
.task-ctl { gap: 8px; }
.pb-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.pb-card { padding: 22px; }
.pb-card .pb-desc { line-height: 1.7; }
.pb-ex-fields, .pb-ex-notes { min-width: 0; }
.week-edit { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

/* Login, dialogs and persistent status. */
.login { margin-block: clamp(20px, 6vh, 64px); padding: 32px; }
.password-control { position: relative; display: flex; align-items: center; }
.password-control input { padding-inline-end: 92px; }
.password-toggle { position: absolute; inset-inline-end: 4px; background: transparent; padding: 6px 10px; min-height: 38px; border: 0; font-size: .78rem; color: var(--text-2); }
.flash { display: flex; align-items: center; gap: 12px; max-width: 1360px; margin-inline: auto; }
.flash > span { flex: 1; }
.flash-dismiss { color: inherit; border: 0; min-width: 44px; padding: 4px; font-size: 1.35rem; flex-shrink: 0; }
.confirm-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); border: 1px solid var(--line-2); border-radius: 20px; padding: 28px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px #0008; }
.confirm-dialog::backdrop { background: #05070bd9; backdrop-filter: blur(4px); }
.confirm-dialog[open], dialog.cam-dialog[open] { animation: ui-enter 220ms var(--ease); }
.confirm-dialog .actions-row { justify-content: flex-end; margin-top: 24px; }
.confirm-dialog p { color: var(--text-2); line-height: 1.65; }
.cam-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
button[aria-disabled="true"] { cursor: wait; opacity: .75; }
form[aria-busy="true"] button[type="submit"]::after, form[aria-busy="true"] button:not([type])::after { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: ui-spin 800ms linear infinite; }

/* Member app: safe areas, readable sessions and a centered desktop shell. */
.app-shell { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.app-main { max-width: 680px; padding-top: max(16px, env(safe-area-inset-top)); }
.app-head { flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.app-head > div:first-child { flex: 1; min-width: 120px; }
.app-head h1 { line-height: 1.3; }
.app-head .lang-seg { flex-shrink: 0; }
.app-head > .logo-big, .app-head > svg:last-child { flex-shrink: 0; }
.tabbar { height: calc(72px + env(safe-area-inset-bottom)); }
.tabbar a { min-height: 52px; font-size: .72rem; }
.tabbar a.on { background: var(--lime-bg); }
.member-hero { padding: 22px; }
.member-hero .top-row { flex-wrap: wrap; }
.member-hero .countdown .until { flex-basis: 100%; margin: 0; }
.exercise { color: var(--text); }
.exercise .txt > .num { color: var(--lime); font-size: .875rem; }
.exercise .txt .small { line-height: 1.6; }
.exercise .thumb { width: 72px; height: 72px; }
.day-tabs { flex-wrap: wrap; }
.day-tabs a { min-width: 70px; }
.head-actions { flex-wrap: wrap; margin-bottom: 14px; }
.session-bar { bottom: calc(72px + env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 8px; }
.app-shell:has(.session-bar) { padding-bottom: calc(172px + env(safe-area-inset-bottom)); }
.set-row input { min-width: 0; }
.set-feedback { grid-column: 1 / -1; color: var(--red-t); font-size: .8rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-feedback button { margin-inline-start: auto; }
.set-row.saving { opacity: .75; }
.set-row.on { transition: background-color 200ms, border-color 200ms; }
#session-status:not(:empty) { padding: 12px; border: 1px solid var(--orange-line); border-radius: 10px; color: var(--orange-t); }
.rest-timer { bottom: calc(154px + env(safe-area-inset-bottom)); }
html[dir="rtl"] .exercise .chev, html[dir="rtl"] .app-head > .icon-btn svg { transform: scaleX(-1); }

@media (hover: hover) {
  .tbl tbody tr:hover { background: var(--surface-2); }
  a.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
  a.card { transition: transform 200ms var(--ease), border-color 200ms; }
}
@media (min-width: 961px) {
  .search-col { position: sticky; top: var(--header-offset); }
  .search-col .results { max-height: calc(100dvh - 280px); overflow-y: auto; scrollbar-width: thin; padding: 4px; margin-inline: -4px; }
  .view-settings .page-head { align-items: flex-start; }
  .view-settings .settings-nav { max-width: 82%; }
}
@media (min-width: 721px) {
  .app-main { padding: 28px 24px; }
  .tabbar { max-width: 680px; margin-inline: auto; border: 1px solid var(--line-2); border-radius: 18px 18px 0 0; }
  .session-bar { max-width: 680px; margin-inline: auto; }
}
@media (max-width: 1250px) {
  .top { height: auto; min-height: 68px; flex-wrap: wrap; padding: 10px 20px; }
  .top .brand-name { display: inline; }
  .nav { order: 3; flex-basis: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; overflow: visible; padding-block: 8px; }
  .nav a { border-radius: 10px; white-space: normal; min-height: 44px; display: flex; align-items: center; }
  .top:has(.nav) .tools { order: 4; width: 100%; flex-wrap: wrap; margin: 0; padding-block: 8px; border-top: 1px solid var(--line-2); }
  .ui-ready .nav-toggle { display: inline-flex; margin-inline-start: auto; }
  .ui-ready .top:has(.nav):not(.nav-open) :is(.nav, .tools) { display: none; }
  .top.nav-open { max-height: 90dvh; overflow-y: auto; }
  .top .who span:last-child, .top .clock-btn span { display: inline; }
}
@media (max-width: 600px) {
  html { font-size: 16px; }
  :root { --pad: 16px; --header-offset: 84px; }
  .top { padding: 10px 16px; min-height: 64px; }
  .top .brand-name { font-size: .95rem; max-width: 180px; overflow-wrap: anywhere; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px 16px 40px; }
  .page-head { margin-bottom: 20px; align-items: flex-start; }
  .page-head h1 { font-size: 1.5rem; line-height: 1.3; }
  .card { padding: 18px; border-radius: 16px; }
  input, textarea, select { font-size: 16px; }
  .small-btn, .lang-seg a, .tabs a, .settings-nav a, .pb-icon { min-height: 44px; }
  .lang-seg a { min-width: 38px; }
  .reception-grid { gap: 12px; }
  .member-head { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
  .member-head .avatar-sq { width: 44px; height: 44px; border-radius: 12px; font-size: 1rem; }
  .member-head .mname { font-size: 1.25rem; }
  .member-head .num { font-size: .8rem; }
  .member-head .status { grid-column: 1 / -1; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
  .member-head .status .small { font-size: .75rem; }
  .member .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 14px; }
  .facts .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .primary-actions { gap: 8px; margin-block: 12px; }
  .primary-actions .big { min-height: 48px; padding: 10px 12px; font-size: .875rem; }
  .primary-actions .checkin-form { flex-basis: auto; }
  .checkin-form:has(input) { flex-basis: 100%; }
  .card > .panel > summary { font-size: .9rem; padding: 14px 12px; }
  .panel form, .panel .panel-body { padding: 14px 12px; }
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-grid label { padding: 12px 10px; }
  .plan-grid label .price { font-size: 1.1rem; }
  .seg { flex-wrap: wrap; }
  .seg label { flex: 1 1 80px; }
  .view-expenses .kpi-row { grid-template-columns: 1fr; }
  .view-expenses .kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .view-expenses .kpi .v { font-size: 1.5rem; grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .view-expenses .kpi .small { grid-column: 1; }
  .month-card .split b { font-size: clamp(.875rem, 4vw, 1.1rem); }
  .view-owner .hero { padding: 22px; }
  .hero .split { gap: 10px; }
  .task-ctl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-ctl select { width: 100%; min-width: 0; }
  .task-ctl button { grid-column: 1 / -1; }
  .settings-nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding: 4px 2px 10px; scrollbar-width: thin; }
  .settings-nav a { flex-shrink: 0; }
  .flash { margin: 12px 16px 0; font-size: .875rem; }
  .login { padding: 24px 20px; }
  .app-main { padding-inline: 16px; }
  .app-head h1 { font-size: 1.4rem; }
  .app-head .lang-seg a { min-width: 32px; padding-inline: 6px; }
  .app-head > svg:last-child { display: none; }
  .exercise { gap: 12px; padding: 14px; }
  .exercise .thumb { width: 60px; height: 60px; }
  .exercise .txt b { font-size: .95rem; }
  .program-card .row { flex-wrap: wrap; }
  .session-bar .btn, .session-bar button { min-height: 44px; font-size: .875rem; padding: 10px 12px; }
  .ex-nav .btn { white-space: normal; line-height: 1.5; display: flex; align-items: center; }
  .imp-steps { gap: 6px; }
}
@keyframes ui-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .main, .app-main { animation: ui-enter 260ms var(--ease); }
  .flash { animation: ui-enter 220ms var(--ease); }
  .nav-open .nav { animation: ui-enter 180ms var(--ease); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .skip-link, .table-hint, .tabbar, .session-bar, .nav-toggle, .confirm-dialog { display: none !important; }
}
/* Follow-up findings from narrow-screen and contrast checks. */
.pb-thumb .muted { color: #47515e; }
.cls-row.cancelled, .cls-row.done, .week-grid span.off { opacity: 1; }
.cls-row.done { background: var(--ink); }
.cls-range { overflow-wrap: anywhere; min-width: 0; }
.cls-week > *, .cls-daycol .cls-row > * { min-width: 0; }
.cls-daycol .badge { white-space: normal; }
.week-edit .schedule-times { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.week-edit .schedule-times > span { color: var(--muted); font-size: .8rem; font-weight: 700; }
@media (max-width: 600px) {
  .cls-daynav .cls-range { flex-basis: 100%; margin-inline: 0; font-size: .8rem; }
}
.week-grid .day.off { opacity: 1; }
.search-box input:focus-visible, .amount input:focus-visible { box-shadow: none; outline: none; }
.session-bar { z-index: 15; padding: 12px; border: 1px solid var(--line-2); border-radius: 16px 16px 0 0; background: var(--ink); box-shadow: 0 -8px 24px #0003; }
