/* N°3 Courchevel — shared calendar.
   Palette: slate blue, snow and timber from the N°3 brand image. Inter for the interface, Cormorant
   for the mark. One spacing scale (4/8/12/16/20/24/32), one control height, one radius family. */

:root {
  --paper: #f2f4f6;
  --paper-2: #e6ebf0;
  --track: var(--paper-2);
  --card: #fbfcfd;
  --ink: #16202b;
  --ink-soft: #3e4b58;
  --mute: #6b7784;
  --rule: #d6dde4;
  --accent: #3f5f7d;
  --danger: #b23b3b;
  --ok: #3f9b6b;
  --warn: #c29a5b;
  --backdrop: rgba(20, 28, 36, .55);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --h: 40px;          /* inputs and buttons */
  --h-sm: 32px;
  --r: 10px;
  --r-sm: 8px;
  --nav-w: 232px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #10161d;
  --paper-2: #1b232c;
  --track: #29333d;
  --card: #161d25;
  --ink: #e9eef3;
  --ink-soft: #b9c4cf;
  --mute: #8592a0;
  --rule: #29333d;
  --accent: #86a6c6;
  --danger: #e07a7a;
  --backdrop: rgba(0, 0, 0, .65);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: var(--font); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background-color .3s var(--ease), color .3s var(--ease); }
img { display: block; max-width: 100%; }
:root[data-theme="dark"] :is(.aptline, .ov__name, .apt-tab, .row__apt) img { filter: brightness(.78); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a, button, input, label { touch-action: manipulation; }
svg.ico, .nav__icon svg, .tab svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Background: mountains at the bottom, snow above them, everything else on top. */
.bg-mountains { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 42vh; min-height: 220px; pointer-events: none; z-index: 0; color: var(--ink); opacity: .05; }
:root[data-theme="dark"] .bg-mountains { opacity: .07; }
.bg-mountains__far { fill: currentColor; opacity: .45; }
.bg-mountains__snow { fill: var(--paper); opacity: .9; }
:root[data-theme="dark"] .bg-mountains__snow { fill: currentColor; opacity: 1; }
.bg-mountains__mid { fill: currentColor; opacity: .7; }
.bg-mountains__near { fill: currentColor; }
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; opacity: .5; }
:root[data-theme="dark"] #snow { opacity: .35; }
.login, .shell { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { #snow { display: none; } }

/* ---------- type ---------- */
.display { font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.kicker { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--mute); }
.muted { color: var(--mute); }
.muted a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }
.error:empty { display: none; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 32px 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 16px;
  border: 1px solid var(--ink); border-radius: var(--r-sm); background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 600; white-space: nowrap; transition: opacity .2s, border-color .2s, background-color .2s, transform .12s var(--ease);
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--rule); }
.btn--destructive { background: var(--danger); border-color: var(--danger); color: var(--paper); }
.btn--sm { height: var(--h-sm); padding: 0 12px; font-size: 12px; }
.btn--block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--h-sm); height: var(--h-sm); border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 18px; line-height: 1; color: var(--mute); }
.linkish { font-size: 13px; color: var(--mute); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.linkish:disabled { opacity: .45; cursor: default; text-decoration: none; }

/* One input style everywhere: left-aligned text, fixed height, so the cursor sits where the text is. */
.input, .field input, .member-add input, .money input, .entity__name { -webkit-appearance: none; appearance: none; }
.input, .field input, .member-add input {
  display: block; width: 100%; height: var(--h); padding: 0 12px; line-height: normal;
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .field input::placeholder, .member-add input::placeholder { color: var(--mute); opacity: .8; }
.input:focus, .field input:focus, .member-add input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.field { display: grid; gap: 8px; text-align: left; }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--mute); }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.mark { display: grid; gap: 4px; justify-items: start; }
.mark__n { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 400; font-size: 34px; line-height: 1; letter-spacing: -.01em; }
.mark__n sup { position: relative; top: .35em; margin: 0 1px 0 2px; font-size: .45em; vertical-align: top; }
.mark small { font-family: var(--font); font-size: 9px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; color: var(--mute); }

/* Segmented control (two or three choices) */
.seg { display: inline-flex; height: var(--h-sm); padding: 2px; gap: 2px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--card); }
.seg button { height: 100%; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--mute); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 600; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { --who: var(--mute); display: inline-flex; align-items: center; gap: 8px; height: var(--h-sm); padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 500; transition: border-color .15s, background-color .15s; }
.chip.is-on, .chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); font-weight: 600; }
.chip.is-on .dot, .chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px var(--paper); }

/* Toolbars: a row of controls with consistent spacing */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.season-bar { display: inline-flex; align-items: center; gap: 8px; }
.season-label { min-width: 140px; font-size: 13px; font-weight: 600; text-align: center; }

/* ---------- sign-in ---------- */
.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: max(32px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.login__box { display: grid; gap: 24px; width: min(380px, 100%); }
.login__box .mark { justify-self: center; justify-items: center; }
.login__box .mark__n { font-size: 56px; }
.login__text { display: grid; gap: 8px; text-align: center; }
.login__text h1 { font-size: 24px; }
.login__text p:empty { display: none; }
.login__text p, #dlg-sub, #dlg-hint, #ask-body, .pricing-default__label { text-wrap: balance; }
.login__form #login-error { margin-top: -8px; text-align: left; }
.login__form { display: grid; gap: 16px; }
.login__links { display: flex; justify-content: space-between; gap: 12px; }
.login__actions { display: flex; justify-content: center; gap: 8px; }
.login__actions:empty { display: none; }
#login-actors:empty { display: none; }
#login-error { margin-top: -8px; text-align: center; }
.code-input { font-size: 20px; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.actors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.actor-pick { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-align: left; border: 1px solid var(--rule); border-radius: var(--r); background: var(--card); transition: border-color .2s; }
.actor-pick strong { font-weight: 600; }
.actor-pick .role { display: block; font-size: 12px; color: var(--mute); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.nav { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; gap: 32px; height: 100vh; height: 100dvh; padding: 24px 16px; border-right: 1px solid var(--rule); background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.nav > .mark { padding: 0 12px; }
.nav__links { display: grid; gap: 4px; }
.nav__link { display: flex; align-items: center; gap: 12px; height: var(--h); padding: 0 12px; border-radius: var(--r-sm); font-weight: 500; color: var(--ink-soft); }
.nav__link .badge { margin-left: auto; }
.nav__icon { display: inline-flex; flex: none; }
.nav__icon svg { width: 18px; height: 18px; }
.nav__short { display: none; }
.nav__link.is-active { background: var(--ink); color: var(--paper); font-weight: 600; }
.badge { min-width: 20px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--paper); font-size: 11px; font-weight: 700; text-align: center; }
.nav__foot { display: grid; gap: 12px; margin-top: auto; }
.nav__me { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 12px; font-weight: 600; }
.nav__tools { display: flex; gap: 8px; }
.ico { display: none; width: 20px; height: 20px; }
.tabbar { display: none; }
.view { width: 100%; max-width: 1200px; padding: 40px 48px 80px; }
.view__head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; min-height: var(--h); margin-bottom: 24px; }
.view__head h1 { font-size: 26px; }

/* ---------- cards ---------- */
.card { display: grid; align-content: center; gap: 4px; padding: 20px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; margin: 0 0 16px; }
.card--ring { grid-template-columns: 88px 1fr; align-items: center; gap: 20px; }
.card--ring > div { display: grid; gap: 4px; }
.ring { width: 88px; height: 88px; transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: var(--track); stroke-width: 9; }
.ring__fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease); }
.stat__label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.stat__value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__value--sm { font-size: 24px; }
.stat__value small { margin-left: 2px; font-size: 16px; font-weight: 600; color: var(--mute); }
.stat__sub { font-size: 12px; color: var(--mute); }
.card--apts { gap: 0; padding: 4px 20px; }
.aptline { display: grid; grid-template-columns: 32px minmax(0, 1fr) minmax(80px, 1fr) 48px 96px; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--rule); white-space: nowrap; }
.aptline:first-child { border-top: 0; }
.aptline img { width: 32px; height: 32px; object-fit: cover; border-radius: var(--r-sm); }
.aptline__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.aptline__pct { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.aptline__n { font-size: 12px; color: var(--mute); text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 6px; overflow: hidden; border-radius: 3px; background: var(--track); }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.ov { display: grid; gap: 8px; padding: 20px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.ov__months { display: grid; column-gap: 3px; margin-left: 164px; font-size: 11px; font-weight: 600; color: var(--mute); }
.ov__months > span { white-space: nowrap; }
.m-short { display: none; }
.ov__row { display: grid; grid-template-columns: 164px 1fr; align-items: center; }
.ov__name { display: flex; align-items: center; gap: 8px; padding-right: 12px; font-size: 13px; font-weight: 600; }
.ov__name { min-width: 0; }
.ov__name img { flex: none; width: 24px; height: 24px; object-fit: cover; border-radius: 6px; }
.ov__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov__cells { display: flex; gap: 3px; }
.ov__cell { --who: var(--mute); flex: 1; height: 22px; border-radius: 4px; background: var(--track); }
.ov__cell.confirmed { background: var(--who); }
.ov__cell.option { background: color-mix(in srgb, var(--who) 25%, var(--card)); box-shadow: inset 0 0 0 1.5px var(--who); }
.ov + .legend { margin-top: 12px; }

/* ---------- calendar ---------- */
.apt-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.apt-tab { display: inline-flex; align-items: center; gap: 8px; height: var(--h); padding: 0 16px 0 4px; border: 1px solid var(--rule); border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 600; color: var(--mute); }
.apt-tab img { width: 30px; height: 30px; object-fit: cover; border-radius: 50%; }
.apt-tab[aria-selected="true"] { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.apt-tab--chalet { border-style: dashed; }
.apt-tab--chalet[aria-selected="true"] { border-style: solid; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.legend i.free { border: 1px solid var(--rule); background: var(--card); }
.legend i.dashed { border: 1.5px dashed var(--mute); background: color-mix(in srgb, var(--mute) 12%, transparent); }
.legend i.blocked { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--mute) 30%, var(--card)) 0 3px, var(--card) 3px 6px); border: 1px dashed var(--mute); }
.unit-note { margin: -8px 0 20px; text-wrap: balance; text-wrap: pretty; }

.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 32px; }
.month { display: grid; align-content: start; gap: 8px; padding: 16px; border: 1px solid var(--rule); border-radius: 12px; background: color-mix(in srgb, var(--card) 85%, transparent); }
.month__title { padding: 0 0 4px; font-size: 15px; font-weight: 600; }
.month__days { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 3px 2px; font-size: 11px; font-weight: 500; color: var(--mute); text-align: center; }
.wk {
  --who: var(--mute);
  position: relative; display: grid; grid-template-columns: repeat(7, 1fr); align-items: start;
  min-height: 56px; padding: 6px 2px 20px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink); text-align: center;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.wk:disabled { cursor: not-allowed; }
.wk.past .day { opacity: .35; }
.day { display: flex; align-items: center; justify-content: center; height: 22px; font-size: 13px; font-variant-numeric: tabular-nums; }
.day.other { color: var(--mute); opacity: .45; }
.day.today { font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.wk__tag, .wk__price { position: absolute; bottom: 6px; font-size: 10px; line-height: 1; pointer-events: none; }
.wk__tag { left: 10px; max-width: calc(100% - 96px); overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.wk__price { right: 10px; font-weight: 500; color: var(--mute); font-variant-numeric: tabular-nums; }
.wk.taken { border: 2px solid var(--who); border-bottom-width: 5px; padding-inline: 1px; }
.wk.taken .wk__tag { color: color-mix(in srgb, var(--who) 55%, var(--ink)); }
.wk.taken .wk__price { color: inherit; opacity: .8; }
.wk.taken.option { border-style: dashed; border-bottom-style: solid; background: color-mix(in srgb, var(--who) 10%, var(--card)); }
.wk.taken.confirmed { background: var(--who); color: var(--on-who, #fff); }
.wk.taken.confirmed .day, .wk.taken.confirmed .day.other { color: var(--on-who, #fff); opacity: 1; }
.wk.taken.confirmed .wk__tag, .wk.taken.confirmed .wk__price { color: var(--on-who, #fff); opacity: 1; }
.wk.taken.more { border-bottom-width: 2px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.wk.taken.cont { margin-top: -8px; border-top-width: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.wk.blocked { border-style: dashed; background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--mute) 16%, var(--card)) 0 4px, var(--card) 4px 9px); }
.wk.blocked .day { opacity: .55; }
.wk.blocked .wk__tag { color: var(--ink-soft); }

/* ---------- reservations ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; margin-bottom: 20px; padding: 16px 20px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.fgroup { display: grid; gap: 8px; }
.fgroup__label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.filters__reset { display: inline-flex; align-items: center; align-self: flex-end; height: var(--h-sm); margin-left: auto; padding: 0; }

/* Header and rows share the table's columns (subgrid), so every column lines up from row to row.
   The layout follows the width of the list itself: full table, then actions under each row,
   then one card per booking. */
#res-list { container-type: inline-size; }
.table { display: grid; grid-template-columns: 160px 160px minmax(150px, 1fr) 64px 100px 104px max-content; column-gap: 16px; overflow-x: auto; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.table--mine { grid-template-columns: 180px minmax(150px, 1fr) 64px 100px 104px max-content; }
.table__empty { grid-column: 1 / -1; padding: 20px; font-size: 13px; }
.thead, .row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; row-gap: 8px; align-items: center; padding: 0 20px; }
.thead { background: var(--paper-2); }
.th { display: inline-flex; align-items: center; gap: 4px; height: 40px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); text-align: left; }
.th.is-sorted { color: var(--ink); }
.th--num { justify-self: end; flex-direction: row-reverse; }
.th__arrow { display: inline-block; width: 10px; }
.thead__label { display: none; }
.row { min-height: 56px; padding-block: 12px; border-top: 1px solid var(--rule); font-size: 13px; }
.row--past { opacity: .55; }
.row__who, .row__apt { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row__who { font-weight: 600; }
.row__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__dur { display: none; color: var(--mute); white-space: nowrap; }
.row__apt img { width: 24px; height: 24px; object-fit: cover; border-radius: 6px; flex: none; }
.row__when { font-variant-numeric: tabular-nums; }
.row__note { display: block; margin-top: 2px; font-size: 12px; color: var(--mute); }
.row__num { color: var(--mute); text-align: right; font-variant-numeric: tabular-nums; }
.row__price { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.row__status { display: grid; justify-items: start; gap: 4px; }
.row__actions { display: flex; justify-content: flex-end; gap: 8px; }
.row__actions:empty { display: none; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.option { border-color: var(--accent); color: var(--accent); }
.pill.confirmed { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.countdown { font-size: 11px; font-weight: 600; color: var(--accent); }
@container (max-width: 1040px) {
  .table { grid-template-columns: 160px 160px minmax(150px, 1fr) 64px 100px 104px; }
  .table--mine { grid-template-columns: 180px minmax(150px, 1fr) 64px 100px 104px; }
  .thead > span:last-child { display: none; }
  .row__actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@container (max-width: 820px) {
  .table { display: block; }
  .thead { display: flex; flex-wrap: nowrap; gap: 0 16px; padding: 4px 16px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .thead::-webkit-scrollbar { display: none; }
  .thead::after { content: ""; flex: none; width: 1px; }
  .th, .thead__label { flex: none; }
  .th:not(.is-sorted) .th__arrow { display: none; }
  .th { min-width: 44px; justify-content: center; }
  .th { height: 32px; }
  .th--num { flex-direction: row; }
  .thead__label { display: inline-flex; align-items: center; font-size: 12px; color: var(--mute); }
  .thead__label::after { content: " :"; white-space: pre; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who price" "apt status" "when when" "actions actions"; gap: 8px 12px; padding: 12px 16px; }
  .table--mine .row { grid-template-areas: "apt status" "when price" "actions actions"; }
  .row__num { display: none; }
  .row__dur { display: inline; }
  .row__who .swatch { margin-inline: 7px; }
  .row__status { display: flex; flex-direction: row-reverse; align-items: center; gap: 8px; }
  .table--mine .row__status { flex-direction: column; align-items: flex-end; gap: 2px; }
  .row__who { grid-area: who; } .row__apt { grid-area: apt; } .row__when { grid-area: when; }
  .row__num { grid-area: num; } .row__price { grid-area: price; } .row__status { grid-area: status; justify-items: end; }
  .row__actions { grid-area: actions; justify-content: flex-start; margin-top: 4px; }
}

/* ---------- pricing ---------- */
.money { position: relative; display: block; }
.money input { width: 100%; height: var(--h); padding: 0 32px 0 12px; line-height: normal; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--card); text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s; }
.money input::placeholder { color: var(--mute); font-weight: 400; }
.money input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.money input.is-invalid, .money input.is-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.money i { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); font-size: 12px; font-style: normal; color: var(--mute); pointer-events: none; }
.pricing-default { margin-bottom: 16px; }
.pricing-default__row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; align-items: center; gap: 24px; }
.pricing-default__label { display: grid; gap: 4px; }
#pricing-error { margin: -4px 0 16px; }
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; padding: 4px 20px 20px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.pricing-grid__month { grid-column: 1 / -1; padding: 16px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; align-items: center; gap: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.price-row__week { color: var(--mute); }
.price-row__week b { font-weight: 600; color: var(--ink); }
.price-row.is-override .money input { border-color: var(--accent); color: var(--accent); }
.price-row.is-override .money i { color: var(--accent); }

/* ---------- people ---------- */
.entities { display: grid; gap: 16px; }
.entity { overflow: hidden; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.entity--new { border-style: dashed; }
.entity__head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--rule); }
.entity--new .entity__head { border-bottom: 0; }
.swatch-pick { position: relative; flex: none; width: 32px; height: 32px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--c, var(--mute)); cursor: pointer; }
.swatch-pick input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.swatch-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.entity__name { flex: 1; min-width: 0; height: var(--h); padding: 0 12px; line-height: normal; text-overflow: ellipsis; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font-size: 15px; font-weight: 600; }
.entity__name:focus { border-color: var(--ink); outline: none; background: var(--paper); }
.entity__role { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.members { list-style: none; }
.member { display: grid; grid-template-columns: minmax(0, 1fr) 240px 224px; align-items: center; gap: 16px; min-height: 56px; padding: 8px 20px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.member--empty { display: flex; align-items: center; color: var(--mute); }
.member__who { display: grid; gap: 2px; min-width: 0; }
.member__who b { font-weight: 600; }
.member__who span { color: var(--mute); overflow-wrap: anywhere; }
.member__status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; }
.member__status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--mute); }
.member__status.is-active::before { background: var(--ok); }
.member__status.is-pending { color: var(--mute); }
.member__status.is-pending::before { background: var(--warn); }
.member__status.is-error { color: var(--danger); }
.member__status.is-error::before { background: var(--danger); }
.member__actions { display: flex; justify-content: flex-end; gap: 8px; }
.member-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) 104px; align-items: end; gap: 12px; padding: 16px 20px; background: color-mix(in srgb, var(--paper) 60%, var(--card)); }
.member-add .btn { width: 100%; }
.member-add-toggle { display: none; }
.entity__error { padding: 0 20px 16px; background: color-mix(in srgb, var(--paper) 60%, var(--card)); }
@media (max-width: 1100px) {
  .member { grid-template-columns: 1fr; gap: 8px; }
  .member__actions { justify-content: flex-start; }
}

/* ---------- dialogs ---------- */
dialog { position: fixed; z-index: 3; width: min(460px, calc(100% - 32px)); margin: auto; padding: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); color: var(--ink); }
#resdlg { width: min(540px, calc(100% - 32px)); }
dialog::backdrop { background: var(--backdrop); }
.dlg { display: grid; gap: 16px; padding: 24px; }
.dlg h2 { font-size: 20px; }
.dlg h2:focus { outline: none; }
.dlg__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg__head > div { display: grid; gap: 4px; }
.dlg__close { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--h-sm); height: var(--h-sm); margin: -4px -6px 0 0; border-radius: 50%; color: var(--mute); font-size: 14px; }
.dlg__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg__actions .btn--danger { margin-right: auto; }
.stepper { display: inline-flex; align-items: stretch; height: var(--h); overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r-sm); justify-self: start; }
.stepper__btn { width: var(--h); background: var(--paper); font-size: 18px; }
.stepper__btn:disabled { opacity: .3; cursor: not-allowed; }
.stepper__value { display: flex; align-items: center; justify-content: center; min-width: 128px; border-inline: 1px solid var(--rule); font-weight: 600; }
.total { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); }
.total strong { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; padding: 16px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); font-size: 13px; }
.facts dt { color: var(--mute); }
.facts dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.facts dd .muted { font-weight: 400; white-space: nowrap; }
.facts .swatch { margin-right: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 10; width: max-content; max-width: calc(100vw - 32px); padding: 10px 16px; text-align: center; border-radius: var(--r-sm); background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 500; transform: translateX(-50%); }

/* ---------- pointer states ---------- */
/* Hover effects only where there is a mouse: on a phone they would stay "stuck" after a tap. */
@media (hover: hover) {
  .btn:hover { opacity: .88; }
  .btn--ghost:hover { opacity: 1; border-color: var(--ink); }
  .btn--danger:hover { opacity: 1; border-color: var(--danger); }
  .icon-btn:hover { border-color: var(--ink); color: var(--ink); }
  .linkish:hover:not(:disabled) { color: var(--ink); }
  .seg button:not([aria-pressed="true"]):hover { color: var(--ink); }
  .chip:hover { border-color: var(--ink); }
  .actor-pick:hover { border-color: var(--ink); }
  .nav__link:not(.is-active):hover { background: var(--paper-2); color: var(--ink); }
  .aptline:hover .aptline__name { color: var(--accent); }
  .ov__name:hover { color: var(--accent); }
  .apt-tab:hover { color: var(--ink); }
  .wk:not(:disabled):hover { border-color: var(--ink); }
  .th:hover { color: var(--ink); }
  .entity__name:not(:focus):hover { border-color: var(--rule); }
  .dlg__close:hover { background: var(--paper-2); color: var(--ink); }
  .stepper__btn:hover:not(:disabled) { background: var(--paper-2); }
}
/* A short press feedback on touch screens (and with a mouse). */
.btn:active:not(:disabled), .icon-btn:active, .chip:active, .apt-tab:active, .seg button:active, .tab:active { transform: scale(.97); }
.wk:active:not(:disabled) { transform: scale(.985); }
.chip, .apt-tab, .icon-btn, .tab, .wk { transition-property: border-color, background-color, color, transform; transition-duration: .15s; }

/* ---------- small screens: phones and tablets ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Top bar: the mark, who is signed in, night mode and sign-out (icons). */
  .nav {
    position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; gap: 12px;
    height: auto; min-height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    border-right: 0; border-bottom: 1px solid var(--rule);
    background: color-mix(in srgb, var(--paper) 86%, transparent); -webkit-backdrop-filter: saturate(1.3) blur(12px); backdrop-filter: saturate(1.3) blur(12px);
  }
  .nav > .mark { gap: 2px; padding: 0; }
  .nav .mark__n { font-size: 26px; }
  .nav .mark small { font-size: 7px; letter-spacing: .3em; }
  .nav__links { display: none; }
  .nav__foot { display: flex; align-items: center; gap: 4px; min-width: 0; margin: 0 0 0 auto; }
  .nav__me { min-width: 0; padding: 0 4px 0 0; font-size: 13px; }
  #whoami-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav__tools { flex: none; gap: 0; margin-right: -10px; }
  .nav__tool { width: 40px; height: 40px; padding: 0; border-color: transparent; background: transparent; }
  .nav__tool .ico { display: block; }
  :root[data-theme="dark"] .nav__tool .ico--moon, :root:not([data-theme="dark"]) .nav__tool .ico--sun { display: none; }
  .nav__tool-text { display: none; }

  /* Bottom tab bar, above the iPhone home indicator. */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--rule);
    background: color-mix(in srgb, var(--paper) 88%, transparent); -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
  }
  .tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 4px; min-width: 0; height: 56px; color: var(--mute); font-size: 11px; font-weight: 500; line-height: 1; }
  .tab svg { width: 24px; height: 24px; }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.is-active { color: var(--ink); font-weight: 600; }
  .tab.is-active svg { stroke-width: 2.2; }
  .tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 2px 5px; font-size: 11px; line-height: 1.2; }
  .nav > .mark { min-height: 40px; align-content: center; }

  .view { padding: 20px max(16px, env(safe-area-inset-right)) calc(56px + 40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .view__head { margin-bottom: 20px; }
  .view__head h1 { font-size: 24px; }
  .dash { grid-template-columns: 1fr; }
  .aptline { grid-template-columns: 32px minmax(0, 1fr) 48px; gap: 8px 12px; }
  .aptline .bar { grid-column: 2 / -1; grid-row: 2; }
  .aptline__n { display: none; }
  .m-long { display: none; }
  .m-short { display: inline; }
  .ov { padding: 16px; }
  .ov__months { margin-left: 88px; }
  .ov__row { grid-template-columns: 88px minmax(0, 1fr); }
  .card { padding: 16px; }
  .card--apts { padding: 4px 16px; }
  #view-dashboard .view__head { row-gap: 4px; }

  /* Calendar: the four tabs in a 2 x 2 grid, all visible. */
  .apt-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .apt-tab { min-width: 0; }
  .apt-tab__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .weeks { grid-template-columns: 1fr; gap: 20px; }
  .wk__tag, .wk__price { font-size: 11px; }

  /* Reservations: each filter is one row of chips that scrolls sideways. */
  .filters { gap: 16px; padding: 16px; }
  .fgroup { width: 100%; min-width: 0; }
  .fgroup .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; overscroll-behavior-x: contain; }
  .fgroup .chips::-webkit-scrollbar { display: none; }
  .fgroup .chips { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
  .chip { flex: none; }
  .filters__reset { margin-left: 0; }

  /* Prices: the save button floats above the tab bar, always within reach. */
  .pricing-grid { grid-template-columns: 1fr; padding: 4px 16px 16px; }
  .pricing-default__row { grid-template-columns: 1fr; gap: 12px; }
  #pricing-save { display: none; }
  body.has-unsaved-prices #pricing-save { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(56px + 16px + env(safe-area-inset-bottom)); z-index: 7; display: inline-flex; height: 48px; padding: 0 24px; border-radius: 999px; box-shadow: 0 8px 24px rgba(16, 22, 29, .22); animation: pop-in .2s var(--ease); }
  body.has-unsaved-prices #view-pricing { padding-bottom: 72px; }

  .entity__head { padding: 12px 16px; }
  .member { padding: 12px 16px; }
  .member-add { display: none; grid-template-columns: 1fr; padding: 16px; }
  .entity.is-adding .member-add { display: grid; }
  .member-add-toggle { display: flex; width: calc(100% - 32px); margin: 16px; }
  .entity.is-adding .member-add-toggle { display: none; }
  .member-add .btn { width: 100%; }
  .entity__error { padding: 0 16px 16px; }

  /* Messages at the top, clear of the tab bar and the floating button. */
  .toast { top: calc(env(safe-area-inset-top) + 68px); bottom: auto; }

  /* iOS zooms into text fields smaller than 16px: keep them at 16px. */
  .input, .field input, .member-add input, .money input, .entity__name { font-size: 16px; }
  .field .code-input { font-size: 20px; }
}

/* Phones in landscape (short screens): compact top bar and tab bar (icon beside the label). */
@media (max-width: 960px) and (max-height: 500px) {
  .nav { min-height: calc(44px + env(safe-area-inset-top)); }
  .tab { display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; }
  .tab svg { flex: none; width: 20px; height: 20px; }
  .tab span { min-width: 0; }
  .tab .badge { position: static; flex: none; }
  .view { padding-bottom: calc(44px + 40px + env(safe-area-inset-bottom)); }
  body.has-unsaved-prices #pricing-save { bottom: calc(44px + 16px + env(safe-area-inset-bottom)); }
  .toast { top: calc(env(safe-area-inset-top) + 56px); }
}
@media (max-height: 500px) {
  .login { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .login__box { gap: 12px; }
  .login__box .mark__n { font-size: 40px; }
  .login__box .mark small { display: none; }
  .login__text h1 { font-size: 20px; }
}

/* Phones: popups slide up from the bottom (sheets), buttons pinned at the bottom.
   Also on short (landscape) screens, where a centered popup would not fit. */
@media (max-width: 560px), (max-height: 500px) {
  dialog, #resdlg {
    width: 100%; max-width: 100%; margin: 0; inset: auto 0 0 0;
    max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
    border-width: 1px 0 0; border-radius: 16px 16px 0 0;
    overscroll-behavior: contain;
  }
  dialog { overflow-y: auto; }
  dialog[open] { animation: sheet-up .26s var(--ease); }
  .dlg { padding: 24px max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); }
  .dlg__actions {
    position: sticky; bottom: 0; z-index: 1; flex-direction: column-reverse; align-items: stretch;
    margin: 0 calc(-1 * max(20px, env(safe-area-inset-right))) 0 calc(-1 * max(20px, env(safe-area-inset-left)));
    padding: 12px max(20px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background: var(--card); box-shadow: 0 -1px 0 var(--rule);
  }
  .dlg__actions .btn--danger { margin-right: 0; }
  .facts { grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; }
}
@media (max-height: 500px) and (min-width: 561px) {
  dialog, #resdlg { width: min(600px, calc(100% - 2 * max(16px, env(safe-area-inset-left)))); margin: 0 auto; border-width: 1px 1px 0; }
  .dlg { gap: 12px; padding: 16px 24px 0; }
  .dlg__actions { flex-direction: row; align-items: center; justify-content: flex-end; margin: 0 -24px; padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); }
  .dlg__actions .btn--danger { margin-right: auto; }
}
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(32px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
/* No page scrolling behind an open popup. */
html:has(dialog[open]) { overflow: hidden; }

/* Touch screens: controls at least 40-44px high (Apple recommends 44pt). */
@media (pointer: coarse) {
  :root { --h: 44px; --h-sm: 40px; }
  .th { height: 40px; }
  .dlg__close { width: 40px; height: 40px; margin: -8px -10px 0 0; }
  .linkish { padding: 12px 0; }
  .ov__name { min-height: 40px; }
  .swatch-pick { width: 40px; height: 40px; }
  .apt-tab { padding-left: 6px; }
}
