/*
 * One stylesheet, no framework. Plain and descriptive, like the product: a
 * near-white page, near-black ink, one azulejo blue for anything you can
 * press, and amber for stars — the one colour people already read as a
 * rating. Dark mode is its own set of steps, not an inversion.
 */
:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #fcfcfb;
  --panel: #efefeb;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --ink: #14161a;
  --muted: #52514e;
  --faint: #898781;
  --accent: #1c5cab;
  --accent-soft: #e3eefb;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --star: #c98a00;
  --star-empty: #d9d6cc;
  --good: #006300;
  --warning: #8a5a00;
  --warning-soft: #fbf0d9;
  --critical: #c22f2f;
  --critical-soft: #f9e3e1;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d; --surface: #1a1a19; --panel: #232321; --line: #2c2c2a; --axis: #383835;
    --ink: #f4f4f2; --muted: #c3c2b7; --faint: #898781;
    --accent: #6da7ec; --accent-soft: #16263b; --accent-ink: #0b0b0b;
    --series-1: #3987e5; --series-2: #d95926; --star: #f0bf4c; --star-empty: #3a3a36;
    --good: #0ca30c; --warning: #f0bf4c; --warning-soft: #34290f; --critical: #f07a7a; --critical-soft: #3a1c1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 72px; }
main.narrow { max-width: 760px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 750; margin: 0 0 14px; }
h2 { font-size: clamp(21px, 3vw, 27px); font-weight: 700; margin: 44px 0 12px; }
h3 { font-size: 18px; font-weight: 700; margin: 20px 0 6px; }
a { color: var(--accent); text-underline-offset: 3px; }
p { margin: 0 0 14px; }
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
.lede { font-size: 19px; color: var(--muted); max-width: 46em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
[hidden] { display: none !important; }

/* ── Header and footer, on every page via BaseLayout ─────────────────────── */
.masthead {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  max-width: 1040px; margin: 0 auto; padding: 16px 20px 0;
}
.wordmark { font-weight: 800; font-size: 23px; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.wordmark span { color: var(--accent); }
.masthead nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.masthead nav.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.masthead nav.tabs a:hover { background: var(--panel); }
.masthead nav.tabs a[aria-current] { background: var(--accent-soft); color: var(--ink); }
.masthead nav.more { margin-left: auto; font-size: 15px; gap: 14px; }
.masthead nav.more a { color: var(--muted); text-decoration: none; }
.masthead nav.more a[aria-current] { color: var(--ink); font-weight: 700; }

.siteftr {
  max-width: 1040px; margin: 0 auto; padding: 24px 20px 44px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.siteftr .feedback-line { font-size: 15px; color: var(--ink); }
.siteftr .feedback-line a { font-weight: 700; }

/* ── Buttons, forms, panels ──────────────────────────────────────────────── */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 650 16px/1.2 var(--sans); padding: 12px 20px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }
button.quiet, .button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--critical); border: 1px solid var(--critical); }
button.small, .button.small { padding: 7px 12px; font-size: 14px; }
button.big, .button.big { padding: 16px 26px; font-size: 18px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

label { display: block; font-weight: 650; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 140px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.error { color: var(--critical); }
.ok { color: var(--good); }
.note { background: var(--accent-soft); border-radius: 10px; padding: 12px 15px; font-size: 15px; }
.warning { background: var(--warning-soft); border-radius: 10px; padding: 12px 15px; font-size: 15px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .two, .three { grid-template-columns: 1fr; } }

pre.sql {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; white-space: pre; margin: 8px 0 12px;
}
.copy-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 12px; }

/* ── The front page ──────────────────────────────────────────────────────── */
.hero { margin: 18px 0 34px; }
.hero h1 { max-width: 17em; }
.hero .controls { margin-top: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin-top: 0; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 16px 0; counter-reset: step; }
.steps > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.steps > div::before { counter-increment: step; content: counter(step); font-weight: 800; font-size: 26px; color: var(--accent); display: block; line-height: 1; margin-bottom: 6px; }
.steps strong { display: block; margin-bottom: 4px; }
.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; margin: 18px 0; }
ul.plain { padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.name { word-break: break-word; }
.table-wrap { overflow-x: auto; }
.share { display: block; height: 4px; border-radius: 2px; background: var(--series-1); margin-top: 4px; min-width: 2px; }

/* ── The app ─────────────────────────────────────────────────────────────── */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list .name { font-weight: 750; font-size: 18px; text-decoration: none; color: var(--ink); }
.status { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; font-weight: 650; padding: 2px 10px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.status.good { color: var(--good); }
.status.waiting { color: var(--warning); }
.status.bad { color: var(--critical); }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.choice label { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); cursor: pointer; font-weight: 600; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: auto; margin-right: 8px; }
.choice .hint { display: block; font-weight: 400; color: var(--muted); font-size: 14px; margin-top: 2px; }

.head-row { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: baseline; justify-content: space-between; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.tile.lead { grid-column: span 2; }
.tile.lead .value { font-size: 48px; line-height: 1.1; white-space: nowrap; }
@media (max-width: 560px) { .tile.lead { grid-column: auto; } .tile.lead .value { font-size: 36px; } }
.range { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.range a { padding: 5px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.range a[aria-current] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }

/* ── The chart ───────────────────────────────────────────────────────────── */
.chart-figure { margin: 10px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 8px; }
.chart-wrap { position: relative; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { stroke: var(--axis); stroke-width: 1; }
svg.chart .tick { fill: var(--faint); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
svg.chart .series-1 { fill: var(--series-1); }
svg.chart .series-2 { fill: var(--series-2); }
svg.chart .line-1 { fill: none; stroke: var(--series-1); stroke-width: 2; }
svg.chart .hit { fill: transparent; cursor: pointer; }
svg.chart .hit:hover { fill: var(--ink); fill-opacity: 0.04; }
.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; line-height: 1.45; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); white-space: nowrap;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.series-1 { background: var(--series-1); }
.swatch.series-2 { background: var(--series-2); }
.table-view { margin-top: 8px; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--muted); }

/* ── pisti ───────────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 8px; }
.search-bar input { flex: 1 1 260px; font-size: 18px; padding: 12px 14px; }
.badge { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.badge.verified { color: var(--good); border: 1px solid currentColor; }
.badge.pending { color: var(--warning); border: 1px solid currentColor; }
.badge.muted { color: var(--muted); border: 1px solid var(--line); }
.stars { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--star-empty); }
.score { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.score small { font-size: 16px; color: var(--muted); font-weight: 600; }
.score-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.withheld { color: var(--muted); font-size: 15px; }

.bars { display: grid; gap: 10px; margin: 8px 0; }
.bars .bar-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) 2fr 44px; gap: 10px; align-items: center; font-size: 15px; }
.bars .track { height: 10px; border-radius: 5px; background: var(--panel); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 5px; background: var(--series-1); }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
@media (max-width: 560px) { .bars .bar-row { grid-template-columns: 1fr 44px; } .bars .track { grid-column: 1 / -1; grid-row: 2; } }
svg.radar { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; }
svg.radar .web { fill: none; stroke: var(--line); }
svg.radar .spoke { stroke: var(--line); }
svg.radar .area { fill: var(--series-1); fill-opacity: 0.22; stroke: var(--series-1); stroke-width: 2; }
svg.radar text { fill: var(--muted); font: 11px var(--sans); }
.score-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: center; }
@media (max-width: 820px) { .score-cols { grid-template-columns: 1fr; } }

.review { border-top: 1px solid var(--line); padding: 16px 0; }
.review:first-child { border-top: 0; }
.review-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.review-head .who { font-weight: 700; }
.review .comment { margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.review .subscores { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); }
.review .reply { margin: 10px 0 0 14px; padding: 8px 12px; border-left: 3px solid var(--line); font-size: 15px; }
.review .reply strong { display: block; font-size: 13px; color: var(--muted); }
.review .photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.review .photos img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.review details { margin-top: 8px; font-size: 14px; }
.review details summary { cursor: pointer; color: var(--muted); }

.map { height: 280px; border-radius: var(--radius); border: 1px solid var(--line); margin: 10px 0; z-index: 0; }
.map.small { height: 200px; }
.results { list-style: none; padding: 0; margin: 0; }
.results > li { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results .title { font-weight: 750; font-size: 18px; text-decoration: none; color: var(--ink); }
.results .nums { display: flex; gap: 18px; font-size: 14px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.filters label { font-size: 14px; }

.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.slider .name { font-weight: 650; }
.slider .hint { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.slider .pick { display: flex; gap: 2px; }
.slider .pick button { background: transparent; color: var(--star-empty); font-size: 28px; padding: 0 2px; line-height: 1; border-radius: 6px; }
.slider .pick button.on { color: var(--star); }
.slider .pick button:hover { filter: none; transform: scale(1.1); }
.counter { font-size: 13px; color: var(--muted); text-align: right; }

.notice-list { list-style: none; padding: 0; margin: 0; }
.notice-list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; font-size: 15px; }
.notice-list li.unread { font-weight: 650; }
.notice-list time { color: var(--faint); font-size: 13px; white-space: nowrap; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--panel); padding: 10px 12px; border-radius: 8px; word-break: break-all; }

/* ── The viewing checklist, /pt/checklist-visita ─────────────────────────── */
.checklist-bar { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.check-list p { margin: 0 0 4px; }
.check-label { font-weight: 650; }
.states { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.states label {
  display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-weight: 500; font-size: 14px; cursor: pointer;
}
.states input { width: auto; margin: 0; accent-color: var(--accent); }
.states label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.states label.state-later:has(input:checked) { border-color: var(--warning); background: var(--warning-soft); }
/* ── The move-in record, /pt/inventario-entrada ─────────────────────────── */
.inv-room-card { margin: 12px 0; }
.inv-room-head { display: flex; gap: 8px; align-items: center; }
.inv-room-head input { font-weight: 650; }
.inv-items { list-style: none; padding: 0; margin: 10px 0 0; }
.inv-item {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name name" "cond remove" "notes notes";
  gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.inv-item input, .inv-item select { margin: 0; }
.inv-item > :nth-child(1) { grid-area: name; }
.inv-item > :nth-child(2) { grid-area: cond; }
.inv-item > :nth-child(3) { grid-area: notes; }
.inv-item > :nth-child(4) { grid-area: remove; }
@media (min-width: 640px) {
  .inv-item { grid-template-columns: 2fr 1.3fr auto; grid-template-areas: "name cond remove" "notes notes notes"; }
}
#record { display: none; }
.inv-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.inv-table th, .inv-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.inv-table th.inv-room { font-size: 16px; background: var(--panel); }
.inv-table { table-layout: fixed; }
.inv-table col.inv-c-item { width: 30%; }
.inv-table col.inv-c-cond { width: 24%; }
.inv-table td { overflow-wrap: anywhere; }
.inv-ticks { font-size: 12px; }
.inv-ticks span { display: block; white-space: nowrap; }
.inv-tall { height: 5em; }
.inv-pre { white-space: pre-wrap; }
.inv-foot { display: flex; gap: 12px; align-items: center; margin-top: 14px; padding-top: 8px; border-top: 1px solid #000; }
.inv-qr svg { display: block; width: 24mm; height: 24mm; }
.inv-url { font-family: var(--mono); word-break: break-all; }
.print-only { display: none; }
.letter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin: 16px 0; line-height: 1.6; }
.letter:empty { display: none; }
.letter p { margin: 0 0 12px; }
.letter-to { margin-left: 45% !important; }
.letter-sign { margin-top: 28px !important; }
.big-answer { font-size: 20px; }
/* ── The damp guide's log, /pt/humidade-casa-arrendada ──────────────────── */
.dm-log-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dm-log-row input, .dm-log-row select { margin: 0; }
.dm-log-row > :nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 640px) { .dm-log-row { grid-template-columns: 9em 1fr 2fr 7em auto; } .dm-log-row > :nth-child(3) { grid-column: auto; } }
.dm-log { margin-top: 18px; }
.dm-log .inv-table td { height: 1.8em; }

@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .masthead, .siteftr, .no-print { display: none !important; }
  .print-only { display: block; }
  .print-head { border-bottom: 1px solid #000; padding-bottom: 6px; }
  main, main.narrow { max-width: none; padding: 0; }
  h1 { font-size: 20pt; }
  h2 { font-size: 15pt; margin-top: 18px; break-after: avoid; }
  .check-list > li { padding: 6px 0; break-inside: avoid; }
  .states label { border-color: #999; padding: 2px 8px; }
  .muted { color: #333; }
  .inv-table { font-size: 10.5pt; }
  .inv-table th, .inv-table td { border-color: #555; padding: 4px 6px; }
  .inv-table th.inv-room { background: #eee; font-size: 12pt; }
  .inv-table tr { break-inside: avoid; }
  .inv-table td { height: 8mm; }
  .inv-ticks { font-size: 8.5pt; line-height: 1.25; }
  .inv-table td.inv-tall { height: 24mm; }
  .inv-foot { display: flex; break-inside: avoid; }
  html[data-print="record"] #record { display: block; }
  html[data-print="record"] #blank { display: none; }
  .letter { border: none; padding: 0; margin: 0; font-size: 12pt; }
  #letter { display: none; }
  html[data-print="letter"] #letter { display: block; }
  html[data-print="letter"] #letter-blank { display: none; }
  .dm-log { break-before: page; }
  /* The move-out guide's two blank letters: both without JavaScript, one per page; the chosen one with it. */
  .mo-blank + .mo-blank { break-before: page; }
  html[data-blank="notice"] #blank-deposit, html[data-blank="deposit"] #blank-notice { display: none; }
}

@page { size: A4; margin: 14mm; }
