/* Base element styles and shared primitives. Owner and renter sites load the same file. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--text-md)/1.5 var(--sans);
  font-feature-settings: 'kern' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-ctl); }
::selection { background: var(--accent-soft); color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
strong { font-weight: 600; }
dialog { color: var(--ink); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }

h1 { font-size: var(--text-3xl); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: var(--text-xl); font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
h3 { font-size: var(--text-md); font-weight: 600; line-height: 1.35; }

.muted { color: var(--ink-3); }
.quiet { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'kern' 1; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.caption { font-size: var(--text-sm); font-weight: 600; color: var(--ink-3); }
.small-copy { font-size: var(--text-sm); line-height: 1.5; }

/* Atmosphere: a fixed, softly tinted backdrop so the glass plane has something to blur. */
.atmosphere { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(70% 60% at 12% 8%, var(--glow-a) 0%, transparent 70%), radial-gradient(60% 55% at 90% 95%, var(--glow-b) 0%, transparent 70%), var(--bg); }

/* Glass: one class, used only for navigation and controls that float over content. */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); border: 1px solid var(--glass-line); box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-float); }
@supports not (backdrop-filter: blur(1px)) { .glass { background: color-mix(in srgb, var(--surface) 94%, transparent); } }
@media (prefers-reduced-transparency: reduce) { .glass { background: color-mix(in srgb, var(--surface) 96%, transparent); } }
@media (prefers-contrast: more) { .glass { border-color: var(--line-2); } }

/* Buttons: pills. Primary is the one accent-filled control on a screen. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: var(--text-md); font-weight: 600; line-height: 1; white-space: nowrap; box-shadow: var(--shadow-ctl);
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent-fill); border-color: transparent; color: var(--accent-text); box-shadow: var(--shadow-ctl), 0 10px 22px -14px var(--accent-fill); }
.btn-primary:hover { background: var(--accent-ink); color: var(--accent-text); }
.btn-quiet { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--text-sm); }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--tap); }
.btn-icon.btn-sm { width: 36px; }
.link { color: var(--accent-ink); font-weight: 600; }
.link svg { width: 14px; height: 14px; vertical-align: -2px; margin-left: 2px; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 9px; border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--accent-soft); color: var(--accent-ink); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill + .pill { margin-left: 6px; }
.pill-quiet { background: var(--surface-3); color: var(--ink-3); font-weight: 600; }
.pill-quiet::before { display: none; }

/* Forms: filled rounded inputs, borders only on focus. */
.field { display: grid; gap: 8px; min-width: 0; }
.field > span, .field > label { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.4; }
.field.wide { grid-column: 1 / -1; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.field-error { color: var(--red); font-size: var(--text-sm); }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"],
input[type="date"], input[type="month"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--sheet-line); background: var(--surface-2); color: var(--ink);
  font-size: var(--text-md); line-height: 1.4; transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
textarea { min-height: 104px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235b6573' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239aa3ae' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E"); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
input[readonly], input:disabled, select:disabled, textarea[readonly] { background: var(--surface-3); color: var(--ink-2); }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-fill); margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-sm); color: var(--ink-2); line-height: 1.45; }
.check input { margin-top: 2px; flex: none; }
.form-error { color: var(--red); font-size: var(--text-sm); margin: 0; }
.form-success { color: var(--green); font-size: var(--text-sm); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.form-grid > .wide, .form-grid > .form-actions, .form-grid > .form-error { grid-column: 1 / -1; }
.form-grid > p.small-copy { grid-column: 1 / -1; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.form-actions .spacer { flex: 1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
/* A file picker styled as a button. The native input stays for keyboard and assistive use. */
.file-btn { position: relative; overflow: hidden; width: fit-content; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Sheets: the solid content plane. Tables, forms, lists and stat groups live on sheets. */
.sheet { background: var(--surface); border: 1px solid var(--sheet-line); border-radius: var(--r-sheet); box-shadow: var(--shadow-sheet); }
.sheet-pad { padding: 22px 22px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.sheet-head h2 { font-size: var(--text-lg); }
.sheet-head a, .sheet-head .count { font-size: var(--text-sm); color: var(--ink-3); font-weight: 500; }
.sheet-head a { display: inline-flex; align-items: center; min-height: 36px; }
.sheet-head a:hover { color: var(--ink); }
.sheet-body { padding: 18px 22px 22px; }
.sheet-head + .sheet-body { padding-top: 12px; }
.sheet > .table-wrap { padding: 4px 0 6px; }
.sheet > .empty, .sheet > .table-wrap + .btn-row { padding-left: 22px; padding-right: 22px; }
.sheet > .btn-row { padding: 0 22px 18px; margin-top: 0; }
.sheet > .table-wrap + .btn-row { padding-top: 4px; }
.sheet-list { padding: 6px 0; }
@media (max-width: 640px) {
  .sheet { border-radius: 18px; }
  .sheet-pad { padding: 16px 16px; }
  .sheet-head { padding: 16px 16px 0; }
  .sheet-body { padding: 14px 16px 16px; }
  .sheet > .empty, .sheet > .btn-row { padding-left: 16px; padding-right: 16px; }
}

/* Notices: soft tinted, no borders. */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; font-size: var(--text-sm); line-height: 1.5; background: var(--surface-3); color: var(--ink-2); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice-amber { background: var(--accent-soft); color: var(--accent-ink); }
.notice-red { background: var(--red-soft); color: var(--red); }
.notice-green { background: var(--green-soft); color: var(--green); }
.notice-blue { background: var(--blue-soft); color: var(--blue); }
.notice a { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.notice-inline { display: inline-flex; width: fit-content; max-width: 100%; }

/* Empty states */
.empty { display: grid; justify-items: start; gap: 6px; padding: 18px 0; color: var(--ink-2); }
.empty h3 { color: var(--ink); font-size: var(--text-md); }
.empty p { font-size: var(--text-sm); max-width: 48ch; color: var(--ink-3); }
.empty .btn { margin-top: 8px; }
.empty-center { justify-items: center; text-align: center; padding: 44px 16px; }
.empty-art { width: 52px; height: 52px; border-radius: 18px; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-3); margin-bottom: 8px; }
.empty-art svg { width: 22px; height: 22px; }

/* Key and value rows */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: var(--text-md); align-items: baseline; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--ink-3); }
.kv strong { font-weight: 600; text-align: right; color: var(--ink); }
.kv .kv-value { color: var(--ink-2); text-align: right; max-width: 32ch; }
.kv-stack { display: grid; }

/* Data tables: real tables that stack into labeled rows on phones. */
.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); padding: 12px 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 15px; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background .12s var(--ease); }
.data tbody tr:hover { background: var(--surface-2); }
.data .primary { font-weight: 600; color: var(--ink); }
.data .sub { display: block; color: var(--ink-3); font-size: var(--text-sm); margin-top: 2px; font-weight: 400; }
.data .right { text-align: right; }
.data .actions { text-align: right; white-space: nowrap; }
.data .actions .btn + .btn { margin-left: 6px; }
.data td:first-child, .data th:first-child { padding-left: 22px; }
.data td:last-child, .data th:last-child { padding-right: 22px; }
@media (max-width: 760px) {
  .data.stack thead { display: none; }
  .data.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 16px 16px; border-bottom: 1px solid var(--line); }
  .data.stack tr:last-child { border-bottom: 0; }
  .data.stack td { display: block; padding: 0; border: 0; }
  .data.stack td.lead { grid-column: 1 / -1; }
  .data.stack td.actions { grid-column: 1 / -1; text-align: left; margin-top: 2px; }
  .data.stack td.right { text-align: left; }
  .data.stack td[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
  .data.stack tbody tr:hover { background: transparent; }
  .data td:first-child, .data th:first-child, .data td:last-child, .data th:last-child { padding-left: 0; padding-right: 0; }
}

/* Toolbar: search and filter as pills. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 440px; }
.toolbar .search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.toolbar .search input { padding-left: 42px; min-height: var(--tap); border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-ctl); }
.toolbar select { width: auto; min-height: var(--tap); font-size: var(--text-md); border-radius: var(--r-pill); background-color: var(--surface); box-shadow: var(--shadow-ctl); padding-left: 16px; }
.toolbar .count { margin-left: auto; font-size: var(--text-sm); color: var(--ink-3); white-space: nowrap; }
.toolbar-primary { display: flex; gap: 8px; }
@media (max-width: 640px) {
  /* Phones: search beside the primary action, filter beside the count. Two short rows, then the list. */
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; margin-bottom: 14px; }
  .toolbar .search { grid-column: 1; grid-row: 1; max-width: none; }
  .toolbar:not(:has(.toolbar-primary)) .search { grid-column: 1 / -1; }
  .toolbar .toolbar-primary { grid-column: 2; grid-row: 1; }
  .toolbar select { grid-column: 1; grid-row: 2; justify-self: start; }
  .toolbar .count { grid-column: 2; grid-row: 2; margin-left: 0; justify-self: end; align-self: center; }
  .toolbar .search input, .toolbar select { min-height: 44px; }
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 40px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); font-size: var(--text-sm); color: var(--ink-2); font-weight: 600; box-shadow: var(--shadow-ctl); transition: background .15s var(--ease), color .15s var(--ease), transform .12s var(--ease); }
.chip:hover { background: var(--surface-2); }
.chip:active { transform: translateY(1px); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Disclosure: progressive reveal with a native details element. */
.disclosure > summary { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 16px 0 14px; border-radius: var(--r-pill); font-size: var(--text-md); font-weight: 600; color: var(--ink-2); transition: background .15s var(--ease), color .15s var(--ease); }
.disclosure > summary:hover { color: var(--ink); background: var(--surface-3); }
.disclosure > summary svg { width: 18px; height: 18px; color: var(--ink-3); transition: transform .2s var(--ease); }
.disclosure[open] > summary svg { transform: rotate(180deg); }
.disclosure-body { padding: 10px 4px 0; }
.disclosure-body > p { font-size: var(--text-md); color: var(--ink-2); line-height: 1.55; max-width: 72ch; }
.disclosure-body > p + p { margin-top: 8px; }
.disclosure-block { margin-top: 16px; }
.disclosure-block > .disclosure-body { padding: 14px 0 0; }

/* Stat group: cardless figures on one sheet. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px 28px; padding: 22px 22px 18px; }
.stat { display: grid; gap: 5px; min-width: 0; }
.stat strong { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.stat small { font-size: var(--text-sm); color: var(--ink-3); line-height: 1.4; }
.stat.tone-green strong { color: var(--green); }
.stat.tone-amber strong { color: var(--accent-ink); }
.stat.tone-red strong { color: var(--red); }
.stats-foot { padding: 0 22px 20px; font-size: var(--text-sm); color: var(--ink-2); display: grid; gap: 6px; line-height: 1.5; }
.stats-line { display: block; }
/* A status pill and its sentence sit side by side; on a narrow screen the sentence drops under the pill instead of wrapping around it. */
.stats-line:has(.pill) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.stats-line .readiness { flex: 1 1 300px; }
.stats-foot .readiness { color: var(--ink-3); }
.stats-foot a { color: var(--accent-ink); font-weight: 600; }
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 16px 18px; padding: 16px; }
  .stat strong { font-size: 24px; }
  .stats-foot { padding: 0 16px 16px; }
}

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(92vw, 520px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: var(--r-pill); font-size: var(--text-sm); font-weight: 500; box-shadow: var(--shadow-pop); }
[data-theme="dark"] .toast { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-2); }

/* Phones: 16px text in every field so iPhone Safari does not zoom on focus; comfortable touch targets. */
@media (max-width: 900px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea, .finder-field input, .toolbar select { font-size: 16px; }
  .chip { height: var(--tap); }
  .disclosure > summary { min-height: var(--tap-lg); }
  .btn-primary:not(.btn-sm) { min-height: var(--tap-lg); }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { min-height: var(--tap-lg); }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}

/* Motion */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
