/* Family Residence owner panel. Needs tokens.css and site.css first. Every class starts with ow- or fg-.
   A tool for daily work: stone ground, espresso sidebar, tight spacing, no decoration. Spec: design/DESIGN.md section 9. */

.ow { --side-w: 248px; --ow-pad: clamp(1rem, 2.6vw, 2.25rem); background-image: none; font-size: var(--fs-small); line-height: 1.45; }

/* ---------- shell ---------- */
.ow-shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100svh; }
.ow-side { display: none; }
.ow-main { min-width: 0; padding: var(--ow-pad); display: grid; gap: var(--s-5); align-content: start; }
@media (min-width: 900px) {
  .ow-shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .ow-side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100svh; overflow-y: auto; padding: var(--s-4) var(--s-3); }
  .ow-mobilebar { display: none !important; }
}
.ow-brand { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: var(--s-1) var(--s-2) var(--s-4); text-decoration: none; }
.ow-brand img { width: 36px; height: auto; }
.ow-brand b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.125rem; line-height: 1.15; white-space: nowrap; }
.ow-brand small { display: block; font-size: var(--fs-label); color: var(--text-quiet); }
.ow-nav { display: grid; gap: 1px; }
.ow-nav__link { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: 8px 10px; border-radius: var(--r-1); font-size: var(--fs-small); text-decoration: none; color: var(--text-quiet); transition: background var(--t-fast), color var(--t-fast); }
.ow-nav__link:hover { background: var(--bg-raised); color: var(--text); }
.ow-nav__link[aria-current="page"] { background: var(--bg-raised); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--ochre-500); }
.ow-nav__badge { margin-left: auto; min-width: 22px; padding: 1px 6px; background: var(--ochre-500); color: var(--espresso-900); font-size: var(--fs-label); font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.ow-side__foot { margin-top: auto; padding: var(--s-4) var(--s-2) var(--s-1); display: grid; gap: var(--s-1); border-top: 1px solid var(--line); font-size: var(--fs-label); color: var(--text-quiet); }
.ow-side__foot a { min-height: var(--tap); display: inline-flex; align-items: center; color: var(--text); }

.ow-mobilebar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 60px; padding: 0 var(--s-4); }
.ow-mobilebar .ow-brand { padding: 0; }
.ow-drawer > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); min-width: var(--tap); padding-inline: var(--s-2); font-weight: 600; cursor: pointer; }
.ow-drawer > summary::-webkit-details-marker { display: none; }
.ow-drawer__panel { position: fixed; z-index: 39; left: 0; right: 0; top: 60px; bottom: 0; overflow-y: auto; padding: var(--s-3) var(--s-4) var(--s-6); background: var(--espresso-900); }
.ow-drawer__panel .ow-nav__link { font-size: 1.0625rem; min-height: 52px; }
html:has(.ow-drawer[open]) { overflow: hidden; }

/* ---------- page head ---------- */
.ow-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-5); }
.ow-head__title { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.625rem, 1.4rem + 1vw, 2.25rem); line-height: 1.15; }
.ow-head__sub { color: var(--text-quiet); }
.ow-head__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ow .btn { min-height: var(--tap); padding: 8px 16px; font-size: var(--fs-small); }
.ow .btn--icon { padding: 0; }

/* ---------- KPI ---------- */
.ow-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
@media (min-width: 1100px) { .ow-kpis { grid-template-columns: repeat(var(--cells, 4), minmax(0, 1fr)); } }
.ow-kpi { display: grid; gap: 2px; align-content: start; padding: var(--s-3) var(--s-4); background: var(--bg-raised); min-width: 0; }
.ow-kpi__label { font-size: var(--fs-label); font-weight: 600; color: var(--text-quiet); }
.ow-kpi__value { font-family: var(--font-display); font-size: clamp(1.625rem, 1.4rem + .9vw, 2.25rem); line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.ow-kpi__value small { font-family: var(--font-text); font-size: .5em; color: var(--text-quiet); }
.ow-kpi__delta { font-size: var(--fs-label); color: var(--text-quiet); }
.ow-kpi__delta.is-up { color: var(--st-ok); font-weight: 600; }
.ow-kpi__delta.is-down { color: var(--st-err); font-weight: 600; }

/* ---------- panel ---------- */
.ow-panel { background: var(--bg-raised); border: 1px solid var(--line); min-width: 0; }
.ow-panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.ow-panel__title { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.ow-panel__body { padding: var(--s-4); }
.ow-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ow-toolbar .input, .ow-toolbar .select { width: auto; min-height: var(--tap); padding-block: 8px; font-size: var(--fs-small); }
.ow-toolbar .input { min-width: 200px; flex: 1; }

/* ---------- table ---------- */
.ow-tablewrap { overflow: auto; max-height: var(--table-h, none); }
.ow-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.ow-table th, .ow-table td { padding: 9px var(--s-4); text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ow-table thead th { position: sticky; top: 0; z-index: 1; background: var(--felt-100); font-size: var(--fs-label); font-weight: 600; color: var(--text-quiet); white-space: nowrap; }
.ow-table tbody tr:hover { background: var(--felt-100); }
.ow-table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--ochre-500); }
.ow-table tr.is-new td { font-weight: 600; }
.ow-table__num { text-align: right !important; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.ow-table__actions { text-align: right !important; white-space: nowrap; }
@media (max-width: 639.98px) {
  .ow-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ow-table--stack, .ow-table--stack tbody, .ow-table--stack tr, .ow-table--stack td { display: block; width: 100%; }
  .ow-table--stack tr { padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--line); }
  .ow-table--stack td { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding: 4px 0; border: 0; text-align: right; min-height: 32px; }
  .ow-table--stack td::before { content: attr(data-label); color: var(--text-quiet); text-align: left; font-weight: 400; }
  .ow-table--stack tr.is-new { box-shadow: inset 3px 0 0 var(--ochre-500); }
  .ow-table--stack tr.is-new td:first-child { box-shadow: none; }
}

/* ---------- status grid: the two blocks, drawn as elevations ---------- */
.fg-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); }
.fg-legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--fs-label); }
.fg-key { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fg-key b { font-weight: 400; color: var(--text-quiet); }
.fg-key::before { content: ""; width: 16px; height: 16px; flex: none; }
.fg-key[data-status="ok"]::before { background: var(--ok-tint); box-shadow: inset 0 0 0 1px var(--ok-ink); }
.fg-key[data-status="hold"]::before { background: var(--ochre-500); }
.fg-key[data-status="sold"]::before { background: var(--espresso-900); }
.fg-key[data-status="ask"]::before { background: #fff; box-shadow: inset 0 0 0 1px var(--line-strong); }
.fg-tabs { display: flex; }
.fg-blocks { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
.fg-block { min-width: 0; }
.fg-block__title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding-bottom: var(--s-2); font-size: 1.0625rem; font-weight: 600; }
.fg-block__title small { font-size: var(--fs-label); font-weight: 400; color: var(--text-quiet); font-variant-numeric: tabular-nums; }
.fg-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: thin; }
.fg-table { width: 100%; min-width: calc(40px + 9 * 44px + 10 * 2px); border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.fg-row--head th { height: 30px; font-size: var(--fs-label); font-weight: 600; color: var(--text-quiet); text-align: center; }
.fg-floor { position: sticky; left: 0; z-index: 2; width: 40px; background: var(--bg-raised); font-size: var(--fs-label); font-weight: 600; text-align: center; font-variant-numeric: lining-nums tabular-nums; color: var(--text-quiet); }
.fg-table td { padding: 0; }
.fg-cell { --c: var(--text); position: relative; display: grid; place-items: center; width: 100%; height: 44px; background: #fff; color: var(--c); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-label); font-weight: 600; cursor: pointer; transition: box-shadow var(--t-fast), background var(--t-fast); }
.fg-cell::before { content: ""; width: 11px; height: 11px; border: 2px solid currentColor; border-radius: 50%; }
.fg-cell[data-status="ok"] { --c: var(--ok-ink); background: var(--ok-tint); box-shadow: inset 0 0 0 1px rgba(43, 90, 65, .4); }
.fg-cell[data-status="ok"]::before { background: currentColor; }
.fg-cell[data-status="hold"] { --c: var(--espresso-900); background: var(--ochre-500); box-shadow: none; }
.fg-cell[data-status="hold"]::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.fg-cell[data-status="sold"] { --c: var(--cream-100); background: var(--espresso-900); box-shadow: none; }
.fg-cell[data-status="sold"]::before { border-radius: 2px; background: linear-gradient(45deg, transparent 42%, currentColor 42%, currentColor 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, currentColor 42%, currentColor 58%, transparent 58%); }
.fg-cell[data-status="ask"] { --c: var(--ask-ink); }
.fg-cell:hover { box-shadow: inset 0 0 0 2px var(--brick-600); }
.fg-cell:focus-visible { outline: 2px solid var(--brick-700); outline-offset: 1px; position: relative; z-index: 1; }
.fg-cell.is-selected { box-shadow: 0 0 0 2px var(--brick-700); z-index: 1; }
.fg-cell.is-changed::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; background: var(--brick-600); box-shadow: 0 0 0 1px #fff; }
.fg-cell.is-saving { opacity: .55; }
.fg-row--service .fg-service { height: 28px; font-size: var(--fs-label); color: var(--text-quiet); text-align: center; background: repeating-linear-gradient(135deg, var(--felt-300) 0 2px, transparent 2px 7px); }
@media (min-width: 1180px) and (pointer: fine) {
  .fg-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fg-tabs { display: none; }
  .fg-table { min-width: 0; }
  .fg-cell { height: 30px; }
}
@media (max-width: 1179.98px), (pointer: coarse) {
  .fg-blocks[data-show="A"] .fg-block[data-block="B"], .fg-blocks[data-show="B"] .fg-block[data-block="A"] { display: none; }
}

/* status picker inside .sheet */
.fg-pick { display: grid; gap: var(--s-2); }
.fg-pick__item { display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-1); font-size: 1rem; font-weight: 600; text-align: left; background: var(--bg-raised); }
.fg-pick__item:hover { background: var(--felt-100); }
.fg-pick__item[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- heatmap ---------- */
.ow-heat { --cols: 9; }
.ow-heat .fg-table { min-width: calc(40px + 9 * 36px); }
.ow-heat__cell { display: grid; place-items: center; height: 32px; font-size: var(--fs-label); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; color: var(--ink-900); background: var(--felt-100); }
.ow-heat__cell[data-l="0"] { color: var(--ink-600); font-weight: 400; }
.ow-heat__cell[data-l="1"] { background: #F2E2BE; }
.ow-heat__cell[data-l="2"] { background: #E9C983; }
.ow-heat__cell[data-l="3"] { background: #D9A448; }
.ow-heat__cell[data-l="4"] { background: var(--brick-600); color: #fff; }
.ow-heat__cell[data-l="5"] { background: var(--brick-800); color: #fff; }
.ow-heat__legend { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-label); color: var(--text-quiet); }
.ow-heat__ramp { display: grid; grid-template-columns: repeat(6, 22px); height: 12px; }
.ow-heat__ramp i:nth-child(1) { background: var(--felt-100); box-shadow: inset 0 0 0 1px var(--line); }
.ow-heat__ramp i:nth-child(2) { background: #F2E2BE; }
.ow-heat__ramp i:nth-child(3) { background: #E9C983; }
.ow-heat__ramp i:nth-child(4) { background: #D9A448; }
.ow-heat__ramp i:nth-child(5) { background: var(--brick-600); }
.ow-heat__ramp i:nth-child(6) { background: var(--brick-800); }

/* ---------- form sections ---------- */
.ow-section { display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg-raised); border: 1px solid var(--line); }
.ow-section__head { padding: var(--s-4); border-bottom: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.ow-section__title { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.ow-section__help { color: var(--text-quiet); max-width: 40ch; }
.ow-section__body { padding: var(--s-4); display: grid; gap: var(--s-4); min-width: 0; }
.ow .input, .ow .select, .ow .textarea { font-size: 1rem; min-height: var(--tap); padding-block: 9px; }
@media (max-width: 899.98px) { .ow .input, .ow .select, .ow .textarea { font-size: 1.0625rem; } }
@media (min-width: 1000px) { .ow-section { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); } .ow-section__head { border-bottom: 0; border-right: 1px solid var(--line); } }
.ow-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-4); background: var(--espresso-900); color: var(--cream-100); }
.ow-savebar .btn--quiet { --btn-fg: var(--cream-100); }

/* ---------- upload ---------- */
.ow-upload { position: relative; display: grid; justify-items: center; gap: var(--s-1); padding: var(--s-6) var(--s-4); text-align: center; border: 2px dashed var(--line-strong); background: var(--felt-100); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.ow-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ow-upload:hover, .ow-upload.is-over { background: var(--hold-tint); border-color: var(--brick-600); }
.ow-upload:focus-within { outline: 2px solid var(--brick-700); outline-offset: 2px; }
.ow-upload__title { font-weight: 600; }
.ow-upload__hint { font-size: var(--fs-label); color: var(--text-quiet); }
.ow-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }
.ow-thumb { display: grid; gap: var(--s-1); min-width: 0; }
.ow-thumb__img { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--felt-300); }
.ow-thumb__img img { width: 100%; height: 100%; object-fit: cover; }
.ow-thumb__name { font-size: var(--fs-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ow-thumb__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .3); }
.ow-thumb__bar i { display: block; height: 100%; background: var(--ochre-500); }
.ow-thumb__remove { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: var(--tap); height: var(--tap); background: rgba(30, 19, 14, .78); color: #fff; }
.ow-thumb.is-error .ow-thumb__name { color: var(--err-ink); font-weight: 600; }

@media print { .ow-side, .ow-mobilebar, .ow-savebar { display: none !important; } }
